Kaynağa Gözat

fix(miniapp): 修复商品详情页会员身份加载与详情图片显示

- 将 loadMembership 从组件顶层移入 methods,修复 onLoad 报
  TypeError: this.loadMembership is not a function
- 商品介绍/详情 mp-html 传入 domain(config.API_BASE_URL),
  修复富文本中相对路径图片被解析到本地 DevTools 服务器的问题

Reviewed-by: Sisyphus
asus 2 ay önce
ebeveyn
işleme
2b69eb472c

+ 19 - 16
cfc-frontend/pages/discover-detail/product-detail/product-detail.vue

@@ -89,12 +89,12 @@
 
       <view class="intro-section" v-if="product.intro">
         <text class="section-title">商品介绍</text>
-        <mp-html :content="product.intro" />
+        <mp-html :content="product.intro" :domain="apiBaseUrl" />
       </view>
 
       <view class="desc-section" v-if="product.description">
         <text class="section-title">商品详情</text>
-        <mp-html :content="product.description" />
+        <mp-html :content="product.description" :domain="apiBaseUrl" />
       </view>
     </scroll-view>
     <view v-else class="empty-wrap">
@@ -150,6 +150,9 @@ export default {
     }
   },
   computed: {
+    apiBaseUrl: function() {
+      return config.API_BASE_URL
+    },
     typeLabel() {
       const map = {
         activity: '活动',
@@ -275,21 +278,21 @@ export default {
     // 实时查询会员身份,用于会员价展示和实付价计算
     this.loadMembership()
   },
-  loadMembership: function() {
-    var that = this
-    getMyMembership().then(function(res) {
-      if (res && res.code === 200 && res.data) {
-        var lvl = res.data.memberLevel || 'FREE'
-        that.memberLevel = lvl
-        that.isMember = lvl !== 'FREE' && lvl !== ''
-      }
-    }).catch(function() {
-      // 查询失败按非会员处理,不阻塞页面
-      that.isMember = false
-      that.memberLevel = 'FREE'
-    })
-  },
   methods: {
+    loadMembership: function() {
+      var that = this
+      getMyMembership().then(function(res) {
+        if (res && res.code === 200 && res.data) {
+          var lvl = res.data.memberLevel || 'FREE'
+          that.memberLevel = lvl
+          that.isMember = lvl !== 'FREE' && lvl !== ''
+        }
+      }).catch(function() {
+        // 查询失败按非会员处理,不阻塞页面
+        that.isMember = false
+        that.memberLevel = 'FREE'
+      })
+    },
     getImageUrl: function(path) {
       if (!path) return '/static/default-product.png'
       if (path.startsWith('http') || path.startsWith('/static/')) return path