feat 添加订单确认页面区分店铺

This commit is contained in:
AERWEN\26795 2023-10-18 03:20:00 +08:00
parent ad4f22e60c
commit f0e2b7ecfc
6 changed files with 158 additions and 134 deletions

View File

@ -2,6 +2,9 @@ import {
mockIp, mockIp,
mockReqId mockReqId
} from '../../utils/mock'; } from '../../utils/mock';
import {
getGoodsFreight
} from '~/services/order/getGoodsFreight';
export const transformGoodsDataToConfirmData = (goodsDataList) => { export const transformGoodsDataToConfirmData = (goodsDataList) => {
const list = []; const list = [];
@ -40,10 +43,11 @@ export const transformGoodsDataToConfirmData = (goodsDataList) => {
}; };
/** 生成结算数据 */ /** 生成结算数据 */
export function genSettleDetail(params) { export async function genSettleDetail(params) {
const { const {
userAddressReq, userAddressReq,
couponList, couponList,
storeInfoList,
goodsRequestList, goodsRequestList,
totalDeliveryFee totalDeliveryFee
} = params; } = params;
@ -67,23 +71,25 @@ export function genSettleDetail(params) {
invoiceRequest: null, invoiceRequest: null,
skuImages: null, skuImages: null,
deliveryFeeList: null, deliveryFeeList: null,
storeGoodsList: [{ storeGoodsList: [
storeId: '1000', // {
storeName: '云Mall深圳旗舰店', // storeId: '1000',
remark: null, // storeName: '云Mall深圳旗舰店',
goodsCount: 1, // remark: null,
deliveryFee: '0', // goodsCount: 1,
deliveryWords: null, // deliveryFee: '0',
storeTotalAmount: '0', // deliveryWords: null,
storeTotalPayAmount: '179997', // storeTotalAmount: '0',
storeTotalDiscountAmount: '110000', // storeTotalPayAmount: '179997',
storeTotalCouponAmount: '0', // storeTotalDiscountAmount: '110000',
skuDetailVos: [], // storeTotalCouponAmount: '0',
couponList: [{ // skuDetailVos: [],
couponId: 11, // couponList: [{
storeId: '1000', // couponId: 11,
}, ], // storeId: '1000',
}, ], // }, ],
// },
],
inValidGoodsList: null, inValidGoodsList: null,
outOfStockGoodsList: null, outOfStockGoodsList: null,
limitGoodsList: null, limitGoodsList: null,
@ -98,10 +104,63 @@ export function genSettleDetail(params) {
success: true, success: true,
}; };
console.log(storeInfoList, '测试前端用店铺判断');
const storeGoodsList = []
// 将商品塞进对应的店铺
storeInfoList.forEach((store) => {
const storeGoods = {
storeId: "",
storeName: "",
goodsCount: 0,
deliveryFee: 0,
storeTotalAmount: 0,
storeTotalDiscountAmount: 0,
storeTotalCouponAmount: 0,
couponList: [{
couponId: 11,
storeId: '1000',
}, ],
}
const storeGoodsRequestList = []
storeGoods.storeId = store.storeId
storeGoods.storeName = store.storeName
goodsRequestList.forEach(item => {
if (item.storeId === store.storeId) {
storeGoods.goodsCount += item.quantity
storeGoods.storeTotalAmount += item.quantity * item.price
storeGoodsRequestList.push(item)
}
});
if (userAddressReq) {
let data = {
GoodsRequestList: storeGoodsRequestList,
CustomerAddressGuid: userAddressReq.customerAddressGuid
}
getGoodsFreight(data).then((res) => {
if (res.code === 0) {
resp.data.abnormalDeliveryGoodsList = storeGoodsRequestList
}
storeGoods.deliveryFee = res.data
storeGoods.storeTotalAmount += res.data
console.log(storeGoods.deliveryFee, '运费');
})
}
const list = transformGoodsDataToConfirmData(storeGoodsRequestList);
storeGoods.skuDetailVos = list
storeGoodsList.push(storeGoods)
})
console.log(storeGoodsList, '看看成果');
const list = transformGoodsDataToConfirmData(goodsRequestList); const list = transformGoodsDataToConfirmData(goodsRequestList);
console.log(list, '看看list'); console.log(list, '看看list');
// 获取购物车传递的商品数据 // 获取购物车传递的商品数据
resp.data.storeGoodsList[0].skuDetailVos = list; // resp.data.storeGoodsList[0].skuDetailVos = list;
// resp.data.storeGoodsList[1].skuDetailVos = list;
resp.data.storeGoodsList = storeGoodsList;
// 判断是否携带优惠券数据 // 判断是否携带优惠券数据
const discountPrice = []; const discountPrice = [];

View File

@ -128,8 +128,6 @@ Page({
if (userAddressReq) { if (userAddressReq) {
// 计算运费接口 // 计算运费接口
console.log(goodsRequestList, '看看看看')
console.log(userAddressReq.customerAddressGuid, '看看看看地址')
let data = { let data = {
GoodsRequestList: goodsRequestList, GoodsRequestList: goodsRequestList,
CustomerAddressGuid: userAddressReq.customerAddressGuid CustomerAddressGuid: userAddressReq.customerAddressGuid
@ -147,7 +145,8 @@ Page({
}); });
this.initData(res.data); this.initData(res.data);
}, },
() => { (e) => {
console.log(e,'异常');
//接口异常处理 //接口异常处理
this.handleError(); this.handleError();
}, },
@ -157,6 +156,7 @@ Page({
// 转换商品卡片显示数据 // 转换商品卡片显示数据
const data = this.handleResToGoodsCard(resData); const data = this.handleResToGoodsCard(resData);
this.userAddressReq = resData.userAddress; this.userAddressReq = resData.userAddress;
console.log(data,'看看data');
if (resData.userAddress) { if (resData.userAddress) {
this.setData({ this.setData({
@ -336,9 +336,7 @@ Page({
}); });
}, },
onNotes(e) { onNotes(e) {
const { const storeNoteIndex = e.currentTarget.dataset.storenoteindex;
storenoteindex: storeNoteIndex
} = e.currentTarget.dataset;
// 添加备注信息 // 添加备注信息
this.setData({ this.setData({
dialogShow: true, dialogShow: true,

View File

@ -4,25 +4,13 @@
<wxs module="getNotes" src="./getNotes.wxs" /> <wxs module="getNotes" src="./getNotes.wxs" />
<view class="order-sure" wx:if="{{!loading}}"> <view class="order-sure" wx:if="{{!loading}}">
<address-card addressData="{{userAddress}}" bind:addclick="onGotoAddress" bind:addressclick="onGotoAddress" /> <address-card addressData="{{userAddress}}" bind:addclick="onGotoAddress" bind:addressclick="onGotoAddress" />
<view
class="order-wrapper" <view class="order-wrapper" wx:for="{{settleDetailData.storeGoodsList}}" wx:for-item="stores" wx:for-index="storeIndex" wx:key="storeIndex">
wx:for="{{settleDetailData.storeGoodsList}}" <view class="store-wrapper">
wx:for-item="stores"
wx:for-index="storeIndex"
wx:key="storeIndex"
>
<!-- <view class="store-wrapper">
<t-icon prefix="wr" size="40rpx" color="#333333" name="store" class="store-logo" /> <t-icon prefix="wr" size="40rpx" color="#333333" name="store" class="store-logo" />
{{stores.storeName}} {{stores.storeName}}
</view> --> </view>
<view <view wx:if="{{orderCardList[storeIndex].goodsList.length > 0}}" wx:for="{{orderCardList[storeIndex].goodsList}}" wx:for-item="goods" wx:for-index="gIndex" wx:key="id" class="goods-wrapper">
wx:if="{{orderCardList[storeIndex].goodsList.length > 0}}"
wx:for="{{orderCardList[storeIndex].goodsList}}"
wx:for-item="goods"
wx:for-index="gIndex"
wx:key="id"
class="goods-wrapper"
>
<image src="{{goods.thumb}}" class="goods-image" mode="aspectFill" /> <image src="{{goods.thumb}}" class="goods-image" mode="aspectFill" />
<view class="goods-content"> <view class="goods-content">
<view class="goods-title">{{goods.title}}</view> <view class="goods-title">{{goods.title}}</view>
@ -33,76 +21,75 @@
<view class="goods-num">x{{goods.num}}</view> <view class="goods-num">x{{goods.num}}</view>
</view> </view>
</view> </view>
</view>
<view class="pay-detail"> <view class="pay-detail">
<view class="pay-item"> <view class="pay-item">
<text>商品总额</text> <text>商品总额</text>
<price <!-- <price priceUnit="yuan" fill decimalSmaller wr-class="pay-item__right font-bold" price="{{settleDetailData.totalSalePrice || '0'}}" /> -->
priceUnit="yuan" <price priceUnit="yuan" fill decimalSmaller wr-class="pay-item__right font-bold" price="{{stores.storeTotalAmount || '0'}}" />
fill
decimalSmaller
wr-class="pay-item__right font-bold"
price="{{settleDetailData.totalSalePrice || '0'}}"
/>
</view>
<view class="pay-item">
<text>运费</text>
<view class="pay-item__right font-bold">
<block wx:if="{{settleDetailData.totalDeliveryFee && settleDetailData.totalDeliveryFee != 0}}">
+
<price priceUnit="yuan" fill decimalSmaller price="{{settleDetailData.totalDeliveryFee}}" />
</block>
<text wx:else>免运费</text>
</view> </view>
</view> <view class="pay-item">
<!-- <view class="pay-item"> <text>运费</text>
<text>活动优惠</text> <view class="pay-item__right font-bold">
<view class="pay-item__right primary font-bold"> <!-- <block wx:if="{{settleDetailData.totalDeliveryFee && settleDetailData.totalDeliveryFee != 0}}"> -->
- <!-- {{stores.deliveryFee}} -->
<price priceUnit="yuan" fill price="{{settleDetailData.totalPromotionAmount || 0}}" /> <block wx:if="{{stores.deliveryFee && stores.deliveryFee != 0}}">
</view> +
</view> --> <!-- <price priceUnit="yuan" fill decimalSmaller price="{{settleDetailData.totalDeliveryFee}}" /> -->
<!-- <view class="pay-item"> <price priceUnit="yuan" fill decimalSmaller price="{{stores.deliveryFee}}" />
<text>优惠券</text>
<view
class="pay-item__right"
data-storeid="{{settleDetailData.storeGoodsList[0].storeId}}"
catchtap="onOpenCoupons"
>
<block wx:if="{{submitCouponList.length}}">
<block wx:if="{{settleDetailData.totalCouponAmount && settleDetailData.totalCouponAmount !== '0'}}">
-<price class="pay-item__right primary font-bold" priceUnit="yuan" fill decimalSmaller price="{{settleDetailData.totalCouponAmount}}" />
</block> </block>
<block wx:else>选择优惠券</block> <text wx:else>免运费</text>
</block> </view>
<text wx:else>无可用</text>
<t-icon name="chevron-right" size="32rpx" color="#BBBBBB" />
</view> </view>
</view> --> <view class="pay-item">
<!-- <view class="pay-item" wx:if="{{settleDetailData.invoiceSupport}}"> <text>活动优惠</text>
<view class="pay-item__right primary font-bold">
-
<price priceUnit="yuan" fill price="{{settleDetailData.totalPromotionAmount || 0}}" />
</view>
</view>
<view class="pay-item">
<text>优惠券</text>
<view class="pay-item__right" data-storeid="{{settleDetailData.storeGoodsList[0].storeId}}" catchtap="onOpenCoupons">
<block wx:if="{{submitCouponList.length}}">
<block wx:if="{{settleDetailData.totalCouponAmount && settleDetailData.totalCouponAmount !== '0'}}">
-
<price class="pay-item__right primary font-bold" priceUnit="yuan" fill decimalSmaller price="{{settleDetailData.totalCouponAmount}}" />
</block>
<block wx:else>选择优惠券</block>
</block>
<text wx:else>无可用</text>
<t-icon name="chevron-right" size="32rpx" color="#BBBBBB" />
</view>
</view>
<!-- <view class="pay-item" wx:if="{{settleDetailData.invoiceSupport}}">
<text>发票</text> <text>发票</text>
<view class="pay-item__right" catchtap="onReceipt"> <view class="pay-item__right" catchtap="onReceipt">
<text>{{handleInvoice(invoiceData)}}</text> <text>{{handleInvoice(invoiceData)}}</text>
<t-icon name="chevron-right" size="32rpx" color="#BBBBBB" /> <t-icon name="chevron-right" size="32rpx" color="#BBBBBB" />
</view> </view>
</view> --> </view> -->
<view class="pay-item"> <view class="pay-item">
<text>订单备注</text> <text>订单备注</text>
<view class="pay-item__right" data-storenoteindex="{{0}}" catchtap="onNotes"> <!-- {{storeNoteIndex}} -->
<text class="pay-remark" <view class="pay-item__right" data-storenoteindex="{{storeIndex}}" catchtap="onNotes">
>{{getNotes(storeInfoList, 0) ? getNotes(storeInfoList, 0) :'选填,建议先和商家沟通确认'}}</text <text class="pay-remark">{{getNotes(storeInfoList, 0) ? getNotes(storeInfoList, 0) :'选填,建议先和商家沟通确认'}}</text>
> <t-icon name="chevron-right" size="32rpx" color="#BBBBBB" />
<t-icon name="chevron-right" size="32rpx" color="#BBBBBB" /> </view>
</view>
</view>
<view class="amount-wrapper">
<view class="pay-amount">
<!-- <text class="order-num">共{{settleDetailData.totalGoodsCount}}件</text> -->
<text class="order-num">共{{stores.goodsCount}}件</text>
<text>小计</text>
<!-- <price priceUnit="yuan" class="total-price" price="{{settleDetailData.totalPayAmount}}" fill="{{false}}" decimalSmaller /> -->
<price priceUnit="yuan" class="total-price" price="{{stores.storeTotalAmount}}" fill="{{false}}" decimalSmaller />
</view> </view>
</view> </view>
</view> </view>
<view class="amount-wrapper">
<view class="pay-amount">
<text class="order-num">共{{settleDetailData.totalGoodsCount}}件</text>
<text>小计</text>
<price priceUnit="yuan" class="total-price" price="{{settleDetailData.totalPayAmount}}" fill="{{false}}" decimalSmaller />
</view>
</view>
<view class="wx-pay-cover"> <view class="wx-pay-cover">
<view class="wx-pay"> <view class="wx-pay">
<price priceUnit="yuan" decimalSmaller fill class="price" price="{{settleDetailData.totalPayAmount || '0'}}" /> <price priceUnit="yuan" decimalSmaller fill class="price" price="{{settleDetailData.totalPayAmount || '0'}}" />
@ -111,42 +98,13 @@
</view> </view>
</view> </view>
</view> </view>
<t-dialog <t-dialog t-class="add-notes" title="填写备注信息" visible="{{dialogShow}}" confirm-btn="确认" cancel-btn="取消" t-class-content="add-notes__content" t-class-confirm="dialog__button-confirm" t-class-cancel="dialog__button-cancel" bindconfirm="onNoteConfirm" bindcancel="onNoteCancel">
t-class="add-notes" <t-textarea slot="content" focus="{{dialogShow}}" class="notes" t-class="add-notes__textarea" value="{{storeInfoList[storeNoteIndex] && storeInfoList[storeNoteIndex].remark}}" placeholder="备注信息" t-class-textarea="add-notes__textarea__font" bindfocus="onFocus" bindblur="onBlur" bindchange="onInput" maxlength="{{50}}" />
title="填写备注信息"
visible="{{dialogShow}}"
confirm-btn="确认"
cancel-btn="取消"
t-class-content="add-notes__content"
t-class-confirm="dialog__button-confirm"
t-class-cancel="dialog__button-cancel"
bindconfirm="onNoteConfirm"
bindcancel="onNoteCancel"
>
<t-textarea
slot="content"
focus="{{dialogShow}}"
class="notes"
t-class="add-notes__textarea"
value="{{storeInfoList[storeNoteIndex] && storeInfoList[storeNoteIndex].remark}}"
placeholder="备注信息"
t-class-textarea="add-notes__textarea__font"
bindfocus="onFocus"
bindblur="onBlur"
bindchange="onInput"
maxlength="{{50}}"
/>
</t-dialog> </t-dialog>
<t-popup visible="{{popupShow}}" placement="bottom" bind:visible-change="onPopupChange"> <t-popup visible="{{popupShow}}" placement="bottom" bind:visible-change="onPopupChange">
<no-goods slot="content" bind:change="onSureCommit" settleDetailData="{{settleDetailData}}" /> <no-goods slot="content" bind:change="onSureCommit" settleDetailData="{{settleDetailData}}" />
</t-popup> </t-popup>
<select-coupons <select-coupons bind:sure="onCoupons" storeId="{{currentStoreId}}" orderSureCouponList="{{couponList}}" promotionGoodsList="{{promotionGoodsList}}" couponsShow="{{couponsShow}}" />
bind:sure="onCoupons"
storeId="{{currentStoreId}}"
orderSureCouponList="{{couponList}}"
promotionGoodsList="{{promotionGoodsList}}"
couponsShow="{{couponsShow}}"
/>
</view> </view>
<t-toast id="t-toast" /> <t-toast id="t-toast" />
<t-dialog id="t-dialog" /> <t-dialog id="t-dialog" />

View File

@ -46,6 +46,14 @@
background: #cccccc; background: #cccccc;
} }
.order-wrapper{
width: 98%;
margin: 0 auto;
margin-bottom: 30rpx;
border-radius: 30rpx;
overflow: hidden;
}
.order-wrapper .store-wrapper { .order-wrapper .store-wrapper {
width: 100%; width: 100%;
height: 96rpx; height: 96rpx;

View File

@ -7,6 +7,7 @@
<view class="pay-money"> <view class="pay-money">
微信支付: 微信支付:
<price <price
priceUnit="yuan"
wx:if="{{totalPaid}}" wx:if="{{totalPaid}}"
price="{{totalPaid}}" price="{{totalPaid}}"
wr-class="pay-money__price" wr-class="pay-money__price"

View File

@ -2,7 +2,7 @@ import {
request request
} from '../_utils/request'; } from '../_utils/request';
/** 修改购物车商品数量 */ /** 修改购物车商品选中状态 */
export function updateCartGoodsSelect(data) { export function updateCartGoodsSelect(data) {
return new Promise((resolve, reject) => { return new Promise((resolve, reject) => {
request({ request({