after.vue 11 KB

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