after.vue 9.4 KB

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