feat: 新增拼团
This commit is contained in:
@@ -60,7 +60,7 @@
|
||||
<view class="content_right_total">
|
||||
<view>¥<text style="font-size: 36rpx">{{
|
||||
pItem.totalPrice
|
||||
}}</text></view>
|
||||
}}</text></view>
|
||||
<view>每件到手价¥{{ pItem.unitPrice }}</view>
|
||||
</view>
|
||||
<view class="shopping_info_quantity">
|
||||
@@ -84,7 +84,7 @@
|
||||
<view class="content_right_total">
|
||||
<view>¥<text style="font-size: 36rpx">{{
|
||||
pItem.totalPrice
|
||||
}}</text></view>
|
||||
}}</text></view>
|
||||
<view>每件到手价¥{{ pItem.unitPrice }}</view>
|
||||
</view>
|
||||
<view class="shopping_info_quantity">
|
||||
@@ -108,7 +108,7 @@
|
||||
<view class="order_freight_item">
|
||||
<view>运费<text style="color: #c0c3c6; margin-left: 20rpx">{{
|
||||
getValue(PRODUCT_DELIVERY_TIME, addItem.deliveryTime)
|
||||
}}</text></view>
|
||||
}}</text></view>
|
||||
<view class="value_">
|
||||
{{ orderInfo.postage ? "¥" + orderInfo.postage : "包邮" }}
|
||||
</view>
|
||||
@@ -351,7 +351,8 @@ import {
|
||||
settle,
|
||||
settlementOrder,
|
||||
updateGoodsNum,
|
||||
setSeckillOrder
|
||||
setSeckillOrder,
|
||||
setGroupBuyOrder
|
||||
} from "@/api/cart.js";
|
||||
import { getSupportPay } from "@/api/order.js";
|
||||
import { assembleAddress } from "@/utils/index.js";
|
||||
@@ -365,6 +366,7 @@ import {
|
||||
} from "@/utils/payUtils.js";
|
||||
|
||||
import CryptoJS from "crypto-js";
|
||||
import Decimal from "decimal.js";
|
||||
import CouponDialog from "./coupon-dialog.vue";
|
||||
|
||||
export default {
|
||||
@@ -478,6 +480,16 @@ export default {
|
||||
this.sed = JSON.parse(option.sed);
|
||||
this.leftPathType = "navigateTo";
|
||||
this.leftPath = null;
|
||||
if (this.sed?.activedType == 'groupBuy') {
|
||||
const goodsId = this.sed.goodsId || this.sed.id;
|
||||
const activityId = this.sed.activityId || 1;
|
||||
let path = `/pages/other_package/productInfo/productInfo?id=${goodsId}&activedType=groupBuy&activityId=${activityId}`;
|
||||
if (this.sed.teamId) {
|
||||
path += `&teamId=${this.sed.teamId}`;
|
||||
}
|
||||
this.leftPath = path;
|
||||
}
|
||||
|
||||
await this.addressList();
|
||||
// console.log('addressListOne',this.addressListOne)
|
||||
// if(this.addressListOne && this.addressListOne.length){
|
||||
@@ -497,15 +509,36 @@ export default {
|
||||
if (addressShowPop && addressShowPop !== "null") {
|
||||
this.addressShow = addressShowPop;
|
||||
}
|
||||
// 支付弹框
|
||||
// const payOpen = option.payOpen;
|
||||
// if (payOpen && payOpen !== "null") {
|
||||
// this.getWayOption();
|
||||
// this.wayShow = payOpen;
|
||||
// }
|
||||
|
||||
this.getWayOption();
|
||||
this.getUserInfo();
|
||||
},
|
||||
onBackPress(options) {
|
||||
if (this.sed?.activedType == 'groupBuy') {
|
||||
const goodsId = this.sed.goodsId || this.sed.id;
|
||||
const activityId = this.sed.activityId || 1;
|
||||
let path = `/pages/other_package/productInfo/productInfo?id=${goodsId}&activedType=groupBuy&activityId=${activityId}`;
|
||||
if (this.sed.teamId) {
|
||||
path += `&teamId=${this.sed.teamId}`;
|
||||
}
|
||||
const pages = getCurrentPages();
|
||||
if (pages && pages.length > 1) {
|
||||
const prevPage = pages[pages.length - 2];
|
||||
const route = prevPage ? (prevPage.route || (prevPage.$page && prevPage.$page.route)) : '';
|
||||
if (route && path.includes(route)) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
uni.redirectTo({
|
||||
url: path,
|
||||
fail: () => {
|
||||
uni.navigateTo({ url: path });
|
||||
}
|
||||
});
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
},
|
||||
mounted() { },
|
||||
methods: {
|
||||
getValue,
|
||||
@@ -727,15 +760,30 @@ export default {
|
||||
params.activityId = Number(this.sed?.activityId);
|
||||
params.activityType = "seckill";
|
||||
}
|
||||
|
||||
if (this.sed?.activedType === "groupBuy") {
|
||||
params.activityId = Number(this.sed?.activityId);
|
||||
params.type = 5
|
||||
}
|
||||
const resp = await getGoodsDetail(params);
|
||||
if (resp && resp.bizcode === 100) {
|
||||
const data = resp.data;
|
||||
this.isPoints = data.type == 3 ? 1 : 0;
|
||||
console.log("秦星星data", data);
|
||||
console.log("秦星星data", data, this.sed);
|
||||
|
||||
const goodsNum = this.sed?.goodsNum || 1;
|
||||
const unitPrice =
|
||||
this.sed?.activedType == "seckill"
|
||||
? (data.activity?.activityPrice ?? 0)
|
||||
: (this.sed?.specsId?.price ?? 0);
|
||||
const amount = new Decimal(goodsNum).times(new Decimal(unitPrice || 0)).toFixed(2);
|
||||
|
||||
this.orderInfo = {
|
||||
address: null,
|
||||
amount: this.sed?.activedType == "seckill" ? data.activity?.activityPrice : this.sed.goodsNum * this.sed.specsId.price || 0,
|
||||
amount: amount,
|
||||
postage: 0,
|
||||
expendNum: data.expendNum,
|
||||
groupPrice: data.groupPrice, //拼团标识
|
||||
shops: [
|
||||
{
|
||||
addrTimes: [
|
||||
@@ -756,13 +804,13 @@ export default {
|
||||
id: this.sed.specsId.id,
|
||||
img: data.goodsGraph.split(",")[0],
|
||||
name: null,
|
||||
num: this.sed.goodsNum,
|
||||
num: goodsNum,
|
||||
phone: null,
|
||||
provinceName: null,
|
||||
specs: this.sed.specsId.combNames,
|
||||
title: data.name,
|
||||
totalPrice: this.sed.goodsNum * this.sed.specsId.price,
|
||||
unitPrice: this.sed.specsId.price,
|
||||
totalPrice: amount,
|
||||
unitPrice: unitPrice,
|
||||
},
|
||||
],
|
||||
},
|
||||
@@ -777,6 +825,7 @@ export default {
|
||||
"this.defaultAddress",
|
||||
this.defaultAddress,
|
||||
this.addressListOne,
|
||||
this.orderInfo
|
||||
);
|
||||
if (
|
||||
this.defaultAddress &&
|
||||
@@ -805,28 +854,7 @@ export default {
|
||||
if (!this.isCoupon && this.sed?.activedType !== "seckill") {
|
||||
await this.refreshDirectSettle();
|
||||
}
|
||||
// if(this.addressListOne && this.addressListOne.length){
|
||||
// this.orderInfo.address = this.addressListOne[0];
|
||||
// }
|
||||
}
|
||||
// const params = {
|
||||
// cartIds: ids,
|
||||
// }
|
||||
// const resp = await getSettleList(params);
|
||||
// if (resp && resp.bizcode === 100) {
|
||||
// const data = resp.data;
|
||||
// const shops = data.shops;
|
||||
// if (shops && shops.length !== 0) {
|
||||
// shops.map(item => {
|
||||
// item.addrTimes.map(addItem => {
|
||||
// addItem.remark = null;
|
||||
// })
|
||||
// })
|
||||
// }
|
||||
// data.shops = shops;
|
||||
// data.paymentMethod = null;// 支付方式
|
||||
// this.orderInfo = data;
|
||||
// }
|
||||
},
|
||||
/**
|
||||
* 数量进行增加删除
|
||||
@@ -1028,10 +1056,8 @@ export default {
|
||||
// #endif
|
||||
}
|
||||
|
||||
console.log("收货地址ID--params", params);
|
||||
|
||||
let resp = null;
|
||||
console.log("orderInfo--22--", this.sed, this.orderInfo);
|
||||
console.log("收货地址ID--params", params, this.sed, this.orderInfo);
|
||||
if (this.sed) {
|
||||
if (
|
||||
this.orderInfo.paymentMethod == "balance" ||
|
||||
@@ -1044,11 +1070,12 @@ export default {
|
||||
params["specsId"] = this.sed.specsId.id;
|
||||
params["goodsNum"] = this.orderInfo.shops[0].addrTimes[0].goods[0].num;
|
||||
|
||||
|
||||
console.log("秦星星params-----", this.sed?.activedType);
|
||||
if (this.sed?.activedType == "seckill") {
|
||||
params["activityId"] = Number(this.sed?.activityId); // 秒杀活动ID
|
||||
resp = await setSeckillOrder(params);
|
||||
} else if (this.orderInfo.groupPrice && this.sed?.activedType == 'groupBuy') {
|
||||
params["activityId"] = Number(this.sed?.activityId); // 秒杀活动ID
|
||||
resp = await setGroupBuyOrder(params);
|
||||
} else {
|
||||
if (this.isCoupon) {
|
||||
params.payway2 = "vcoin";
|
||||
@@ -1095,22 +1122,37 @@ export default {
|
||||
}
|
||||
|
||||
if (resp && resp.bizcode === 100) {
|
||||
console.log("提交订单成功", resp.data);
|
||||
const item = resp.data;
|
||||
console.log("提交订单成功", resp.data, resp.data.teamId);
|
||||
const isGroupBuy = Boolean(
|
||||
this.orderInfo.groupPrice && this.sed?.activedType == "groupBuy"
|
||||
);
|
||||
const item = isGroupBuy ? resp.data?.payment : resp.data;
|
||||
|
||||
const groupDetailUrl = isGroupBuy
|
||||
? `/pages/active/group-detail/group-detail?teamId=${resp.data.teamId}`
|
||||
: null;
|
||||
|
||||
if (item.status === 1) {
|
||||
if (isGroupBuy) {
|
||||
uni.redirectTo({
|
||||
url: groupDetailUrl,
|
||||
});
|
||||
return;
|
||||
}
|
||||
jumpWayOk();
|
||||
return;
|
||||
}
|
||||
if (item.douyin) {
|
||||
if (groupDetailUrl) item.customSuccessUrl = groupDetailUrl;
|
||||
await appDypayFun(item);
|
||||
} else if (item.wechat && Object.keys(item.wechat).length !== 0) {
|
||||
this.appWxpay(item.wechat, item.orderId, item.orderNum, item);
|
||||
this.appWxpay(item.wechat, item.orderId, item.orderNum, item, groupDetailUrl);
|
||||
} else if (
|
||||
item.alipay &&
|
||||
Object.keys(item.alipay).length !== 0 &&
|
||||
item.alipay
|
||||
) {
|
||||
this.zfbPay(item.alipay, item.orderId, item.orderNum, item);
|
||||
this.zfbPay(item.alipay, item.orderId, item.orderNum, item, groupDetailUrl);
|
||||
} else {
|
||||
this.$refs.uToastRef.show({
|
||||
type: "error",
|
||||
@@ -1128,9 +1170,9 @@ export default {
|
||||
} finally { this._paySubmitting = false; }
|
||||
},
|
||||
// app 微信支付
|
||||
async appWxpay(alipay, orderId, orderNum, item) {
|
||||
async appWxpay(alipay, orderId, orderNum, item, customSuccessUrl) {
|
||||
try {
|
||||
const result = await appWxpayFun(alipay, orderId, orderNum, item);
|
||||
const result = await appWxpayFun(alipay, orderId, orderNum, customSuccessUrl);
|
||||
console.log("支付成功", result);
|
||||
// 处理支付成功后的逻辑,如更新订单状态等
|
||||
} catch (error) {
|
||||
@@ -1139,9 +1181,9 @@ export default {
|
||||
}
|
||||
},
|
||||
// 支付宝支付
|
||||
async zfbPay(alipay, orderId, orderNum, item) {
|
||||
async zfbPay(alipay, orderId, orderNum, item, customSuccessUrl) {
|
||||
try {
|
||||
const result = await zfbPayFun(alipay, orderId, orderNum, item);
|
||||
const result = await zfbPayFun(alipay, orderId, orderNum, customSuccessUrl);
|
||||
console.log("支付成功", result);
|
||||
// 处理支付成功后的逻辑,如更新订单状态等
|
||||
} catch (error) {
|
||||
@@ -1227,7 +1269,7 @@ export default {
|
||||
this.selectedCoupon = coupon;
|
||||
},
|
||||
async refreshDirectSettle(couponUserId) {
|
||||
if (!this.sed || !this.sed.specsId) return false;
|
||||
if (!this.sed || !this.sed.specsId || !couponUserId) return false;
|
||||
const resp = await getDirectSettleList({
|
||||
goodsId: this.sed.id,
|
||||
specsId: this.sed.specsId.id,
|
||||
|
||||
Reference in New Issue
Block a user