소스 검색

fix(frontend): shop core pages use API_BASE_URL for uploaded product images

Convert relative product cover image paths to absolute URLs via config.API_BASE_URL in shop index, cart, and checkout pages.

Ultraworked with [Sisyphus](https://github.com/code-yeongyu/oh-my-openagent)

Co-authored-by: Sisyphus <clio-agent@sisyphuslabs.ai>
Xiaogang Liao 1 개월 전
부모
커밋
cda0a0b919
3개의 변경된 파일15개의 추가작업 그리고 4개의 파일을 삭제
  1. 5 1
      cfc-frontend/pages/shop/cart/cart.vue
  2. 4 1
      cfc-frontend/pages/shop/checkout/checkout.vue
  3. 6 2
      cfc-frontend/pages/shop/index/index.vue

+ 5 - 1
cfc-frontend/pages/shop/cart/cart.vue

@@ -31,7 +31,7 @@
           <view class="item-left">
             <image
               class="item-image"
-              :src="item.coverImage || '/static/default-product.png'"
+              :src="getImageUrl(item.coverImage) || '/static/default-product.png'"
               mode="aspectFill"
             />
           </view>
@@ -85,6 +85,7 @@
 
 <script>
 import config from '@/config.js'
+import config from '@/config.js'
 import { getMyMembership } from '@/utils/api.js'
 
 export default {
@@ -264,6 +265,9 @@ export default {
     formatPriceWithSymbol(price) {
       if (price === null || price === undefined) return '0.00'
       return (Number(price) / 100).toFixed(2)
+    },
+    getImageUrl: function(path) {
+      return config.API_BASE_URL + path
     }
   }
 }

+ 4 - 1
cfc-frontend/pages/shop/checkout/checkout.vue

@@ -57,7 +57,7 @@
         >
           <image
             class="item-image"
-            :src="item.coverImage || '/static/default-product.png'"
+            :src="getImageUrl(item.coverImage) || '/static/default-product.png'"
             mode="aspectFill"
           />
           <view class="item-info">
@@ -501,6 +501,9 @@ export default {
         return phone.substr(0, 3) + '****' + phone.substr(7)
       }
       return phone
+    },
+    getImageUrl: function(path) {
+      return config.API_BASE_URL + path
     }
   }
 }

+ 6 - 2
cfc-frontend/pages/shop/index/index.vue

@@ -79,7 +79,7 @@
           >
             <image
               class="recommend-img"
-              :src="item.image || item.coverImage || '/static/default-product.png'"
+              :src="getImageUrl(item.image || item.coverImage) || '/static/default-product.png'"
               mode="aspectFill"
             />
             <text class="recommend-name">{{ item.name }}</text>
@@ -112,7 +112,7 @@
         >
           <image
             class="cover"
-            :src="item.image || item.coverImage || '/static/default-product.png'"
+            :src="getImageUrl(item.image || item.coverImage) || '/static/default-product.png'"
             mode="aspectFill"
           />
           <view class="card-body">
@@ -143,6 +143,7 @@
 
 <script>
 import { goodsCategory, productList, getMyMembership } from '@/utils/api.js'
+import config from '@/config.js'
 export default {
   data() {
     return {
@@ -278,6 +279,9 @@ export default {
     formatPriceWithSymbol(price) {
       if (price === null || price === undefined) return ''
       return '¥' + parseFloat(price).toFixed(2)
+    },
+    getImageUrl: function(path) {
+      return config.API_BASE_URL + path
     }
   }
 }