diff --git a/src/pages/client/category/components/GoodItem.vue b/src/pages/client/category/components/GoodItem.vue
index d3b98dc..1fdb1b4 100644
--- a/src/pages/client/category/components/GoodItem.vue
+++ b/src/pages/client/category/components/GoodItem.vue
@@ -13,7 +13,7 @@
¥
- {{data.prices[0].original_price || 0 }}
+ {{data.prices[0].original_price / 100 || 0 }}
diff --git a/src/pages/client/home/index.vue b/src/pages/client/home/index.vue
index 108c292..4973b81 100644
--- a/src/pages/client/home/index.vue
+++ b/src/pages/client/home/index.vue
@@ -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
+ }, ],
+ });
+ },
+ });
},
diff --git a/src/pages/client/order/create.vue b/src/pages/client/order/create.vue
index 732b75e..d1d3455 100644
--- a/src/pages/client/order/create.vue
+++ b/src/pages/client/order/create.vue
@@ -195,8 +195,41 @@ export default {
const eventChannel = this.getOpenerEventChannel();
eventChannel.on("createOrder", (data) => {
- this.orderData = data?.goodList || [];
- this.payPrice = (data?.goodList || []).reduce(
+ // Helper function to extract first image from image_list
+ const extractFirstImage = (imageList) => {
+ if (!imageList) return '';
+ try {
+ const parsedList = typeof imageList === 'string' ? JSON.parse(imageList) : imageList;
+ if (Array.isArray(parsedList) && parsedList.length > 0) {
+ return parsedList[0].url || parsedList[0] || '';
+ }
+ } catch (e) {
+ console.error('Error parsing image_list:', e);
+ }
+ return '';
+ };
+
+ this.orderData = (data?.goodList || []).map(item => {
+ // Check if product_pic is actually an image_list that needs parsing
+ let processedItem = { ...item };
+ if (processedItem.product_pic) {
+ // If product_pic looks like an array or JSON string, try to parse it
+ if (typeof processedItem.product_pic === 'string' && (processedItem.product_pic.startsWith('[') || processedItem.product_pic.startsWith('{'))) {
+ const extractedUrl = extractFirstImage(processedItem.product_pic);
+ if (extractedUrl) {
+ processedItem.product_pic = extractedUrl;
+ }
+ } else if (Array.isArray(processedItem.product_pic)) {
+ const extractedUrl = extractFirstImage(processedItem.product_pic);
+ if (extractedUrl) {
+ processedItem.product_pic = extractedUrl;
+ }
+ }
+ }
+ return processedItem;
+ });
+
+ this.payPrice = this.orderData.reduce(
(sum, item) =>
sum +
Number((item.product_price || item.goods_price) * item.number || 0),
@@ -236,6 +269,7 @@ export default {
plugin.createOrder({
skuList: res.data.skuList,
payment: res.data.payment,
+ bookInfo:res.data.bookInfo,
success: (res) => {
const { orderId, outOrderNo } = res;
console.log("success res", res);
diff --git a/src/pages/client/shop/components/GoodItem.vue b/src/pages/client/shop/components/GoodItem.vue
index b752de0..e92e1a2 100644
--- a/src/pages/client/shop/components/GoodItem.vue
+++ b/src/pages/client/shop/components/GoodItem.vue
@@ -1,6 +1,6 @@
-
+
{{ data.product.product_name || "" }}
@@ -13,7 +13,7 @@
¥
{{
- data.product.product_type || 0
+ data.sku.actual_amount / 100 || 0
}}
@@ -410,7 +410,7 @@
number,
goods_name: this.details.goods_name,
price_name: priceInfo?.price_name,
- goods_price: +(+priceInfo?.actual_price * number).toFixed(2),
+ goods_price: +((priceInfo?.actual_price / 100) * number).toFixed(2),
}, ],
});
},
diff --git a/src/pages/client/shop/index.vue b/src/pages/client/shop/index.vue
index 17b67c1..8f2f401 100644
--- a/src/pages/client/shop/index.vue
+++ b/src/pages/client/shop/index.vue
@@ -274,8 +274,7 @@ export default {
})
.then((res) => {
const list = res?.data || [];
- this.goodsList =
- this.page === 1 ? list : [...this.goodsList, ...list];
+ this.goodsList = list;
this.total = res?.count || 0;
})
.finally(() => {
@@ -397,8 +396,8 @@ export default {
product_id: good.product_id,
product_name: good.product_name,
product_pic: good.product_pic,
- goods_price: good.prices?.[0]?.actual_price,
- product_price: good.prices?.[0]?.actual_price,
+ goods_price: good.prices?.[0]?.actual_price / 100,
+ product_price: good.prices?.[0]?.actual_price / 100,
original_price: good.prices?.[0]?.original_price,
yunfei: good.yunfei || 0,
},