after.vue 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449
  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: '1',
  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. that.$set(that, `typeList`, res.data)
  182. var menu = res.data.map((item) => {
  183. return {
  184. title: item.label,
  185. active: item.value
  186. }
  187. })
  188. that.$set(that.tabs, `menu`, menu)
  189. }
  190. res = await that.$api(`/dictData`, 'GET', {
  191. code: "afterSale_status"
  192. });
  193. if (res.errcode == '0') {
  194. that.$set(that, `statusList`, res.data)
  195. }
  196. },
  197. // 分页
  198. toPage(e) {
  199. const that = this;
  200. let list = that.list;
  201. let limit = that.limit;
  202. if (that.total > list.length) {
  203. uni.showLoading({
  204. title: '加载中',
  205. mask: true
  206. })
  207. let page = that.page + 1;
  208. that.$set(that, `page`, page)
  209. let skip = page * limit;
  210. that.$set(that, `skip`, skip)
  211. that.search();
  212. uni.hideLoading();
  213. } else that.$set(that, `is_bottom`, true)
  214. },
  215. toScroll(e) {
  216. const that = this;
  217. let up = that.scrollTop;
  218. that.$set(that, `scrollTop`, e.detail.scrollTop);
  219. let num = Math.sign(up - e.detail.scrollTop);
  220. if (num == 1) that.$set(that, `is_bottom`, false);
  221. },
  222. // 输入框
  223. toInput(e) {
  224. const that = this;
  225. if (that.searchInfo.goods) {
  226. that.$set(that.searchInfo, `goods`, e.detail.value)
  227. } else {
  228. that.$set(that, `searchInfo`, {})
  229. }
  230. that.clearPage();
  231. that.search();
  232. },
  233. // 选择选项卡
  234. tabsChange(e) {
  235. const that = this;
  236. that.$set(that.tabs, `active`, e.active)
  237. that.$set(that, `type`, e.active);
  238. that.clearPage();
  239. that.search()
  240. },
  241. // 售后详细信息
  242. toView(item) {
  243. uni.navigateTo({
  244. url: `/pagesMy/order/afterInfo?id=${item._id}`
  245. })
  246. },
  247. // 订单详细
  248. toInfo(item) {
  249. uni.navigateTo({
  250. url: `/pagesMy/order/info?id=${item.order_detail._id}&status=${item.order_detail.status}`
  251. })
  252. },
  253. // 维护单号
  254. toMaintain(item) {
  255. uni.navigateTo({
  256. url: `/pagesMy/order/detail?id=${item._id}`
  257. })
  258. },
  259. // 确认收货
  260. async toConfirm(item) {
  261. const that = this;
  262. uni.showModal({
  263. title: '提示',
  264. content: '是否确认收货?',
  265. success: async function(res) {
  266. if (res.confirm) {
  267. item.transport.customer_receive = true;
  268. const arr = await that.$api(`/afterSale/${item.id}`, 'POST', {
  269. transport: item.transport
  270. });
  271. if (arr.errcode == '0') {
  272. uni.showToast({
  273. title: `确认收货成功`,
  274. icon: 'success',
  275. });
  276. that.clearPage();
  277. that.search();
  278. } else {
  279. uni.showToast({
  280. title: arr.errmsg,
  281. icon: 'none',
  282. })
  283. }
  284. }
  285. }
  286. });
  287. },
  288. // 查看物流
  289. toLogi(e) {
  290. uni.navigateTo({
  291. url: `/pagesMy/logistics/index?id=${e._id}&type=${'afterSale'}`
  292. })
  293. },
  294. // 取消售后
  295. toCancel(e) {
  296. const that = this;
  297. uni.showModal({
  298. title: '提示',
  299. content: '确定取消售后申请吗?',
  300. success: async function(res) {
  301. if (res.confirm) {
  302. const arr = await that.$api(`/afterSale/${e._id}`, 'DELETE');
  303. if (arr.errcode == '0') {
  304. uni.showToast({
  305. title: '取消售后成功',
  306. icon: 'none'
  307. })
  308. that.clearPage();
  309. that.search();
  310. } else {
  311. uni.showToast({
  312. title: arr.errmsg,
  313. icon: 'none'
  314. })
  315. }
  316. }
  317. }
  318. });
  319. },
  320. // 清空列表
  321. clearPage() {
  322. const that = this;
  323. that.$set(that, `list`, [])
  324. that.$set(that, `skip`, 0)
  325. that.$set(that, `limit`, 6)
  326. that.$set(that, `page`, 0)
  327. }
  328. }
  329. }
  330. </script>
  331. <style lang="scss">
  332. .main {
  333. display: flex;
  334. flex-direction: column;
  335. width: 100vw;
  336. height: 100vh;
  337. .one {
  338. padding: 2vw;
  339. input {
  340. padding: 2vw;
  341. background-color: var(--f1Color);
  342. font-size: var(--font14Size);
  343. border-radius: 5px;
  344. }
  345. }
  346. .two {
  347. position: relative;
  348. flex-grow: 1;
  349. background-color: var(--f9Color);
  350. .tabsList {
  351. position: relative;
  352. width: 100vw;
  353. height: 82vh;
  354. .list {
  355. margin: 2vw 2vw 0 2vw;
  356. background-color: var(--fffColor);
  357. padding: 2vw;
  358. width: 92vw;
  359. border-radius: 5px;
  360. .list_1 {
  361. display: flex;
  362. justify-content: space-between;
  363. font-size: var(--font16Size);
  364. margin: 0 0 2vw 0;
  365. .shopname {
  366. text {
  367. margin: 0 0 0 1vw;
  368. }
  369. }
  370. .type {
  371. color: var(--ff0Color);
  372. }
  373. }
  374. .list_2 {
  375. display: flex;
  376. justify-content: space-between;
  377. .image {
  378. width: 25vw;
  379. height: 25vw;
  380. margin: 0 2vw 1vw 0;
  381. border: 1px solid var(--f85Color);
  382. }
  383. .other {
  384. flex-grow: 1;
  385. .name {
  386. font-size: var(--font16Size);
  387. }
  388. .other_1 {
  389. font-size: var(--font14Size);
  390. text {
  391. color: var(--f85Color);
  392. }
  393. }
  394. }
  395. }
  396. .btn {
  397. text-align: right;
  398. button {
  399. margin: 2vw 0 0 2vw;
  400. }
  401. }
  402. }
  403. }
  404. }
  405. }
  406. .scroll-view {
  407. position: absolute;
  408. top: 0;
  409. left: 0;
  410. right: 0;
  411. bottom: 0;
  412. .list-scroll-view {
  413. display: flex;
  414. flex-direction: column;
  415. }
  416. }
  417. .is_bottom {
  418. text-align: center;
  419. text {
  420. padding: 2vw 0;
  421. display: inline-block;
  422. color: #858585;
  423. font-size: 14px;
  424. }
  425. }
  426. </style>