after.vue 7.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365
  1. <template>
  2. <mobile-frame>
  3. <view class="main">
  4. <view class="one">
  5. <input type="text" v-model="searchInfo.name" @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:''" mode="">
  24. </image>
  25. <view class="other">
  26. <view class="name">
  27. {{item.goods.goods.name||'暂无'}}
  28. </view>
  29. <view class="other_1">
  30. 商品规格:<text>{{item.goods.name||'暂无'}}</text>
  31. </view>
  32. <view class="other_1" v-if="item.type!='2'">
  33. 退款:<text>¥{{item.money||0}}</text>
  34. </view>
  35. <view class="other_1">
  36. 申请时间:<text>{{item.apply_time||'暂无'}}</text>
  37. </view>
  38. <view class="other_1">
  39. 售后描述:<text>{{item.desc||'暂无'}}</text>
  40. </view>
  41. <view class="other_1">
  42. 售后处理人:<text>{{item.deal_person.name||'暂无'}}</text>
  43. </view>
  44. </view>
  45. </view>
  46. <view class="btn">
  47. <button v-if="item.status=='0'||item.status=='1'" type="default" size="mini" @tap.stop="toCancel(item)">取消售后</button>
  48. <button v-if="item.type!='0'" type="default" size="mini" @tap.stop="toRevise(item)">维护信息</button>
  49. </view>
  50. </view>
  51. <view class="is_bottom" v-if="is_bottom">
  52. <text>我们也是有底线的!</text>
  53. </view>
  54. </view>
  55. </scroll-view>
  56. </view>
  57. </tabs>
  58. </view>
  59. </view>
  60. </mobile-frame>
  61. </template>
  62. <script>
  63. import tabs from '@/components/tabs/index.vue';
  64. export default {
  65. components: {
  66. tabs
  67. },
  68. data() {
  69. return {
  70. user: {},
  71. list: [],
  72. typeList: [],
  73. total: 0,
  74. skip: 0,
  75. limit: 5,
  76. page: 0,
  77. tabs: {
  78. active: '0',
  79. menu: [{
  80. title: '申请售后',
  81. active: '0'
  82. },
  83. {
  84. title: '正在处理退款',
  85. active: '1'
  86. },
  87. {
  88. title: '已退款',
  89. active: '-1'
  90. },
  91. {
  92. title: '已退货',
  93. active: '-2'
  94. },
  95. {
  96. title: '正在处理换货',
  97. active: '3'
  98. },
  99. {
  100. title: '已换货',
  101. active: '-3'
  102. }
  103. ]
  104. },
  105. status: '0',
  106. // 数据是否触底
  107. is_bottom: false,
  108. scrollTop: 0,
  109. };
  110. },
  111. onShow: async function() {
  112. const that = this;
  113. that.clearPage();
  114. // 查询其他信息
  115. await that.searchOther();
  116. // 监听用户登录
  117. await that.watchLogin();
  118. },
  119. methods: {
  120. // 选择选项卡
  121. tabsChange(e) {
  122. const that = this;
  123. that.$set(that.tabs, `active`, e.active)
  124. that.$set(that, `status`, e.active);
  125. that.clearPage();
  126. that.search()
  127. },
  128. // 订单详细
  129. toInfo(item) {
  130. uni.navigateTo({
  131. url: `/pagesMy/order/info?id=${item.order_detail._id}&status=${item.order_detail.status}`
  132. })
  133. },
  134. // 维护信息
  135. toRevise(e) {
  136. uni.navigateTo({
  137. url: `/pagesMy/order/detail?id=${e.id||e._id}`
  138. })
  139. },
  140. // 取消售后
  141. toCancel(e) {
  142. const that = this;
  143. uni.showModal({
  144. title: '提示',
  145. content: '确定删除售后申请吗?',
  146. success: async function(res) {
  147. if (res.confirm) {
  148. const arr = await that.$api(`/afterSale/${e._id}`, 'DELETE');
  149. if (arr.errcode == '0') {
  150. uni.showToast({
  151. title: '删除售后成功',
  152. icon: 'none'
  153. })
  154. that.clearPage();
  155. that.search();
  156. } else {
  157. uni.showToast({
  158. title: arr.errmsg,
  159. icon: 'none'
  160. })
  161. }
  162. }
  163. }
  164. });
  165. },
  166. // 监听用户是否登录
  167. watchLogin() {
  168. const that = this;
  169. uni.getStorage({
  170. key: 'token',
  171. success: function(res) {
  172. let user = that.$jwt(res.data);
  173. if (user) that.$set(that, `user`, user);
  174. that.search();
  175. },
  176. fail: function(err) {
  177. uni.navigateTo({
  178. url: `/pages/login/index`
  179. })
  180. }
  181. });
  182. },
  183. // 查询列表
  184. async search() {
  185. const that = this;
  186. let user = that.user;
  187. let status = that.status;
  188. const arr = await that.$api(`/afterSale`, 'GET', {
  189. customer: user._id,
  190. status: that.status,
  191. });
  192. if (arr.errcode == '0') {
  193. let list = [...that.list, ...arr.data];
  194. for (let val of list) {
  195. let type = that.typeList.find(i => i.value == val.type)
  196. if (type) val.zhType = type.label;
  197. val.url = val?.goods?.goods?.file;
  198. }
  199. that.$set(that, `list`, list)
  200. that.$set(that, `total`, arr.total)
  201. } else {
  202. uni.showToast({
  203. title: arr.errmsg,
  204. });
  205. }
  206. },
  207. // 查询其他信息
  208. async searchOther() {
  209. const that = this;
  210. let res;
  211. res = await that.$api(`/dictData`, 'GET', {
  212. code: "afterSale_type"
  213. });
  214. if (res.errcode == '0') {
  215. that.$set(that, `typeList`, res.data)
  216. }
  217. },
  218. // 分页
  219. toPage(e) {
  220. const that = this;
  221. let list = that.list;
  222. let limit = that.limit;
  223. if (that.total > list.length) {
  224. uni.showLoading({
  225. title: '加载中',
  226. mask: true
  227. })
  228. let page = that.page + 1;
  229. that.$set(that, `page`, page)
  230. let skip = page * limit;
  231. that.$set(that, `skip`, skip)
  232. that.search();
  233. uni.hideLoading();
  234. } else that.$set(that, `is_bottom`, true)
  235. },
  236. toScroll(e) {
  237. const that = this;
  238. let up = that.scrollTop;
  239. that.$set(that, `scrollTop`, e.detail.scrollTop);
  240. let num = Math.sign(up - e.detail.scrollTop);
  241. if (num == 1) that.$set(that, `is_bottom`, false);
  242. },
  243. // 清空列表
  244. clearPage() {
  245. const that = this;
  246. that.$set(that, `list`, [])
  247. that.$set(that, `skip`, 0)
  248. that.$set(that, `limit`, 5)
  249. that.$set(that, `page`, 0)
  250. }
  251. }
  252. }
  253. </script>
  254. <style lang="scss">
  255. .main {
  256. display: flex;
  257. flex-direction: column;
  258. width: 100vw;
  259. height: 100vh;
  260. .one {
  261. // border-bottom: 1px solid var(--f85Color);
  262. padding: 2vw;
  263. input {
  264. padding: 2vw;
  265. background-color: var(--f1Color);
  266. font-size: var(--font14Size);
  267. border-radius: 5px;
  268. }
  269. }
  270. .two {
  271. position: relative;
  272. flex-grow: 1;
  273. background-color: var(--f9Color);
  274. .tabsList {
  275. position: relative;
  276. width: 100vw;
  277. height: 82vh;
  278. .list {
  279. margin: 2vw;
  280. background-color: var(--fffColor);
  281. padding: 2vw;
  282. width: 92vw;
  283. border-radius: 5px;
  284. .list_1 {
  285. display: flex;
  286. justify-content: space-between;
  287. font-size: var(--font16Size);
  288. margin: 0 0 2vw 0;
  289. .shopname {
  290. text {
  291. margin: 0 0 0 1vw;
  292. }
  293. }
  294. .type {
  295. color: var(--ff0Color);
  296. }
  297. }
  298. .list_2 {
  299. display: flex;
  300. justify-content: space-between;
  301. align-items: center;
  302. .image {
  303. width: 25vw;
  304. height: 25vw;
  305. margin: 0 2vw 1vw 0;
  306. }
  307. .other {
  308. flex-grow: 1;
  309. .name {
  310. font-size: var(--font16Size);
  311. }
  312. .other_1 {
  313. font-size: var(--font14Size);
  314. text {
  315. color: var(--f85Color);
  316. }
  317. }
  318. }
  319. }
  320. .btn {
  321. text-align: right;
  322. button {
  323. margin: 2vw 0 0 2vw;
  324. }
  325. }
  326. }
  327. .list:nth-child(2n) {
  328. margin: 0 0 2vw 0;
  329. }
  330. }
  331. }
  332. }
  333. .scroll-view {
  334. position: absolute;
  335. top: 0;
  336. left: 0;
  337. right: 0;
  338. bottom: 0;
  339. .list-scroll-view {
  340. display: flex;
  341. flex-direction: column;
  342. }
  343. }
  344. </style>