after.vue 6.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292
  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.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.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"
  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 (status) val.zhType = status.label;
  136. }
  137. that.$set(that, `list`, list)
  138. that.$set(that, `total`, arr.total)
  139. } else {
  140. uni.showToast({
  141. title: arr.errmsg,
  142. });
  143. }
  144. },
  145. // 查询其他信息
  146. async searchOther() {
  147. const that = this;
  148. let res;
  149. res = await that.$api(`/dictData`, 'GET', {
  150. code: "afterSale_type"
  151. });
  152. if (res.errcode == '0') {
  153. that.$set(that, `typeList`, res.data)
  154. }
  155. },
  156. // 分页
  157. toPage(e) {
  158. const that = this;
  159. let list = that.list;
  160. let limit = that.limit;
  161. if (that.total > list.length) {
  162. uni.showLoading({
  163. title: '加载中',
  164. mask: true
  165. })
  166. let page = that.page + 1;
  167. that.$set(that, `page`, page)
  168. let skip = page * limit;
  169. that.$set(that, `skip`, skip)
  170. that.search();
  171. uni.hideLoading();
  172. } else uni.showToast({
  173. title: '没有更多数据了'
  174. });
  175. },
  176. // 清空列表
  177. clearPage() {
  178. const that = this;
  179. that.$set(that, `list`, [])
  180. that.$set(that, `skip`, 0)
  181. that.$set(that, `limit`, 5)
  182. that.$set(that, `page`, 0)
  183. }
  184. }
  185. }
  186. </script>
  187. <style lang="scss">
  188. .main {
  189. display: flex;
  190. flex-direction: column;
  191. width: 100vw;
  192. height: 100vh;
  193. .one {
  194. border-bottom: 1px solid var(--f85Color);
  195. padding: 2vw;
  196. input {
  197. padding: 2vw;
  198. background-color: var(--f1Color);
  199. font-size: var(--font14Size);
  200. border-radius: 5px;
  201. }
  202. }
  203. .two {
  204. position: relative;
  205. flex-grow: 1;
  206. background-color: var(--f9Color);
  207. .list {
  208. margin: 2vw;
  209. background-color: var(--fffColor);
  210. padding: 2vw;
  211. width: 92vw;
  212. border-radius: 5px;
  213. .list_1 {
  214. display: flex;
  215. justify-content: space-between;
  216. font-size: var(--font16Size);
  217. margin: 0 0 2vw 0;
  218. .shopname {
  219. text {
  220. margin: 0 0 0 1vw;
  221. }
  222. }
  223. .type {
  224. color: var(--ff0Color);
  225. }
  226. }
  227. .list_2 {
  228. display: flex;
  229. justify-content: space-between;
  230. align-items: center;
  231. .image {
  232. width: 25vw;
  233. height: 25vw;
  234. margin: 0 2vw 1vw 0;
  235. }
  236. .other {
  237. flex-grow: 1;
  238. .name {
  239. font-size: var(--font16Size);
  240. }
  241. .other_1 {
  242. font-size: var(--font14Size);
  243. text {
  244. color: var(--f85Color);
  245. }
  246. }
  247. }
  248. }
  249. .btn {
  250. text-align: right;
  251. button {
  252. margin: 2vw 0 0 2vw;
  253. }
  254. }
  255. }
  256. .list:nth-child(2n) {
  257. margin: 0 0 2vw 0;
  258. }
  259. }
  260. }
  261. .scroll-view {
  262. position: absolute;
  263. top: 0;
  264. left: 0;
  265. right: 0;
  266. bottom: 0;
  267. .list-scroll-view {
  268. display: flex;
  269. flex-direction: column;
  270. }
  271. }
  272. </style>