tousudetail.vue
3.0 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
<template>
<view class="container">
<view class="top">{{tousudetail.name}}</view>
<view class="contentbox">
<rich-text :nodes="content"></rich-text>
</view>
</view>
</template>
<script>
import app from "../../App.vue";
export default {
data() {
return {
tousuid: "",
tousudetail:'',
content:''
}
},
onLoad(options) {
console.log(options)
this.tousuid=options.tousuid
this.gettousudetail(this.tousuid)
},
methods: {
text(details) {
var texts = '';//待拼接的内容
while (details.indexOf('<img') != -1) {//寻找img 循环
texts += details.substring('0', details.indexOf('<img') + 4);//截取到<img前面的内容
details = details.substring(details.indexOf('<img') + 4);//<img 后面的内容
if (details.indexOf('style=') != -1 && details.indexOf('style=') < details.indexOf('>')) {
texts += details.substring(0, details.indexOf('style="') + 7) + "max-width:100%;height:auto;margin:0 auto;";//从 <img 后面的内容 截取到style= 加上自己要加的内容
details = details.substring(details.indexOf('style="') + 7); //style后面的内容拼接
} else {
texts += ' style="max-width:100%;height:auto;margin:0 auto;" ';
}
}
while (details.indexOf('<td') != -1) {//寻找img 循环
texts += details.substring('0', details.indexOf('<td') + 4);//截取到<img前面的内容
details = details.substring(details.indexOf('<td') + 4);//<img 后面的内容
if (details.indexOf('style=') != -1 && details.indexOf('style=') < details.indexOf('>')) {
texts += details.substring(0, details.indexOf('style="') + 7) + "max-width:74!important;height:auto;margin:0 auto;";//从 <img 后面的内容 截取到style= 加上自己要加的内容
details = details.substring(details.indexOf('style="') + 7); //style后面的内容拼接
} else {
texts += ' style="max-width:100%;height:auto;margin:0 auto;" ';
}
}
texts += details;//最后拼接的内容
return texts
},
gettousudetail(id){
let that = this;
var url = 'protect/get_detail';
var params = {
protect_id:id,
}
app.post(url, params, "post").then((res) => {
console.log(res);
that.tousudetail=res.data.data;
this.content=this.text(res.data.data.content)
}).catch((err) => {
console.log(err)
})
}
}
}
</script>
<style>
.datebox{
margin-top:20rpx
}
.container{
padding: 32rpx;
box-sizing: border-box;
}
.top {
font-size: 32rpx;
font-weight: bold;
}
.botleft {
color: #C29445;
font-size: 24rpx;
}
.botright {
color: #8c9198;
font-size: 24rpx;
margin-left: 24rpx;
}
.contentbox{
margin-top:20rpx
}
</style>