This commit is contained in:
2024-09-09 11:19:59 +08:00
parent 9d87cc70a9
commit be841069ef
456 changed files with 5731 additions and 238053 deletions

View File

@@ -15,7 +15,13 @@
</view>
<!-- </uni-section> -->
<!-- <uni-section class="mb-10" titleFontSize="18px" title="内容" type="line"> -->
<view class="item" v-html="prescriptDetail.content"> </view>
<rich-text
v-if="prescriptDetail.content"
class="item"
:nodes="formatRichText(prescriptDetail.content)"
></rich-text>
<!-- </uni-section> -->
<!-- <view class="item" v-html="prescriptDetail.content">
</view> -->
@@ -35,6 +41,7 @@ import $http from "@/config/requestConfig.js";
export default {
data() {
return {
options: {},
playData: {},
prescriptDetail: {
images: [],
@@ -46,13 +53,49 @@ export default {
duration: 500,
};
},
onLoad(e) {
this.id = e.id;
onLoad(options) {
this.id = options.id;
this.options = options;
},
onShow() {
this.getDetail();
},
methods: {
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(/<img[^>]*>/gi, function(match, capture) {
// match = match.replace(/<img[^>]*>/gi, "@click='1111'").replace(/<img[^>]*>/gi, "@click='1111'");
// return match;
// });
newContent = newContent.replace(/<br[^>]*\/>/gi, "");
newContent = newContent.replace(
/\<img/gi,
'<img style="max-width:100%;height:auto;display:inline-block;margin:10rpx auto;"'
);
return newContent;
},
// 放大图片
previewImage(url) {
console.log(url);
@@ -70,12 +113,20 @@ export default {
getDetail() {
$http
.request({
url: "common/message/getMessageById?id=" + this.id,
url:
this.options.type == "taihu"
? "common/taihuWelfare/getTaihuWelfareArticleDetail"
: "common/message/getMessageById?id=" + this.id,
method: "POST", // POST、GET、PUT、DELETE具体说明查看官方文档
data: {
// loadAnimate: 'none', // 请求加载动画
// 'prescriptId': this.prescriptId
},
data:
this.options.type == "taihu"
? {
id: this.options.id,
}
: {
// loadAnimate: 'none', // 请求加载动画
// 'prescriptId': this.prescriptId
},
header: {
//默认 无 说明:请求头
"Content-Type": "application/json",
@@ -89,10 +140,12 @@ export default {
this.prescriptDetail.content &&
this.prescriptDetail.contentType == 1
) {
this.prescriptDetail.content = res.result.content.replace(
/<img/g,
'<img style="max-width: 100%;"'
);
this.prescriptDetail.content = res.result.content;
//.replace(
// /<img/g,
// '<img style="max-width: 100%;"'
// );
}
// if (this.prescriptDetail.image) {
// this.prescriptDetail.images = this.prescriptDetail.image.split(';');