93 lines
2.1 KiB
JavaScript
93 lines
2.1 KiB
JavaScript
export default {
|
|
data() {
|
|
return {
|
|
minScrollTop: 100,
|
|
wechatQrcode: '',
|
|
diyRoute: '/pages/index/index'
|
|
};
|
|
},
|
|
onLoad(option) {
|
|
// #ifdef H5
|
|
if (option.module && option.module == 'locationPicker') {
|
|
option.name = '';
|
|
}
|
|
// #endif
|
|
this.name = option.name || 'DIY_VIEW_INDEX';
|
|
},
|
|
onShow() {
|
|
this.getFollowQrcode();
|
|
// 页面显示时,检查是否需要弹窗
|
|
this.checkAndShowPrivacy();
|
|
},
|
|
mounted() {
|
|
this.unsubscribe = this.$eventBus?.onMany([
|
|
'rubik-cube-tap',
|
|
'picture-tap',
|
|
'text-tap',
|
|
'goods-list-tap',
|
|
'presale-tap',
|
|
'notes-tap',
|
|
'merch-list-tap',
|
|
'map-tap',
|
|
'img-ads-tap',
|
|
'many-goods-list-tap',
|
|
'search-tap',
|
|
], this._handleDiyGroupInteractionEvent);
|
|
},
|
|
beforeDestroy() {
|
|
if (this.unsubscribe) this.unsubscribe();
|
|
},
|
|
methods: {
|
|
// --- 新增:检查并显示隐私弹窗 ---
|
|
checkAndShowPrivacy() {
|
|
// 1. 为了测试,先强制清除缓存(正式发布时请删除下面这行)
|
|
uni.removeStorageSync('privacyAgreed');
|
|
|
|
// 2. 获取缓存状态
|
|
const hasAgreed = uni.getStorageSync('privacyAgreed');
|
|
|
|
// 3. 如果没有同意过,且组件已加载,强制调用组件的 popUp 方法
|
|
if (!hasAgreed) {
|
|
this.$nextTick(() => {
|
|
if (this.$refs.privacyPopup) {
|
|
console.log('强制调用 privacyPopup.popUp()');
|
|
// 直接调用组件里的 popUp 方法,把 showPop 设为 true
|
|
this.$refs.privacyPopup.popUp();
|
|
}
|
|
});
|
|
}
|
|
},
|
|
|
|
// 关注公众号
|
|
getFollowQrcode() {
|
|
if (!this.$util.isWeiXin()) return;
|
|
this.$api.sendRequest({
|
|
url: '/wechat/api/wechat/followqrcode',
|
|
success: res => {
|
|
if (res.code >= 0 && res.data) {
|
|
this.wechatQrcode = res.data.qrcode;
|
|
}
|
|
}
|
|
});
|
|
},
|
|
officialAccountsOpen() {
|
|
this.$refs.officialAccountsPopup.open();
|
|
},
|
|
officialAccountsClose() {
|
|
this.$refs.officialAccountsPopup.close();
|
|
},
|
|
// 统一处理点击及触摸事件
|
|
_handleDiyGroupInteractionEvent(payload) {
|
|
// #ifdef H5
|
|
return true;
|
|
// #endif
|
|
|
|
if (this.storeToken) {
|
|
return true;
|
|
}
|
|
|
|
this.$refs.login?.open();
|
|
return false;
|
|
}
|
|
}
|
|
} |