after.vue 8.4 KB

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