after.vue 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466
  1. <template>
  2. <mobile-frame>
  3. <view class="main">
  4. <view class="one">
  5. <input type="text" v-model="searchInfo.goods" @input="toInput" placeholder="搜索商品" @scroll="toScroll">
  6. </view>
  7. <view class="two">
  8. <tabs :tabs="tabs" @tabsChange="tabsChange">
  9. <view class="tabsList">
  10. <scroll-view scroll-y="true" class="scroll-view" @scrolltolower="toPage">
  11. <view class="list-scroll-view">
  12. <view class="list" v-for="(item,index) in list" :key="index" @tap="toInfo(item)">
  13. <view class="list_1">
  14. <view class="shopname">
  15. <text class="iconfont icon-shangdian"></text>
  16. <text>{{item.shop.name}}</text>
  17. </view>
  18. <view class="type">
  19. {{item.zhType||'暂无'}}
  20. </view>
  21. </view>
  22. <view class="list_2">
  23. <image class="image" :src="item.url&&item.url.length>0?item.url[0].url:''"
  24. mode="">
  25. </image>
  26. <view class="other">
  27. <view class="name textOver">
  28. {{item.goods.goods.name||'暂无'}}
  29. </view>
  30. <view class="other_1">
  31. 商品规格:<text>{{item.goods.name||'暂无'}}</text>
  32. </view>
  33. <view class="other_1" v-if="item.type!='3'">
  34. 退款:<text>¥{{item.money||0}}</text>
  35. </view>
  36. <view class="other_1">
  37. 申请时间:<text>{{item.apply_time||'暂无'}}</text>
  38. </view>
  39. <view class="other_1">
  40. 售后类型:<text>{{item.zhStatus||'暂无'}}</text>
  41. </view>
  42. <view class="other_1">
  43. <text v-if="item.goods&&item.goods.gift&&item.goods.gift.length>0" class="gift">赠品</text>
  44. <text v-if="item.goods.sp_price" class="act">特价</text>
  45. </view>
  46. </view>
  47. </view>
  48. <view class="btn">
  49. <button type="default" size="mini" @tap.stop="toView(item)">详细信息</button>
  50. <button v-if="item.status=='0'" type="default" size="mini"
  51. @tap.stop="toCancel(item)">取消售后</button>
  52. <button
  53. v-if="item.type!='1'&&item.status=='2'||item.status=='3'&&!item.transport.shop_receive"
  54. type="default" size="mini" @tap.stop="toMaintain(item)">维护单号</button>
  55. <button
  56. v-if="item.type=='3'&&item.status=='3'&&item.transport.shop_receive==true"
  57. type="default" size="mini" @tap.stop="toLogi(item)">查看物流</button>
  58. <button
  59. v-if="item.type=='3'&&item.status=='3'&&item.transport.shop_receive==true&&!item.transport.customer_receive"
  60. type="default" size="mini" @tap.stop="toConfirm(item)">确认收货</button>
  61. </view>
  62. </view>
  63. <view class="is_bottom" v-if="is_bottom">
  64. <text>{{config.bottom_title}}</text>
  65. </view>
  66. </view>
  67. </scroll-view>
  68. </view>
  69. </tabs>
  70. </view>
  71. </view>
  72. </mobile-frame>
  73. </template>
  74. <script>
  75. import tabs from '../components/tabs/index.vue';
  76. export default {
  77. components: {
  78. tabs
  79. },
  80. data() {
  81. return {
  82. // 系统设置
  83. config: {},
  84. user: {},
  85. searchInfo: {},
  86. // 售后类型
  87. typeList: [],
  88. // 售后状态
  89. statusList: [],
  90. tabs: {
  91. active: '1',
  92. menu: []
  93. },
  94. type: '1',
  95. list: [],
  96. total: 0,
  97. skip: 0,
  98. limit: 10,
  99. page: 0,
  100. // 数据是否触底
  101. is_bottom: false,
  102. scrollTop: 0,
  103. };
  104. },
  105. onLoad: async function() {
  106. const that = this;
  107. that.searchConfig();
  108. // 查询其他信息
  109. await that.searchOther();
  110. // 监听用户登录
  111. await that.watchLogin();
  112. },
  113. onPullDownRefresh: async function() {
  114. const that = this;
  115. that.clearPage();
  116. await that.search();
  117. uni.stopPullDownRefresh();
  118. },
  119. methods: {
  120. // 查询基本设置
  121. searchConfig() {
  122. const that = this;
  123. uni.getStorage({
  124. key: 'config',
  125. success: function(res) {
  126. if (res.data) that.$set(that, `config`, res.data)
  127. },
  128. fail: function(err) {
  129. console.log(err);
  130. }
  131. })
  132. },
  133. // 监听用户是否登录
  134. watchLogin() {
  135. const that = this;
  136. uni.getStorage({
  137. key: 'token',
  138. success: function(res) {
  139. let user = that.$jwt(res.data);
  140. if (user) that.$set(that, `user`, user);
  141. that.search();
  142. },
  143. fail: function(err) {
  144. uni.navigateTo({
  145. url: `/pages/login/index`
  146. })
  147. }
  148. });
  149. },
  150. // 查询列表
  151. async search() {
  152. const that = this;
  153. let user = that.user;
  154. let type = that.type;
  155. const arr = await that.$api(`/afterSale`, 'GET', {
  156. customer: user._id,
  157. type: that.type,
  158. ...that.searchInfo
  159. });
  160. if (arr.errcode == '0') {
  161. let list = [...that.list, ...arr.data];
  162. for (let val of list) {
  163. let type = that.typeList.find(i => i.value == val.type)
  164. if (type) val.zhType = type.label;
  165. let status = that.statusList.find(i => i.value == val.status)
  166. if (status) val.zhStatus = status.label;
  167. val.url = val?.goods?.goods?.file;
  168. }
  169. that.$set(that, `list`, list)
  170. that.$set(that, `total`, arr.total)
  171. } else {
  172. uni.showToast({
  173. title: arr.errmsg,
  174. });
  175. }
  176. },
  177. // 查询其他信息
  178. async searchOther() {
  179. const that = this;
  180. let res;
  181. res = await that.$api(`/dictData`, 'GET', {
  182. code: "afterSale_type"
  183. });
  184. if (res.errcode == '0') {
  185. that.$set(that, `typeList`, res.data)
  186. var menu = res.data.map((item) => {
  187. return {
  188. title: item.label,
  189. active: item.value
  190. }
  191. })
  192. that.$set(that.tabs, `menu`, menu)
  193. }
  194. res = await that.$api(`/dictData`, 'GET', {
  195. code: "afterSale_status"
  196. });
  197. if (res.errcode == '0') that.$set(that, `statusList`, res.data)
  198. },
  199. // 分页
  200. toPage(e) {
  201. const that = this;
  202. let list = that.list;
  203. let limit = that.limit;
  204. if (that.total > list.length) {
  205. uni.showLoading({
  206. title: '加载中',
  207. mask: true
  208. })
  209. let page = that.page + 1;
  210. that.$set(that, `page`, page)
  211. let skip = page * limit;
  212. that.$set(that, `skip`, skip)
  213. that.search();
  214. uni.hideLoading();
  215. } else that.$set(that, `is_bottom`, true)
  216. },
  217. toScroll(e) {
  218. const that = this;
  219. let up = that.scrollTop;
  220. that.$set(that, `scrollTop`, e.detail.scrollTop);
  221. let num = Math.sign(up - e.detail.scrollTop);
  222. if (num == 1) that.$set(that, `is_bottom`, false);
  223. },
  224. // 输入框
  225. toInput(e) {
  226. const that = this;
  227. if (that.searchInfo.goods) that.$set(that.searchInfo, `goods`, e.detail.value)
  228. else that.$set(that, `searchInfo`, {})
  229. that.clearPage();
  230. that.search();
  231. },
  232. // 选择选项卡
  233. tabsChange(e) {
  234. const that = this;
  235. that.$set(that.tabs, `active`, e.active)
  236. that.$set(that, `type`, e.active);
  237. that.clearPage();
  238. that.search()
  239. },
  240. // 售后详细信息
  241. toView(item) {
  242. uni.navigateTo({
  243. url: `/pagesMy/order/afterInfo?id=${item._id}&status=${'0'}`
  244. })
  245. },
  246. // 订单详细
  247. toInfo(item) {
  248. uni.navigateTo({
  249. url: `/pagesMy/order/info?id=${item.order_detail._id}&status=${item.order_detail.status}`
  250. })
  251. },
  252. // 维护单号
  253. toMaintain(item) {
  254. uni.navigateTo({
  255. url: `/pagesMy/order/detail?id=${item._id}&status=${'0'}`
  256. })
  257. },
  258. // 确认收货
  259. async toConfirm(item) {
  260. const that = this;
  261. uni.showModal({
  262. title: '提示',
  263. content: '是否确认收货?',
  264. success: async function(res) {
  265. if (res.confirm) {
  266. item.transport.customer_receive = true;
  267. const arr = await that.$api(`/afterSale/${item.id}`, 'POST', {
  268. transport: item.transport
  269. });
  270. if (arr.errcode == '0') {
  271. uni.showToast({
  272. title: `确认收货成功`,
  273. icon: 'success',
  274. });
  275. that.clearPage();
  276. that.search();
  277. } else {
  278. uni.showToast({
  279. title: arr.errmsg,
  280. icon: 'none',
  281. })
  282. }
  283. }
  284. }
  285. });
  286. },
  287. // 查看物流
  288. toLogi(e) {
  289. uni.navigateTo({
  290. url: `/pagesMy/logistics/index?id=${e._id}&type=${'afterSale'}`
  291. })
  292. },
  293. // 取消售后
  294. toCancel(e) {
  295. const that = this;
  296. uni.showModal({
  297. title: '提示',
  298. content: '确定取消售后申请吗?',
  299. success: async function(res) {
  300. if (res.confirm) {
  301. const arr = await that.$api(`/afterSale/${e._id}`, 'DELETE');
  302. if (arr.errcode == '0') {
  303. uni.showToast({
  304. title: '取消售后成功',
  305. icon: 'none'
  306. })
  307. that.clearPage();
  308. that.search();
  309. } else {
  310. uni.showToast({
  311. title: arr.errmsg,
  312. icon: 'none'
  313. })
  314. }
  315. }
  316. }
  317. });
  318. },
  319. // 清空列表
  320. clearPage() {
  321. const that = this;
  322. that.$set(that, `list`, [])
  323. that.$set(that, `skip`, 0)
  324. that.$set(that, `limit`, 6)
  325. that.$set(that, `page`, 0)
  326. }
  327. }
  328. }
  329. </script>
  330. <style lang="scss">
  331. .main {
  332. display: flex;
  333. flex-direction: column;
  334. width: 100vw;
  335. height: 100vh;
  336. .one {
  337. padding: 2vw;
  338. input {
  339. padding: 2vw;
  340. background-color: var(--f1Color);
  341. font-size: var(--font14Size);
  342. border-radius: 5px;
  343. }
  344. }
  345. .two {
  346. position: relative;
  347. flex-grow: 1;
  348. background-color: var(--f9Color);
  349. .tabsList {
  350. position: relative;
  351. width: 100vw;
  352. height: 82vh;
  353. .list {
  354. margin: 2vw 2vw 0 2vw;
  355. background-color: var(--fffColor);
  356. padding: 2vw;
  357. width: 92vw;
  358. border-radius: 5px;
  359. .list_1 {
  360. display: flex;
  361. justify-content: space-between;
  362. font-size: var(--font16Size);
  363. margin: 0 0 2vw 0;
  364. .shopname {
  365. text {
  366. margin: 0 0 0 1vw;
  367. }
  368. }
  369. .type {
  370. color: var(--fFB1Color);
  371. }
  372. }
  373. .list_2 {
  374. display: flex;
  375. justify-content: space-between;
  376. .image {
  377. width: 25vw;
  378. height: 25vw;
  379. margin: 0 2vw 1vw 0;
  380. border: 1px solid var(--f85Color);
  381. }
  382. .other {
  383. width: 65vw;
  384. flex-grow: 1;
  385. .name {
  386. font-size: var(--font16Size);
  387. }
  388. .other_1 {
  389. font-size: var(--font14Size);
  390. text {
  391. color: var(--f85Color);
  392. }
  393. .gift {
  394. margin: 0 1vw 0 0;
  395. font-size: 12px;
  396. color: #FFA500;
  397. border: 1px solid #FFA500;
  398. border-radius: 5px;
  399. padding: 0 1vw;
  400. }
  401. .act {
  402. font-size: 12px;
  403. border: 1px solid var(--fFB1Color);
  404. color: var(--fFB1Color);
  405. border-radius: 5px;
  406. padding: 0 1vw;
  407. }
  408. }
  409. }
  410. }
  411. .btn {
  412. text-align: right;
  413. button {
  414. margin: 2vw 0 0 2vw;
  415. }
  416. }
  417. }
  418. }
  419. }
  420. }
  421. .scroll-view {
  422. position: absolute;
  423. top: 0;
  424. left: 0;
  425. right: 0;
  426. bottom: 0;
  427. .list-scroll-view {
  428. display: flex;
  429. flex-direction: column;
  430. }
  431. }
  432. .is_bottom {
  433. text-align: center;
  434. text {
  435. padding: 2vw 0;
  436. display: inline-block;
  437. color: #858585;
  438. font-size: 14px;
  439. }
  440. }
  441. </style>