after.vue 7.6 KB

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