Browse Source

fix(frontend): upload/meal/points pages use API_BASE_URL for uploaded images

Convert relative image paths to absolute URLs via config.API_BASE_URL in report upload, meal, and points mall pages.

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

Co-authored-by: Sisyphus <clio-agent@sisyphuslabs.ai>
Xiaogang Liao 1 month ago
parent
commit
a72e9528e5

+ 5 - 1
cfc-frontend/pages/dan-assessment/report-upload.vue

@@ -39,7 +39,7 @@
             :key="item.id"
             @click="goToProduct(item.id)"
           >
-            <image class="purchase-cover" :src="item.coverImage || '/static/default-product.png'" mode="aspectFill" />
+            <image class="purchase-cover" :src="getImageUrl(item.coverImage) || '/static/default-product.png'" mode="aspectFill" />
             <text class="purchase-name">{{ item.name }}</text>
             <text class="purchase-price">{{ formatPriceWithSymbol(item.price) }}</text>
             <view class="purchase-btn">
@@ -141,6 +141,7 @@
 
 <script>
 import { danParsePreview, danConfirmReport, productList } from '../../utils/api.js'
+import config from '@/config.js'
 
 var REPORT_DOMAIN_MAP = {
   mind: 'mind',
@@ -279,6 +280,9 @@ export default {
     formatPriceWithSymbol: function(cents) {
       if (cents === null || cents === undefined) return '¥0'
       return '¥' + (cents / 100).toFixed(2)
+    },
+    getImageUrl: function(path) {
+      return config.API_BASE_URL + path
     }
   }
 }

+ 5 - 1
cfc-frontend/pages/health/report-upload.vue

@@ -116,7 +116,7 @@
             :key="item.id"
             @click="goToProduct(item.id)"
           >
-            <image class="purchase-cover" :src="item.coverImage || '/static/default-product.png'" mode="aspectFill" />
+            <image class="purchase-cover" :src="getImageUrl(item.coverImage) || '/static/default-product.png'" mode="aspectFill" />
             <text class="purchase-name">{{ item.name }}</text>
             <text class="purchase-price">{{ formatPriceWithSymbol(item.price) }}</text>
             <view class="purchase-btn">
@@ -170,6 +170,7 @@
 
 <script>
 import { productList, getFamilyMembers, addFamilyMember, getPublicConfig } from '../../utils/api.js'
+import config from '@/config.js'
 
 export default {
   data() {
@@ -579,6 +580,9 @@ export default {
       }
 
       uni.navigateTo({ url: '/pages/health/report-confirm?' + params })
+    },
+    getImageUrl: function(path) {
+      return config.API_BASE_URL + path
     }
   }
 }

+ 5 - 1
cfc-frontend/pages/meal/recipe-detail.vue

@@ -4,7 +4,7 @@
       <!-- 头部信息 -->
       <view class="header">
         <view v-if="recipe.coverImage" class="cover-wrap">
-          <image class="cover" :src="recipe.coverImage" mode="aspectFill" />
+          <image class="cover" :src="getImageUrl(recipe.coverImage)" mode="aspectFill" />
         </view>
         <text class="title">{{ recipe.name }}</text>
         <view v-if="recipe.mealType" class="tag-row">
@@ -78,6 +78,7 @@
 
 <script>
 import { getMealRecommend } from '@/utils/api'
+import config from '@/config.js'
 
 export default {
   name: 'RecipeDetail',
@@ -145,6 +146,9 @@ export default {
       } catch (e) {
         this.stepList = str.split(/[;;\n]/).filter(function(s) { return s.trim() })
       }
+    },
+    getImageUrl: function(path) {
+      return config.API_BASE_URL + path
     }
   }
 }

+ 5 - 1
cfc-frontend/pages/points/mall.vue

@@ -37,7 +37,7 @@
         >
           <image
             class="product-cover"
-            :src="product.coverImage || '/static/default-product.png'"
+            :src="getImageUrl(product.coverImage) || '/static/default-product.png'"
             mode="aspectFill"
           />
           <view class="product-info">
@@ -125,6 +125,7 @@ import {
   getPointsExchangeRecords,
   getSystemBalance
 } from '@/utils/api.js'
+import config from '@/config.js'
 
 export default {
   data() {
@@ -282,6 +283,9 @@ export default {
       var month = date.getMonth() + 1
       var day = date.getDate()
       return year + '-' + (month < 10 ? '0' + month : month) + '-' + (day < 10 ? '0' + day : day)
+    },
+    getImageUrl: function(path) {
+      return config.API_BASE_URL + path
     }
   }
 }