after.vue 9.0 KB

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