Commit cf149e8c authored by spc's avatar spc

fixed

parent c03517f0
......@@ -49,7 +49,8 @@
<view class="detail-section">
<text class="detail-title">详情信息</text>
<view class="detail-banner" v-if="goodsData.goodsContent">
<rich-text class="banner-text" :nodes="goodsData.goodsContent"></rich-text>
<rich-text style="width: 100%; /* 或设置为具体的像素值 */ overflow-x: hidden;" class="banner-text"
:nodes="formatRichText(goodsData.goodsContent)"></rich-text>
</view>
</view>
</view>
......@@ -84,7 +85,8 @@
<text v-else class="image-placeholder">商品图片</text>
</view>
<view class="product-details">
<text class="product-points">{{ goodsData.points }}{{ goodsData.creditsTypeName || '积分' }}</text>
<text class="product-points">{{ goodsData.points }}{{ goodsData.creditsTypeName || '积分'
}}</text>
<text class="product-stock">库存 {{ formatCount(goodsData.exchangeCount) }}</text>
</view>
</view>
......@@ -598,6 +600,23 @@ export default {
return levelMap[memberLevelName] || 1;
},
// 富文本格式化处理函数
formatRichText(html) {
let newContent = html.replace(/<img[^>]*>/gi, function(match, capture) {
match = match.replace(/style="[^"]+"/gi, '').replace(/style='[^']+'/gi, '');
match = match.replace(/width="[^"]+"/gi, '').replace(/width='[^']+'/gi, '');
match = match.replace(/height="[^"]+"/gi, '').replace(/height='[^']+'/gi, '');
return match;
});
newContent = newContent.replace(/style="[^"]+"/gi, function(match, capture) {
match = match.replace(/width:[^;]+;/gi, 'max-width:100%;').replace(/width:[^;]+;/gi, 'max-width:100%;');
return match;
});
newContent = newContent.replace(/<br[^>]*\/>/gi, '');
newContent = newContent.replace(/<img/gi, '<img style="max-width:100%;height:auto;display:block;margin-top:0;margin-bottom:0;"');
return newContent;
},
// 根据等级数字获取等级名称
getUserLevelName(level) {
const levelMap = {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment