修复商品详情页面bug

This commit is contained in:
weipengfei 2023-10-27 17:57:05 +08:00
parent 3e95d174f7
commit 366793e9cc
2 changed files with 79 additions and 14 deletions

View File

@ -264,14 +264,22 @@
</view> </view>
<view class='product-intro' id="past3"> <view class='product-intro' id="past3">
<view class='title'>产品介绍</view> <view class='title'>产品介绍</view>
<jyf-parser v-if="description.type == 0" :domain='domain' :html="description.content.replace(/<br\/>/ig, '')" <!-- #ifndef APP-PLUS -->
ref="article" :tag-style="tagStyle"></jyf-parser> <jyf-parser v-if="description.type == 0 && typeof description.content == 'string'" :domain='domain'
:html="description.content.replace(/<br\/>/ig, '')" ref="article"
:tag-style="tagStyle"></jyf-parser>
<!-- #endif -->
<!-- #ifdef APP-PLUS -->
<view v-if="description.type == 0 && typeof description.content == 'string'" class="description"
v-html="description.content.replace(/<br\/>/ig, '')"></view>
<!-- #endif -->
<view v-else class="product_content"> <view v-else class="product_content">
<view v-if="description.content && description.content.title" class="title">{{description.content.title}} <view v-if="description.content && description.content.title" class="product_content_title">{{description.content.title}}
</view>
<view v-if="description.content && description.content.image" class="pictures">
<image v-for="(item,index) in description.content.image" :key="index" :src="item"></image>
</view> </view>
<block v-if="description.content && description.content.image">
<image v-for="(item,index) in description.content.image" :key="index" :src="item" mode="widthFix" style="background-color: #fff;width: 100vw;">
</image>
</block>
</view> </view>
</view> </view>
<view style='height:120rpx;'></view> <view style='height:120rpx;'></view>
@ -558,6 +566,23 @@
} }
that.$set(that, 'storeInfo', storeInfo); that.$set(that, 'storeInfo', storeInfo);
that.$set(that, 'description', storeInfo.content); that.$set(that, 'description', storeInfo.content);
if(typeof that.description.content == 'string'){
try{
that.description.content = JSON.parse(that.description.content);
}catch(e){
console.log(e);
}
}
if (that.description.type == 0 && typeof that.description.content == 'string') {
that.description.content = that.description.content.replace(
/<img/gi,
'<img style="max-width:100%;height:auto;float:left;display:block" '
);
that.description.content = that.description.content.replace(
/<video/gi,
'<video style="width:100%;height:300px;display:block" '
);
}
that.$set(that, 'reply', res.data.topReply ? [res.data.topReply] : []); that.$set(that, 'reply', res.data.topReply ? [res.data.topReply] : []);
that.$set(that.attr, 'productAttr', res.data.attr); that.$set(that.attr, 'productAttr', res.data.attr);
that.$set(that, 'productValue', res.data.sku); that.$set(that, 'productValue', res.data.sku);
@ -608,6 +633,23 @@
} }
that.$set(that, 'storeInfo', storeInfo); that.$set(that, 'storeInfo', storeInfo);
that.$set(that, 'description', storeInfo.content); that.$set(that, 'description', storeInfo.content);
if(typeof that.description.content == 'string'){
try{
that.description.content = JSON.parse(that.description.content);
}catch(e){
console.log(e);
}
}
if (that.description.type == 0 && typeof that.description.content == 'string') {
that.description.content = that.description.content.replace(
/<img/gi,
'<img style="max-width:100%;height:auto;float:left;display:block" '
);
that.description.content = that.description.content.replace(
/<video/gi,
'<video style="width:100%;height:300px;display:block" '
);
}
that.$set(that.description, 'type', storeInfo.content.type || 0); that.$set(that.description, 'type', storeInfo.content.type || 0);
that.$set(that, 'reply', res.data.topReply ? [res.data.topReply] : []); that.$set(that, 'reply', res.data.topReply ? [res.data.topReply] : []);
that.$set(that.attr, 'productAttr', res.data.attr); that.$set(that.attr, 'productAttr', res.data.attr);
@ -1592,4 +1634,19 @@
} }
} }
} }
.product_content{
background-color: #fff;
&_title{
width: 100%;
height: auto;
line-height: 50rpx;
padding: 28rpx;
word-wrap: break-word;
text-align: center;
}
image{
width: 750rpx;
// height: 750rpx;
}
}
</style> </style>

View File

@ -278,22 +278,22 @@
<view class='title'>产品介绍</view> <view class='title'>产品介绍</view>
<view class='conter' v-if="description" style="min-height:50rpx;"> <view class='conter' v-if="description" style="min-height:50rpx;">
<!-- #ifndef APP-PLUS --> <!-- #ifndef APP-PLUS -->
<jyf-parser v-if="description.type == 0" :domain='domain' <jyf-parser v-if="description.type == 0 && typeof description.content == 'string'" :domain='domain'
:html="description.content.replace(/<br\/>/ig, '')" ref="article" :html="description.content.replace(/<br\/>/ig, '')" ref="article"
:tag-style="tagStyle"></jyf-parser> :tag-style="tagStyle"></jyf-parser>
<!-- #endif --> <!-- #endif -->
<!-- #ifdef APP-PLUS --> <!-- #ifdef APP-PLUS -->
<view v-if="description.type == 0" class="description" <view v-if="description.type == 0 && typeof description.content == 'string'" class="description"
v-html="description.content.replace(/<br\/>/ig, '')"></view> v-html="description.content.replace(/<br\/>/ig, '')"></view>
<!-- #endif --> <!-- #endif -->
<view v-else class="product_content"> <view v-else class="product_content">
<view v-if="description.content && description.content.title" class="product_content_title"> <view v-if="description.content && description.content.title" class="product_content_title">
{{description.content.title}} {{description.content.title}}
</view> </view>
<view v-if="description.content && description.content.image" class="pictures" style="background-color: #fff;"> <block v-if="description.content && description.content.image">
<image v-for="(item,index) in description.content.image" :key="index" :src="item" mode="aspectFit"> <image v-for="(item,index) in description.content.image" :key="index" :src="item" mode="widthFix" style="background-color: #fff;width: 100vw;">
</image> </image>
</view> </block>
</view> </view>
</view> </view>
<!-- 价格说明 --> <!-- 价格说明 -->
@ -1059,7 +1059,14 @@
} }
that.$set(that, 'storeInfo', storeInfo); that.$set(that, 'storeInfo', storeInfo);
that.$set(that, 'description', storeInfo.content); that.$set(that, 'description', storeInfo.content);
if (that.description.type == 0) { if(typeof that.description.content == 'string'){
try{
that.description.content = JSON.parse(that.description.content);
}catch(e){
console.log(e);
}
}
if (that.description.type == 0 && typeof that.description.content == 'string') {
that.description.content = that.description.content.replace( that.description.content = that.description.content.replace(
/<img/gi, /<img/gi,
'<img style="max-width:100%;height:auto;float:left;display:block" ' '<img style="max-width:100%;height:auto;float:left;display:block" '
@ -2533,7 +2540,8 @@
} }
image{ image{
width: 750rpx; width: 750rpx;
height: 750rpx; // height: auto;
// height: 750rpx;
} }
} }
</style> </style>