fixed 修改订单提交参数
This commit is contained in:
parent
cab6ac91e2
commit
f8b6610566
@ -1,8 +1,17 @@
|
||||
import Toast from 'tdesign-miniprogram/toast/index';
|
||||
import { fetchSettleDetail } from '~/services/order/orderConfirm';
|
||||
import { getGoodsFreight } from '~/services/order/getGoodsFreight';
|
||||
import { commitPay, wechatPayOrder } from './pay';
|
||||
import { getAddressPromise } from '../../usercenter/address/list/util';
|
||||
import {
|
||||
fetchSettleDetail
|
||||
} from '~/services/order/orderConfirm';
|
||||
import {
|
||||
getGoodsFreight
|
||||
} from '~/services/order/getGoodsFreight';
|
||||
import {
|
||||
commitPay,
|
||||
wechatPayOrder
|
||||
} from './pay';
|
||||
import {
|
||||
getAddressPromise
|
||||
} from '../../usercenter/address/list/util';
|
||||
|
||||
const stripeImg = `https://cdn-we-retail.ym.tencent.com/miniapp/order/stripe.png`;
|
||||
|
||||
@ -68,13 +77,21 @@ Page({
|
||||
this.setData({
|
||||
loading: true,
|
||||
});
|
||||
const { goodsRequestList } = this;
|
||||
this.handleOptionsParams({ goodsRequestList });
|
||||
const {
|
||||
goodsRequestList
|
||||
} = this;
|
||||
this.handleOptionsParams({
|
||||
goodsRequestList
|
||||
});
|
||||
},
|
||||
// 处理不同情况下跳转到结算页时需要的参数
|
||||
async handleOptionsParams(options, couponList) {
|
||||
let { goodsRequestList } = this; // 商品列表
|
||||
let { userAddressReq } = this; // 收货地址
|
||||
let {
|
||||
goodsRequestList
|
||||
} = this; // 商品列表
|
||||
let {
|
||||
userAddressReq
|
||||
} = this; // 收货地址
|
||||
|
||||
const storeInfoList = []; // 门店列表
|
||||
// 如果是从地址选择页面返回,则使用地址显选择页面新选择的地址去获取结算数据
|
||||
@ -85,7 +102,7 @@ Page({
|
||||
// 从购物车跳转过来时,获取传入的商品列表数据
|
||||
const goodsRequestListJson = wx.getStorageSync('order.goodsRequestList');
|
||||
goodsRequestList = JSON.parse(goodsRequestListJson);
|
||||
console.log(goodsRequestList,'数据看看');
|
||||
console.log(goodsRequestList, '数据看看');
|
||||
} else if (typeof options.goodsRequestList === 'string') {
|
||||
goodsRequestList = JSON.parse(options.goodsRequestList);
|
||||
}
|
||||
@ -109,20 +126,20 @@ Page({
|
||||
couponList,
|
||||
};
|
||||
|
||||
if(userAddressReq){
|
||||
if (userAddressReq) {
|
||||
// 计算运费接口
|
||||
console.log(goodsRequestList,'看看看看')
|
||||
console.log(userAddressReq.customerAddressGuid,'看看看看地址')
|
||||
let data = {
|
||||
console.log(goodsRequestList, '看看看看')
|
||||
console.log(userAddressReq.customerAddressGuid, '看看看看地址')
|
||||
let data = {
|
||||
GoodsRequestList: goodsRequestList,
|
||||
CustomerAddressGuid: userAddressReq.customerAddressGuid
|
||||
}
|
||||
await getGoodsFreight(data).then((res) => {
|
||||
params.totalDeliveryFee = res.data
|
||||
console.log(this.data.settleDetailData,'运费');
|
||||
console.log(this.data.settleDetailData, '运费');
|
||||
})
|
||||
}
|
||||
console.log(params,'计算参数');
|
||||
console.log(params, '计算参数');
|
||||
fetchSettleDetail(params).then(
|
||||
(res) => {
|
||||
this.setData({
|
||||
@ -142,9 +159,13 @@ Page({
|
||||
this.userAddressReq = resData.userAddress;
|
||||
|
||||
if (resData.userAddress) {
|
||||
this.setData({ userAddress: resData.userAddress });
|
||||
this.setData({
|
||||
userAddress: resData.userAddress
|
||||
});
|
||||
}
|
||||
this.setData({ settleDetailData: data });
|
||||
this.setData({
|
||||
settleDetailData: data
|
||||
});
|
||||
this.isInvalidOrder(data);
|
||||
},
|
||||
|
||||
@ -156,10 +177,14 @@ Page({
|
||||
data.abnormalDeliveryGoodsList.length > 0) ||
|
||||
(data.inValidGoodsList && data.inValidGoodsList.length > 0)
|
||||
) {
|
||||
this.setData({ popupShow: true });
|
||||
this.setData({
|
||||
popupShow: true
|
||||
});
|
||||
return true;
|
||||
}
|
||||
this.setData({ popupShow: false });
|
||||
this.setData({
|
||||
popupShow: false
|
||||
});
|
||||
if (data.settleType === 0) {
|
||||
return true;
|
||||
}
|
||||
@ -186,7 +211,9 @@ Page({
|
||||
const filterStoreGoodsList = [];
|
||||
storeGoodsList &&
|
||||
storeGoodsList.forEach((store) => {
|
||||
const { storeName } = store;
|
||||
const {
|
||||
storeName
|
||||
} = store;
|
||||
store.skuDetailVos &&
|
||||
store.skuDetailVos.forEach((goods) => {
|
||||
const data = goods;
|
||||
@ -246,7 +273,9 @@ Page({
|
||||
specs: item.skuSpecLst?.map((s) => s.specValue), // 规格列表 string[]
|
||||
price: item.tagPrice || item.settlePrice || '0', // 优先取限时活动价
|
||||
settlePrice: item.settlePrice,
|
||||
titlePrefixTags: item.tagText ? [{ text: item.tagText }] : [],
|
||||
titlePrefixTags: item.tagText ? [{
|
||||
text: item.tagText
|
||||
}] : [],
|
||||
num: item.quantity,
|
||||
skuId: item.skuId,
|
||||
spuId: item.spuId,
|
||||
@ -269,10 +298,14 @@ Page({
|
||||
orderCardList.push(orderCard);
|
||||
});
|
||||
|
||||
|
||||
|
||||
|
||||
this.setData({ orderCardList, storeInfoList, submitCouponList });
|
||||
|
||||
this.setData({
|
||||
orderCardList,
|
||||
storeInfoList,
|
||||
submitCouponList
|
||||
});
|
||||
return data;
|
||||
},
|
||||
onGotoAddress() {
|
||||
@ -280,12 +313,17 @@ Page({
|
||||
getAddressPromise()
|
||||
.then((address) => {
|
||||
this.handleOptionsParams({
|
||||
userAddressReq: { ...address, checked: true },
|
||||
userAddressReq: {
|
||||
...address,
|
||||
checked: true
|
||||
},
|
||||
});
|
||||
})
|
||||
.catch(() => {});
|
||||
|
||||
const { userAddressReq } = this; // 收货地址
|
||||
const {
|
||||
userAddressReq
|
||||
} = this; // 收货地址
|
||||
|
||||
let id = '';
|
||||
|
||||
@ -298,7 +336,9 @@ Page({
|
||||
});
|
||||
},
|
||||
onNotes(e) {
|
||||
const { storenoteindex: storeNoteIndex } = e.currentTarget.dataset;
|
||||
const {
|
||||
storenoteindex: storeNoteIndex
|
||||
} = e.currentTarget.dataset;
|
||||
// 添加备注信息
|
||||
this.setData({
|
||||
dialogShow: true,
|
||||
@ -306,7 +346,9 @@ Page({
|
||||
});
|
||||
},
|
||||
onInput(e) {
|
||||
const { storeNoteIndex } = this.data;
|
||||
const {
|
||||
storeNoteIndex
|
||||
} = this.data;
|
||||
this.noteInfo[storeNoteIndex] = e.detail.value;
|
||||
},
|
||||
onBlur() {
|
||||
@ -326,7 +368,10 @@ Page({
|
||||
},
|
||||
onNoteConfirm() {
|
||||
// 备注信息 确认按钮
|
||||
const { storeInfoList, storeNoteIndex } = this.data;
|
||||
const {
|
||||
storeInfoList,
|
||||
storeNoteIndex
|
||||
} = this.data;
|
||||
this.tempNoteInfo[storeNoteIndex] = this.noteInfo[storeNoteIndex];
|
||||
storeInfoList[storeNoteIndex].remark = this.noteInfo[storeNoteIndex];
|
||||
|
||||
@ -337,7 +382,9 @@ Page({
|
||||
},
|
||||
onNoteCancel() {
|
||||
// 备注信息 取消按钮
|
||||
const { storeNoteIndex } = this.data;
|
||||
const {
|
||||
storeNoteIndex
|
||||
} = this.data;
|
||||
this.noteInfo[storeNoteIndex] = this.tempNoteInfo[storeNoteIndex];
|
||||
this.setData({
|
||||
dialogShow: false,
|
||||
@ -346,9 +393,15 @@ Page({
|
||||
|
||||
onSureCommit() {
|
||||
// 商品库存不足继续结算
|
||||
const { settleDetailData } = this.data;
|
||||
const { outOfStockGoodsList, storeGoodsList, inValidGoodsList } =
|
||||
settleDetailData;
|
||||
const {
|
||||
settleDetailData
|
||||
} = this.data;
|
||||
const {
|
||||
outOfStockGoodsList,
|
||||
storeGoodsList,
|
||||
inValidGoodsList
|
||||
} =
|
||||
settleDetailData;
|
||||
if (
|
||||
(outOfStockGoodsList && outOfStockGoodsList.length > 0) ||
|
||||
(inValidGoodsList && storeGoodsList)
|
||||
@ -358,7 +411,9 @@ Page({
|
||||
const filterOutGoodsList = [];
|
||||
outOfStockGoodsList &&
|
||||
outOfStockGoodsList.forEach((outOfStockGoods) => {
|
||||
const { storeName } = outOfStockGoods;
|
||||
const {
|
||||
storeName
|
||||
} = outOfStockGoods;
|
||||
outOfStockGoods.unSettlementGoods.forEach((ele) => {
|
||||
const data = ele;
|
||||
data.quantity = ele.reminderStock;
|
||||
@ -368,7 +423,9 @@ Page({
|
||||
});
|
||||
const filterStoreGoodsList = this.getRequestGoodsList(storeGoodsList);
|
||||
const goodsRequestList = filterOutGoodsList.concat(filterStoreGoodsList);
|
||||
this.handleOptionsParams({ goodsRequestList });
|
||||
this.handleOptionsParams({
|
||||
goodsRequestList
|
||||
});
|
||||
}
|
||||
},
|
||||
// 提交订单
|
||||
@ -380,7 +437,9 @@ Page({
|
||||
storeInfoList,
|
||||
submitCouponList,
|
||||
} = this.data;
|
||||
const { goodsRequestList } = this;
|
||||
const {
|
||||
goodsRequestList
|
||||
} = this;
|
||||
|
||||
if (!userAddressReq && !settleDetailData.userAddress) {
|
||||
Toast({
|
||||
@ -403,7 +462,7 @@ Page({
|
||||
// this.payLock = true;
|
||||
const resSubmitCouponList = this.handleCouponList(submitCouponList);
|
||||
const openId = wx.getStorageSync('openId')
|
||||
console.log(openId,'我的openId');
|
||||
console.log(openId, '我的openId');
|
||||
const params = {
|
||||
userAddressReq: settleDetailData.userAddress || userAddressReq,
|
||||
goodsRequestList: goodsRequestList,
|
||||
@ -412,18 +471,21 @@ Page({
|
||||
invoiceRequest: null,
|
||||
storeInfoList,
|
||||
couponList: resSubmitCouponList,
|
||||
openId: openId
|
||||
openId: openId,
|
||||
customerAddressGuid: settleDetailData.userAddress.customerAddressGuid
|
||||
};
|
||||
if (invoiceData && invoiceData.email) {
|
||||
params.invoiceRequest = invoiceData;
|
||||
}
|
||||
console.log(params,'下单参数!');
|
||||
/** 提交订单方法(接口) */
|
||||
console.log(params, '下单参数!');
|
||||
/** 提交订单方法(接口) */
|
||||
commitPay(params).then(
|
||||
(res) => {
|
||||
this.payLock = false;
|
||||
const { data } = res;
|
||||
console.log(res,'后端接口返回调起微信支付的参数');
|
||||
const {
|
||||
data
|
||||
} = res;
|
||||
console.log(res, '后端接口返回调起微信支付的参数');
|
||||
// 提交出现 失效 不在配送范围 限购的商品 提示弹窗
|
||||
if (this.isInvalidOrder(data)) {
|
||||
return;
|
||||
@ -468,19 +530,22 @@ Page({
|
||||
icon: 'close-circle',
|
||||
});
|
||||
setTimeout(() => {
|
||||
wx.redirectTo({ url: '/order/list' });
|
||||
wx.redirectTo({
|
||||
url: '/order/list'
|
||||
});
|
||||
});
|
||||
} else if (err.code === 'ILLEGAL_CONFIG_PARAM') {
|
||||
Toast({
|
||||
context: this,
|
||||
selector: '#t-toast',
|
||||
message:
|
||||
'支付失败,微信支付商户号设置有误,请商家重新检查支付设置。',
|
||||
message: '支付失败,微信支付商户号设置有误,请商家重新检查支付设置。',
|
||||
duration: 2000,
|
||||
icon: 'close-circle',
|
||||
});
|
||||
setTimeout(() => {
|
||||
wx.redirectTo({ url: '/order/list' });
|
||||
wx.redirectTo({
|
||||
url: '/order/list'
|
||||
});
|
||||
});
|
||||
} else {
|
||||
Toast({
|
||||
@ -501,8 +566,17 @@ Page({
|
||||
|
||||
// 处理支付
|
||||
handlePay(data, settleDetailData) {
|
||||
const { channel, jsApiUiPackage, outTradeNo, interactId, transactionId } = data;
|
||||
const { totalAmount, totalPayAmount } = settleDetailData;
|
||||
const {
|
||||
channel,
|
||||
jsApiUiPackage,
|
||||
outTradeNo,
|
||||
interactId,
|
||||
transactionId
|
||||
} = data;
|
||||
const {
|
||||
totalAmount,
|
||||
totalPayAmount
|
||||
} = settleDetailData;
|
||||
const payOrderInfo = {
|
||||
payInfo: jsApiUiPackage,
|
||||
orderId: outTradeNo,
|
||||
@ -512,10 +586,10 @@ Page({
|
||||
tradeNo: outTradeNo,
|
||||
transactionId: transactionId,
|
||||
};
|
||||
console.log(payOrderInfo,'支付信息');
|
||||
console.log(payOrderInfo, '支付信息');
|
||||
|
||||
// if (channel === 'wechat') {
|
||||
wechatPayOrder(payOrderInfo);
|
||||
wechatPayOrder(payOrderInfo);
|
||||
// }
|
||||
},
|
||||
|
||||
@ -536,24 +610,36 @@ Page({
|
||||
},
|
||||
|
||||
onCoupons(e) {
|
||||
const { submitCouponList, currentStoreId } = this.data;
|
||||
const { goodsRequestList } = this;
|
||||
const { selectedList } = e.detail;
|
||||
const {
|
||||
submitCouponList,
|
||||
currentStoreId
|
||||
} = this.data;
|
||||
const {
|
||||
goodsRequestList
|
||||
} = this;
|
||||
const {
|
||||
selectedList
|
||||
} = e.detail;
|
||||
const tempSubmitCouponList = submitCouponList.map((storeCoupon) => {
|
||||
return {
|
||||
couponList:
|
||||
storeCoupon.storeId === currentStoreId
|
||||
? selectedList
|
||||
: storeCoupon.couponList,
|
||||
couponList: storeCoupon.storeId === currentStoreId ?
|
||||
selectedList :
|
||||
storeCoupon.couponList,
|
||||
};
|
||||
});
|
||||
const resSubmitCouponList = this.handleCouponList(tempSubmitCouponList);
|
||||
//确定选择优惠券
|
||||
this.handleOptionsParams({ goodsRequestList }, resSubmitCouponList);
|
||||
this.setData({ couponsShow: false });
|
||||
this.handleOptionsParams({
|
||||
goodsRequestList
|
||||
}, resSubmitCouponList);
|
||||
this.setData({
|
||||
couponsShow: false
|
||||
});
|
||||
},
|
||||
onOpenCoupons(e) {
|
||||
const { storeid } = e.currentTarget.dataset;
|
||||
const {
|
||||
storeid
|
||||
} = e.currentTarget.dataset;
|
||||
this.setData({
|
||||
couponsShow: true,
|
||||
currentStoreId: storeid,
|
||||
@ -572,23 +658,36 @@ Page({
|
||||
|
||||
onGoodsNumChange(e) {
|
||||
const {
|
||||
detail: { value },
|
||||
detail: {
|
||||
value
|
||||
},
|
||||
currentTarget: {
|
||||
dataset: { goods },
|
||||
dataset: {
|
||||
goods
|
||||
},
|
||||
},
|
||||
} = e;
|
||||
const index = this.goodsRequestList.findIndex(
|
||||
({ storeId, spuId, skuId }) =>
|
||||
goods.storeId === storeId &&
|
||||
goods.spuId === spuId &&
|
||||
goods.skuId === skuId,
|
||||
({
|
||||
storeId,
|
||||
spuId,
|
||||
skuId
|
||||
}) =>
|
||||
goods.storeId === storeId &&
|
||||
goods.spuId === spuId &&
|
||||
goods.skuId === skuId,
|
||||
);
|
||||
if (index >= 0) {
|
||||
// eslint-disable-next-line no-confusing-arrow
|
||||
const goodsRequestList = this.goodsRequestList.map((item, i) =>
|
||||
i === index ? { ...item, quantity: value } : item,
|
||||
i === index ? {
|
||||
...item,
|
||||
quantity: value
|
||||
} : item,
|
||||
);
|
||||
this.handleOptionsParams({ goodsRequestList });
|
||||
this.handleOptionsParams({
|
||||
goodsRequestList
|
||||
});
|
||||
}
|
||||
},
|
||||
|
||||
@ -597,4 +696,4 @@ Page({
|
||||
popupShow: !this.data.popupShow,
|
||||
});
|
||||
},
|
||||
});
|
||||
});
|
@ -25,6 +25,7 @@ export const commitPay = (params) => {
|
||||
couponList: params.couponList,
|
||||
groupInfo: params.groupInfo,
|
||||
openId: params.openId, // openId
|
||||
customerAddressGuid: params.customerAddressGuid, // openId
|
||||
});
|
||||
};
|
||||
|
||||
|
@ -10,7 +10,7 @@
|
||||
|
||||
|
||||
<view class="content-wrapper">
|
||||
<button type="primary" bind:tap="getOpenIdFun">获取OpenID</button>
|
||||
<!-- <button type="primary" bind:tap="getOpenIdFun">获取OpenID</button> -->
|
||||
<view class="order-group-wrapper">
|
||||
<t-order-group orderTagInfos="{{orderTagInfos}}" bind:onClickTop="jumpAllOrder" bind:onClickItem="jumpNav" />
|
||||
</view>
|
||||
|
Loading…
Reference in New Issue
Block a user