This commit is contained in:
2026-04-04 18:09:09 +08:00
parent 46bbce84aa
commit 3b8c991e1a
6 changed files with 98 additions and 29 deletions

View File

@ -321,24 +321,39 @@ export default {
// 立即购买
addToCar(goodsData) {
console.log(goodsData,'--=')
uni.navigateTo({
url: `/pages/client/order/create`,
success: (res) => {
// 通过eventChannel向被打开页面传送数据
res.eventChannel.emit("createOrder", {
goodList: [{
...this.goodsData,
goods_id:goodsData.product.out_id,
// price_id:goodsData.prices[0].price_id,
number:1,
goods_name: goodsData.product.product_name,
price_name: goodsData?.product.product_name,
goods_price: goodsData.product.product_type,
product_pic:goodsData.product.product_type
}, ],
});
},
});
// Parse image_list and get the first image URL
let firstImageUrl = '';
const imageList = goodsData.product.attr_key_value_map.image_list;
if (imageList) {
try {
// Try to parse as JSON if it's a string
const parsedList = typeof imageList === 'string' ? JSON.parse(imageList) : imageList;
if (Array.isArray(parsedList) && parsedList.length > 0) {
firstImageUrl = parsedList[0].url || parsedList[0] || '';
}
} catch (e) {
console.error('Error parsing image_list:', e);
}
}
uni.navigateTo({
url: `/pages/client/order/create`,
success: (res) => {
// 通过eventChannel向被打开页面传送数据
res.eventChannel.emit("createOrder", {
goodList: [{
...this.goodsData,
goods_id:goodsData.product.out_id,
// price_id:goodsData.prices[0].price_id,
product_pic: firstImageUrl,
number:1,
goods_name: goodsData.product.product_name,
price_name: goodsData?.product.product_name,
goods_price: goodsData.sku.actual_amount / 100
}, ],
});
},
});
},