1
This commit is contained in:
@ -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
|
||||
}, ],
|
||||
});
|
||||
},
|
||||
});
|
||||
|
||||
},
|
||||
|
||||
|
||||
Reference in New Issue
Block a user