|
|
@ -1,8 +1,7 @@ |
|
|
|
<template> |
|
|
|
<view class="page"> |
|
|
|
<!-- 导航栏 --> |
|
|
|
<navbar title="订单详情 " leftClick @leftClick="navigateBack" bgColor="#019245" |
|
|
|
color="#fff" /> |
|
|
|
<navbar title="订单详情 " leftClick @leftClick="navigateBack" bgColor="#019245" color="#fff" /> |
|
|
|
|
|
|
|
<!-- 店铺信息 --> |
|
|
|
<view class="shop-info"> |
|
|
@ -54,13 +53,13 @@ |
|
|
|
<view class="order-info"> |
|
|
|
<view class="info-item"> |
|
|
|
<text class="info-label">合计:</text> |
|
|
|
<text class="info-value price">¥{{ orderDetail.priceAll.toFixed(2) }}</text> |
|
|
|
<text class="info-value price">¥{{ orderDetail.pricePay }}</text> |
|
|
|
</view> |
|
|
|
<view class="info-item" v-if="orderStatus != '-1'" > |
|
|
|
<view class="info-item"> |
|
|
|
<text class="info-label">创建时间:</text> |
|
|
|
<text class="info-value">{{ orderDetail.createTime }}</text> |
|
|
|
</view> |
|
|
|
<view class="info-item" v-if="orderStatus != '-1'"> |
|
|
|
<view class="info-item"> |
|
|
|
<text class="info-label">订单编号:</text> |
|
|
|
<text class="info-value">{{orderDetail.id}}</text> |
|
|
|
</view> |
|
|
@ -68,56 +67,62 @@ |
|
|
|
</view> |
|
|
|
<view class="discount-info-container"> |
|
|
|
<!-- 优惠信息 --> |
|
|
|
<view class="discount-info" @click="gotoCoupon"> |
|
|
|
<view class="discount-info"> |
|
|
|
<view class="discount-header"> |
|
|
|
<text>优惠</text> |
|
|
|
</view> |
|
|
|
|
|
|
|
<view class="discount-item"> |
|
|
|
<view class="discount-left"> |
|
|
|
<view class="discount-left" v-ifan class="s">="orderDetail.pricePreferential"> |
|
|
|
<image src="@/static/image/券.webp" mode="aspectFill" class="coupon-icon" /> |
|
|
|
<view>新用户立减</view> |
|
|
|
</view> |
|
|
|
<text class="discount-amount">-¥{{ orderDetail.pricePreferential || 0 }}</text> |
|
|
|
<text v-if="orderDetail.pricePreferential" class="discount-amount">{{orderDetail.pricePreferential}}</text> |
|
|
|
<text v-else class="none-discount-amount">未使用优惠卷</text> |
|
|
|
</view> |
|
|
|
</view> |
|
|
|
|
|
|
|
<!-- 备注 --> |
|
|
|
<view class="remark-section"> |
|
|
|
<view class="remark-header"> |
|
|
|
<text>备注</text> |
|
|
|
</view> |
|
|
|
<view class="remark-content"> |
|
|
|
<input v-if="orderStatus === '0' || orderStatus === '-1'" type="text" v-model="orderDetail.remark" |
|
|
|
placeholder="请输入您要备注的内容" placeholder-style="font-size: 28rpx" /> |
|
|
|
<text v-else>{{orderDetail.remark || '无备注信息'}}</text> |
|
|
|
</view> |
|
|
|
</view> |
|
|
|
</view> |
|
|
|
|
|
|
|
<!-- 支付方式 --> |
|
|
|
<uv-radio-group v-model="payMethod" v-if="orderStatus === '0' || orderStatus === '-1'"> |
|
|
|
<view class="payment-methods"> |
|
|
|
<view class="payment-item"> |
|
|
|
<uv-icon name="weixin-circle-fill" size="70rpx" color="#019245" /> |
|
|
|
<text class="payment-name">微信支付</text> |
|
|
|
<uv-radio activeColor="#019245" size="40rpx" name="0" /> |
|
|
|
<!-- 备注 --> |
|
|
|
<view class="remark-section"> |
|
|
|
<view class="remark-header"> |
|
|
|
<text>备注</text> |
|
|
|
</view> |
|
|
|
<view class="remark-content"> |
|
|
|
<input v-if="orderStatus === '0' " type="text" v-model="orderDetail.remark" |
|
|
|
placeholder="请输入您要备注的内容" placeholder-style="font-size: 28rpx" /> |
|
|
|
<text v-else>{{orderDetail.remark || '无备注信息'}}</text> |
|
|
|
</view> |
|
|
|
</view> |
|
|
|
<view class="payment-item"> |
|
|
|
<uv-icon name="red-packet" size="70rpx" color="#019245" /> |
|
|
|
<text class="payment-name">账户余额<text class="balance-text">(余额: ¥{{ userInfo.balance }})</text></text> |
|
|
|
<uv-radio activeColor="#019245" size="40rpx" name="1" /> |
|
|
|
|
|
|
|
<!-- 支付方式 --> |
|
|
|
<uv-radio-group v-model="payMethod" v-if="orderStatus === '0' "> |
|
|
|
<view class="payment-methods"> |
|
|
|
<view class="payment-item"> |
|
|
|
<uv-icon name="weixin-circle-fill" size="70rpx" color="#019245" /> |
|
|
|
<text class="payment-name">微信支付</text> |
|
|
|
<uv-radio activeColor="#019245" size="40rpx" name="0" /> |
|
|
|
</view> |
|
|
|
<view class="payment-item"> |
|
|
|
<uv-icon name="red-packet" size="70rpx" color="#019245" /> |
|
|
|
<text class="payment-name">账户余额<text class="balance-text">(余额: ¥{{ userInfo.balance }})</text></text> |
|
|
|
<!-- 钱不够就会禁用 --> |
|
|
|
<uv-radio activeColor="#019245" size="40rpx" name="1" :disabled="userInfo.balance < orderDetail.pricePay" /> |
|
|
|
</view> |
|
|
|
</view> |
|
|
|
</view> |
|
|
|
</uv-radio-group> |
|
|
|
</uv-radio-group> |
|
|
|
|
|
|
|
<!-- 底部支付栏 --> |
|
|
|
<view class="bottom-bar"> |
|
|
|
<view class="total-section"> |
|
|
|
<text class="total-label">共{{ orderDetail.goodsList.length || 0 }}个,<text style="color: black;">合计</text> </text> |
|
|
|
<text class="total-price">¥{{ (orderDetail.pricePay || cartPay).toFixed(2) }}</text> |
|
|
|
<!-- 底部支付栏 --> |
|
|
|
<view class="bottom-bar"> |
|
|
|
<view class="total-section"> |
|
|
|
<text class="total-label"> |
|
|
|
共{{ (orderDetail.goodsList || []).length }}个, |
|
|
|
<text style="color: black;">合计</text> |
|
|
|
</text> |
|
|
|
<text class="total-price">¥{{ ( orderDetail.pricePay || 0 ).toFixed(2) || 0 }}</text> |
|
|
|
</view> |
|
|
|
<view class="pay-button" @tap="handlePay" v-if="orderStatus === '0' ">立即下单</view> |
|
|
|
<view class="pay-button" @tap="handleTake" v-if="orderStatus === '3'">取餐完成</view> |
|
|
|
</view> |
|
|
|
<view class="pay-button" @tap="handlePay" v-if="orderStatus === '0' || orderStatus === '-1'">立即下单</view> |
|
|
|
<view class="pay-button" @tap="handleTake" v-if="orderStatus === '3'">取餐完成</view> |
|
|
|
</view> |
|
|
|
</view> |
|
|
|
</template> |
|
|
@ -148,57 +153,26 @@ |
|
|
|
} |
|
|
|
}, |
|
|
|
computed: { |
|
|
|
...mapState(['cartData', 'userInfo']), |
|
|
|
...mapState([ 'userInfo']), |
|
|
|
showedFoods() { |
|
|
|
return this.showAllFoods ? this.orderDetail.goodsList : this.orderDetail.goodsList.slice(0, 3) |
|
|
|
}, |
|
|
|
|
|
|
|
cartPay() { |
|
|
|
return this.orderDetail.priceAll - this.cartDiscount |
|
|
|
return this.showAllFoods ? this.orderDetail.goodsList : (this.orderDetail.goodsList.length > 3 ? this.orderDetail.goodsList.slice(0, 3) : this.orderDetail.goodsList) |
|
|
|
}, |
|
|
|
orderStatus() { |
|
|
|
return this.orderDetail.status |
|
|
|
}, |
|
|
|
// 格式为 goodId,goodNum;goodId2,goodsNum |
|
|
|
goodss() { |
|
|
|
return this.orderDetail.goodsList.map(item => { |
|
|
|
return `${item.goodsId},${item.num},${item.goods.price * item.num}` |
|
|
|
}).join(';') |
|
|
|
} |
|
|
|
|
|
|
|
}, |
|
|
|
onLoad(options) { |
|
|
|
// 如果是购物车调过来的结账页面 |
|
|
|
if (options.status === 'cart') { |
|
|
|
this.showCartData() |
|
|
|
// 独一无二代表购物车的状态 |
|
|
|
this.orderDetail.status = '-1' |
|
|
|
this.checkBindLeader() |
|
|
|
|
|
|
|
} |
|
|
|
else if (options.id) { |
|
|
|
if (options.id) { |
|
|
|
this.getOrderDetail(options.id) |
|
|
|
} |
|
|
|
console.log('userInfo', this.userInfo); |
|
|
|
|
|
|
|
}, |
|
|
|
methods: { |
|
|
|
...mapMutations(['checkBindLeader']), |
|
|
|
...mapMutations([ 'clearCouponData']), |
|
|
|
// 返回上一页 |
|
|
|
navigateBack() { |
|
|
|
uni.navigateBack() |
|
|
|
}, |
|
|
|
// 如果是购物车结账页面 |
|
|
|
showCartData() { |
|
|
|
this.$api('queryMyLeader', {}, res => { |
|
|
|
if (res.code === 200) { |
|
|
|
this.teamLeader = res.result |
|
|
|
} |
|
|
|
}) |
|
|
|
this.orderDetail.goodsList = this.cartData.sendData |
|
|
|
this.orderDetail.priceAll = this.cartData.priceAll |
|
|
|
this.orderDetail.status = '-1' |
|
|
|
}, |
|
|
|
// 获取订单详情 |
|
|
|
getOrderDetail(id) { |
|
|
|
this.id = id |
|
|
@ -206,8 +180,6 @@ |
|
|
|
id: this.id |
|
|
|
}, res => { |
|
|
|
if (res.code === 200) { |
|
|
|
console.log('res', res); |
|
|
|
|
|
|
|
this.orderDetail = res.result.records[0] |
|
|
|
this.teamLeader = res.result.records[0].teamLeader |
|
|
|
} |
|
|
@ -220,93 +192,41 @@ |
|
|
|
title: '支付处理中...' |
|
|
|
}) |
|
|
|
|
|
|
|
// 正常订单调用支付接口 |
|
|
|
if(this.orderStatus === '0'){ |
|
|
|
this.$api('payOrder',{ |
|
|
|
payType: this.payMethod, |
|
|
|
orderId: this.id, |
|
|
|
}, res => { |
|
|
|
uni.hideLoading() |
|
|
|
if (res.code === 200) { |
|
|
|
if (this.payMethod == '0') { |
|
|
|
uni.requestPaymentWxPay(res) |
|
|
|
.then(( ) => { |
|
|
|
setTimeout(uni.redirectTo, 700, { |
|
|
|
url: '/pages/index/order' |
|
|
|
}) |
|
|
|
this.$api('payOrder',{ |
|
|
|
payType: this.payMethod, |
|
|
|
orderId: this.id, |
|
|
|
}, res => { |
|
|
|
uni.hideLoading() |
|
|
|
if (res.code === 200) { |
|
|
|
if (this.payMethod == '0') { |
|
|
|
uni.requestPaymentWxPay(res) |
|
|
|
.then(( ) => { |
|
|
|
setTimeout(uni.redirectTo, 700, { |
|
|
|
url: '/pages/index/order?tabIndex=1' |
|
|
|
}) |
|
|
|
} else { |
|
|
|
uni.showToast({ |
|
|
|
title: '下单成功', |
|
|
|
icon: 'success' |
|
|
|
}) |
|
|
|
setTimeout(uni.redirectTo, 700, { |
|
|
|
url: '/pages/index/order' |
|
|
|
}) |
|
|
|
} |
|
|
|
} |
|
|
|
}) |
|
|
|
|
|
|
|
} |
|
|
|
// 购物车调用创造订单接口 |
|
|
|
else if(this.orderStatus === '-1'){ |
|
|
|
console.log('goodss', this.goodss); |
|
|
|
|
|
|
|
this.$api('createOrder',{ |
|
|
|
priceAll: this.orderDetail.priceAll, |
|
|
|
pricePay: this.orderDetail.priceAll - 0, |
|
|
|
pricePreferential: 0, |
|
|
|
payType: this.payMethod, |
|
|
|
leaderId: this.teamLeader.id, |
|
|
|
goodss: this.goodss |
|
|
|
}, res => { |
|
|
|
uni.hideLoading() |
|
|
|
console.log('res', res); |
|
|
|
if(res.code === 200){ |
|
|
|
if (this.payMethod == '0') { |
|
|
|
uni.requestPaymentWxPay(res) |
|
|
|
.then(n => { |
|
|
|
} else { |
|
|
|
uni.showModal({ |
|
|
|
title: '提示', |
|
|
|
content: '确认使用余额支付吗?', |
|
|
|
confirmColor: '#019245', |
|
|
|
success: (result) => { |
|
|
|
if (result.confirm) { |
|
|
|
uni.showToast({ |
|
|
|
title: '下单成功', |
|
|
|
icon: 'success' |
|
|
|
}) |
|
|
|
setTimeout(uni.redirectTo, 700, { |
|
|
|
url: '/pages/index/order' |
|
|
|
url: '/pages/index/order?tabIndex=1' |
|
|
|
}) |
|
|
|
}) |
|
|
|
} else { |
|
|
|
uni.showToast({ |
|
|
|
title: '下单成功', |
|
|
|
icon: 'success' |
|
|
|
}) |
|
|
|
setTimeout(uni.redirectTo, 700, { |
|
|
|
url: '/pages/index/order' |
|
|
|
}) |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
}) |
|
|
|
} |
|
|
|
}) |
|
|
|
} |
|
|
|
} |
|
|
|
}) |
|
|
|
}, |
|
|
|
|
|
|
|
// handlePickOrder(orderId) { |
|
|
|
// uni.showModal({ |
|
|
|
// title: '提示', |
|
|
|
// content: '确定取餐完成?', |
|
|
|
// confirmColor: '#019245', |
|
|
|
// success: (res) => { |
|
|
|
// if (res.confirm) { |
|
|
|
// this.$api('finishMemberOrderById', { |
|
|
|
// memberOrderId: orderId |
|
|
|
// }, res => { |
|
|
|
// if (res.code === 200) { |
|
|
|
// uni.showToast({ |
|
|
|
// title: '取餐完成', |
|
|
|
// icon: 'success', |
|
|
|
// duration: 2000 |
|
|
|
// }) |
|
|
|
// this.getData() |
|
|
|
// } |
|
|
|
// }) |
|
|
|
// } |
|
|
|
// } |
|
|
|
// }) |
|
|
|
// } |
|
|
|
// 取餐完成 |
|
|
|
handleTake() { |
|
|
|
this.$api('finishMemberOrderById', { |
|
|
@ -322,12 +242,6 @@ |
|
|
|
}, 1000) |
|
|
|
} |
|
|
|
}) |
|
|
|
}, |
|
|
|
// 去优惠页面 |
|
|
|
gotoCoupon() { |
|
|
|
this.$utils.navigateTo({ |
|
|
|
url: '/pages_order/mine/coupon?isUseinOrder=true' |
|
|
|
}) |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
@ -524,6 +438,11 @@ |
|
|
|
color: #f00; |
|
|
|
font-weight: 500; |
|
|
|
} |
|
|
|
|
|
|
|
.none-discount-amount{ |
|
|
|
color: gray; |
|
|
|
font-weight: 500; |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|