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