after.vue 8.4 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. <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. 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. toRevise(e) {
  152. uni.navigateTo({
  153. url: `/pagesMy/order/detail?id=${e.id||e._id}`
  154. })
  155. },
  156. // 取消售后
  157. toCancel(e) {
  158. const that = this;
  159. uni.showModal({
  160. title: '提示',
  161. content: '确定删除售后申请吗?',
  162. success: async function(res) {
  163. if (res.confirm) {
  164. const arr = await that.$api(`/afterSale/${e._id}`, 'DELETE');
  165. if (arr.errcode == '0') {
  166. uni.showToast({
  167. title: '删除售后成功',
  168. icon: 'none'
  169. })
  170. that.clearPage();
  171. that.search();
  172. } else {
  173. uni.showToast({
  174. title: arr.errmsg,
  175. icon: 'none'
  176. })
  177. }
  178. }
  179. }
  180. });
  181. },
  182. // 监听用户是否登录
  183. watchLogin() {
  184. const that = this;
  185. uni.getStorage({
  186. key: 'token',
  187. success: function(res) {
  188. let user = that.$jwt(res.data);
  189. if (user) that.$set(that, `user`, user);
  190. that.search();
  191. },
  192. fail: function(err) {
  193. uni.navigateTo({
  194. url: `/pages/login/index`
  195. })
  196. }
  197. });
  198. },
  199. // 查询列表
  200. async search() {
  201. const that = this;
  202. let user = that.user;
  203. let status = that.status;
  204. const arr = await that.$api(`/afterSale`, 'GET', {
  205. customer: user._id,
  206. status: that.status,
  207. });
  208. if (arr.errcode == '0') {
  209. let list = [...that.list, ...arr.data];
  210. for (let val of list) {
  211. let type = that.typeList.find(i => i.value == val.type)
  212. if (type) val.zhType = type.label;
  213. val.url = val?.goods?.goods?.file;
  214. }
  215. that.$set(that, `list`, list)
  216. that.$set(that, `total`, arr.total)
  217. } else {
  218. uni.showToast({
  219. title: arr.errmsg,
  220. });
  221. }
  222. },
  223. // 查询其他信息
  224. async searchOther() {
  225. const that = this;
  226. let res;
  227. res = await that.$api(`/dictData`, 'GET', {
  228. code: "afterSale_type"
  229. });
  230. if (res.errcode == '0') {
  231. that.$set(that, `typeList`, res.data)
  232. }
  233. },
  234. // 分页
  235. toPage(e) {
  236. const that = this;
  237. let list = that.list;
  238. let limit = that.limit;
  239. if (that.total > list.length) {
  240. uni.showLoading({
  241. title: '加载中',
  242. mask: true
  243. })
  244. let page = that.page + 1;
  245. that.$set(that, `page`, page)
  246. let skip = page * limit;
  247. that.$set(that, `skip`, skip)
  248. that.search();
  249. uni.hideLoading();
  250. } else that.$set(that, `is_bottom`, true)
  251. },
  252. toScroll(e) {
  253. const that = this;
  254. let up = that.scrollTop;
  255. that.$set(that, `scrollTop`, e.detail.scrollTop);
  256. let num = Math.sign(up - e.detail.scrollTop);
  257. if (num == 1) that.$set(that, `is_bottom`, false);
  258. },
  259. // 清空列表
  260. clearPage() {
  261. const that = this;
  262. that.$set(that, `list`, [])
  263. that.$set(that, `skip`, 0)
  264. that.$set(that, `limit`, 5)
  265. that.$set(that, `page`, 0)
  266. }
  267. }
  268. }
  269. </script>
  270. <style lang="scss">
  271. .main {
  272. display: flex;
  273. flex-direction: column;
  274. width: 100vw;
  275. height: 100vh;
  276. .one {
  277. // border-bottom: 1px solid var(--f85Color);
  278. padding: 2vw;
  279. input {
  280. padding: 2vw;
  281. background-color: var(--f1Color);
  282. font-size: var(--font14Size);
  283. border-radius: 5px;
  284. }
  285. }
  286. .two {
  287. position: relative;
  288. flex-grow: 1;
  289. background-color: var(--f9Color);
  290. .tabsList {
  291. position: relative;
  292. width: 100vw;
  293. height: 82vh;
  294. .list {
  295. margin: 2vw;
  296. background-color: var(--fffColor);
  297. padding: 2vw;
  298. width: 92vw;
  299. border-radius: 5px;
  300. .list_1 {
  301. display: flex;
  302. justify-content: space-between;
  303. font-size: var(--font16Size);
  304. margin: 0 0 2vw 0;
  305. .shopname {
  306. text {
  307. margin: 0 0 0 1vw;
  308. }
  309. }
  310. .type {
  311. color: var(--ff0Color);
  312. }
  313. }
  314. .list_2 {
  315. display: flex;
  316. justify-content: space-between;
  317. align-items: center;
  318. .image {
  319. width: 25vw;
  320. height: 25vw;
  321. margin: 0 2vw 1vw 0;
  322. }
  323. .other {
  324. flex-grow: 1;
  325. .name {
  326. font-size: var(--font16Size);
  327. }
  328. .other_1 {
  329. font-size: var(--font14Size);
  330. text {
  331. color: var(--f85Color);
  332. }
  333. }
  334. }
  335. }
  336. .btn {
  337. text-align: right;
  338. button {
  339. margin: 2vw 0 0 2vw;
  340. }
  341. }
  342. }
  343. .list:nth-child(2n) {
  344. margin: 0 0 2vw 0;
  345. }
  346. }
  347. }
  348. }
  349. .scroll-view {
  350. position: absolute;
  351. top: 0;
  352. left: 0;
  353. right: 0;
  354. bottom: 0;
  355. .list-scroll-view {
  356. display: flex;
  357. flex-direction: column;
  358. }
  359. }
  360. .is_bottom {
  361. text-align: center;
  362. text {
  363. padding: 2vw 0;
  364. display: inline-block;
  365. color: #858585;
  366. font-size: 14px;
  367. }
  368. }
  369. </style>