after.vue 10 KB

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