|
|
@@ -1,10 +1,20 @@
|
|
|
<template>
|
|
|
- <view style="font-size:30upx;">
|
|
|
- <view style="padding:0upx 8upx 30upx 8upx">
|
|
|
- <view v-for="(item, index) in itemData" :key="index">
|
|
|
- <view :class="[item.gap == 2 ? 'hasGap':'noGap',item.bold == 2 ? 'hasBold':'noBold']">{{item.content}}</view>
|
|
|
- </view>
|
|
|
- </view>
|
|
|
+ <view class="privacy-container">
|
|
|
+ <view class="privacy-content" v-if="parsedItems.length > 0">
|
|
|
+ <view
|
|
|
+ v-for="(item, index) in parsedItems"
|
|
|
+ :key="index"
|
|
|
+ :class="{
|
|
|
+ 'privacy-item': true,
|
|
|
+ 'hasBold': item.bold === 2,
|
|
|
+ 'noBold': item.bold !== 2,
|
|
|
+ 'hasGap': item.gap === 2,
|
|
|
+ 'noGap': item.gap !== 2
|
|
|
+ }"
|
|
|
+ >
|
|
|
+ {{ item.content }}
|
|
|
+ </view>
|
|
|
+ </view>
|
|
|
</view>
|
|
|
</template>
|
|
|
<script>
|
|
|
@@ -15,34 +25,90 @@ export default {
|
|
|
mixins: [],
|
|
|
data() {
|
|
|
return {
|
|
|
- itemData:[]
|
|
|
+ html: '',
|
|
|
+ parsedItems: []
|
|
|
}
|
|
|
},
|
|
|
computed: {
|
|
|
},
|
|
|
onLoad(){
|
|
|
getPrivacyAgreement().then(res=>{
|
|
|
- console.log(res)
|
|
|
if(res.code == 1){
|
|
|
- this.itemData = res.data.html
|
|
|
+ this.html = res.data.html
|
|
|
+ this.parsePrivacyHtml(this.html)
|
|
|
}
|
|
|
})
|
|
|
},
|
|
|
methods: {
|
|
|
+ init(){
|
|
|
+
|
|
|
+ },
|
|
|
+ // 拆解后端返回的隐私协议HTML字符串
|
|
|
+ parsePrivacyHtml(htmlStr) {
|
|
|
+
|
|
|
+ // 按换行符拆解字符串
|
|
|
+ const arr = htmlStr.split('\n')
|
|
|
+ .map(item => item.trim())
|
|
|
+ .filter(item => item !== '');
|
|
|
+
|
|
|
+ // 移除重复项
|
|
|
+ const uniqueArr = Array.from(new Set(arr));
|
|
|
+
|
|
|
+ // 处理每一项,提取样式标记和内容
|
|
|
+ const newItems = [];
|
|
|
+ uniqueArr.forEach(item => {
|
|
|
+ const current = {};
|
|
|
+
|
|
|
+ // 检查 _@@_ 标记(间距)
|
|
|
+ if (item.indexOf('_@@_') !== -1) {
|
|
|
+ current.gap = 2;
|
|
|
+ }
|
|
|
+
|
|
|
+ // 检查 _BB_ 标记(粗体)
|
|
|
+ if (item.indexOf('_BB_') !== -1) {
|
|
|
+ current.bold = 2;
|
|
|
+ }
|
|
|
+
|
|
|
+ // 移除标记符,保留内容
|
|
|
+ let content = item.replace(/_BB_/g, '');
|
|
|
+ content = content.replace(/_@@_/g, '');
|
|
|
+ current.content = content;
|
|
|
+
|
|
|
+ newItems.push(current);
|
|
|
+ });
|
|
|
+
|
|
|
+ this.parsedItems = newItems;
|
|
|
+ },
|
|
|
}
|
|
|
};
|
|
|
</script>
|
|
|
<style lang="scss" scoped>
|
|
|
-.hasGap{
|
|
|
- margin-top:49upx;
|
|
|
+.privacy-container {
|
|
|
+ padding: 30upx 30upx 30upx 30upx;
|
|
|
+ font-size: 30upx;
|
|
|
}
|
|
|
-.hasBold{
|
|
|
- font-weight:bold;
|
|
|
+
|
|
|
+.privacy-content {
|
|
|
+ line-height: 1.6;
|
|
|
}
|
|
|
-.noGap{
|
|
|
- margin-top:0upx;
|
|
|
+
|
|
|
+.privacy-item {
|
|
|
+ padding: 15upx 0;
|
|
|
}
|
|
|
-.noBold{
|
|
|
- font-weight:normal;
|
|
|
+
|
|
|
+.hasGap {
|
|
|
+ margin-top: 40upx;
|
|
|
+}
|
|
|
+
|
|
|
+.hasBold {
|
|
|
+ font-weight: bold;
|
|
|
+}
|
|
|
+
|
|
|
+.noGap {
|
|
|
+ margin-top: 0upx;
|
|
|
+}
|
|
|
+
|
|
|
+.noBold {
|
|
|
+ font-weight: normal;
|
|
|
}
|
|
|
</style>
|