11<template >
22 <view >
33 <view class =" wrap" >
4- <u-sticky >
4+ <u-sticky bgColor = " #ffffff " >
55 <view class =" u-tabs-box" >
6- <u-tabs activeColor =" #f29100 " ref = " tabs " :list =" list" :current =" current" @change =" change" :is-scroll = " false " swiperWidth = " 750 " ></u-tabs >
6+ <u-tabs lineColor =" #e64340 " :list =" list" :current =" current" @change =" change" ></u-tabs >
77 </view >
88 </u-sticky >
99 <page-box-empty v-if =" !orderList || orderList.length == 0" title =" 您还没有相关的订单" sub-title =" 可以去看看有那些想买的~" :show-btn =" true" />
3636 </view >
3737 <view v-if =" item.status == 0" class =" bottom" >
3838 <view class =" exchange btn" @click =" close(item.id)" >取消订单</view >
39- <view class =" evaluate btn u-margin-left-24 " @click =" pay(index)" >立即支付</view >
39+ <view class =" evaluate btn ml24 " @click =" pay(index)" >立即支付</view >
4040 </view >
4141 </view >
4242 </view >
@@ -52,47 +52,42 @@ export default {
5252 orderList: undefined ,
5353 dataList: undefined ,
5454 list: [
55+ {
56+ name: ' 全部' ,
57+ status: ' '
58+ },
5559 {
5660 name: ' 待付款' ,
57- count : 0
61+ status : ' 0 '
5862 },
5963 {
60- name: ' 待发货'
64+ name: ' 待发货' ,
65+ status: ' 1'
6166 },
6267 {
63- name: ' 待收货'
68+ name: ' 待收货' ,
69+ status: ' 2'
6470 },
6571 ],
6672 current: 0 ,
6773 tabsHeight: 0 ,
6874 };
6975 },
7076 onLoad (e ) {
71- if (! e .status ) {
72- e .status = 0
73- }
74- this .current = e .status
75- this .change (e .status )
76- },
77- computed: {
78- // 价格小数
79- priceDecimal () {
80- return val => {
81- if (val !== parseInt (val)) return val .slice (- 2 );
82- else return ' 00' ;
83- };
84- },
85- // 价格整数
86- priceInt () {
87- return val => {
88- if (val !== parseInt (val)) return val .split (' .' )[0 ];
89- else return val;
90- };
77+ if (e .status ) {
78+ const a = this .list .findIndex (ele => { return ele .status == e .status })
79+ if (a != - 1 ) {
80+ this .current = a * 1
81+ }
9182 }
83+ this .change ({ index: this .current })
9284 },
9385 methods: {
9486 async _orderStatistics (){
95- const res = await this .$api .orderStatistics (this .token )
87+ // https://www.yuque.com/apifm/nu0f75/dapuli
88+ const res = await this .$wxapi .orderStatisticsv2 ({
89+ token: this .token
90+ })
9691 if (res .code == 0 ) {
9792 this .list [0 ].count = res .data .count_id_no_pay
9893 this .list [1 ].count = res .data .count_id_no_transfer
@@ -102,10 +97,12 @@ export default {
10297 },
10398 // 页面数据
10499 async getOrderList () {
100+ const curTab = this .list [this .current ]
105101 this .orderList = null
106- const res = await this .$api .orderList ({
102+ // https://www.yuque.com/apifm/nu0f75/uwggsm
103+ const res = await this .$wxapi .orderList ({
107104 token: this .token ,
108- status: this . current
105+ status: curTab . status
109106 })
110107 if (res .code == 0 ) {
111108 const goodsMap = res .data .goodsMap
@@ -121,8 +118,8 @@ export default {
121118 })
122119 },
123120 // tab栏切换
124- change (index ) {
125- this .current = index
121+ change (e ) {
122+ this .current = e . index
126123 this ._orderStatistics ()
127124 this .getOrderList ();
128125 },
@@ -138,7 +135,8 @@ export default {
138135 });
139136 },
140137 async _close (orderId ) {
141- const res = await this .$api .orderClose (this .token , orderId)
138+ // https://www.yuque.com/apifm/nu0f75/wh4rrs
139+ const res = await this .$wxapi .orderClose (this .token , orderId)
142140 if (res .code != 0 ) {
143141 uni .showToast ({
144142 title: res .msg ,
@@ -152,7 +150,8 @@ export default {
152150 }
153151 },
154152 async pay (index ) {
155- let res = await this .$api .userAmount (this .token )
153+ // https://www.yuque.com/apifm/nu0f75/wrqkcb
154+ let res = await this .$wxapi .userAmount (this .token )
156155 let balance = 0
157156 if (res .code != 0 ) {
158157 uni .showToast ({
@@ -164,8 +163,8 @@ export default {
164163 const orderInfo = this .orderList [index]
165164 const needPay = (orderInfo .amountReal - balance).toFixed (2 )
166165 if (needPay <= 0 ) {
167- // 直接调用支付接口
168- const res = await this .$api .orderPay (this .token , orderInfo .id )
166+ // 直接调用支付接口 https://www.yuque.com/apifm/nu0f75/lwt2vi
167+ const res = await this .$wxapi .orderPay (this .token , orderInfo .id )
169168 if (res .code != 0 ) {
170169 uni .showToast ({
171170 title: res .msg ,
@@ -183,7 +182,7 @@ export default {
183182 wxpay .wxpay (' order' , needPay, orderInfo .id , ' ' )
184183 // #endif
185184 // #ifndef MP-WEIXIN
186- console .log (' 点击了支付订单' )
185+ console .log (' 点击了支付订单' ) // 需要判断是h5,然后是微信内还是微信外,调用接口是不一样的
187186 // #endif
188187 }
189188 },
@@ -241,6 +240,7 @@ page {
241240 }
242241 }
243242 .content {
243+ flex : 1 ;
244244 .title {
245245 font-size : 28 rpx;
246246 line-height : 50 rpx;
@@ -310,4 +310,7 @@ page {
310310.swiper-item {
311311 height : 100% ;
312312}
313+ .ml24 {
314+ margin-left : 24 rpx;
315+ }
313316 </style >
0 commit comments