Skip to content

Commit 768582a

Browse files
committed
完成订单管理
1 parent 2d7b6ee commit 768582a

5 files changed

Lines changed: 70 additions & 60 deletions

File tree

pages.json

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,18 @@
8484
"style": {
8585
"navigationBarTitleText": "收货地址"
8686
}
87+
},
88+
{
89+
"path" : "pages/order/index",
90+
"style": {
91+
"navigationBarTitleText": "我的订单"
92+
}
93+
},
94+
{
95+
"path" : "pages/order/detail",
96+
"style": {
97+
"navigationBarTitleText": "订单详情"
98+
}
8799
}
88100
],
89101
"globalStyle": {

pages/order/detail.vue

Lines changed: 17 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
<template>
22
<view v-if="orderDetail" class="to-pay-order">
3-
<u-section class="shop-section" title="配送地址" :right="false"></u-section>
4-
<u-cell-item v-if="orderDetail.logistics" icon="map" :arrow="false" hover-class="none" :title="orderDetail.logistics.linkMan + ' ' + orderDetail.logistics.mobile" :label="orderDetail.logistics.provinceStr + orderDetail.logistics.cityStr + orderDetail.logistics.areaStr + orderDetail.logistics.address"></u-cell-item>
5-
<u-section class="shop-section" title="商品信息" :right="false"></u-section>
3+
<u-divider text="收货地址"></u-divider>
4+
<u-cell v-if="orderDetail.logistics" icon="map" :border="false" :title="orderDetail.logistics.linkMan + ' ' + orderDetail.logistics.mobile" :label="orderDetail.logistics.provinceStr + orderDetail.logistics.cityStr + orderDetail.logistics.areaStr + orderDetail.logistics.address"></u-cell>
5+
<u-divider text="商品信息"></u-divider>
66
<view class="order">
77
<view class="item" v-for="(item, index) in orderDetail.goods" :key="'a' + index">
88
<view class="left"><image :src="item.pic" mode="aspectFill"></image></view>
@@ -24,28 +24,20 @@
2424
</text>
2525
</view>
2626
</view>
27-
<u-section v-if="orderDetail.orderInfo.remark" class="shop-section" title="订单备注" :right="false"></u-section>
27+
<u-divider v-if="orderDetail.orderInfo.remark" text="订单备注"></u-divider>
2828
<view v-if="orderDetail.orderInfo.remark" class="remark">
2929
{{ orderDetail.orderInfo.remark }}
3030
</view>
31-
<u-section class="shop-section" title="合计" :right="false"></u-section>
32-
<u-cell-item title="商品金额" :value="'¥' + orderDetail.orderInfo.amount" :arrow="false"></u-cell-item>
33-
<u-cell-item title="配送费" :value="'¥' + orderDetail.orderInfo.amountLogistics" :arrow="false"></u-cell-item>
34-
<u-cell-item title="总计" :value="'¥' + orderDetail.orderInfo.amountReal" :arrow="false"></u-cell-item>
31+
<u-divider text="合计"></u-divider>
32+
<u-cell :border="false" title="商品金额" :value="'¥' + orderDetail.orderInfo.amount" :arrow="false"></u-cell>
33+
<u-cell :border="false" title="快递费" :value="'¥' + orderDetail.orderInfo.amountLogistics" :arrow="false"></u-cell>
34+
<u-cell :border="false" title="总计" :value="'¥' + orderDetail.orderInfo.amountReal" :arrow="false"></u-cell>
3535
<template v-if="orderDetail.logisticsTraces">
36-
<u-section class="shop-section" title="配送信息" :right="false"></u-section>
36+
<u-divider text="快递信息"></u-divider>
3737
<view class="logisticsTraces">
38-
<u-time-line>
39-
<u-time-line-item v-for="(item, index) in orderDetail.logisticsTraces" :key="index">
40-
<!-- 此处没有自定义左边的内容,会默认显示一个点 -->
41-
<template v-slot:content>
42-
<view>
43-
<view class="u-order-desc">{{ item.AcceptStation }}</view>
44-
<view class="u-order-time">{{ item.AcceptTime }}</view>
45-
</view>
46-
</template>
47-
</u-time-line-item>
48-
</u-time-line>
38+
<u-steps dot direction="column">
39+
<u-steps-item v-for="(item, index) in orderDetail.logisticsTraces" :key="index" :title="item.AcceptStation" :desc="item.AcceptTime"></u-steps-item>
40+
</u-steps>
4941
</view>
5042
</template>
5143
<view v-if="orderDetail.orderInfo.status == 2" class="submit safe-area-inset-bottom">
@@ -78,7 +70,8 @@
7870
},
7971
methods: {
8072
async _orderDetail(orderId) {
81-
const res = await this.$api.orderDetail(this.token, orderId)
73+
// https://www.yuque.com/apifm/nu0f75/oamel8
74+
const res = await this.$wxapi.orderDetail(this.token, orderId)
8275
if (res.code != 0) {
8376
uni.showToast({
8477
title: res.msg,
@@ -101,7 +94,8 @@
10194
})
10295
},
10396
async _orderDelivery() {
104-
const res = await this.$api.orderDelivery(this.token, this.orderDetail.orderInfo.id)
97+
// https://www.yuque.com/apifm/nu0f75/vy8eai
98+
const res = await this.$wxapi.orderDelivery(this.token, this.orderDetail.orderInfo.id)
10599
if(res.code == 0) {
106100
uni.showToast({
107101
title: '已收到货',
@@ -160,6 +154,7 @@
160154
}
161155
}
162156
.content {
157+
flex: 1;
163158
.title {
164159
font-size: 28rpx;
165160
line-height: 50rpx;

pages/order/index.vue

Lines changed: 39 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
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" />
@@ -36,7 +36,7 @@
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: 28rpx;
246246
line-height: 50rpx;
@@ -310,4 +310,7 @@ page {
310310
.swiper-item {
311311
height: 100%;
312312
}
313+
.ml24 {
314+
margin-left: 24rpx;
315+
}
313316
</style>

pages/pay/order.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@
5555
<u-cell v-if="userAmount" title="可用余额" :value="'¥' + userAmount.balance" :arrow="false"></u-cell>
5656
</view>
5757
<view class="submit safe-area-inset-bottom">
58-
<u-button type="success" @click="submit" :disabled="!canSubmit">提交订单</u-button>
58+
<u-button type="error" @click="submit" :disabled="!canSubmit">提交订单</u-button>
5959
</view>
6060
</view>
6161
</template>

store/index.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ const store = new Vuex.Store({
3737
},
3838
app_show_pic_version: lifeData.app_show_pic_version ? lifeData.app_show_pic_version : '',
3939
referrer: lifeData.referrer ? lifeData.referrer : '',
40-
token: lifeData.token ? lifeData.token : '3c3fc856-cb23-4f04-93ff-3541fbf1006d',
40+
token: lifeData.token ? lifeData.token : 'cd89185a-2886-4ab5-8673-1b52a5f22995',
4141
uid: lifeData.uid ? lifeData.uid : '2518576',
4242
cartNumber: 0
4343
},

0 commit comments

Comments
 (0)