From 6ab71eb4bfa88687111a0c88dfe610cbff6c4a2e Mon Sep 17 00:00:00 2001
From: "AERWEN\\26795" <123456789a>
Date: Wed, 18 Oct 2023 20:45:09 +0800
Subject: [PATCH] =?UTF-8?q?fixed=20=E4=BC=98=E5=8C=96=E8=B4=AD=E7=89=A9?=
=?UTF-8?q?=E8=BD=A6=EF=BC=8C=E6=B8=B2=E6=9F=93=E4=BC=98=E6=83=A0=E5=88=B8?=
=?UTF-8?q?=E5=88=97=E8=A1=A8?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
model/order/orderConfirm.js | 84 +++++++++++--------
pages/coupon/coupon-list/index.wxml | 4 +-
.../components/promotion-popup/index.js | 4 +-
.../components/promotion-popup/index.json | 11 +--
.../components/promotion-popup/index.wxml | 33 ++++----
pages/goods/details/index.js | 12 +--
pages/goods/details/index.wxml | 3 +-
pages/goods/details/index.wxss | 4 +-
.../components/selectCoupons/selectCoupons.js | 35 +++++---
pages/order/order-confirm/index.js | 9 +-
pages/order/order-confirm/index.wxml | 13 +--
project.config.json | 3 +-
services/coupon/index.js | 2 +-
13 files changed, 133 insertions(+), 84 deletions(-)
diff --git a/model/order/orderConfirm.js b/model/order/orderConfirm.js
index 572e21d..230707d 100644
--- a/model/order/orderConfirm.js
+++ b/model/order/orderConfirm.js
@@ -104,7 +104,20 @@ export async function genSettleDetail(params) {
success: true,
};
- console.log(storeInfoList, '测试前端用店铺判断');
+ // 判断是否携带优惠券数据
+ const discountPrice = [];
+ console.log(couponList, '计算一下');
+ if (couponList && couponList.length > 0) {
+ couponList.forEach((coupon) => {
+ if (coupon.status === 'default') {
+ discountPrice.push({
+ shopGuid: coupon.shopGuid,
+ type: coupon.type,
+ value: coupon.value,
+ });
+ }
+ });
+ }
const storeGoodsList = []
// 将商品塞进对应的店铺
@@ -118,8 +131,7 @@ export async function genSettleDetail(params) {
storeTotalDiscountAmount: 0,
storeTotalCouponAmount: 0,
couponList: [{
- couponId: 11,
- storeId: '1000',
+
}, ],
}
const storeGoodsRequestList = []
@@ -129,26 +141,42 @@ export async function genSettleDetail(params) {
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
+ })
+ }
+
+ // 计算优惠券价格
+ let storeTotalCouponAmount = 0
+ if (discountPrice && discountPrice.length > 0) {
+ discountPrice.forEach(e => {
+ if (e.shopGuid === item.storeId) {
+ if (e.type === 1) {
+ storeTotalCouponAmount = e.value;
+ }
+ if (e.type === 2) {
+ storeTotalCouponAmount = (Number(storeGoods.storeTotalAmount) * e.value) / 10;
+ }
+ }
+ });
+ }
+ storeGoods.storeTotalCouponAmount = storeTotalCouponAmount;
+ storeGoods.storeTotalAmount += item.quantity * item.price + storeGoods.deliveryFee - storeTotalCouponAmount;
+
}
});
- 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)
@@ -156,25 +184,11 @@ export async function genSettleDetail(params) {
console.log(storeGoodsList, '看看成果');
const list = transformGoodsDataToConfirmData(goodsRequestList);
- console.log(list, '看看list');
+
// 获取购物车传递的商品数据
// resp.data.storeGoodsList[0].skuDetailVos = list;
- // resp.data.storeGoodsList[1].skuDetailVos = list;
resp.data.storeGoodsList = storeGoodsList;
- // 判断是否携带优惠券数据
- const discountPrice = [];
-
- if (couponList && couponList.length > 0) {
- couponList.forEach((coupon) => {
- if (coupon.status === 'default') {
- discountPrice.push({
- type: coupon.type,
- value: coupon.value,
- });
- }
- });
- }
// 模拟计算场景
@@ -207,8 +221,6 @@ export async function genSettleDetail(params) {
if (totalDeliveryFee) {
resp.data.totalPayAmount += resp.data.totalDeliveryFee
- console.log(typeof (totalDeliveryFee), '类型是什么');
- console.log(totalDeliveryFee, '这里呢');
}
list.forEach(item => {
diff --git a/pages/coupon/coupon-list/index.wxml b/pages/coupon/coupon-list/index.wxml
index 654c308..be5644f 100644
--- a/pages/coupon/coupon-list/index.wxml
+++ b/pages/coupon/coupon-list/index.wxml
@@ -28,7 +28,7 @@
-
+
diff --git a/pages/goods/details/components/promotion-popup/index.js b/pages/goods/details/components/promotion-popup/index.js
index 9743cc1..cf8e630 100644
--- a/pages/goods/details/components/promotion-popup/index.js
+++ b/pages/goods/details/components/promotion-popup/index.js
@@ -7,7 +7,7 @@ Component({
list: Array,
title: {
type: String,
- value: '促销说明',
+ value: '领券中心',
},
show: {
type: Boolean,
@@ -27,6 +27,8 @@ Component({
},
closePromotionPopup() {
+ console.log(this.list);
+
this.triggerEvent('closePromotionPopup', {
show: false,
});
diff --git a/pages/goods/details/components/promotion-popup/index.json b/pages/goods/details/components/promotion-popup/index.json
index a9de77d..e9bcd2b 100644
--- a/pages/goods/details/components/promotion-popup/index.json
+++ b/pages/goods/details/components/promotion-popup/index.json
@@ -1,7 +1,8 @@
{
- "component": true,
- "usingComponents": {
- "t-popup": "tdesign-miniprogram/popup/popup",
- "t-icon": "tdesign-miniprogram/icon/icon"
- }
+ "component": true,
+ "usingComponents": {
+ "t-popup": "tdesign-miniprogram/popup/popup",
+ "t-icon": "tdesign-miniprogram/icon/icon",
+ "coupon-card": "/components/coupon-card/index"
+ }
}
\ No newline at end of file
diff --git a/pages/goods/details/components/promotion-popup/index.wxml b/pages/goods/details/components/promotion-popup/index.wxml
index c1cea9d..7525c8d 100644
--- a/pages/goods/details/components/promotion-popup/index.wxml
+++ b/pages/goods/details/components/promotion-popup/index.wxml
@@ -1,13 +1,13 @@
-
\ No newline at end of file
diff --git a/pages/goods/details/index.js b/pages/goods/details/index.js
index 97b388b..103658e 100644
--- a/pages/goods/details/index.js
+++ b/pages/goods/details/index.js
@@ -453,12 +453,12 @@ Page({
});
});
const promotionArray = [];
- activityList.forEach((item) => {
- promotionArray.push({
- tag: item.promotionSubCode === 'MYJ' ? '满减' : '满折',
- label: '满100元减99.9元',
- });
- });
+ // activityList.forEach((item) => {
+ // promotionArray.push({
+ // tag: item.promotionSubCode === 'MYJ' ? '满减' : '满折',
+ // label: '满100元减99.9元',
+ // });
+ // });
this.setData({
details,
activityList,
diff --git a/pages/goods/details/index.wxml b/pages/goods/details/index.wxml
index 40fd59a..38f52fb 100644
--- a/pages/goods/details/index.wxml
+++ b/pages/goods/details/index.wxml
@@ -40,7 +40,7 @@
已售{{soldNum}}
{{ details.goodsSellingPoint }}
-
+
{{details.title}}
diff --git a/pages/goods/details/index.wxss b/pages/goods/details/index.wxss
index d876903..e06d437 100644
--- a/pages/goods/details/index.wxss
+++ b/pages/goods/details/index.wxss
@@ -65,7 +65,9 @@ page {
.goods-detail-page .goods-info .goods-activity {
display: flex;
margin-top: 16rpx;
- justify-content: space-between;
+ position: relative;
+ /* justify-content: space-between; */
+ justify-content: flex-end;
}
.goods-detail-page .goods-info .goods-activity .tags-container {
diff --git a/pages/order/components/selectCoupons/selectCoupons.js b/pages/order/components/selectCoupons/selectCoupons.js
index 6f941f9..e187039 100644
--- a/pages/order/components/selectCoupons/selectCoupons.js
+++ b/pages/order/components/selectCoupons/selectCoupons.js
@@ -61,8 +61,8 @@ Component({
selectedCoupons,
storeId,
}).then((res) => {
- console.log(res,'res来咯');
- this.initData(res);
+ // console.log(res,'res来咯');
+ // this.initData(res);
});
}
},
@@ -92,11 +92,12 @@ Component({
selectedNum++;
selectedList.push({
couponId: coupon.key,
- promotionId: ruleId,
+ // promotionId: ruleId,
storeId: this.storeId,
});
}
return {
+ shopGuid: coupon.shopGuid,
key: coupon.key,
title: coupon.title,
isSelected: false,
@@ -104,7 +105,7 @@ Component({
value: coupon.value,
status: coupon.status === 1 ? 'default' : 'useless',
desc: coupon.desc,
- type,
+ type : coupon.type,
tag: '',
};
});
@@ -150,16 +151,30 @@ Component({
coupons(coupon = {}) {
return new Promise((resolve, reject) => {
console.log(coupon,'coupon里有什么');
+ const {
+ storeId
+ } =
+ this.data;
+ console.log(storeId);
if (coupon?.selectedCoupons) {
+ let data = {
+ couponResultList: [],
+ reduce: 1000,
+ }
// 优惠券接口
- fetchCouponList({
- status: 1
- }).then((res) => {
- resolve({
- couponResultList: res,
- reduce: 1000,
+ fetchCouponList({
+ shopGuid: storeId,
+ status: 1
+ }).then((res) => {
+ data.couponResultList = res
+ this.initData(data);
});
+
+ resolve({
+ couponResultList: data,
+ reduce: 1000,
});
+
}
return reject({
couponResultList: [],
diff --git a/pages/order/order-confirm/index.js b/pages/order/order-confirm/index.js
index 87f69d1..5804f7a 100644
--- a/pages/order/order-confirm/index.js
+++ b/pages/order/order-confirm/index.js
@@ -48,6 +48,7 @@ Page({
promotionGoodsList: [], //当前门店商品列表(优惠券)
couponList: [], //当前门店所选优惠券
submitCouponList: [], //所有门店所选优惠券
+ resSubmitCouponList:[],
currentStoreId: null, //当前优惠券storeId
userAddress: null,
},
@@ -434,6 +435,7 @@ Page({
invoiceData,
storeInfoList,
submitCouponList,
+ resSubmitCouponList
} = this.data;
const {
goodsRequestList
@@ -458,7 +460,8 @@ Page({
return;
}
// this.payLock = true;
- const resSubmitCouponList = this.handleCouponList(submitCouponList);
+ console.log(submitCouponList);
+ // const resSubmitCouponList = this.handleCouponList(submitCouponList);
const openId = wx.getStorageSync('openId')
console.log(openId, '我的openId');
const params = {
@@ -625,12 +628,16 @@ Page({
storeCoupon.couponList,
};
});
+ console.log(tempSubmitCouponList,'查看确定优惠券 temp');
const resSubmitCouponList = this.handleCouponList(tempSubmitCouponList);
+ console.log(resSubmitCouponList,'查看确定优惠券 res');
+
//确定选择优惠券
this.handleOptionsParams({
goodsRequestList
}, resSubmitCouponList);
this.setData({
+ resSubmitCouponList:resSubmitCouponList,
couponsShow: false
});
},
diff --git a/pages/order/order-confirm/index.wxml b/pages/order/order-confirm/index.wxml
index 62fc308..67edfaa 100644
--- a/pages/order/order-confirm/index.wxml
+++ b/pages/order/order-confirm/index.wxml
@@ -41,20 +41,23 @@
免运费
-
+
优惠券
-
+
-
+
+
-
-
+
+
+
选择优惠券
diff --git a/project.config.json b/project.config.json
index 8ef4e1c..95e4fc7 100644
--- a/project.config.json
+++ b/project.config.json
@@ -43,7 +43,8 @@
"showES6CompileOption": false,
"useCompilerPlugins": false,
"ignoreUploadUnusedFiles": true,
- "useStaticServer": true
+ "useStaticServer": true,
+ "condition": false
},
"compileType": "miniprogram",
"libVersion": "2.23.1",
diff --git a/services/coupon/index.js b/services/coupon/index.js
index 7d3d3b6..dbf9a0c 100644
--- a/services/coupon/index.js
+++ b/services/coupon/index.js
@@ -3,7 +3,7 @@ import {
} from '../_utils/request';
/** 优惠券列表 */
-export function fetchCouponList(parm) {
+export async function fetchCouponList(parm) {
return new Promise((resolve, reject) => {
request({
url: `CustomerCouponApi/getCustomerCouponList`,