after.vue 6.3 KB

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