【订单确认】

1. 接入订单商品列表
pull/1/MERGE
YunaiV 2023-06-29 23:32:16 +08:00
parent 3ae38b6626
commit fe955e9fb1
3 changed files with 89 additions and 54 deletions

View File

@ -1,7 +1,17 @@
import request from "@/utils/request.js"; import request from "@/utils/request.js";
export function settlementOrder(data) { export function settlementOrder(data) {
return request.get("app-api/trade/order/settlement", data); const data2 = {
...data,
}
// 解决 SpringMVC 接受 List<Item> 参数的问题
delete data2.items
for (let i = 0; i < data.items.length; i++) {
data2['items[' + i + '].skuId'] = data.items[i].skuId;
data2['items[' + i + '].count'] = data.items[i].count;
data2['items[' + i + '].cartId'] = data.items[i].cartId;
}
return request.get("app-api/trade/order/settlement", data2);
} }
export function createOrder(data) { export function createOrder(data) {

View File

@ -1,35 +1,40 @@
<template> <template>
<view class="orderGoods borRadius14"> <view class="orderGoods borRadius14">
<view class='total'>{{ orderProNum?orderProNum:totalNmu}}件商品</view> <view class='total'>{{ totalNmu }}件商品</view>
<view class='goodWrapper pad30'> <view class='goodWrapper pad30'>
<view class='item acea-row row-between-wrapper' v-for="(item,index) in cartInfo" :key="index" <view class='item acea-row row-between-wrapper' v-for="(item,index) in cartInfo" :key="index"
@click="jumpCon(item.productId)"> @click="jumpCon(item.spuId)">
<view class='pictrue'> <view class='pictrue'>
<image :src='item.image'></image> <image :src='item.picUrl' />
</view> </view>
<view class='text'> <view class='text'>
<view class='acea-row row-between-wrapper'> <view class='acea-row row-between-wrapper'>
<view class='name line1'>{{item.productName ? item.productName : item.storeName}}</view> <view class='name line1'>{{ item.spuName }}</view>
<view class='num'>x {{item.payNum ? item.payNum : item.cartNum}}</view> <view class='num'>x {{ item.count }}</view>
</view> </view>
<view class='attr line1' v-if="item.sku">{{item.sku}}</view> <view class='attr line1'>
<view class='money font-color'>{{item.price}}</view> <text v-for="(property, propertyIndex) in item.properties" :key="propertyIndex" style="padding-right: 10rpx;">
<view class='evaluate' v-if='item.isReply==0 && evaluate==2' @click.stop="evaluateTap(item)">评价 {{ property.valueName }} 
</text>
</view> </view>
<view class='evaluate' v-else-if="item.isReply==1">已评价</view> <view class='money font-color'>{{ fen2yuan(item.price) }}</view>
<!-- 评价状态 -->
<view class='evaluate' v-if='item.replyStatus === false && evaluate === 2' @click.stop="evaluateTap(item)">
评价
</view>
<view class='evaluate' v-else-if="item.replyStatus === true">已评价</view>
</view> </view>
</view> </view>
</view> </view>
</view> </view>
</template> </template>
<script> <script>
import * as Util from '@/utils/util.js';
export default { export default {
props: { props: {
evaluate: { evaluate: {
type: Number, type: Number,
default: 0, default: 0, // 0 - 2 -
}, },
cartInfo: { cartInfo: {
type: Array, type: Array,
@ -49,12 +54,6 @@
type: Boolean, type: Boolean,
default: false, default: false,
}, },
orderProNum: {
type: Number,
default: function() {
return 0;
}
},
productType: { productType: {
type: Number, type: Number,
default: function() { default: function() {
@ -64,36 +63,40 @@
}, },
data() { data() {
return { return {
totalNmu: '' totalNmu: 0 //
}; };
}, },
watch: { watch: {
cartInfo: function(nVal, oVal) { cartInfo: function(nVal, oVal) {
let num = 0 let num = 0
nVal.forEach((item, index) => { nVal.forEach((item, index) => {
num += item.cartNum num += item.count
}) })
this.totalNmu = num this.totalNmu = num
} }
}, },
methods: { methods: {
// TODO
evaluateTap(item) { evaluateTap(item) {
uni.navigateTo({ uni.navigateTo({
url: "/pages/users/goods_comment_con/index?unique=" + item.attrId + "&orderId=" + this.orderId + '&id=' + this.ids url: "/pages/users/goods_comment_con/index?unique=" + item.attrId + "&orderId=" + this.orderId + '&id=' + this.ids
}) })
}, },
jumpCon: function(id) { jumpCon: function(id) {
let type = this.productType==0?'normal':'video' let type = this.productType === 0 ?'normal':'video'
if (this.jump) { if (this.jump) {
uni.navigateTo({ uni.navigateTo({
url: `/pages/goods_details/index?id=${id}&type=${type}` url: `/pages/goods_details/index?id=${id}&type=${type}`
}) })
} }
} },
fen2yuan(price) {
return Util.fen2yuan(price)
},
} }
} }
</script> </script>
<style scoped lang="scss"> <style scoped lang="scss">
.orderGoods { .orderGoods {
background-color: #fff; background-color: #fff;

View File

@ -3,13 +3,13 @@
<view class='order-submission'> <view class='order-submission'>
<view class="allAddress" :style="store_self_mention ? '':'padding-top:10rpx;'"> <view class="allAddress" :style="store_self_mention ? '':'padding-top:10rpx;'">
<view class="nav acea-row"> <view class="nav acea-row">
<view class="item font-color" :class="shippingType === 0 ? 'on' : 'on2'"
@tap="addressType(0)" v-if='store_self_mention' />
<view class="item font-color" :class="shippingType === 1 ? 'on' : 'on2'" <view class="item font-color" :class="shippingType === 1 ? 'on' : 'on2'"
@tap="addressType(0)" v-if='store_self_mention' />
<view class="item font-color" :class="shippingType === 2 ? 'on' : 'on2'"
@tap="addressType(1)" v-if='store_self_mention' /> @tap="addressType(1)" v-if='store_self_mention' />
</view> </view>
<!-- 收货地址的选择 --> <!-- 收货地址的选择 -->
<view class='address acea-row row-between-wrapper' @tap='onAddress' v-if='shippingType === 0' <view class='address acea-row row-between-wrapper' @tap='onAddress' v-if='shippingType === 1'
:style="store_self_mention ? '':'border-top-left-radius: 14rpx;border-top-right-radius: 14rpx;'"> :style="store_self_mention ? '':'border-top-left-radius: 14rpx;border-top-right-radius: 14rpx;'">
<view class='addressCon' v-if="addressInfo.name"> <view class='addressCon' v-if="addressInfo.name">
<view class='name'>{{ addressInfo.name }} <view class='name'>{{ addressInfo.name }}
@ -46,10 +46,10 @@
</view> </view>
</view> </view>
<view class="pad30"> <view class="pad30">
<orderGoods :cartInfo="cartInfo" :orderProNum="orderProNum"></orderGoods> <orderGoods :cartInfo="cartInfo" />
<view class='wrapper borRadius14'> <view class='wrapper borRadius14'>
<view class='item acea-row row-between-wrapper' @tap='couponTap' <view class='item acea-row row-between-wrapper' @tap='couponTap'
v-if="!orderInfoVo.bargainId && !orderInfoVo.combinationId && !orderInfoVo.seckillId && productType==='normal'"> v-if="orderInfoVo.type === 1 && productType==='normal'">
<view>优惠券</view> <view>优惠券</view>
<view class='discount'>{{couponTitle}} <view class='discount'>{{couponTitle}}
<text class='iconfont icon-jiantou'></text> <text class='iconfont icon-jiantou'></text>
@ -57,7 +57,7 @@
</view> </view>
<view class='item acea-row row-between-wrapper' <view class='item acea-row row-between-wrapper'
v-if="!orderInfoVo.bargainId && !orderInfoVo.combinationId && !orderInfoVo.seckillId && productType==='normal'"> v-if="orderInfoVo.type === 1 && productType==='normal'">
<view>积分抵扣</view> <view>积分抵扣</view>
<!-- --> <!-- -->
<view class='discount acea-row row-middle'> <view class='discount acea-row row-middle'>
@ -74,7 +74,7 @@
<view>会员优惠</view> <view>会员优惠</view>
<view class='discount'>-{{priceGroup.vipPrice}}</view> <view class='discount'>-{{priceGroup.vipPrice}}</view>
</view> --> </view> -->
<view class='item acea-row row-between-wrapper' v-if='shippingType==0'> <view class='item acea-row row-between-wrapper' v-if='shippingType === 1'>
<view>快递费用</view> <view>快递费用</view>
<view class='discount' v-if='parseFloat(orderInfoVo.freightFee) > 0'> <view class='discount' v-if='parseFloat(orderInfoVo.freightFee) > 0'>
+{{orderInfoVo.freightFee}} +{{orderInfoVo.freightFee}}
@ -175,10 +175,10 @@
postOrderComputed, postOrderComputed,
wechatOrderPay, wechatOrderPay,
wechatQueryPayResult, wechatQueryPayResult,
loadPreOrderApi
} from '@/api/order.js'; } from '@/api/order.js';
import * as AddressApi from '@/api/member/address.js'; import * as AddressApi from '@/api/member/address.js';
import * as CouponApi from '@/api/promotion/coupon.js'; import * as CouponApi from '@/api/promotion/coupon.js';
import * as OrderApi from '@/api/trade/order.js';
import { import {
openPaySubscribe openPaySubscribe
} from '@/utils/SubscribeMessage.js'; } from '@/utils/SubscribeMessage.js';
@ -189,7 +189,7 @@
import home from '@/components/home'; import home from '@/components/home';
import { toLogin } from '@/libs/login.js'; import { toLogin } from '@/libs/login.js';
import { mapGetters } from "vuex"; import { mapGetters } from "vuex";
import coupon from "../../../../admin/src/views/marketing/coupon"; import * as Util from '@/utils/util.js';
export default { export default {
components: { components: {
couponListWindow, couponListWindow,
@ -199,6 +199,11 @@
}, },
data() { data() {
return { return {
items: [], //
cartInfo: [], //
orderInfoVo: {}, //
// TODO
textareaStatus: true, textareaStatus: true,
// //
cartArr: [{ cartArr: [{
@ -229,7 +234,6 @@
toPay: false, // toPay: false, //
contacts: '', contacts: '',
contactsTel: '', contactsTel: '',
cartInfo: [],
priceGroup: {}, priceGroup: {},
animated: false, animated: false,
totalPrice: 0, totalPrice: 0,
@ -238,8 +242,6 @@
bargain: false, // bargain: false, //
combination: false, // combination: false, //
secKill: false, // secKill: false, //
orderInfoVo: {},
orderProNum: 0,
preOrderNo: '', // preOrderNo: '', //
// ========== ========== // ========== ==========
@ -252,7 +254,7 @@
}, },
// ========== ========== // ========== ==========
shippingType: 0, // 0 - 1 - shippingType: 1, // 1 - 2 -
addressId: 0, // param id addressId: 0, // param id
addressInfo: {}, // addressInfo: {}, //
address: { // address: { //
@ -286,13 +288,24 @@
return return
} }
// TODO
// #ifdef H5 // #ifdef H5
this.payChannel = this.$wechat.isWeixin() ? 'public' : 'weixinh5'; this.payChannel = this.$wechat.isWeixin() ? 'public' : 'weixinh5';
// #endif // #endif
// #ifdef MP // #ifdef MP
this.payChannel = 'routine'; this.payChannel = 'routine';
// #endif // #endif
this.preOrderNo = options.preOrderNo || 0;
//
if (options.cartIds && options.cartIds.length > 0) {
const cartIds = options.cartIds.split(',');
this.items = cartIds.map(cartId => ({ cartId }));
} else if (options.skuId > 0) {
this.items = [{
skuId: options.skuId,
count: options.count | 1
}]
}
this.getloadPreOrder(); this.getloadPreOrder();
// address // address
@ -324,14 +337,23 @@
}) })
}, },
methods: { methods: {
// /**
* 获得订单确认信息
*/
getloadPreOrder: function() { getloadPreOrder: function() {
loadPreOrderApi(this.preOrderNo).then(res => { OrderApi.settlementOrder({
let orderInfoVo = res.data.orderInfoVo items: this.items,
addressId: this.address.addressId > 0 && this.shippingType === 1 ? this.address.addressId : undefined,
shippingType: parseInt() + 1,
couponId: this.couponId > 0 ? this.couponId : undefined,
// TODO
}).then(res => {
const orderInfoVo = res.data
this.orderInfoVo = orderInfoVo; this.orderInfoVo = orderInfoVo;
this.cartInfo = orderInfoVo.orderDetailList; this.cartInfo = orderInfoVo.items;
this.orderProNum = orderInfoVo.orderProNum;
this.address.addressId = this.addressId ? this.addressId :orderInfoVo.addressId; this.address.addressId = this.addressId ? this.addressId :orderInfoVo.addressId;
// TODO
this.cartArr[1].title = '可用余额:' + orderInfoVo.userBalance; this.cartArr[1].title = '可用余额:' + orderInfoVo.userBalance;
this.cartArr[1].payStatus = parseInt(res.data.yuePayStatus) === 1 ? 1 : 2; this.cartArr[1].payStatus = parseInt(res.data.yuePayStatus) === 1 ? 1 : 2;
this.cartArr[0].payStatus = parseInt(res.data.payWeixinOpen) === 1 ? 1 : 0; this.cartArr[0].payStatus = parseInt(res.data.payWeixinOpen) === 1 ? 1 : 0;
@ -340,23 +362,19 @@
this.$nextTick(function() { this.$nextTick(function() {
this.$refs.addressWindow.getAddressList(); this.$refs.addressWindow.getAddressList();
}) })
//
this.getCouponList();
}).catch(err => { }).catch(err => {
return this.$util.Tips({ return this.$util.Tips({
title: err title: err
}); });
}) })
// TODO
this.getCouponList();
}, },
// //
computedPrice: function() { computedPrice: function() {
let shippingType = this.shippingType;
postOrderComputed({ postOrderComputed({
addressId: this.address.addressId,
useIntegral: this.useIntegral, useIntegral: this.useIntegral,
couponId: this.couponId,
shippingType: parseInt(shippingType) + 1,
preOrderNo: this.preOrderNo preOrderNo: this.preOrderNo
}).then(res => { }).then(res => {
let data = res.data; let data = res.data;
@ -721,10 +739,10 @@
if (!that.payType) return that.$util.Tips({ if (!that.payType) return that.$util.Tips({
title: '请选择支付方式' title: '请选择支付方式'
}); });
if (!that.address.addressId && !that.shippingType) return that.$util.Tips({ if (!that.address.addressId && that.shippingType === 1) return that.$util.Tips({
title: '请选择收货地址' title: '请选择收货地址'
}); });
if (that.shippingType == 1) { if (that.shippingType == 2) {
if (that.contacts == "" || that.contactsTel == "") { if (that.contacts == "" || that.contactsTel == "") {
return that.$util.Tips({ return that.$util.Tips({
title: '请填写联系人或联系人电话' title: '请填写联系人或联系人电话'
@ -894,7 +912,7 @@
addressType: function(shippingType) { addressType: function(shippingType) {
this.shippingType = shippingType; this.shippingType = shippingType;
this.computedPrice(); this.computedPrice();
if (shippingType === 1) { if (shippingType === 2) {
this.getList(); this.getList();
} }
}, },
@ -927,6 +945,10 @@
}); });
}) })
}, },
fen2yuan(price) {
return Util.fen2yuan(price)
},
} }
} }
</script> </script>