chore:解决了siteInfo,bgUrl错误

This commit is contained in:
2026-01-15 14:08:32 +08:00
parent 82df9ddbac
commit c6a8bc04f2

View File

@@ -1,246 +1,255 @@
<template> <template>
<view :style="themeColor"> <view :style="themeColor">
<view :style="{ backgroundColor: bgColor, minHeight: openBottomNav ? 'calc(100vh - 55px)' : '' }" <view :style="{ backgroundColor: bgColor, minHeight: openBottomNav ? 'calc(100vh - 55px)' : '' }"
class="page-img"> class="page-img">
<view class="site-info-box" <view class="site-info-box"
v-if="$util.isWeiXin() && followOfficialAccount && followOfficialAccount.isShow && wechatQrcode"> v-if="$util.isWeiXin() && followOfficialAccount && followOfficialAccount.isShow && wechatQrcode">
<view class="site-info"> <view class="site-info">
<view class="img-box" v-if="siteInfo.logo_square"> <view class="img-box" v-if="siteInfo.logo_square">
<image :src="$util.img(siteInfo.logo_square)" mode="aspectFill"></image> <image :src="$util.img(siteInfo.logo_square)" mode="aspectFill"></image>
</view> </view>
<view class="info-box" :style="{ color: '#ffffff' }"> <view class="info-box" :style="{ color: '#ffffff' }">
<text class="font-size-base">{{ siteInfo.site_name }}</text> <text class="font-size-base">{{ siteInfo.site_name }}</text>
<text>{{ followOfficialAccount.welcomeMsg }}</text> <text>{{ followOfficialAccount.welcomeMsg }}</text>
</view> </view>
</view> </view>
<view class="dite-button" @click="officialAccountsOpen">{{ isEnEnv ? 'Follow Official Account' : '关注公众号' <view class="dite-button" @click="officialAccountsOpen">{{ isEnEnv ? 'Follow Official Account' : '关注公众号'
}}</view> }}</view>
</view> </view>
<!-- <view class="page-header" v-if="diyData.global && diyData.global.navBarSwitch" :style="{ backgroundImage: bgImg }"> <diy-index-page v-if="topIndexValue" ref="indexPage" :value="topIndexValue" :bgUrl="safeBgUrl"
<ns-navbar :title-color="textNavColor" :data="diyData.global" :scrollTop="scrollTop" :isBack="false"/> :scrollTop="scrollTop" :diyGlobal="diyData.global" class="diy-index-page">
</view> --> <template v-slot:components>
<diy-group ref="diyGroup" v-if="diyData.value" :diyData="diyData" :scrollTop="scrollTop"
<diy-index-page v-if="topIndexValue" ref="indexPage" :value="topIndexValue" :bgUrl="bgUrl" :haveTopCategory="true" :followOfficialAccount="followOfficialAccount" />
:scrollTop="scrollTop" :diyGlobal="diyData.global" class="diy-index-page"> </template>
<template v-slot:components> <template v-slot:default>
<diy-group ref="diyGroup" v-if="diyData.value" :diyData="diyData" :scrollTop="scrollTop" <ns-copyright v-show="isShowCopyRight" />
:haveTopCategory="true" :followOfficialAccount="followOfficialAccount" /> </template>
</template> </diy-index-page>
<template v-slot:default>
<ns-copyright v-show="isShowCopyRight" /> <view v-else class="bg-index"
</template> :style="{ backgroundImage: backgroundUrlStyle, paddingTop: paddingTop, marginTop: marginTop }">
</diy-index-page> <diy-group ref="diyGroup" v-if="diyData.value" :diyData="diyData" :scrollTop="scrollTop"
:followOfficialAccount="followOfficialAccount" />
<view v-else class="bg-index" <ns-copyright v-show="isShowCopyRight" />
:style="{ backgroundImage: backgroundUrl, paddingTop: paddingTop, marginTop: marginTop }"> </view>
<diy-group ref="diyGroup" v-if="diyData.value" :diyData="diyData" :scrollTop="scrollTop"
:followOfficialAccount="followOfficialAccount" /> <template v-if="adv.advshow != -1">
<ns-copyright v-show="isShowCopyRight" /> <view @touchmove.prevent.stop>
</view> <uni-popup ref="uniPopupWindow" type="center" class="wap-floating" :maskClick="false">
<view class="small-bot">
<template v-if="adv.advshow != -1"> <swiper autoplay="true" :circular="true" indicator-active-color="#fff"
<view @touchmove.prevent.stop> indicator-color="rgba(255,255,255,0.6)" :indicator-dots="true" interval="3000">
<uni-popup ref="uniPopupWindow" type="center" class="wap-floating" :maskClick="false"> <swiper-item v-for="(item, index) in adv.list" :key="index">
<view class="small-bot"> <image class="slide-image" @click="$util.diyRedirectTo(item.link)" height="100%"
<!-- <view class="adver-time" wx:if="{{startadv.params.style=='default'&&startadv.params.canclose==1}}"> :src="$util.img(item.imageUrl)" width="100%"></image>
<view bindtap="adverclose">跳过</view> </swiper-item>
<view class="time">{{clock}}s</view> </swiper>
</view> <view class="small-bot-close" @click="closePopupWindow">
<view class="adver-time" wx:if="{{startadv.params.style=='default'&&startadv.params.canclose==0}}"> <i class="iconfont icon-round-close" style="color:#fff"></i>
<view class="time" style="line-height: 64rpx;">{{clock}}s</view> </view>
</view> --> </view>
<swiper autoplay="true" :circular="true" indicator-active-color="#fff" </uni-popup>
indicator-color="rgba(255,255,255,0.6)" :indicator-dots="true" interval="3000"> </view>
<swiper-item v-for="(item, index) in adv.list" :key="index"> </template>
<image class="slide-image" @click="$util.diyRedirectTo(item.link)" height="100%"
:src="$util.img(item.imageUrl)" width="100%"></image> <!-- 底部tabBar -->
<!-- <image bindtap="adverclose" class="slide-image" height="100%" src="{{item.imgurl}}" width="100%" wx:if="{{item.click==1}}"></image> --> <view class="page-bottom" v-if="openBottomNav">
</swiper-item> <diy-bottom-nav @callback="callback" :name="name" />
</swiper> </view>
<view bindtap="adverclose" class="small-bot-close" @click="closePopupWindow">
<i class="iconfont icon-round-close" style="color:#fff"></i> <!-- 关注公众号弹窗 -->
</view> <view @touchmove.prevent class="official-accounts-inner" v-if="wechatQrcode">
</view> <uni-popup ref="officialAccountsPopup" type="center">
<!-- <view class="image-wrap"> <view class="official-accounts-wrap">
<swiper class="swiper" style="width:100%;height: 1200rpx;" :autoplay="true" interval="3000" circular="true" :indicator-dots="true" indicator-color="#000" indicator-active-color="red"> <image class="content" :src="$util.img(wechatQrcode)" mode="aspectFit"></image>
<swiper-item class="swiper-item" v-for="(item, index) in adv.list" :key="index" v-if="item.imageUrl" @click="$util.diyRedirectTo(item.link)"> <text class="desc">关注了解更多</text>
<view class="item"> <text class="close iconfont icon-round-close" @click="officialAccountsClose"></text>
<image :src="$util.img(item.imageUrl)" mode="aspectFit" :show-menu-by-longpress="true"/> </view>
</view> </uni-popup>
</swiper-item> </view>
</swiper>
</view> <!-- 收藏 -->
<text class="iconfont icon-round-close" @click="closePopupWindow"></text> --> <uni-popup ref="collectPopupWindow" type="top" class="wap-floating wap-floating-collect">
</uni-popup> <view v-if="showTip" class="collectPopupWindow"
</view> :style="{ marginTop: (collectTop + statusBarHeight) * 2 + 'rpx' }">
</template> <image :src="$util.img('public/uniapp/index/collect2.png')" mode="aspectFit" />
<text @click="closeCollectPopupWindow">我知道了</text>
<!-- 底部tabBar --> </view>
<view class="page-bottom" v-if="openBottomNav"> </uni-popup>
<diy-bottom-nav @callback="callback" :name="name" />
</view> <!-- 选择门店弹出框 -->
<view @touchmove.prevent.stop class="choose-store">
<!-- 关注公众号弹窗 --> <uni-popup ref="chooseStorePopup" type="center" :maskClick="false" class="choose-store">
<view @touchmove.prevent class="official-accounts-inner" v-if="wechatQrcode"> <view class="choose-store-popup">
<uni-popup ref="officialAccountsPopup" type="center"> <view class="head-wrap" @click="closeChooseStorePopup">请确认门店</view>
<view class="official-accounts-wrap"> <view class="position-wrap">
<image class="content" :src="$util.img(wechatQrcode)" mode="aspectFit"></image> <text class="iconfont icon-dizhi"></text>
<text class="desc">关注了解更多</text> <text class="address">{{ currentPosition }}</text>
<text class="close iconfont icon-round-close" @click="officialAccountsClose"></text> <view class="reposition" @click="reposition"
</view> v-if="globalStoreConfig && globalStoreConfig.is_allow_change == 1">
</uni-popup> <text class="iconfont icon-dingwei"></text>
</view> <text>重新定位</text>
</view>
<!-- 收藏 --> </view>
<uni-popup ref="collectPopupWindow" type="top" class="wap-floating wap-floating-collect"> <view class="store-wrap" v-if="nearestStore">
<view v-if="showTip" class="collectPopupWindow" <text class="tag">当前门店</text>
:style="{ marginTop: (collectTop + statusBarHeight) * 2 + 'rpx' }"> <view class="store-name">{{ nearestStore.store_name }}</view>
<image :src="$util.img('public/uniapp/index/collect2.png')" mode="aspectFit" /> <view class="address">{{ nearestStore.show_address }}</view>
<text @click="closeCollectPopupWindow">我知道了</text> <view class="distance" v-if="nearestStore.distance">
</view> <text class="iconfont icon-dizhi"></text>
</uni-popup> <text>{{ nearestStore.distance > 1 ? nearestStore.distance + 'km' :
nearestStore.distance *
<!-- 选择门店弹出框定位当前位置展示最近的一个门店 --> 1000 +
<view @touchmove.prevent.stop class="choose-store"> 'm' }}</text>
<uni-popup ref="chooseStorePopup" type="center" :maskClick="false" class="choose-store"> </view>
<view class="choose-store-popup"> </view>
<view class="head-wrap" @click="closeChooseStorePopup">确认门店</view> <button type="primary" @click="enterStore">确认进入</button>
<view class="position-wrap"> <view class="other-store" @click="chooseOtherStore"
<text class="iconfont icon-dizhi"></text> v-if="globalStoreConfig && globalStoreConfig.is_allow_change == 1">
<text class="address">{{ currentPosition }}</text> <text>选择其他门店</text>
<view class="reposition" @click="reposition" <text class="iconfont icon-right"></text>
v-if="globalStoreConfig && globalStoreConfig.is_allow_change == 1"> </view>
<text class="iconfont icon-dingwei"></text> </view>
<text>重新定位</text> </uni-popup>
</view> </view>
</view> <hover-nav :need="true"></hover-nav>
<view class="store-wrap" v-if="nearestStore"> <privacy-popup ref="privacyPopup"></privacy-popup>
<text class="tag">当前门店</text> <to-top v-if="showTop" @toTop="scrollToTopNative()"></to-top>
<view class="store-name">{{ nearestStore.store_name }}</view> <ns-login ref="login"></ns-login>
<view class="address">{{ nearestStore.show_address }}</view> </view>
<view class="distance" v-if="nearestStore.distance"> </view>
<text class="iconfont icon-dizhi"></text> </template>
<text>{{ nearestStore.distance > 1 ? nearestStore.distance + 'km' :
nearestStore.distance * <script>
1000 + import diyJs from '@/common/js/diy.js';
'm' }}</text> import scroll from '@/common/js/scroll-view.js';
</view> import indexJs from './public/js/index.js';
</view>
<button type="primary" @click="enterStore">确认进入</button> export default {
<view class="other-store" @click="chooseOtherStore" mixins: [diyJs, scroll, indexJs],
v-if="globalStoreConfig && globalStoreConfig.is_allow_change == 1">
<text>选择其他门店</text> data() {
<text class="iconfont icon-right"></text> return {
</view> diyData: { global: {}, value: null },
</view> followOfficialAccount: {},
</uni-popup> wechatQrcode: '',
</view> adv: { advshow: -1, list: [] },
<hover-nav :need="true"></hover-nav> // ❌ 不要定义 siteInfo、bgUrl除非你明确知道它们不会冲突
<!-- 隐私协议 --> };
<privacy-popup ref="privacyPopup"></privacy-popup> },
<to-top v-if="showTop" @toTop="scrollToTopNative()"></to-top>
<ns-login ref="login"></ns-login> computed: {
</view> // ✅ 安全获取 bgUrl用于 diy-index-page 的 prop
</view> safeBgUrl() {
</template> // 优先取全局配置中的 bgUrl没有则用组件自己的 bgUrl如有否则为空
return this.diyData?.global?.bgUrl || this.bgUrl || '';
<script> },
// ✅ 安全生成 background-image 样式字符串(用于 fallback 区域)
import diyJs from '@/common/js/diy.js'; backgroundUrlStyle() {
import scroll from '@/common/js/scroll-view.js'; const url = this.diyData?.global?.bgUrl || this.bgUrl || '';
import indexJs from './public/js/index.js'; return url ? `url(${url})` : 'none';
}
export default { },
mixins: [diyJs, scroll, indexJs]
}; // 如果你的 mixin 中已经处理了数据加载,这里可以留空
</script> // 否则建议在 created/mounted 中初始化默认值或请求数据
created() {
<style lang="scss"> // 可选:如果 mixin 没有初始化 diyData这里再兜底一次
@import '@/common/css/diy.scss'; if (!this.diyData) {
@import './public/css/index.scss'; this.diyData = { global: {}, value: null };
}
.small-bot { }
width: 100%; };
height: 100%; </script>
position: fixed;
top: 0; <style lang="scss">
bottom: 0; @import '@/common/css/diy.scss';
left: 0; @import './public/css/index.scss';
right: 0;
z-index: 122; .small-bot {
} width: 100%;
height: 100%;
.small-bot swiper { position: fixed;
width: 560rpx; top: 0;
height: 784rpx; bottom: 0;
margin: 120rpx auto 0; left: 0;
border-radius: 10rpx; right: 0;
overflow: hidden; z-index: 122;
} }
.small-bot swiper .slide-image { .small-bot swiper {
width: 100%; width: 560rpx;
height: 100%; height: 784rpx;
} margin: 120rpx auto 0;
border-radius: 10rpx;
.small-bot-close { overflow: hidden;
width: 66rpx; }
height: 66rpx;
border-radius: 50%; .small-bot swiper .slide-image {
text-align: center; width: 100%;
line-height: 64rpx; height: 100%;
font-size: 64rpx; }
color: #fff;
margin: 30rpx auto 0; .small-bot-close {
} width: 66rpx;
height: 66rpx;
.small-bot-close i { border-radius: 50%;
font-size: 60rpx; text-align: center;
} line-height: 64rpx;
</style> font-size: 64rpx;
<style scoped> color: #fff;
.swiper /deep/ .uni-swiper-dots-horizontal { margin: 30rpx auto 0;
left: 40%; }
bottom: 40px
} .small-bot-close i {
font-size: 60rpx;
.wap-floating>>>.uni-popup__wrapper.uni-custom .uni-popup__wrapper-box { }
background: none !important; </style>
}
<style scoped>
.choose-store>>>.goodslist-uni-popup-box { .swiper /deep/ .uni-swiper-dots-horizontal {
width: 80%; left: 40%;
} bottom: 40px
}
/deep/.diy-index-page .uni-popup .uni-popup__wrapper-box {
border-radius: 0; .wap-floating>>>.uni-popup__wrapper.uni-custom .uni-popup__wrapper-box {
} background: none !important;
}
/deep/ .placeholder {
height: 0; .choose-store>>>.goodslist-uni-popup-box {
} width: 80%;
}
/deep/::-webkit-scrollbar {
width: 0; /deep/.diy-index-page .uni-popup .uni-popup__wrapper-box {
height: 0; border-radius: 0;
background-color: transparent; }
display: none;
} /deep/ .placeholder {
height: 0;
/deep/ .sku-layer .uni-popup__wrapper.uni-custom .uni-popup__wrapper-box { }
max-height: unset !important;
} /deep/::-webkit-scrollbar {
width: 0;
/deep/ .mescroll-totop { height: 0;
/* #ifdef H5 */ background-color: transparent;
right: 28rpx !important; display: none;
bottom: 200rpx !important; }
/* #endif */
/* #ifdef MP-WEIXIN */ /deep/ .sku-layer .uni-popup__wrapper.uni-custom .uni-popup__wrapper-box {
right: 27rpx !important; max-height: unset !important;
bottom: 180rpx !important; }
/* #endif */
} /deep/ .mescroll-totop {
/* #ifdef H5 */
right: 28rpx !important;
bottom: 200rpx !important;
/* #endif */
/* #ifdef MP-WEIXIN */
right: 27rpx !important;
bottom: 180rpx !important;
/* #endif */
}
</style> </style>