|
@@ -10,10 +10,10 @@
|
|
|
<view class="addr page-wrap u-flex u-row-between">
|
|
|
<view class="left">
|
|
|
<view class="top">
|
|
|
- <text class="label" v-if="isDefaultAddr">默认</text>{{theAddr.address}}
|
|
|
+ <text class="label" v-if="orderInfo.receive.ifDefault">默认</text>{{receive.address}}
|
|
|
</view>
|
|
|
- <view class="center">{{theAddr.receiveAdress}}</view>
|
|
|
- <view class="bottom">{{theAddr.receiveName}} {{theAddr.receivePhone}}</view>
|
|
|
+ <view class="center">{{receive.receiveAdress}}</view>
|
|
|
+ <view class="bottom">{{receive.receiveName}} {{receive.receivePhone}}</view>
|
|
|
</view>
|
|
|
<u-icon name="arrow-right" color="#676767" size="20" @click="selectAddr"></u-icon>
|
|
|
</view>
|
|
@@ -25,7 +25,7 @@
|
|
|
</view>
|
|
|
</view> -->
|
|
|
<view class="order-product page-wrap">
|
|
|
- <view class="product u-flex" v-for="(item,index) in dataList" :key="item.id">
|
|
|
+ <view class="product u-flex" v-for="(item,index) in orderInfo.goodsList" :key="item.id">
|
|
|
<u--image :showLoading="true" :src="item.mainImg" width="180rpx" height="180rpx"></u--image>
|
|
|
<view class="text">
|
|
|
<view class="up">
|
|
@@ -51,7 +51,7 @@
|
|
|
</view>
|
|
|
</view>
|
|
|
</view>
|
|
|
- <view class="page-wrap order-reduced">
|
|
|
+<!-- <view class="page-wrap order-reduced">
|
|
|
<view class="reduced-item u-flex u-row-between u-border-bottom">
|
|
|
<view class="left">
|
|
|
<text>优惠券</text>
|
|
@@ -75,23 +75,23 @@
|
|
|
</u-checkbox-group>
|
|
|
</view>
|
|
|
</view>
|
|
|
- </view>
|
|
|
+ </view> -->
|
|
|
<view class="page-wrap total">
|
|
|
<view class="total-item u-flex u-row-between u-border-bottom">
|
|
|
<view class="left">
|
|
|
商品金额
|
|
|
</view>
|
|
|
- <view class="right">
|
|
|
- ¥2399.00
|
|
|
+ <view class="right red">
|
|
|
+ ¥ {{totalAmount}}
|
|
|
</view>
|
|
|
</view>
|
|
|
<view class="total-item u-flex u-row-between">
|
|
|
<view class="left">
|
|
|
运费
|
|
|
- <text class="gray">总重:40kg</text>
|
|
|
+ <text class="gray">总重:{{totalWeight}}</text>
|
|
|
</view>
|
|
|
- <view class="right">
|
|
|
- + ¥2399.00
|
|
|
+ <view class="right red">
|
|
|
+ <text>+ ¥ {{distribution.distributionPrice}}</text>
|
|
|
</view>
|
|
|
</view>
|
|
|
</view>
|
|
@@ -99,10 +99,10 @@
|
|
|
<view class="inner u-flex u-row-between">
|
|
|
<view class="left u-flex">
|
|
|
<view class="total-price">
|
|
|
- 待支付:<text class="red">¥4322.00</text>
|
|
|
+ 待支付:<text class="red">¥ {{payAmount + distribution.distributionPrice}}</text>
|
|
|
</view>
|
|
|
</view>
|
|
|
- <view class="btn">去结算</view>
|
|
|
+ <view class="btn" @click="submitOrder">去结算</view>
|
|
|
</view>
|
|
|
</view>
|
|
|
</view>
|
|
@@ -114,18 +114,36 @@
|
|
|
fromPage:'',
|
|
|
useIntegral:false,
|
|
|
dataList:[],
|
|
|
- theAddr:{},
|
|
|
+ receiveId:'',
|
|
|
+ receive:{},
|
|
|
isDefaultAddr:false,
|
|
|
+ orderInfo:{goodsList:[]},
|
|
|
+ distribution:{},//物流信息
|
|
|
+ totalAmount:null,//订单总金额
|
|
|
+ payAmount:null,//订单支付金额
|
|
|
+ userTotalBalance:null,//用户总余额
|
|
|
+ userTotalCredit:null,//用户总积分
|
|
|
+ orderTotalCredit:null,//订单需要的总积分
|
|
|
}
|
|
|
},
|
|
|
onLoad(page) {
|
|
|
// console.log('page',page);
|
|
|
- // console.log('selectGoods',JSON.parse(page.selectGoods));
|
|
|
- this.dataList = JSON.parse(page.selectGoods);
|
|
|
+ this.setData(page.selectGoods,true)
|
|
|
},
|
|
|
onShow() {
|
|
|
- if(this.fromPage!='addrlist'){
|
|
|
- this.getAddrList()
|
|
|
+ if(this.fromPage=='addrlist'){
|
|
|
+ this.settlement()
|
|
|
+ }
|
|
|
+ },
|
|
|
+ computed: {
|
|
|
+ totalWeight() {
|
|
|
+ let that = this;
|
|
|
+ return this.orderInfo.goodsList.reduce((total, item) => {
|
|
|
+ let weight = null;
|
|
|
+ weight = item.weight
|
|
|
+ total += weight * item.quantity;
|
|
|
+ return total;
|
|
|
+ }, 0);
|
|
|
}
|
|
|
},
|
|
|
methods: {
|
|
@@ -137,42 +155,106 @@
|
|
|
},
|
|
|
selectAddr(){
|
|
|
uni.$u.route('/center/addrlist', {
|
|
|
- from: 'submitorder'
|
|
|
+ from: 'settlement'
|
|
|
});
|
|
|
},
|
|
|
- getAddrList(){
|
|
|
- this.$u.api.addrList().then(res=>{
|
|
|
- this.theAddr = res.data.rows;
|
|
|
- let defaultAddress;
|
|
|
- let firstAddress = res.data.rows[0];
|
|
|
- res.data.rows.forEach(address => {
|
|
|
- if (address.ifDefault) { // 如果有默认地址标识
|
|
|
- defaultAddress = address;
|
|
|
- this.isDefaultAddr = true;
|
|
|
- }
|
|
|
- });
|
|
|
+ // getAddrList(){
|
|
|
+ // this.$u.api.addrList().then(res=>{
|
|
|
+ // this.theAddr = res.data.rows;
|
|
|
+ // let defaultAddress;
|
|
|
+ // let firstAddress = res.data.rows[0];
|
|
|
+ // res.data.rows.forEach(address => {
|
|
|
+ // if (address.ifDefault) { // 如果有默认地址标识
|
|
|
+ // defaultAddress = address;
|
|
|
+ // this.isDefaultAddr = true;
|
|
|
+ // }
|
|
|
+ // });
|
|
|
|
|
|
- if (!defaultAddress) { // 如果没有默认地址标识
|
|
|
- defaultAddress = firstAddress;
|
|
|
- }
|
|
|
- this.theAddr = defaultAddress;
|
|
|
- }).catch(err=>{
|
|
|
- console.log('getAddrList',err.data);
|
|
|
- })
|
|
|
- },
|
|
|
+ // if (!defaultAddress) { // 如果没有默认地址标识
|
|
|
+ // defaultAddress = firstAddress;
|
|
|
+ // }
|
|
|
+ // this.theAddr = defaultAddress;
|
|
|
+ // }).catch(err=>{
|
|
|
+ // console.log('getAddrList',err.data);
|
|
|
+ // })
|
|
|
+ // },
|
|
|
// 改变商品数量
|
|
|
changeQuantity(index, value) {
|
|
|
+ console.log('goodsList',this.orderInfo.goodsList);
|
|
|
+ this.$nextTick(()=>{
|
|
|
+ this.settlement();
|
|
|
+ })
|
|
|
|
|
|
- this.changeQuantityApi(this.dataList[index].id,value.value)
|
|
|
},
|
|
|
- changeQuantityApi(id,num){
|
|
|
- this.$u.api.updateQuantity({id:id,quantity:num}).then(res=>{
|
|
|
- // this.dataList[index].quantity = num
|
|
|
+ settlement(){
|
|
|
+ // console.log('settlement',this.selectGoods);
|
|
|
+ let param = {
|
|
|
+ receiveId:this.receive.id
|
|
|
+ };
|
|
|
+ param.goodsList = this.orderInfo.goodsList.map(item=>{
|
|
|
+ return {goodsId:item.id,quantity:item.quantity}
|
|
|
+ });
|
|
|
+ console.log('param',param);
|
|
|
+ this.$u.api.getSettlement(param).then(res=>{
|
|
|
console.log('res',res.data);
|
|
|
- }).catch(err=>{
|
|
|
- console.log('changeQuantityApi',err.data);
|
|
|
+ this.setData(res.data,false)
|
|
|
+
|
|
|
+ }).catch(err=>{
|
|
|
+ console.log('getSettlement',err);
|
|
|
})
|
|
|
},
|
|
|
+ setData(originData,isString){
|
|
|
+ let jsonData;
|
|
|
+ if(isString){
|
|
|
+ jsonData = JSON.parse(originData);
|
|
|
+ }else{
|
|
|
+ jsonData = originData
|
|
|
+ }
|
|
|
+ let {
|
|
|
+ receive,
|
|
|
+ distribution,
|
|
|
+ totalAmount,
|
|
|
+ payAmount,
|
|
|
+ userTotalBalance,
|
|
|
+ userTotalCredit,
|
|
|
+ orderTotalCredit } = jsonData || {};
|
|
|
+ this.orderInfo = jsonData;
|
|
|
+ this.receive = receive;
|
|
|
+ this.distribution = distribution;//物流信息
|
|
|
+ this.totalAmount = totalAmount;//订单总金额
|
|
|
+ this.payAmount = payAmount;// 订单支付金额
|
|
|
+ this.userTotalBalance = userTotalBalance;// 用户总余额
|
|
|
+ this.userTotalCredit = userTotalCredit;// 用户总积分
|
|
|
+ this.orderTotalCredit = orderTotalCredit;//订单需要的总积分
|
|
|
+ },
|
|
|
+ submitOrder(){
|
|
|
+ let that = this;
|
|
|
+ let param = {
|
|
|
+ receiveId:this.receive.id,
|
|
|
+ distribution:this.distribution,
|
|
|
+ };
|
|
|
+ param.goodsList = this.orderInfo.goodsList.map(item=>{
|
|
|
+ return {goodsId:item.id,quantity:item.quantity}
|
|
|
+ })
|
|
|
+ //获取经纬度
|
|
|
+ uni.getLocation({
|
|
|
+ type: 'gcj02',
|
|
|
+ success: (res) => {
|
|
|
+ param.latitude = res.latitude;
|
|
|
+ param.longitude = res.longitude;
|
|
|
+ that.$u.api.submitOrder(param).then(res=>{
|
|
|
+ console.log('res',res.data);
|
|
|
+ uni.$u.route('/shopping/pay', {
|
|
|
+ orderId: res.data.orderId,
|
|
|
+ // openid: that.vuex_wechatOpenid,
|
|
|
+ payAmount:res.data.payAmount
|
|
|
+ });
|
|
|
+ }).catch(err=>{
|
|
|
+ console.log('submitOrder',err);
|
|
|
+ })
|
|
|
+ },
|
|
|
+ });
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
</script>
|