after.vue 9.0 KB

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