notice.vue
3.84 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
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
<template>
<view class="bgView">
<view class="content">
<!-- <view class="titleView" v-if="videoURL.valueOf().length === 0">
<view class="title">{{title}}</view>
</view> -->
<view class="time" v-if="videoURL.valueOf().length === 0">{{createTime}}</view>
<video class="videoView" :src="videoURL.valueOf()" v-if="videoURL.valueOf().length > 0"></video>
<view class="textContent">
<rich-text class="textView" :nodes="format(text)"></rich-text>
</view>
</view>
</view>
</template>
<script setup lang="ts">
import { onLoad,onShow } from '@dcloudio/uni-app'
import { getCurrentInstance, ref } from 'vue'
import registerApi from "@/api/register"
const instance = getCurrentInstance()
const { proxy } = instance
const videoURL = ref<string>('')
const text = ref<string>('')
const title = ref<string>('')
const createTime = ref<string>('')
onLoad((options) => {
requestData()
})
onShow(() => {
})
function requestData() {
registerApi.getNotice({type: 'tos'}).then((res) => {
console.log('getNotice', res)
text.value = res.data.noticeContent
// videoURL.value = res.data.video
title.value = res.data.noticeTitle
}).catch((error) => {
uni.showToast({
title: error.msg,
icon: 'none'
})
})
}
function format(html) {
var GRT = [
// img 样式
['img', "max-width:100%;height:auto;"],
];
for (let i = 0; i < GRT.length; i++) {
html = html.replace(new RegExp('<' + GRT[i][0] + '>|<' + GRT[i][0] + ' (.*?)>', 'gi'), function (word) {
// 分析 dom 上是否带有 style=""
if (word.indexOf('style=') != -1) {
var regIn = new RegExp('<' + GRT[i][0] + '(.*?)style="(.*?)"(.*?)(/?)>', 'gi');
return word.replace(regIn, '<' + GRT[i][0] + '$1style="$2 ' + GRT[i][1] + '"$3$4>');
} else {
var regIn = new RegExp('<' + GRT[i][0] + '(.*?)(/?)>', 'gi');
return word.replace(regIn, '<' + GRT[i][0] + '$1 style="' + GRT[i][1] + '$2">');
}
});
}
return html;
}
</script>
<style lang="scss" scoped>
.bgView {
display: flex;
position: relative;
flex-direction: column;
align-items: center;
width: 100%;
height: 100%;
background-color: #FFFFFF;
.footer_wrapper {
display: flex;
position: fixed;
bottom: 0;
left: 0;
z-index: 10;
width: 100vw;
overflow: hidden;
background: #ffffff;
height: 160rpx;
.liuzi {
display: flex;
background: #587CF7;
box-shadow: 0rpx 4rpx 10rpx 0rpx rgba(0, 0, 0, 0.2);
border-radius: 44rpx;
margin-left: 16rpx;
margin-right: 16rpx;
justify-content: center;
align-items: center;
font-weight: 500;
font-size: 32rpx;
color: #FFFFFF;
line-height: 45rpx;
text-shadow: 0px 4px 10px rgba(0, 0, 0, 0.2);
flex: 1;
height: 88rpx;
margin-top: 20rpx;
}
.disable {
opacity: 0.5;
}
}
.content {
display: flex;
position: relative;
flex-direction: column;
align-items: center;
width: 100%;
.titleView {
display: flex;
position: relative;
width: 100%;
margin-top: 20rpx;
.title {
display: flex;
position: relative;
font-size: 34rpx;
font-family: PingFangSC, PingFang SC;
font-weight: 500;
color: #000000;
line-height: 48rpx;
margin-left: 30rpx;
margin-right: 30rpx;
}
}
.time {
display: flex;
position: relative;
width: 100%;
font-size: 26rpx;
font-family: PingFangSC, PingFang SC;
font-weight: 400;
color: #6B6D73;
line-height: 40rpx;
padding-left: 60rpx;
margin-top: 20rpx;
}
.videoView {
width: 100%;
margin-top: 20rpx;
}
.textContent {
margin-top: 40rpx;
margin-left: 30rpx;
margin-right: 30rpx;
.textView {
font-size: 28rpx;
font-family: PingFangSC, PingFang SC;
font-weight: 400;
color: #222222;
line-height: 48rpx;
white-space: pre-wrap;
}
}
}
}
</style>