after.vue 6.1 KB

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