after.vue 9.1 KB

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