mine_order_list.vue 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413
  1. <template>
  2. <view class="dt-page">
  3. <view class="scroll-tab-wrap">
  4. <DtScrollTab :config="configTab" :dataList="tabList" :current.sync="curTab" @change="onTabChange" />
  5. </view>
  6. <swiper :style="calcHeight" duration="300" :current="curTab" @change="onSwiperChange">
  7. <swiper-item v-for="(tItem, tIdx) in tabList" :key="tIdx">
  8. <scroll-view @scrolltolower="onReachLower" scroll-y="true" class="scoll-h">
  9. <block v-if="curTab==tIdx">
  10. <view v-if="emptyType==0" class="content-wrap">
  11. <view v-for="(item,idx) in dataList" :key="idx" class="order-item-wrap">
  12. <DtOrderItem :dataDetail="item" @timer="onTimer(idx)" @tapbtn="onTapBtn($event,idx)" @order="onOrderTap" />
  13. </view>
  14. <DtNoMore v-if="isNoMore" />
  15. </view>
  16. <DtEmpty :type="emptyType"/>
  17. <!-- <DtEmpty :type="emptyType" :wrapHeight="50+'%'" :loadingPaddingTop="20+'%'"/> -->
  18. <view v-if="recomendList.length>0" clsss="recommend">
  19. <DtRecommendWrap title="新邻推荐" />
  20. <DtRecommendGoodsList :dataList="recomendList" />
  21. </view>
  22. </block>
  23. </scroll-view>
  24. </swiper-item>
  25. </swiper>
  26. <!-- 微信客服 -->
  27. <DtService />
  28. </view>
  29. </template>
  30. <script>
  31. import DtScrollTab from '../comps/dt_scroll_tab.vue'
  32. import DtOrderItem from '../comps/dt_order_item.vue'
  33. import DtEmpty from '../comps/dt_empty.vue'
  34. import DtNoMore from '../comps/dt_no_more.vue'
  35. import DtService from '../comps/dt_service.vue'
  36. import DtRecommendWrap from '../comps/dt_recommend_wrap.vue'
  37. import DtRecommendGoodsList from '../comps/dt_recommend_goods_list.vue'
  38. export default {
  39. components: {
  40. DtScrollTab,
  41. DtOrderItem,
  42. DtEmpty,
  43. DtNoMore,
  44. DtService,
  45. DtRecommendWrap,
  46. DtRecommendGoodsList
  47. },
  48. data() {
  49. return {
  50. configTab: {
  51. width: '20vw',
  52. isActiveLine: true
  53. },
  54. curTab: 0,
  55. tabList: ['全部', '待付款', '待发货', '待收货', '已取消', '待评价','已完成','退款/售后'],
  56. winHeight: "", //窗口高度,
  57. dataList: [],
  58. memberId: '',
  59. isOne: true,
  60. recomendList:[]
  61. }
  62. },
  63. computed: {
  64. calcHeight() {
  65. return "height:" + this.winHeight + "px;";
  66. },
  67. tabValues() {
  68. return [
  69. this.orderState.all,
  70. this.orderState.waitForPay,
  71. this.orderState.waitForDelive,
  72. this.orderState.waitForReceive,
  73. this.orderState.cancel,
  74. this.orderState.waitForAppraise,
  75. this.orderState.finished,
  76. this.orderState.afterSale
  77. ]
  78. },
  79. orderState() {
  80. return this.$global.orderState
  81. },
  82. saledStatus(){
  83. return this.$global.saledStatus
  84. },
  85. saledStatusName(){
  86. return this.$global.saledStatusName
  87. },
  88. refundState() {
  89. return [
  90. this.orderState.refunded, // 已退款
  91. this.orderState.failRefund, // 退款失败
  92. this.orderState.refunding, // 退款中
  93. ]
  94. },
  95. },
  96. methods: {
  97. // 推荐商品列表
  98. async queryRecomendList() {
  99. let params = [
  100. {
  101. t: 3,
  102. v: -1,
  103. k: "hits"
  104. },
  105. {
  106. t: 1,
  107. v: this.$global.server.storeId,
  108. k: "storeId"
  109. }
  110. ]
  111. let resp = await this.$api.searchProduct({
  112. memberId: this.memberId,
  113. pageNo: this.pageIndex,
  114. pageSize: 10,
  115. params: params
  116. })
  117. let list = this.getDataList(resp);
  118. this.recomendList = this.recomendList.concat(list)
  119. },
  120. onSwiperChange(e) {
  121. console.log(113, e)
  122. this.curTab = e.detail.current
  123. this.isNoMore = false
  124. this.emptyType = -1
  125. this.pageIndex = 0;
  126. this.dataList.length = 0
  127. this.queryDataList(this.tabValues[this.curTab])
  128. },
  129. onTabChange(idx) {
  130. console.log(23, this.tabValues[idx])
  131. },
  132. onOrderTap(item) {
  133. let isAfterSales = this.curTab === this.tabList.length-1
  134. if(isAfterSales){
  135. uni.navigateTo({
  136. url: '/pagesM/pages/order_sale_detail?orderSns='+ item.sn +'&adfterSaleId=' + item.id +'&isAfterSales='+1
  137. })
  138. }else{
  139. uni.navigateTo({
  140. url: '/pagesM/pages/order_detail?orderSns=' + item.sn
  141. })
  142. }
  143. },
  144. // 过期
  145. onTimer(idx) {
  146. let dataList = this.dataList.slice(0)
  147. let curItem = dataList[idx]
  148. let state = this.orderState.cancel
  149. curItem.status = state
  150. curItem.statusTxt = this.$global.orderStateName[state]
  151. dataList[idx] = curItem
  152. this.dataList = dataList
  153. },
  154. onTapBtn({flag, item},idx) {
  155. console.log(118, flag, item, idx)
  156. switch (flag) {
  157. case 'cancel':
  158. this.cancelOrder(item)
  159. break;
  160. case 'pay':
  161. this.payOrder(item)
  162. break;
  163. case 'refund':
  164. this.refund(item)
  165. break;
  166. case 'cancelRefund':
  167. this.cancelRefund(item)
  168. break;
  169. case 'refund_choose':
  170. this.refund_choose(item)
  171. break;
  172. case 'receive':
  173. this.$dialog.confirm({
  174. content: '确认收货吗?',
  175. success: async (res) => {
  176. if (res.confirm) {
  177. this.receiveOrder(item)
  178. }
  179. }
  180. })
  181. break;
  182. case 'appraise':
  183. uni.navigateTo({
  184. url: '/pagesM/pages/order_appraise?idx=' + idx
  185. })
  186. break;
  187. case 'delete':
  188. this.$dialog.confirm({
  189. content: '确认删除该订单吗?',
  190. success: async (res) => {
  191. if (res.confirm) {
  192. this.delOrder(item)
  193. }
  194. }
  195. })
  196. break;
  197. default: break;
  198. }
  199. },
  200. async refund_choose(item) {
  201. uni.navigateTo({
  202. url:'/pagesM/pages/after_sale_choose?orderId='+item.id
  203. })
  204. },
  205. async cancelOrder(item) {
  206. this.$dialog.confirm({
  207. content:'确认取消该订单吗?',
  208. success: (res) => {
  209. if (res.confirm) {
  210. todoCancelOrder()
  211. }
  212. }
  213. })
  214. let ctx = this
  215. async function todoCancelOrder(){
  216. let resp = await ctx.$api.cancelOrder({
  217. sn: item.sn,
  218. detail:'订单取消',
  219. remark:'B2C微信小程序用户取消订单',
  220. })
  221. ctx.$dialog.success('取消成功',()=>{
  222. ctx.$util.refreshPage(['pages/mine'])
  223. ctx.onPullDownRefreshPage()
  224. })
  225. }
  226. // let resp = await this.$api.cancelOrder({
  227. // sn: item.sn,
  228. // detail: '订单取消',
  229. // remark: 'B2C微信小程序用户取消订单',
  230. // })
  231. // this.$util.refreshPage(['pages/mine'])
  232. // this.isPull = true
  233. // this.queryDataList(this.tabValues[this.curTab])
  234. },
  235. async payOrder(item) {
  236. let sns = [item.sn]
  237. uni.navigateTo({ url: "/pagesM/pages/order_pay?orderSns=" + JSON.stringify(sns) + "&payFlag=" + this.$global.payFlag.order });
  238. },
  239. async refund(item) {
  240. uni.navigateTo({
  241. // url:'/pages/after_sale_choose?orderId='+item.id
  242. url:'/pagesM/pages/after_sale_submit?orderId='+item.id
  243. })
  244. },
  245. async cancelRefund(item) {
  246. this.$dialog.confirm({
  247. content: '确定取消售后吗?',
  248. success: async (res) => {
  249. if (res.confirm) {
  250. todoCancelRefund()
  251. }
  252. }
  253. })
  254. let ctx = this
  255. async function todoCancelRefund(){
  256. let resp = await ctx.$api.cancelAftersales({
  257. _isShowLoading:true,
  258. id:item.id
  259. })
  260. ctx.$dialog.success('取消成功',()=>{
  261. ctx.$util.refreshPage(['pages/mine'])
  262. ctx.onPullDownRefreshPage()
  263. })
  264. }
  265. },
  266. async receiveOrder(item) {
  267. let resp = await this.$api.orderChange({
  268. memberId: this.memberId,
  269. orderId: item.id,
  270. execType: 2
  271. })
  272. this.$dialog.success('确认收货',()=>{
  273. this.$util.refreshPage(['pages/mine'])
  274. this.onPullDownRefreshPage()
  275. })
  276. },
  277. async delOrder(item) {
  278. let resp = await this.$api.delOrder({
  279. orderId: item.id
  280. })
  281. // this.$dialog.success('删除成功')
  282. this.$util.refreshPage(['pages/mine'])
  283. this.onPullDownRefreshPage()
  284. },
  285. // tapToDetail(item){
  286. // uni.navigateTo({
  287. // url:'/pages/order_detail'
  288. // })
  289. // },
  290. onReachLower(ev) {
  291. console.log(108, ev)
  292. this.onReachBottomPage();
  293. },
  294. // 查询数据
  295. async queryDataList(status) {
  296. if (this.isPull) {
  297. this.emptyType = -1
  298. this.isNoMore = false
  299. this.pageIndex = 0
  300. this.dataList.length = 0
  301. }
  302. let resp = null, list = []
  303. if(this.curTab==7){
  304. resp = await this.$api.getAftersaless({
  305. _isShowLoading:true,
  306. _isPull: this.isPull,
  307. memberId:this.memberId,
  308. pageNo:this.pageIndex,
  309. pageSize:this.pageSize
  310. })
  311. }else{
  312. resp = await this.$api.getMyOrders({
  313. _isShowLoading: true,
  314. _isPull: this.isPull,
  315. status: status || this.$global.orderState.all,
  316. memberId: this.memberId,
  317. pageNo: this.pageIndex,
  318. pageSize: this.pageSize
  319. })
  320. }
  321. list = this.getDataList(resp);
  322. if(this.curTab==7){
  323. list.map((item) => {
  324. item.sn = item.orderSN
  325. item.amount = 0
  326. item.products = item.aftersalesItems.slice(0)
  327. item.products.map((itm) => {
  328. itm.specificationsDesc = itm.specifications.join(' ')
  329. item.amount += itm.quantity * itm.price
  330. return itm
  331. })
  332. let status = item.status
  333. item.status = this.saledStatus[status]
  334. item.statusTxt = this.saledStatusName[status]
  335. return item
  336. })
  337. }else{
  338. list.map((item) => {
  339. item.products.map((itm) => {
  340. itm.specificationsDesc = itm.specifications.join(' ')
  341. return itm
  342. })
  343. return item
  344. })
  345. }
  346. this.dataList = this.dataList.concat(list)
  347. },
  348. onLoadPage(options) {
  349. wx.hideShareMenu();
  350. if (this.isLoad) {
  351. this.curTab = parseInt(options.state)
  352. this.memberId = this.$auth.getMemberId()
  353. if (options.state == 0) {
  354. this.queryDataList()
  355. }
  356. // 初始化高度
  357. let res = uni.getSystemInfoSync();
  358. let clientHeight = res.windowHeight;
  359. let clientWidth = res.windowWidth;
  360. let upxR = 750 / clientWidth;
  361. let calc = clientHeight * upxR - 110;
  362. let height = uni.upx2px(calc);
  363. this.winHeight = height;
  364. }
  365. if (this.isReach || this.isPull) {
  366. console.log(331, 'isReach',this.isReach,this.isPull)
  367. this.queryDataList(this.tabValues[this.curTab]);
  368. }
  369. },
  370. },
  371. onShow(){
  372. this.onShowPage()
  373. // if(this.isOne){
  374. // this.isOne = false;
  375. // return;
  376. // }
  377. let e = {detail:{current:this.curTab}};
  378. //发起售后返回后会刷新执行,所以加个判断
  379. if (!this.isReach&&!this.isPull) {
  380. this.onSwiperChange(e);
  381. }
  382. },
  383. onPullDownRefresh(){
  384. this.onPullDownRefreshPage()
  385. },
  386. }
  387. </script>
  388. <style lang="scss" scoped>
  389. .dt-page {
  390. min-height: 100vh;
  391. background-color: #f2f2f2;
  392. .scroll-tab-wrap {
  393. margin-bottom: 20upx;
  394. }
  395. .scoll-h {
  396. height: 100%;
  397. // .conttent-wrap {
  398. // }
  399. }
  400. .content-wrap {
  401. .order-item-wrap {
  402. margin-bottom: 20upx;
  403. }
  404. }
  405. }
  406. </style>