after.vue 5.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272
  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. <scroll-view scroll-y="true" class="scroll-view" @scrolltolower="toPage">
  9. <view class="list-scroll-view">
  10. <view class="list" v-for="(item,index) in list" :key="index">
  11. <view class="list_1">
  12. <view class="shopname">
  13. <text class="iconfont icon-shangdian"></text>
  14. <text>{{item.shop.name}}</text>
  15. </view>
  16. <view class="type">
  17. {{item.type=='0'?'退款':item.type=='1'?'换货':'维修'}}
  18. </view>
  19. </view>
  20. <view class="list_2">
  21. <image class="image" :src="item.file&&item.file.length>0?item.file[0].url:''" mode="">
  22. </image>
  23. <view class="other">
  24. <view class="name">
  25. {{item.goods.goods.name||'暂无'}}
  26. </view>
  27. <view class="other_1">
  28. 商品规格:<text>{{item.goods.name||'暂无'}}</text>
  29. </view>
  30. <view class="other_1">
  31. 退款:<text>¥{{item.result.money||'暂无'}}</text>
  32. </view>
  33. <view class="other_1">
  34. 申请时间:<text>{{item.apply_time||'暂无'}}</text>
  35. </view>
  36. <view class="other_1">
  37. 售后描述:<text>{{item.desc||'暂无'}}</text>
  38. </view>
  39. </view>
  40. </view>
  41. <view class="btn">
  42. <button type="default" size="mini" @click="toCancel(item)">取消售后</button>
  43. <button v-if="item.type!='0'" type="default" size="mini" @click="toRevise(item)">维护信息</button>
  44. </view>
  45. </view>
  46. </view>
  47. </scroll-view>
  48. </view>
  49. </view>
  50. </mobile-frame>
  51. </template>
  52. <script>
  53. export default {
  54. data() {
  55. return {
  56. user: {},
  57. list: [],
  58. total: 0,
  59. skip: 0,
  60. limit: 5,
  61. page: 0
  62. };
  63. },
  64. onShow: function() {
  65. const that = this;
  66. that.clearPage();
  67. that.watchLogin();
  68. },
  69. methods: {
  70. // 维护信息
  71. toRevise(e) {
  72. uni.navigateTo({
  73. url: `/pagesMy/order/detail?id=${e.id||e._id}`
  74. })
  75. },
  76. // 取消售后
  77. toCancel(e) {
  78. const that = this;
  79. uni.showModal({
  80. title: '提示',
  81. content: '确定删除售后申请吗?',
  82. success: async function(res) {
  83. if (res.confirm) {
  84. const arr = await that.$api(`/afterSale/${e._id}`, 'DELETE');
  85. if (arr.errcode == '0') {
  86. uni.showToast({
  87. title: '删除售后成功',
  88. icon: 'none'
  89. })
  90. that.clearPage();
  91. that.search();
  92. } else {
  93. uni.showToast({
  94. title: arr.errmsg,
  95. icon: 'none'
  96. })
  97. }
  98. }
  99. }
  100. });
  101. },
  102. // 监听用户是否登录
  103. watchLogin() {
  104. const that = this;
  105. uni.getStorage({
  106. key: 'token',
  107. success: function(res) {
  108. let user = that.$jwt(res.data);
  109. if (user) that.$set(that, `user`, user);
  110. that.search();
  111. },
  112. fail: function(err) {
  113. uni.navigateTo({
  114. url: `/pages/login/index`
  115. })
  116. }
  117. });
  118. },
  119. // 查询列表
  120. async search() {
  121. const that = this;
  122. let user = that.user;
  123. const arr = await that.$api(`/afterSale`, 'GET', {
  124. customer: user._id
  125. });
  126. if (arr.errcode == '0') {
  127. let list = [...that.list, ...arr.data];
  128. that.$set(that, `list`, list)
  129. that.$set(that, `total`, arr.total)
  130. } else {
  131. uni.showToast({
  132. title: arr.errmsg,
  133. });
  134. }
  135. },
  136. // 分页
  137. toPage(e) {
  138. const that = this;
  139. let list = that.list;
  140. let limit = that.limit;
  141. if (that.total > list.length) {
  142. uni.showLoading({
  143. title: '加载中',
  144. mask: true
  145. })
  146. let page = that.page + 1;
  147. that.$set(that, `page`, page)
  148. let skip = page * limit;
  149. that.$set(that, `skip`, skip)
  150. that.search();
  151. uni.hideLoading();
  152. } else uni.showToast({
  153. title: '没有更多数据了'
  154. });
  155. },
  156. // 清空列表
  157. clearPage() {
  158. const that = this;
  159. that.$set(that, `list`, [])
  160. that.$set(that, `skip`, 0)
  161. that.$set(that, `limit`, 5)
  162. that.$set(that, `page`, 0)
  163. }
  164. }
  165. }
  166. </script>
  167. <style lang="scss">
  168. .main {
  169. display: flex;
  170. flex-direction: column;
  171. width: 100vw;
  172. height: 100vh;
  173. .one {
  174. border-bottom: 1px solid var(--f85Color);
  175. padding: 2vw;
  176. input {
  177. padding: 2vw;
  178. background-color: var(--f1Color);
  179. font-size: var(--font14Size);
  180. border-radius: 5px;
  181. }
  182. }
  183. .two {
  184. position: relative;
  185. flex-grow: 1;
  186. background-color: var(--f9Color);
  187. .list {
  188. margin: 2vw;
  189. background-color: var(--fffColor);
  190. padding: 2vw;
  191. width: 92vw;
  192. border-radius: 5px;
  193. .list_1 {
  194. display: flex;
  195. justify-content: space-between;
  196. font-size: var(--font16Size);
  197. margin: 0 0 2vw 0;
  198. .shopname {
  199. text {
  200. margin: 0 0 0 1vw;
  201. }
  202. }
  203. .type {
  204. color: var(--f85Color);
  205. }
  206. }
  207. .list_2 {
  208. display: flex;
  209. justify-content: space-between;
  210. align-items: center;
  211. .image {
  212. width: 25vw;
  213. height: 25vw;
  214. margin: 0 2vw 1vw 0;
  215. }
  216. .other {
  217. flex-grow: 1;
  218. .name {
  219. font-size: var(--font16Size);
  220. }
  221. .other_1 {
  222. font-size: var(--font14Size);
  223. text {
  224. color: var(--f85Color);
  225. }
  226. }
  227. }
  228. }
  229. .btn {
  230. text-align: right;
  231. button {
  232. margin: 2vw 0 0 2vw;
  233. }
  234. }
  235. }
  236. .list:nth-child(2n) {
  237. margin: 0 0 2vw 0;
  238. }
  239. }
  240. }
  241. .scroll-view {
  242. position: absolute;
  243. top: 0;
  244. left: 0;
  245. right: 0;
  246. bottom: 0;
  247. .list-scroll-view {
  248. display: flex;
  249. flex-direction: column;
  250. }
  251. }
  252. </style>