fixed 修改细节

This commit is contained in:
lwh 2023-09-22 22:09:03 +08:00
parent 2181e41643
commit 9d350dbb53
11 changed files with 158 additions and 113 deletions

View File

@ -1,4 +1,7 @@
import { mockIp, mockReqId } from '../../utils/mock';
import {
mockIp,
mockReqId
} from '../../utils/mock';
export const transformGoodsDataToConfirmData = (goodsDataList) => {
const list = [];
@ -6,10 +9,11 @@ export const transformGoodsDataToConfirmData = (goodsDataList) => {
goodsDataList.forEach((goodsData) => {
list.push({
storeId: goodsData.storeId,
storeName: goodsData?.storeName,
spuId: goodsData.spuId,
skuId: goodsData.skuId,
goodsName: goodsData.title,
image: goodsData.primaryImage,
image: goodsData.thumb,
reminderStock: 119,
quantity: goodsData.quantity,
payPrice: goodsData.price,
@ -37,18 +41,22 @@ export const transformGoodsDataToConfirmData = (goodsDataList) => {
/** 生成结算数据 */
export function genSettleDetail(params) {
const { userAddressReq, couponList, goodsRequestList } = params;
const {
userAddressReq,
couponList,
goodsRequestList
} = params;
const resp = {
data: {
settleType: 0,
userAddress: null,
totalGoodsCount: 3,
packageCount: 1,
totalGoodsCount: 0,
packageCount: 0,
totalAmount: '289997',
totalPayAmount: '',
totalDiscountAmount: '110000',
totalPromotionAmount: '1100',
totalPromotionAmount: '0',
totalCouponAmount: '0',
totalSalePrice: '289997',
totalGoodsAmount: '289997',
@ -56,27 +64,23 @@ export function genSettleDetail(params) {
invoiceRequest: null,
skuImages: null,
deliveryFeeList: null,
storeGoodsList: [
{
storeGoodsList: [{
storeId: '1000',
storeName: '云Mall深圳旗舰店',
remark: null,
goodsCount: 1,
deliveryFee: '0',
deliveryWords: null,
storeTotalAmount: '0',
storeTotalPayAmount: '179997',
storeTotalDiscountAmount: '110000',
storeTotalCouponAmount: '0',
skuDetailVos: [],
couponList: [{
couponId: 11,
storeId: '1000',
storeName: '云Mall深圳旗舰店',
remark: null,
goodsCount: 1,
deliveryFee: '0',
deliveryWords: null,
storeTotalAmount: '0',
storeTotalPayAmount: '179997',
storeTotalDiscountAmount: '110000',
storeTotalCouponAmount: '0',
skuDetailVos: [],
couponList: [
{
couponId: 11,
storeId: '1000',
},
],
},
],
}, ],
}, ],
inValidGoodsList: null,
outOfStockGoodsList: null,
limitGoodsList: null,
@ -92,7 +96,7 @@ export function genSettleDetail(params) {
};
const list = transformGoodsDataToConfirmData(goodsRequestList);
console.log(list, '看看list');
// 获取购物车传递的商品数据
resp.data.storeGoodsList[0].skuDetailVos = list;
@ -119,18 +123,18 @@ export function genSettleDetail(params) {
// 计算折扣
const totalDiscountPrice =
discountPrice.length > 0
? discountPrice.reduce((pre, cur) => {
if (cur.type === 1) {
return pre + cur.value;
}
if (cur.type === 2) {
return pre + (Number(totalPrice) * cur.value) / 10;
}
discountPrice.length > 0 ?
discountPrice.reduce((pre, cur) => {
if (cur.type === 1) {
return pre + cur.value;
}
if (cur.type === 2) {
return pre + (Number(totalPrice) * cur.value) / 10;
}
return pre + cur;
}, 0)
: 0;
return pre + cur;
}, 0) :
0;
resp.data.totalSalePrice = totalPrice;
@ -139,6 +143,10 @@ export function genSettleDetail(params) {
resp.data.totalPayAmount =
totalPrice - totalDiscountPrice - Number(resp.data.totalPromotionAmount);
list.forEach(item => {
resp.data.totalGoodsCount += item.quantity
});
if (userAddressReq) {
resp.data.settleType = 1;
resp.data.userAddress = userAddressReq;

View File

@ -259,7 +259,7 @@
}
.popup-sku-actions .sku-operate .sku-operate-addCart {
background-color: #ffece9;
background-color: #f8f8f8;
color: #1989fa;
border-radius: 48rpx 0 0 48rpx;
}

View File

@ -39,7 +39,8 @@
</view>
<view class="sold-num">已售{{soldNum}}</view>
</view>
<view wx:if="{{activityList.length > 0}}" class="goods-activity" bindtap="showPromotionPopup">
<view wx:if="{{details.goodsSellingPoint}}">{{ details.goodsSellingPoint }}</view>
<!-- <view wx:if="{{activityList.length > 0}}" class="goods-activity" bindtap="showPromotionPopup">
<view class="tags-container">
<view wx:for="{{activityList}}" data-promotionId="{{item.promotionId}}" wx:key="index" wx:if="{{index<4}}">
<view class="goods-activity-tag">{{item.tag}}</view>
@ -49,7 +50,7 @@
<view class="activity-show-text">领劵</view>
<t-icon name="chevron-right" size="42rpx" />
</view>
</view>
</view> -->
<view class="goods-title">
<view class="goods-name">{{details.title}}</view>
<view class="goods-tag">

View File

@ -377,13 +377,14 @@ page {
width: 180rpx;
overflow: hidden;
margin-right: 20rpx;
border-radius: 50%;
border: 1rpx solid rgb(204, 204, 204);
}
.shop-left-img {
height: 100%;
width: 100%;
object-fit: cover;
border: 1rpx solid rgb(204, 204, 204);
}
.shop-left-box {

View File

@ -1,6 +1,10 @@
import dayjs from 'dayjs';
import { couponsData } from './mock';
import {
couponsData
} from './mock';
import {
fetchCouponList
} from '~/services/coupon/index';
const emptyCouponImg = `https://cdn-we-retail.ym.tencent.com/miniapp/coupon/ordersure-coupon-newempty.png`;
Component({
@ -19,8 +23,12 @@ Component({
value: false,
observer(couponsShow) {
if (couponsShow) {
const { promotionGoodsList, orderSureCouponList, storeId } =
this.data;
const {
promotionGoodsList,
orderSureCouponList,
storeId
} =
this.data;
const products =
promotionGoodsList &&
promotionGoodsList.map((goods) => {
@ -53,6 +61,7 @@ Component({
selectedCoupons,
storeId,
}).then((res) => {
console.log(res,'res来咯');
this.initData(res);
});
}
@ -69,41 +78,32 @@ Component({
},
methods: {
initData(data = {}) {
const { couponResultList = [], reduce = 0 } = data;
const {
couponResultList = [], reduce = 0
} = data;
console.log(data,'data来咯');
const selectedList = [];
let selectedNum = 0;
const couponsList =
couponResultList &&
couponResultList.map((coupon) => {
const { status, couponVO } = coupon;
const {
couponId,
condition = '',
endTime = 0,
name = '',
startTime = 0,
value,
type,
} = couponVO;
if (status === 1) {
console.log(coupon,'优惠价');
if (coupon.status === 1) {
selectedNum++;
selectedList.push({
couponId,
couponId: coupon.key,
promotionId: ruleId,
storeId: this.storeId,
});
}
const val = type === 2 ? value / 100 : value / 10;
return {
key: couponId,
title: name,
key: coupon.key,
title: coupon.title,
isSelected: false,
timeLimit: `${dayjs(+startTime).format('YYYY-MM-DD')}-${dayjs(
+endTime,
).format('YYYY-MM-DD')}`,
value: val,
status: status === -1 ? 'useless' : 'default',
desc: condition,
timeLimit: coupon.timeLimit,
value: coupon.value,
status: coupon.status === 1 ? 'default' : 'useless',
desc: coupon.desc,
type,
tag: '',
};
@ -116,8 +116,13 @@ Component({
});
},
selectCoupon(e) {
const { key } = e.currentTarget.dataset;
const { couponsList, selectedList } = this.data;
const {
key
} = e.currentTarget.dataset;
const {
couponsList,
selectedList
} = this.data;
couponsList.forEach((coupon) => {
if (coupon.key === key) {
coupon.isSelected = !coupon.isSelected;
@ -144,10 +149,16 @@ Component({
},
coupons(coupon = {}) {
return new Promise((resolve, reject) => {
console.log(coupon,'coupon里有什么');
if (coupon?.selectedCoupons) {
resolve({
couponResultList: couponsData.couponResultList,
reduce: couponsData.reduce,
// 优惠券接口
fetchCouponList({
status: 1
}).then((res) => {
resolve({
couponResultList: res,
reduce: 1000,
});
});
}
return reject({

View File

@ -10,19 +10,19 @@
</wxs>
<view class="address-card wr-class">
<t-cell wx:if="{{addressData && addressData.detailAddress}}" bindtap="onAddressTap" hover>
<t-cell wx:if="{{addressData}}" bindtap="onAddressTap" hover>
<view class="order-address" slot="title">
<t-icon name="location" color="#333333" size="40rpx" />
<view class="address-content">
<view class="title">
<view class="address-tag" wx:if="{{addressData.addressTag}}">
{{addressData.addressTag}}
<view class="address-tag" wx:if="{{addressData.isDefault}}">
默认
</view>
{{addressData.provinceName}} {{addressData.cityName}} {{addressData.districtName}}
</view>
<view class="detail">{{addressData.detailAddress}}</view>
<view class="detail">{{addressData.detaiaddresslAddress}}</view>
<view class="info">
{{addressData.name}} {{utils.hidePhoneNum(addressData.phone)}}
{{addressData.name}} {{utils.hidePhoneNum(addressData.phoneNumber)}}
</view>
</view>
<t-icon

View File

@ -84,6 +84,7 @@ Page({
// 从购物车跳转过来时,获取传入的商品列表数据
const goodsRequestListJson = wx.getStorageSync('order.goodsRequestList');
goodsRequestList = JSON.parse(goodsRequestListJson);
console.log(goodsRequestList,'数据看看');
} else if (typeof options.goodsRequestList === 'string') {
goodsRequestList = JSON.parse(options.goodsRequestList);
}
@ -226,7 +227,7 @@ Page({
id: index,
thumb: item.image,
title: item.goodsName,
specs: item.skuSpecLst.map((s) => s.specValue), // 规格列表 string[]
specs: item.skuSpecLst?.map((s) => s.specValue), // 规格列表 string[]
price: item.tagPrice || item.settlePrice || '0', // 优先取限时活动价
settlePrice: item.settlePrice,
titlePrefixTags: item.tagText ? [{ text: item.tagText }] : [],
@ -242,6 +243,7 @@ Page({
storeName: ele.storeName,
remark: '',
});
submitCouponList.push({
storeId: ele.storeId,
couponList: ele.couponList || [],
@ -251,6 +253,9 @@ Page({
orderCardList.push(orderCard);
});
this.setData({ orderCardList, storeInfoList, submitCouponList });
return data;
},
@ -393,15 +398,18 @@ Page({
if (invoiceData && invoiceData.email) {
params.invoiceRequest = invoiceData;
}
/** 提交订单方法(接口) */
commitPay(params).then(
(res) => {
this.payLock = false;
const { data } = res;
console.log(res,'后端接口返回调起微信支付的参数');
// 提交出现 失效 不在配送范围 限购的商品 提示弹窗
if (this.isInvalidOrder(data)) {
return;
}
if (res.code === 'Success') {
console.log("正在调起支付");
this.handlePay(data, settleDetailData);
} else {
Toast({
@ -484,6 +492,7 @@ Page({
tradeNo: tradeNo,
transactionId: transactionId,
};
console.log(payOrderInfo,'支付信息');
if (channel === 'wechat') {
wechatPayOrder(payOrderInfo);

View File

@ -11,10 +11,10 @@
wx:for-index="storeIndex"
wx:key="storeIndex"
>
<view class="store-wrapper">
<!-- <view class="store-wrapper">
<t-icon prefix="wr" size="40rpx" color="#333333" name="store" class="store-logo" />
{{stores.storeName}}
</view>
</view> -->
<view
wx:if="{{orderCardList[storeIndex].goodsList.length > 0}}"
wx:for="{{orderCardList[storeIndex].goodsList}}"
@ -23,13 +23,13 @@
wx:key="id"
class="goods-wrapper"
>
<t-image src="{{goods.thumb}}" t-class="goods-image" mode="aspectFill" />
<image src="{{goods.thumb}}" class="goods-image" mode="aspectFill" />
<view class="goods-content">
<view class="goods-title">{{goods.title}}</view>
<view>{{goods.specs}}</view>
</view>
<view class="goods-right">
<price wr-class="goods-price" price="{{goods.price}}" fill="{{true}}" decimalSmaller />
<price priceUnit="yuan" wr-class="goods-price" price="{{goods.price}}" fill="{{true}}" decimalSmaller />
<view class="goods-num">x{{goods.num}}</view>
</view>
</view>
@ -38,6 +38,7 @@
<view class="pay-item">
<text>商品总额</text>
<price
priceUnit="yuan"
fill
decimalSmaller
wr-class="pay-item__right font-bold"
@ -49,19 +50,19 @@
<view class="pay-item__right font-bold">
<block wx:if="{{settleDetailData.totalDeliveryFee && settleDetailData.totalDeliveryFee != 0}}">
+
<price fill decimalSmaller price="{{settleDetailData.totalDeliveryFee}}" />
<price priceUnit="yuan" fill decimalSmaller price="{{settleDetailData.totalDeliveryFee}}" />
</block>
<text wx:else>免运费</text>
</view>
</view>
<view class="pay-item">
<!-- <view class="pay-item">
<text>活动优惠</text>
<view class="pay-item__right primary font-bold">
-
<price fill price="{{settleDetailData.totalPromotionAmount || 0}}" />
<price priceUnit="yuan" fill price="{{settleDetailData.totalPromotionAmount || 0}}" />
</view>
</view>
<view class="pay-item">
</view> -->
<!-- <view class="pay-item">
<text>优惠券</text>
<view
class="pay-item__right"
@ -70,21 +71,21 @@
>
<block wx:if="{{submitCouponList.length}}">
<block wx:if="{{settleDetailData.totalCouponAmount && settleDetailData.totalCouponAmount !== '0'}}">
-<price fill decimalSmaller price="{{settleDetailData.totalCouponAmount}}" />
-<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}}">
</view> -->
<!-- <view class="pay-item" wx:if="{{settleDetailData.invoiceSupport}}">
<text>发票</text>
<view class="pay-item__right" catchtap="onReceipt">
<text>{{handleInvoice(invoiceData)}}</text>
<t-icon name="chevron-right" size="32rpx" color="#BBBBBB" />
</view>
</view>
</view> -->
<view class="pay-item">
<text>订单备注</text>
<view class="pay-item__right" data-storenoteindex="{{0}}" catchtap="onNotes">
@ -99,12 +100,12 @@
<view class="pay-amount">
<text class="order-num">共{{settleDetailData.totalGoodsCount}}件</text>
<text>小计</text>
<price class="total-price" price="{{settleDetailData.totalPayAmount}}" fill="{{false}}" decimalSmaller />
<price priceUnit="yuan" class="total-price" price="{{settleDetailData.totalPayAmount}}" fill="{{false}}" decimalSmaller />
</view>
</view>
<view class="wx-pay-cover">
<view class="wx-pay">
<price decimalSmaller fill class="price" price="{{settleDetailData.totalPayAmount || '0'}}" />
<price priceUnit="yuan" decimalSmaller fill class="price" price="{{settleDetailData.totalPayAmount || '0'}}" />
<view class="submit-btn {{ settleDetailData.settleType === 1 ? '':'btn-gray'}}" bindtap="submitOrder">
提交订单
</view>

View File

@ -1,7 +1,9 @@
import Dialog from 'tdesign-miniprogram/dialog/index';
import Toast from 'tdesign-miniprogram/toast/index';
import { dispatchCommitPay } from '../../../services/order/orderConfirm';
import {
dispatchCommitPay
} from '../../../services/order/orderConfirm';
// 真实的提交支付
export const commitPay = (params) => {
@ -26,7 +28,12 @@ export const commitPay = (params) => {
};
export const paySuccess = (payOrderInfo) => {
const { payAmt, tradeNo, groupId, promotionId } = payOrderInfo;
const {
payAmt,
tradeNo,
groupId,
promotionId
} = payOrderInfo;
// 支付成功
Toast({
context: this,
@ -50,7 +57,9 @@ export const paySuccess = (payOrderInfo) => {
.map((k) => `${k}=${params[k]}`)
.join('&');
// 跳转支付结果页面
wx.redirectTo({ url: `/pages/order/pay-result/index?${paramsStr}` });
wx.redirectTo({
url: `/pages/order/pay-result/index?${paramsStr}`
});
};
export const payFail = (payOrderInfo, resultMsg) => {
@ -63,7 +72,9 @@ export const payFail = (payOrderInfo, resultMsg) => {
confirmBtn: '放弃',
cancelBtn: '继续付款',
}).then(() => {
wx.redirectTo({ url: '/pages/order/order-list/index' });
wx.redirectTo({
url: '/pages/order/order-list/index'
});
});
} else {
//订单列表页订单详情页取消付款toast提示
@ -83,21 +94,24 @@ export const payFail = (payOrderInfo, resultMsg) => {
duration: 2000,
icon: 'close-circle',
});
setTimeout(() => {
wx.redirectTo({ url: '/pages/order/order-list/index' });
}, 2000);
console.log(resultMsg,'错误信息');
// setTimeout(() => {
// wx.redirectTo({
// url: '/pages/order/order-list/index'
// });
// }, 2000);
}
};
// 微信支付方式
export const wechatPayOrder = (payOrderInfo) => {
// const payInfo = JSON.parse(payOrderInfo.payInfo);
// const { timeStamp, nonceStr, signType, paySign } = payInfo;
const payInfo = JSON.parse(payOrderInfo.payInfo);
const { timeStamp, nonceStr, signType, paySign } = payInfo;
return new Promise((resolve) => {
// demo 中直接走支付成功
paySuccess(payOrderInfo);
resolve();
/* wx.requestPayment({
// paySuccess(payOrderInfo);
// resolve();
wx.requestPayment({
timeStamp,
nonceStr,
package: payInfo.package,
@ -110,6 +124,6 @@ export const wechatPayOrder = (payOrderInfo) => {
fail: function (err) {
payFail(payOrderInfo, err.errMsg);
},
}); */
});
});
};

View File

@ -16,10 +16,10 @@ export const getAddressPromise = () => {
/** 用户选择了一个地址 */
export const resolveAddress = (allAddress,address) => {
allAddress.forEach(({ resolver }) => resolver(address));
addressPromise.forEach(({ resolver }) => resolver(address));
};
/** 用户没有选择任何地址只是返回上一页了 */
export const rejectAddress = (allAddress) => {
allAddress.forEach(({ rejecter }) => rejecter(new Error('cancel')));
addressPromise.forEach(({ rejecter }) => rejecter(new Error('cancel')));
};

View File

@ -1,5 +1,5 @@
{
"description": "项目配置文件,详见文档:https://developers.weixin.qq.com/miniprogram/dev/devtools/projectconfig.html",
"description": "Project configuration file, more information: https://developers.weixin.qq.com/miniprogram/dev/devtools/projectconfig.html",
"packOptions": {
"ignore": [],
"include": []