2022-08-03 13:28:45 +00:00
|
|
|
|
<template>
|
|
|
|
|
<view>
|
|
|
|
|
<status-container titlet="确认订单" returnc="#FFFFFF">
|
2022-08-15 10:15:13 +00:00
|
|
|
|
<view slot="content" style="margin-top: -20rpx;" v-if="loading">
|
2022-08-08 10:15:03 +00:00
|
|
|
|
<view @tap="$toolAll.tools.goPage(`/pagesA/my-address/my-address?ifChoose=1`)" class="bacf disjbac fon24 pad-sx20 pad-zy30 boxshowb">
|
|
|
|
|
<view class="fon20 line-h40" v-if="addressInfo">
|
|
|
|
|
<view class="" style="color: #676767;">{{addressInfo.province_str}}{{addressInfo.city_str}}{{addressInfo.county_str}}</view>
|
|
|
|
|
<view class="fon26">{{addressInfo.address}}</view>
|
|
|
|
|
<view class="">{{addressInfo.name}} {{$toolAll.tools.hideMPhone(addressInfo.phone)}}</view>
|
2022-08-03 13:28:45 +00:00
|
|
|
|
</view>
|
2022-08-08 10:15:03 +00:00
|
|
|
|
<view class="fon20 line-h40" v-else>请添加收货地址</view>
|
2022-08-03 13:28:45 +00:00
|
|
|
|
<view class="icon icon-next fon28" style="color: #777777;"></view>
|
|
|
|
|
</view>
|
|
|
|
|
<view class="bacf mar-s30 pad30 fon24 boxshowb">
|
2022-08-09 10:21:46 +00:00
|
|
|
|
<view class="disac bbot pad-x30" v-for="(item,index) in orderInfo.list" :key="index">
|
|
|
|
|
<image :src="item.sku_cover" mode="aspectFill" class="flexs mar-y20" style="width: 228rpx;height: 160rpx;" lazy-load></image>
|
|
|
|
|
<view class="disjb fc pad-sx10 fon24 width100" style="height: 160rpx;">
|
|
|
|
|
<view class="col26 clips2">{{item.goods_name}}</view>
|
|
|
|
|
<view class="col26 width100">
|
|
|
|
|
<view class="mar-x10">{{item.sku_name}}</view>
|
|
|
|
|
<view class=" disjbac">
|
|
|
|
|
<view class="">¥{{item.price}}</view>
|
2022-08-10 10:18:06 +00:00
|
|
|
|
<view>X <span class="mar-z6">{{item.num}}</span></view>
|
2022-08-09 10:21:46 +00:00
|
|
|
|
</view>
|
2022-08-03 13:28:45 +00:00
|
|
|
|
</view>
|
|
|
|
|
</view>
|
|
|
|
|
</view>
|
|
|
|
|
<view class="bbot pad-sx30">
|
|
|
|
|
<view class="disjbac">
|
|
|
|
|
<view class="">商品金额</view>
|
2022-08-11 10:27:47 +00:00
|
|
|
|
<view class="pad-y30">¥{{$toolAll.tools.addXiaoShu(orderInfo.original_total*1)}}</view>
|
2022-08-03 13:28:45 +00:00
|
|
|
|
</view>
|
2022-08-11 10:27:47 +00:00
|
|
|
|
<!-- <view class="disjbac mar-s30">
|
2022-08-03 13:28:45 +00:00
|
|
|
|
<view class="">优惠券抵扣</view>
|
2022-08-10 10:18:06 +00:00
|
|
|
|
<view class="disjbac col-e42417">-¥{{couponInfo.coupon_price}} <view class="icon icon-next fon28 mar-z10" style="color: #777777;"></view></view>
|
2022-08-11 10:27:47 +00:00
|
|
|
|
</view> -->
|
2022-08-03 13:28:45 +00:00
|
|
|
|
<view class="disjbac mar-s30">
|
|
|
|
|
<view class="">积分抵扣</view>
|
2022-08-11 10:27:47 +00:00
|
|
|
|
<view class="disac col-e42417">-¥{{scorePrice}} <view class="icon icon-next fon28 mar-z10" style="color: #777777;"></view></view>
|
2022-08-03 13:28:45 +00:00
|
|
|
|
</view>
|
|
|
|
|
</view>
|
|
|
|
|
<view class="disje pad-s30 pad-x10 pad-y30">
|
2022-08-10 10:18:06 +00:00
|
|
|
|
合计:¥{{realityPrice}}
|
2022-08-03 13:28:45 +00:00
|
|
|
|
</view>
|
|
|
|
|
</view>
|
|
|
|
|
<!-- 立即购买 -->
|
|
|
|
|
<view class="posixzy bacf pad-sx20 disjbac pad-zy30 boxshowt">
|
2022-08-10 10:18:06 +00:00
|
|
|
|
<view class="fon24">合计:<span class="col-e42417 fon34 bold">¥{{realityPrice}}</span></view>
|
2022-08-09 10:21:46 +00:00
|
|
|
|
<view @tap="goPay" class="fon24 colf radius32 disjcac" style="background-color: #f37617;width: 184rpx;height: 64rpx;">去支付</view>
|
2022-08-03 13:28:45 +00:00
|
|
|
|
</view>
|
|
|
|
|
</view>
|
|
|
|
|
</status-container>
|
|
|
|
|
</view>
|
|
|
|
|
</template>
|
|
|
|
|
|
|
|
|
|
<script>
|
|
|
|
|
// 底部组件
|
|
|
|
|
import footTab from '@/components/foot-tabs/foot-tab.vue';
|
|
|
|
|
export default {
|
|
|
|
|
components:{'foot-tab' :footTab},
|
|
|
|
|
data() {
|
|
|
|
|
return {
|
2022-08-09 10:21:46 +00:00
|
|
|
|
addressInfo:'',
|
|
|
|
|
orderInfo:'',
|
2022-08-10 10:18:06 +00:00
|
|
|
|
flag:true,
|
2022-08-11 10:27:47 +00:00
|
|
|
|
// couponInfo:{
|
|
|
|
|
// coupon_id:'',//优惠券ID
|
|
|
|
|
// coupon_price:0//优惠券抵扣金额
|
|
|
|
|
// },
|
|
|
|
|
score:0,
|
2022-08-15 10:15:13 +00:00
|
|
|
|
scorePrice:0,
|
|
|
|
|
loading:false
|
2022-08-03 13:28:45 +00:00
|
|
|
|
}
|
|
|
|
|
},
|
2022-08-08 10:15:03 +00:00
|
|
|
|
onShow() {
|
|
|
|
|
this.addressInfo = uni.getStorageSync('addressInfo');
|
|
|
|
|
},
|
2022-08-03 13:28:45 +00:00
|
|
|
|
onLoad() {
|
2022-08-09 10:21:46 +00:00
|
|
|
|
this.getAddress();
|
2022-08-15 10:15:13 +00:00
|
|
|
|
// this.scoreToPrice();
|
2022-08-03 13:28:45 +00:00
|
|
|
|
},
|
2022-08-10 10:18:06 +00:00
|
|
|
|
computed:{
|
|
|
|
|
realityPrice(){
|
|
|
|
|
let newPrice = 0;
|
|
|
|
|
if(this.orderInfo){
|
2022-08-15 10:15:13 +00:00
|
|
|
|
this.loading = true;
|
2022-08-10 10:18:06 +00:00
|
|
|
|
this.orderInfo.list.forEach(item=>{
|
|
|
|
|
let tempprice = this.$toolAll.tools.operationEv(item.price,item.num,'*',2)
|
|
|
|
|
newPrice = this.$toolAll.tools.operationEv(tempprice,newPrice,'+',2);
|
|
|
|
|
})
|
|
|
|
|
}
|
|
|
|
|
// 商品金额减优惠券抵扣
|
2022-08-11 10:27:47 +00:00
|
|
|
|
// newPrice = this.$toolAll.tools.operationEv(newPrice,this.couponInfo.coupon_price,'-',2);
|
2022-08-10 10:18:06 +00:00
|
|
|
|
// 商品金额减积分抵扣
|
2022-08-11 10:27:47 +00:00
|
|
|
|
newPrice = this.$toolAll.tools.operationEv(newPrice,this.scorePrice,'-',2);
|
|
|
|
|
return newPrice<0?0:newPrice;
|
2022-08-10 10:18:06 +00:00
|
|
|
|
}
|
|
|
|
|
},
|
2022-08-03 13:28:45 +00:00
|
|
|
|
methods: {
|
2022-08-11 10:27:47 +00:00
|
|
|
|
// 积分转金额
|
2022-08-15 10:15:13 +00:00
|
|
|
|
// scoreToPrice(){
|
|
|
|
|
// this.$requst.post('/api/index/score2price',{score:this.score}).then(res=>{
|
|
|
|
|
// if(res.code==0){
|
|
|
|
|
// this.scorePrice = res.data.price;
|
|
|
|
|
// }
|
|
|
|
|
// })
|
|
|
|
|
// },
|
2022-08-09 10:21:46 +00:00
|
|
|
|
// 收货地址查询
|
|
|
|
|
getAddress(){
|
|
|
|
|
this.$requst.get('/api/user/address').then(res=>{
|
|
|
|
|
if(res.code==0){
|
|
|
|
|
if(res.data.length){
|
|
|
|
|
res.data.forEach(item=>{
|
|
|
|
|
if(item.is_default){
|
|
|
|
|
this.addressInfo = item;
|
|
|
|
|
} else {
|
|
|
|
|
this.addressInfo = res.data[0];
|
|
|
|
|
}
|
|
|
|
|
})
|
|
|
|
|
}
|
2022-08-15 10:15:13 +00:00
|
|
|
|
uni.setStorageSync('addressInfo',this.addressInfo);
|
2022-08-09 10:21:46 +00:00
|
|
|
|
this.orderInfo = uni.getStorageSync('orderInfo');
|
2022-08-15 10:15:13 +00:00
|
|
|
|
this.score = this.orderInfo.score_use*1;
|
|
|
|
|
this.scorePrice = this.orderInfo.score_deduct_price*1;
|
2022-08-09 10:21:46 +00:00
|
|
|
|
}
|
|
|
|
|
})
|
|
|
|
|
},
|
|
|
|
|
// 去支付
|
|
|
|
|
goPay(){
|
|
|
|
|
if(this.flag){
|
|
|
|
|
this.flag = false;
|
2022-08-15 10:15:13 +00:00
|
|
|
|
if(this.addressInfo){
|
|
|
|
|
this.$toolAll.tools.showToast('正在调起支付...');
|
|
|
|
|
let params = {
|
|
|
|
|
sku_list:uni.getStorageSync('skuList'),
|
|
|
|
|
total:this.realityPrice,//实际付款金额 即:使用优惠券、积分抵扣等所有优惠后的金额(需加上运费)
|
|
|
|
|
express_code:'',
|
|
|
|
|
freight:0,//运费
|
|
|
|
|
// ...this.couponInfo,
|
|
|
|
|
address_id:this.addressInfo.id,//地址ID
|
|
|
|
|
type:'spu',//订单类型 spu=商品 course=课程
|
|
|
|
|
score:this.score,//使用积分
|
|
|
|
|
score_deduct_price:this.scorePrice//积分抵扣的金额
|
|
|
|
|
}
|
|
|
|
|
this.$requst.post('/api/order/create',params).then(res=>{
|
|
|
|
|
if(res.code==0){
|
|
|
|
|
let info = res.data;
|
|
|
|
|
if(info.status!='completed'){
|
|
|
|
|
uni.requestPayment({
|
|
|
|
|
provider: 'wxpay',
|
|
|
|
|
appId:info.payment_params.appId,//appId
|
|
|
|
|
timeStamp: info.payment_params.timeStamp,//时间戳
|
|
|
|
|
nonceStr: info.payment_params.nonceStr,//随机字符串
|
|
|
|
|
package: info.payment_params.package,//package
|
|
|
|
|
signType: info.payment_params.signType,//MD5
|
|
|
|
|
paySign: info.payment_params.sign,//签名
|
|
|
|
|
success:(result)=> {
|
|
|
|
|
this.$requst.post('/api/order/paid',{order_coding:info.coding}).then(res=>{
|
|
|
|
|
if(res.code==0){
|
|
|
|
|
this.$toolAll.tools.showToast('支付成功(*^▽^*)');
|
|
|
|
|
setTimeout(()=>{
|
|
|
|
|
uni.navigateTo({
|
|
|
|
|
url:'/pagesA/my-order/my-order'
|
|
|
|
|
})
|
|
|
|
|
},1000)
|
|
|
|
|
} else this.$toolAll.tools.showToast(res.msg);
|
|
|
|
|
})
|
|
|
|
|
},
|
|
|
|
|
fail:()=> {
|
|
|
|
|
this.$toolAll.tools.showToast('支付已取消o(╥﹏╥)o');
|
|
|
|
|
},
|
|
|
|
|
complete:()=> {
|
|
|
|
|
this.flag = true;
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
} else {
|
|
|
|
|
this.$toolAll.tools.showToast('支付成功(*^▽^*)');
|
|
|
|
|
setTimeout(()=>{
|
|
|
|
|
uni.navigateTo({
|
|
|
|
|
url:'/pagesA/my-order/my-order'
|
2022-08-11 10:27:47 +00:00
|
|
|
|
})
|
2022-08-15 10:15:13 +00:00
|
|
|
|
},1000)
|
|
|
|
|
}
|
2022-08-11 10:27:47 +00:00
|
|
|
|
} else {
|
2022-08-15 10:15:13 +00:00
|
|
|
|
this.flag = true;
|
2022-08-11 10:27:47 +00:00
|
|
|
|
}
|
2022-08-15 10:15:13 +00:00
|
|
|
|
})
|
|
|
|
|
} else {
|
|
|
|
|
this.flag = true;
|
|
|
|
|
this.$toolAll.tools.showToast('请添加收货地址');
|
|
|
|
|
setTimeout(()=>{
|
|
|
|
|
uni.navigateTo({
|
|
|
|
|
url:'/pagesA/my-address/my-address?ifChoose=1'
|
|
|
|
|
})
|
|
|
|
|
},1000)
|
|
|
|
|
}
|
2022-08-09 10:21:46 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
2022-08-03 13:28:45 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
</script>
|
|
|
|
|
|
|
|
|
|
<style></style>
|