Commit 4621e78b authored by 王炽's avatar 王炽

Merge branch 'dev' of http://gitlab2.dui88.com/fh/20250528_FHQ1 into dev

parents 2986933c f434f37a
......@@ -100,7 +100,7 @@ export default {
// 跳转到首页
uni.reLaunch({
url: '/pages/index/index?pageType=home'
url: '/pages/index/index'
});
} else {
uni.showToast({
......
......@@ -148,13 +148,13 @@
</template>
<script>
import { fetchTradeCredits } from '@/api/goods.js';
import { fetchTradeCredits, fetchSeckillTakeOrder } from '@/api/goods.js';
import { getAddressList } from '@/api/address.js';
import { useHomeStore } from '@/stores/home';
import { jump, JumpType } from '../../utils';
export default {
data() {
data() {
return {
orderNotes: '',
// 订单来源子渠道
......@@ -182,7 +182,14 @@ export default {
showAddressModal: false,
showSelectAddressModal: false,
// 用于防连点
isSubmitting: false
isSubmitting: false,
// 秒杀相关参数
isSeckill: false,
seckillParams: {
activityId: '', // 活动ID
sessionKey: '', // 会话密钥
appGoodsId: '' // 应用商品ID
}
}
},
onLoad(options) {
......@@ -250,6 +257,19 @@ export default {
parsePageParams(options) {
console.log('结算页面接收到的参数:', options);
// 判断是否为秒杀
this.isSeckill = !!(options.isSeckill === 'true' || options.isSeckill === true || options.activityId);
// 解析秒杀参数
if (this.isSeckill) {
this.seckillParams = {
activityId: options.activityId || '',
sessionKey: options.sessionKey || '',
appGoodsId: options.appGoodsId || options.gid || ''
};
console.log('秒杀参数:', this.seckillParams);
}
// 基础订单参数
this.orderParams = {
gid: options.gid || '',
......@@ -264,7 +284,7 @@ export default {
projectId: options.projectId || ''
};
// 解析价格数据
// 解析价格数据(秒杀商品可能没有价格数据)
if (options.priceData) {
try {
this.priceData = JSON.parse(decodeURIComponent(options.priceData));
......@@ -285,6 +305,7 @@ export default {
};
console.log('解析后的商品信息:', this.goodsInfo);
console.log('是否为秒杀:', this.isSeckill);
},
// 检查收货地址
......@@ -462,9 +483,33 @@ export default {
title: '下单中...'
});
console.log('下单参数:', this.orderParams);
const response = await fetchTradeCredits(this.orderParams);
console.log('下单结果:', response);
let response;
if (this.isSeckill) {
// 秒杀商品:调用秒杀下单接口
const seckillOrderParams = {
id: this.seckillParams.activityId,
appGoodsId: this.seckillParams.appGoodsId || this.orderParams.gid,
sessionKey: this.seckillParams.sessionKey,
orderSubSource: this.orderSubSource,
addressId: this.orderParams.addressId || '',
buyNum: this.orderParams.buy_num || 1
};
// 添加备注(如果有)
if (this.orderParams.remark) {
seckillOrderParams.remark = this.orderParams.remark;
}
console.log('秒杀下单参数:', seckillOrderParams);
response = await fetchSeckillTakeOrder(seckillOrderParams);
console.log('秒杀下单结果:', response);
} else {
// 普通商品:调用普通下单接口
console.log('普通下单参数:', this.orderParams);
response = await fetchTradeCredits(this.orderParams);
console.log('普通下单结果:', response);
}
uni.hideLoading();
......@@ -473,7 +518,7 @@ export default {
this.navigateToPayResult(true, response.data);
} else {
// 下单失败
this.navigateToPayResult(false, null, response.msg);
this.navigateToPayResult(false, null, response.msg || response.message);
}
} catch (error) {
console.error('下单失败:', error);
......@@ -514,14 +559,20 @@ export default {
quantity: this.goodsInfo.quantity,
// 价格数据
priceData: JSON.stringify(this.priceData),
priceData: this.priceData ? JSON.stringify(this.priceData) : '',
// 订单参数
gid: this.orderParams.gid,
skuld: this.orderParams.skuld,
buy_num: this.orderParams.buy_num,
// 订单来源子渠道
orderSubSource: this.orderSubSource
orderSubSource: this.orderSubSource,
// 秒杀相关参数
isSeckill: this.isSeckill,
activityId: this.seckillParams.activityId || '',
sessionKey: this.seckillParams.sessionKey || '',
appGoodsId: this.seckillParams.appGoodsId || ''
};
if (!isSuccess) {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment