Bladeren bron

fix(image): 云文件绝对 URL 不再重复叠加 API_BASE_URL 前缀

后端改用云文件服务后返回绝对 URL(http(s)://...),getImageUrl 统一加绝对地址判断,避免出现 https://域名https//... 双前缀。覆盖首页、活动、文章、成长、商城订单等 22 个页面与组件。
Sisyphus Agent 1 week geleden
bovenliggende
commit
93e1b7aa9b

+ 1 - 0
cfc-frontend/pages/activity/activity-detail/activity-detail.vue

@@ -358,6 +358,7 @@ export default {
   methods: {
     // ===== 工具方法 =====
     getImageUrl: function(path) {
+ cff388913 (fix(image): 云文件绝对 URL 不再重复叠加 API_BASE_URL 前缀)
       if (!path || path === 'null' || path === 'undefined' || path === '/null') return ''
       var s = String(path).trim()
       if (!s || s === 'null' || s === '/null') return ''

+ 1 - 0
cfc-frontend/pages/activity/index.vue

@@ -376,6 +376,7 @@ export default {
   },
   methods: {
     getImageUrl: function(path) {
+ cff388913 (fix(image): 云文件绝对 URL 不再重复叠加 API_BASE_URL 前缀)
       if (!path || path === 'null' || path === 'undefined' || path === '/null') return ''
       var s = String(path).trim()
       if (!s || s === 'null' || s === '/null') return ''

+ 5 - 1
cfc-frontend/pages/article-center/article-detail.vue

@@ -163,7 +163,11 @@ export default {
     getImageUrl: function(path) {
       if (!path) return ''
       if (path.indexOf('http://') === 0 || path.indexOf('https://') === 0) return path
-      return config.API_BASE_URL + path
+      if (!path || path === 'null' || path === 'undefined' || path === '/null') return ''
+      var s = String(path).trim()
+      if (!s || s === 'null' || s === '/null') return ''
+      if (s.indexOf('http://') === 0 || s.indexOf('https://') === 0) return s
+      return config.API_BASE_URL + (s.charAt(0) === '/' ? s : '/' + s)
     },
     resolveContentUrls: function(html) {
       if (!html) return html

+ 5 - 2
cfc-frontend/pages/discover-detail/product-detail/product-detail.vue

@@ -348,9 +348,12 @@ export default {
       })
     },
     getImageUrl: function(path) {
-      if (!path) return '/static/default-product.png'
+      if (!path || path === 'null' || path === 'undefined' || path === '/null') return '/static/default-product.png'
       if (path.startsWith('http') || path.startsWith('/static/')) return path
-      return config.API_BASE_URL + path
+      var s = String(path).trim()
+      if (!s || s === 'null' || s === 'undefined' || s === '/null') return ''
+      if (s.indexOf('http://') === 0 || s.indexOf('https://') === 0) return s
+      return config.API_BASE_URL + (s.charAt(0) === '/' ? s : '/' + s)
     },
     onSwiperImageError: function(idx) {
       // 单张图片加载失败时,替换为占位图

+ 7 - 12
cfc-frontend/pages/growth/upload.vue

@@ -273,18 +273,13 @@ export default {
     formatPrice: function(cents) {
       if (cents === null || cents === undefined) return '¥0'
       return '¥' + (cents / 100).toFixed(2)
-    },getImageUrl: function(path) {
-
-      if (!path || path === 'null' || path === 'undefined' || path === '/null') return ''
-
-      var s = String(path).trim()
-
-      if (!s || s === 'null' || s === '/null') return ''
-
-      if (s.indexOf('http://') === 0 || s.indexOf('https://') === 0) return s
-
-      return config.API_BASE_URL + (s.charAt(0) === '/' ? s : '/' + s)
-
+        getImageUrl: function(path) {
+          if (!path || path === 'null' || path === 'undefined' || path === '/null') return ''
+          var s = String(path).trim()
+          if (!s || s === 'null' || s === '/null') return ''
+          if (s.indexOf('http://') === 0 || s.indexOf('https://') === 0) return s
+          return config.API_BASE_URL + (s.charAt(0) === '/' ? s : '/' + s)
+        } cff388913 (fix(image): 云文件绝对 URL 不再重复叠加 API_BASE_URL 前缀)
     }
   }
 }

+ 7 - 12
cfc-frontend/pages/guide/activities/detail.vue

@@ -318,18 +318,13 @@ export default {
       var h = ('0' + d.getHours()).slice(-2)
       var mi = ('0' + d.getMinutes()).slice(-2)
       return y + '-' + m + '-' + day + ' ' + h + ':' + mi
-    },getImageUrl: function(path) {
-
-      if (!path || path === 'null' || path === 'undefined' || path === '/null') return ''
-
-      var s = String(path).trim()
-
-      if (!s || s === 'null' || s === '/null') return ''
-
-      if (s.indexOf('http://') === 0 || s.indexOf('https://') === 0) return s
-
-      return config.API_BASE_URL + (s.charAt(0) === '/' ? s : '/' + s)
-
+        getImageUrl: function(path) {
+          if (!path || path === 'null' || path === 'undefined' || path === '/null') return ''
+          var s = String(path).trim()
+          if (!s || s === 'null' || s === '/null') return ''
+          if (s.indexOf('http://') === 0 || s.indexOf('https://') === 0) return s
+          return config.API_BASE_URL + (s.charAt(0) === '/' ? s : '/' + s)
+        } cff388913 (fix(image): 云文件绝对 URL 不再重复叠加 API_BASE_URL 前缀)
     }
   }
 }

+ 7 - 12
cfc-frontend/pages/guide/activities/index.vue

@@ -207,18 +207,13 @@ export default {
       var h = ('0' + d.getHours()).slice(-2)
       var mi = ('0' + d.getMinutes()).slice(-2)
       return y + '-' + m + '-' + day + ' ' + h + ':' + mi
-    },getImageUrl: function(path) {
-
-      if (!path || path === 'null' || path === 'undefined' || path === '/null') return ''
-
-      var s = String(path).trim()
-
-      if (!s || s === 'null' || s === '/null') return ''
-
-      if (s.indexOf('http://') === 0 || s.indexOf('https://') === 0) return s
-
-      return config.API_BASE_URL + (s.charAt(0) === '/' ? s : '/' + s)
-
+        getImageUrl: function(path) {
+          if (!path || path === 'null' || path === 'undefined' || path === '/null') return ''
+          var s = String(path).trim()
+          if (!s || s === 'null' || s === '/null') return ''
+          if (s.indexOf('http://') === 0 || s.indexOf('https://') === 0) return s
+          return config.API_BASE_URL + (s.charAt(0) === '/' ? s : '/' + s)
+        } cff388913 (fix(image): 云文件绝对 URL 不再重复叠加 API_BASE_URL 前缀)
     }
   }
 }

+ 7 - 12
cfc-frontend/pages/guide/packages/share.vue

@@ -154,18 +154,13 @@ export default {
     },
     closePoster() {
       this.$refs.posterPopup.close()
-    },getImageUrl: function(path) {
-
-      if (!path || path === 'null' || path === 'undefined' || path === '/null') return ''
-
-      var s = String(path).trim()
-
-      if (!s || s === 'null' || s === '/null') return ''
-
-      if (s.indexOf('http://') === 0 || s.indexOf('https://') === 0) return s
-
-      return config.API_BASE_URL + (s.charAt(0) === '/' ? s : '/' + s)
-
+        getImageUrl: function(path) {
+          if (!path || path === 'null' || path === 'undefined' || path === '/null') return ''
+          var s = String(path).trim()
+          if (!s || s === 'null' || s === '/null') return ''
+          if (s.indexOf('http://') === 0 || s.indexOf('https://') === 0) return s
+          return config.API_BASE_URL + (s.charAt(0) === '/' ? s : '/' + s)
+        } cff388913 (fix(image): 云文件绝对 URL 不再重复叠加 API_BASE_URL 前缀)
     }
   }
 }

+ 7 - 12
cfc-frontend/pages/meal/recipe-detail.vue

@@ -147,18 +147,13 @@ export default {
       } catch (e) {
         this.stepList = str.split(/[;;\n]/).filter(function(s) { return s.trim() })
       }
-    },getImageUrl: function(path) {
-
-      if (!path || path === 'null' || path === 'undefined' || path === '/null') return ''
-
-      var s = String(path).trim()
-
-      if (!s || s === 'null' || s === '/null') return ''
-
-      if (s.indexOf('http://') === 0 || s.indexOf('https://') === 0) return s
-
-      return config.API_BASE_URL + (s.charAt(0) === '/' ? s : '/' + s)
-
+        getImageUrl: function(path) {
+          if (!path || path === 'null' || path === 'undefined' || path === '/null') return ''
+          var s = String(path).trim()
+          if (!s || s === 'null' || s === '/null') return ''
+          if (s.indexOf('http://') === 0 || s.indexOf('https://') === 0) return s
+          return config.API_BASE_URL + (s.charAt(0) === '/' ? s : '/' + s)
+        } cff388913 (fix(image): 云文件绝对 URL 不再重复叠加 API_BASE_URL 前缀)
     }
   }
 }

+ 7 - 12
cfc-frontend/pages/mind-detail/articles.vue

@@ -254,18 +254,13 @@ onShow: function() {
         .replace(/"/gi, '"')
         .replace(/\s+/g, ' ')
         .trim()
-    },getImageUrl: function(path) {
-
-      if (!path || path === 'null' || path === 'undefined' || path === '/null') return ''
-
-      var s = String(path).trim()
-
-      if (!s || s === 'null' || s === '/null') return ''
-
-      if (s.indexOf('http://') === 0 || s.indexOf('https://') === 0) return s
-
-      return config.API_BASE_URL + (s.charAt(0) === '/' ? s : '/' + s)
-
+        getImageUrl: function(path) {
+          if (!path || path === 'null' || path === 'undefined' || path === '/null') return ''
+          var s = String(path).trim()
+          if (!s || s === 'null' || s === '/null') return ''
+          if (s.indexOf('http://') === 0 || s.indexOf('https://') === 0) return s
+          return config.API_BASE_URL + (s.charAt(0) === '/' ? s : '/' + s)
+        } cff388913 (fix(image): 云文件绝对 URL 不再重复叠加 API_BASE_URL 前缀)
     }
   }
 }

+ 7 - 12
cfc-frontend/pages/promotion/material.vue

@@ -220,18 +220,13 @@ export default {
           uni.showToast({ title: '下载失败', icon: 'none' })
         }
         })
-    },getImageUrl: function(path) {
-
-      if (!path || path === 'null' || path === 'undefined' || path === '/null') return ''
-
-      var s = String(path).trim()
-
-      if (!s || s === 'null' || s === '/null') return ''
-
-      if (s.indexOf('http://') === 0 || s.indexOf('https://') === 0) return s
-
-      return config.API_BASE_URL + (s.charAt(0) === '/' ? s : '/' + s)
-
+        getImageUrl: function(path) {
+          if (!path || path === 'null' || path === 'undefined' || path === '/null') return ''
+          var s = String(path).trim()
+          if (!s || s === 'null' || s === '/null') return ''
+          if (s.indexOf('http://') === 0 || s.indexOf('https://') === 0) return s
+          return config.API_BASE_URL + (s.charAt(0) === '/' ? s : '/' + s)
+        } cff388913 (fix(image): 云文件绝对 URL 不再重复叠加 API_BASE_URL 前缀)
     }
   }
 }

+ 7 - 12
cfc-frontend/pages/shop/checkout/checkout.vue

@@ -1115,18 +1115,13 @@ showOnlineSlotPicker: function() {
     selectServicePerson: function(person) {
       this.selectedServicePerson = person
       this.showServicePersonModal = false
-    },getImageUrl: function(path) {
-
-      if (!path || path === 'null' || path === 'undefined' || path === '/null') return ''
-
-      var s = String(path).trim()
-
-      if (!s || s === 'null' || s === '/null') return ''
-
-      if (s.indexOf('http://') === 0 || s.indexOf('https://') === 0) return s
-
-      return config.API_BASE_URL + (s.charAt(0) === '/' ? s : '/' + s)
-
+        getImageUrl: function(path) {
+          if (!path || path === 'null' || path === 'undefined' || path === '/null') return ''
+          var s = String(path).trim()
+          if (!s || s === 'null' || s === '/null') return ''
+          if (s.indexOf('http://') === 0 || s.indexOf('https://') === 0) return s
+          return config.API_BASE_URL + (s.charAt(0) === '/' ? s : '/' + s)
+        } cff388913 (fix(image): 云文件绝对 URL 不再重复叠加 API_BASE_URL 前缀)
     }
   }
 }

+ 7 - 12
cfc-frontend/pages/shop/order-detail/order-detail.vue

@@ -290,18 +290,13 @@ export default {
     formatPriceWithSymbol(price) {
       if (!price && price !== 0) return '-'
       return '¥' + (price / 100).toFixed(2)
-    },getImageUrl: function(path) {
-
-      if (!path || path === 'null' || path === 'undefined' || path === '/null') return ''
-
-      var s = String(path).trim()
-
-      if (!s || s === 'null' || s === '/null') return ''
-
-      if (s.indexOf('http://') === 0 || s.indexOf('https://') === 0) return s
-
-      return config.API_BASE_URL + (s.charAt(0) === '/' ? s : '/' + s)
-
+        getImageUrl: function(path) {
+          if (!path || path === 'null' || path === 'undefined' || path === '/null') return ''
+          var s = String(path).trim()
+          if (!s || s === 'null' || s === '/null') return ''
+          if (s.indexOf('http://') === 0 || s.indexOf('https://') === 0) return s
+          return config.API_BASE_URL + (s.charAt(0) === '/' ? s : '/' + s)
+        } cff388913 (fix(image): 云文件绝对 URL 不再重复叠加 API_BASE_URL 前缀)
     },
     // 履约状态标签
     fulfillStatusLabel: function(status) {

+ 7 - 12
cfc-frontend/pages/shop/order-list/order-list.vue

@@ -356,18 +356,13 @@ export default {
     },
     onImgError(e, item) {
       item.coverImage = ''
-    },getImageUrl: function(path) {
-
-      if (!path || path === 'null' || path === 'undefined' || path === '/null') return ''
-
-      var s = String(path).trim()
-
-      if (!s || s === 'null' || s === '/null') return ''
-
-      if (s.indexOf('http://') === 0 || s.indexOf('https://') === 0) return s
-
-      return config.API_BASE_URL + (s.charAt(0) === '/' ? s : '/' + s)
-
+        getImageUrl: function(path) {
+          if (!path || path === 'null' || path === 'undefined' || path === '/null') return ''
+          var s = String(path).trim()
+          if (!s || s === 'null' || s === '/null') return ''
+          if (s.indexOf('http://') === 0 || s.indexOf('https://') === 0) return s
+          return config.API_BASE_URL + (s.charAt(0) === '/' ? s : '/' + s)
+        } cff388913 (fix(image): 云文件绝对 URL 不再重复叠加 API_BASE_URL 前缀)
     }
   }
 }