after.vue 8.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392
  1. <template>
  2. <mobile-frame>
  3. <view class="main">
  4. <view class="one">
  5. <input type="text" v-model="searchInfo.name" @input="toInput" placeholder="搜索商品" @scroll="toScroll">
  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:''" mode="">
  24. </image>
  25. <view class="other">
  26. <view class="name">
  27. {{item.goods.goods.name||'暂无'}}
  28. </view>
  29. <view class="other_1">
  30. 商品规格:<text>{{item.goods.name||'暂无'}}</text>
  31. </view>
  32. <view class="other_1" v-if="item.type!='2'">
  33. 退款:<text>¥{{item.money||0}}</text>
  34. </view>
  35. <view class="other_1">
  36. 申请时间:<text>{{item.apply_time||'暂无'}}</text>
  37. </view>
  38. <view class="other_1">
  39. 售后描述:<text>{{item.desc||'暂无'}}</text>
  40. </view>
  41. <view class="other_1">
  42. 售后处理人:<text>{{item.deal_person.name||'暂无'}}</text>
  43. </view>
  44. </view>
  45. </view>
  46. <view class="btn">
  47. <button v-if="item.status=='0'||item.status=='1'" type="default" size="mini" @tap.stop="toCancel(item)">取消售后</button>
  48. </view>
  49. </view>
  50. <view class="is_bottom" v-if="is_bottom">
  51. <text>{{config.bottom_title}}</text>
  52. </view>
  53. </view>
  54. </scroll-view>
  55. </view>
  56. </tabs>
  57. </view>
  58. </view>
  59. </mobile-frame>
  60. </template>
  61. <script>
  62. import tabs from '@/components/tabs/index.vue';
  63. export default {
  64. components: {
  65. tabs
  66. },
  67. data() {
  68. return {
  69. // 系统设置
  70. config: {},
  71. user: {},
  72. list: [],
  73. typeList: [],
  74. total: 0,
  75. skip: 0,
  76. limit: 10,
  77. page: 0,
  78. tabs: {
  79. active: '0',
  80. menu: [{
  81. title: '申请售后',
  82. active: '0'
  83. },
  84. {
  85. title: '正在处理退款',
  86. active: '1'
  87. },
  88. {
  89. title: '已退款',
  90. active: '-1'
  91. },
  92. {
  93. title: '已退货',
  94. active: '-2'
  95. },
  96. {
  97. title: '正在处理换货',
  98. active: '3'
  99. },
  100. {
  101. title: '已换货',
  102. active: '-3'
  103. }
  104. ]
  105. },
  106. status: '0',
  107. // 数据是否触底
  108. is_bottom: false,
  109. scrollTop: 0,
  110. };
  111. },
  112. onLoad: async function() {
  113. const that = this;
  114. that.searchConfig();
  115. // 查询其他信息
  116. await that.searchOther();
  117. // 监听用户登录
  118. await that.watchLogin();
  119. },
  120. onPullDownRefresh: async function() {
  121. const that = this;
  122. that.clearPage();
  123. await that.search();
  124. uni.stopPullDownRefresh();
  125. },
  126. methods: {
  127. // 查询基本设置
  128. searchConfig() {
  129. const that = this;
  130. uni.getStorage({
  131. key: 'config',
  132. success: function(res) {
  133. if (res.data) that.$set(that, `config`, res.data)
  134. },
  135. fail: function(err) {
  136. console.log(err);
  137. }
  138. })
  139. },
  140. // 监听用户是否登录
  141. watchLogin() {
  142. const that = this;
  143. uni.getStorage({
  144. key: 'token',
  145. success: function(res) {
  146. let user = that.$jwt(res.data);
  147. if (user) that.$set(that, `user`, user);
  148. that.search();
  149. },
  150. fail: function(err) {
  151. uni.navigateTo({
  152. url: `/pages/login/index`
  153. })
  154. }
  155. });
  156. },
  157. // 查询列表
  158. async search() {
  159. const that = this;
  160. let user = that.user;
  161. let status = that.status;
  162. const arr = await that.$api(`/afterSale`, 'GET', {
  163. customer: user._id,
  164. status: that.status,
  165. });
  166. if (arr.errcode == '0') {
  167. let list = [...that.list, ...arr.data];
  168. for (let val of list) {
  169. let type = that.typeList.find(i => i.value == val.type)
  170. if (type) val.zhType = type.label;
  171. val.url = val?.goods?.goods?.file;
  172. }
  173. that.$set(that, `list`, list)
  174. that.$set(that, `total`, arr.total)
  175. } else {
  176. uni.showToast({
  177. title: arr.errmsg,
  178. });
  179. }
  180. },
  181. // 查询其他信息
  182. async searchOther() {
  183. const that = this;
  184. let res;
  185. res = await that.$api(`/dictData`, 'GET', {
  186. code: "afterSale_type"
  187. });
  188. if (res.errcode == '0') {
  189. that.$set(that, `typeList`, res.data)
  190. }
  191. },
  192. // 分页
  193. toPage(e) {
  194. const that = this;
  195. let list = that.list;
  196. let limit = that.limit;
  197. if (that.total > list.length) {
  198. uni.showLoading({
  199. title: '加载中',
  200. mask: true
  201. })
  202. let page = that.page + 1;
  203. that.$set(that, `page`, page)
  204. let skip = page * limit;
  205. that.$set(that, `skip`, skip)
  206. that.search();
  207. uni.hideLoading();
  208. } else that.$set(that, `is_bottom`, true)
  209. },
  210. toScroll(e) {
  211. const that = this;
  212. let up = that.scrollTop;
  213. that.$set(that, `scrollTop`, e.detail.scrollTop);
  214. let num = Math.sign(up - e.detail.scrollTop);
  215. if (num == 1) that.$set(that, `is_bottom`, false);
  216. },
  217. // 选择选项卡
  218. tabsChange(e) {
  219. const that = this;
  220. that.$set(that.tabs, `active`, e.active)
  221. that.$set(that, `status`, e.active);
  222. that.clearPage();
  223. that.search()
  224. },
  225. // 订单详细
  226. toInfo(item) {
  227. uni.navigateTo({
  228. url: `/pagesMy/order/info?id=${item.order_detail._id}&status=${item.order_detail.status}`
  229. })
  230. },
  231. // 取消售后
  232. toCancel(e) {
  233. const that = this;
  234. uni.showModal({
  235. title: '提示',
  236. content: '确定删除售后申请吗?',
  237. success: async function(res) {
  238. if (res.confirm) {
  239. const arr = await that.$api(`/afterSale/${e._id}`, 'DELETE');
  240. if (arr.errcode == '0') {
  241. uni.showToast({
  242. title: '删除售后成功',
  243. icon: 'none'
  244. })
  245. that.clearPage();
  246. that.search();
  247. } else {
  248. uni.showToast({
  249. title: arr.errmsg,
  250. icon: 'none'
  251. })
  252. }
  253. }
  254. }
  255. });
  256. },
  257. // 清空列表
  258. clearPage() {
  259. const that = this;
  260. that.$set(that, `list`, [])
  261. that.$set(that, `skip`, 0)
  262. that.$set(that, `limit`, 6)
  263. that.$set(that, `page`, 0)
  264. }
  265. }
  266. }
  267. </script>
  268. <style lang="scss">
  269. .main {
  270. display: flex;
  271. flex-direction: column;
  272. width: 100vw;
  273. height: 100vh;
  274. .one {
  275. // border-bottom: 1px solid var(--f85Color);
  276. padding: 2vw;
  277. input {
  278. padding: 2vw;
  279. background-color: var(--f1Color);
  280. font-size: var(--font14Size);
  281. border-radius: 5px;
  282. }
  283. }
  284. .two {
  285. position: relative;
  286. flex-grow: 1;
  287. background-color: var(--f9Color);
  288. .tabsList {
  289. position: relative;
  290. width: 100vw;
  291. height: 82vh;
  292. .list {
  293. margin: 2vw;
  294. background-color: var(--fffColor);
  295. padding: 2vw;
  296. width: 92vw;
  297. border-radius: 5px;
  298. .list_1 {
  299. display: flex;
  300. justify-content: space-between;
  301. font-size: var(--font16Size);
  302. margin: 0 0 2vw 0;
  303. .shopname {
  304. text {
  305. margin: 0 0 0 1vw;
  306. }
  307. }
  308. .type {
  309. color: var(--ff0Color);
  310. }
  311. }
  312. .list_2 {
  313. display: flex;
  314. justify-content: space-between;
  315. align-items: center;
  316. .image {
  317. width: 25vw;
  318. height: 25vw;
  319. margin: 0 2vw 1vw 0;
  320. }
  321. .other {
  322. flex-grow: 1;
  323. .name {
  324. font-size: var(--font16Size);
  325. }
  326. .other_1 {
  327. font-size: var(--font14Size);
  328. text {
  329. color: var(--f85Color);
  330. }
  331. }
  332. }
  333. }
  334. .btn {
  335. text-align: right;
  336. button {
  337. margin: 2vw 0 0 2vw;
  338. }
  339. }
  340. }
  341. .list:nth-child(2n) {
  342. margin: 0 0 2vw 0;
  343. }
  344. }
  345. }
  346. }
  347. .scroll-view {
  348. position: absolute;
  349. top: 0;
  350. left: 0;
  351. right: 0;
  352. bottom: 0;
  353. .list-scroll-view {
  354. display: flex;
  355. flex-direction: column;
  356. }
  357. }
  358. .is_bottom {
  359. text-align: center;
  360. text {
  361. padding: 2vw 0;
  362. display: inline-block;
  363. color: #858585;
  364. font-size: 14px;
  365. }
  366. }
  367. </style>