after.vue 8.4 KB

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