Commit 2f22d8ed authored by 张九刚's avatar 张九刚

feat: 优化 Home.vue 中的弹窗逻辑,使用 qrObj 替代原有的 qrInfoList 访问方式,确保弹窗内容的安全渲染,并增加对 qrInfoList 的默认值处理。

parent ed5e4b08
...@@ -111,14 +111,14 @@ ...@@ -111,14 +111,14 @@
<!-- 普通弹窗 --> <!-- 普通弹窗 -->
<uni-popup :is-mask-click="false" :safe-area="false" ref="popup" background-color="#fff" <uni-popup :is-mask-click="false" :safe-area="false" ref="popup" background-color="#fff"
border-radius="48rpx"> border-radius="48rpx">
<view v-if="this.popupIndex !== 3 && this.qrInfoList && this.qrInfoList[this.popupIndex]" class="popup-content"> <view v-if="qrObj !== null" class="popup-content">
<image class="btnclose" @tap="closePop" :src="$baseUrl + 'homepage/btnclose.png'"></image> <image class="btnclose" @tap="closePop" :src="$baseUrl + 'homepage/btnclose.png'"></image>
<view class="title"> <view class="title">
{{ this.qrInfoList[this.popupIndex]?.title || '' }} {{ qrObj.title || '' }}
</view> </view>
<rich-text class="desc" :nodes="this.qrInfoList[this.popupIndex]?.desc || ''"></rich-text> <rich-text class="desc" :nodes="qrObj.desc || ''"></rich-text>
<image :show-menu-by-longpress="true" class="qrcode" :src="$baseUrl + (this.qrInfoList[this.popupIndex]?.qrUrl || '')"></image> <image :show-menu-by-longpress="true" class="qrcode" :src="$baseUrl + (qrObj.qrUrl || '')"></image>
<image @tap="downloadHandler($baseUrl + (this.qrInfoList[this.popupIndex]?.qrUrl || ''))" class="btndownload" <image @tap="downloadHandler($baseUrl + (qrObj.qrUrl || ''))" class="btndownload"
:src="$baseUrl + 'homepage/btn_download.png'"></image> :src="$baseUrl + 'homepage/btn_download.png'"></image>
</view> </view>
<view v-else class="popup-content" style="height: 977rpx;"> <view v-else class="popup-content" style="height: 977rpx;">
...@@ -173,7 +173,8 @@ export default { ...@@ -173,7 +173,8 @@ export default {
bottomLinkList: [], bottomLinkList: [],
qrInfoObj: undefined, qrInfoObj: undefined,
popupIndex: 0, popupIndex: 0,
qrInfoList: [{ title: '', desc: '', qrUrl: '' }], qrInfoList: [{ title: '', desc: '', qrUrl: '' },{ title: '', desc: '', qrUrl: '' },{ title: '', desc: '', qrUrl: '' },{ title: '', desc: '', qrUrl: '' }],
qrObj:{ title: '', desc: '', qrUrl: ''},
showVideo: false, showVideo: false,
currentVideoUrl: '', currentVideoUrl: '',
isClickPhoneAuth:false, isClickPhoneAuth:false,
...@@ -215,7 +216,6 @@ export default { ...@@ -215,7 +216,6 @@ export default {
const { data } = await fetchHomeJSON(); const { data } = await fetchHomeJSON();
console.log('111111111111',data);
if (data) { if (data) {
this.swiperList = data.swiperList; this.swiperList = data.swiperList;
this.vipConfigList = data.vipConfigList; this.vipConfigList = data.vipConfigList;
...@@ -225,7 +225,7 @@ export default { ...@@ -225,7 +225,7 @@ export default {
this.changelInfoList = data.changelInfoList; this.changelInfoList = data.changelInfoList;
this.childrenInfoList = data.childrenInfoList[0] || []; this.childrenInfoList = data.childrenInfoList[0] || [];
this.bottomLinkList = data.bottomLinkList; this.bottomLinkList = data.bottomLinkList;
this.qrInfoList = data.qrInfoList; this.qrInfoList = data.qrInfoList||[];
this.vipCardList = data.vipCardList; this.vipCardList = data.vipCardList;
this.voiceStory = data.voiceStory; this.voiceStory = data.voiceStory;
this.suggest = data.suggest; this.suggest = data.suggest;
...@@ -311,7 +311,15 @@ export default { ...@@ -311,7 +311,15 @@ export default {
this.channelTabIndex = _index; this.channelTabIndex = _index;
}, },
showPopup(_index) { showPopup(_index) {
this.popupIndex = _index; // this.popupIndex = Math.max(0, Math.min(_index, this.qrInfoList.length - 1));
if(_index === 3){
this.qrObj = null;
}else{
_index= Math.max(0, Math.min(_index, this.qrInfoList.length - 1));
this.qrObj = this.qrInfoList[_index];
}
this.$refs.popup.open(this.popType); this.$refs.popup.open(this.popType);
}, },
closePop() { closePop() {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment