dingdong-master/pages/index/index.vue

156 lines
4.7 KiB
Vue
Raw Normal View History

2022-04-29 17:23:40 +08:00
<template>
<view>
<index v-if="curPageCode === 'indexPage'" @changeCurPageCode="changeCurPageCode"></index>
2022-05-24 18:03:36 +08:00
<goods-manage v-else-if="curPageCode === 'supplyChainPage'"></goods-manage>
<my-home v-else-if="curPageCode === 'myPage'"></my-home>
2022-05-21 23:49:53 +08:00
<msg-home v-else-if="curPageCode === 'msgPage'"></msg-home>
<module-bar ref="moduleBar" :moduleBarInfos="moduleBarInfos" @getCurPageInfo="getCurPageInfo"></module-bar>
<!-- 首页引导 -->
<vertify-worker-type ref="vertifyWorkerType"></vertify-worker-type>
<!-- 登录校验弹窗 -->
<vertify-login ref="vertifyLogin" @reload="reloadForwardPage"></vertify-login>
2023-03-27 01:52:25 +08:00
<!-- <vertify-phone ref="vertifyPhone" @reload="reloadForwardPage"></vertify-phone> -->
<!-- 订阅授权 -->
2023-05-07 23:07:29 +08:00
<vertify-subscribe ref="vertifySubscribe"></vertify-subscribe>
<vertify-settingSubscribe ref="vertifySettingSubscribe"></vertify-settingSubscribe>
2022-04-29 17:23:40 +08:00
</view>
</template>
<script>
import moduleBar from '@/components/custom-bar/module-bar.vue';
2022-05-24 18:03:36 +08:00
import index from '@/pages/index/index-home.vue';
import myHome from '@/pages/index/my-home.vue';
2022-05-21 23:49:53 +08:00
import msgHome from '@/pages/index/msg-home.vue';
2022-05-24 18:03:36 +08:00
import goodsManage from '@/pages/index/goods-manage.vue';
2022-04-29 17:23:40 +08:00
export default {
components: {
moduleBar,
2022-05-24 18:03:36 +08:00
index,
myHome,
msgHome,
goodsManage
2022-04-29 17:23:40 +08:00
},
data() {
return {
moduleBarInfos: [],
curPageCode: 'indexPage',
forwardingPageCode: null
2022-04-29 17:23:40 +08:00
}
},
2022-06-22 17:40:50 +08:00
onLoad(options) {
this.loadData();
2022-06-22 17:40:50 +08:00
if (options && options.menuCode) {
this.changeCurPageCode(options.menuCode)
}
2022-04-29 17:23:40 +08:00
},
methods: {
async loadData() {
2022-05-24 18:03:36 +08:00
// uni.getSystemInfo({
// success: function(res) {
// console.log('DPR' + res.pixelRatio)
// console.log('宽度:' + res.screenWidth)
// console.log('高度:' + res.screenHeight)
// }
// })
2023-03-27 01:52:25 +08:00
this.moduleBarInfos = await this.$api.data('moduleBarInfos');
let curUserInfo = this.$request.getCurUserInfo();
let _this = this;
2023-05-07 23:07:29 +08:00
2023-03-27 01:52:25 +08:00
if (curUserInfo && curUserInfo.phone && curUserInfo.type != null) {
wx.getSetting({
withSubscriptions: true,
success(res) {
console.log(res.subscriptionsSetting)
2023-05-07 23:07:29 +08:00
if (res.subscriptionsSetting.mainSwitch && (!res.subscriptionsSetting.itemSettings
|| !res.subscriptionsSetting.itemSettings['yqd3p4qsqn1RiyUb8kO4dPqoGKipRQg_y99nGw0jtLE']
|| !res.subscriptionsSetting.itemSettings['gFoPAYF4J6Y_O5OzzNUbvMxTrsAS7aUWffdNH42xhzM'])) {
2023-03-27 01:52:25 +08:00
// 提示授权订单进度消息提示
_this.$refs.vertifySubscribe.showModal();
2023-05-07 23:07:29 +08:00
} else if (!res.subscriptionsSetting.mainSwitch
|| res.subscriptionsSetting.itemSettings['yqd3p4qsqn1RiyUb8kO4dPqoGKipRQg_y99nGw0jtLE'] !== 'accept'
|| res.subscriptionsSetting.itemSettings['gFoPAYF4J6Y_O5OzzNUbvMxTrsAS7aUWffdNH42xhzM'] !== 'accept') {
_this.$refs.vertifySettingSubscribe.showModal();
2023-03-27 01:52:25 +08:00
}
}
})
}
},
reloadForwardPage() {
this.getCurPageInfo({
curPageCode: this.forwardingPageCode
})
},
async getCurPageInfo(data) {
let pageCode = data.curPageCode;
this.forwardingPageCode = pageCode;
// 登录校验
if (['supplyChainPage', 'myPage'].indexOf(pageCode) >= 0) {
let loginRes = await this.authLogin();
if (!loginRes) {
return;
}
}
this.forwardingPageCode = null;
if (pageCode === 'publishPage') {
this.isShowPublish = true;
} else {
this.isShowPublish = false;
this.curPageCode = pageCode;
}
},
async authLogin() {
// 更新缓存中的userInfo
2022-08-10 23:01:52 +08:00
// let res = await this.$request.storageExistUser();
// 获取缓存中的userInfo
let curUserInfo = this.$request.getCurUserInfo();
// 校验提示登录
2022-08-10 23:01:52 +08:00
// if (!curUserInfo || !curUserInfo.openId) {
// this.$refs.vertifyLogin.showModal();
// return false;
// } else {
// this.$refs.vertifyLogin.hideModal();
// }
if (!curUserInfo) {
uni.reLaunch({
url: '/pages/login/login'
})
return false;
}
2022-08-09 20:11:13 +08:00
// 校验是否注册过
if (!curUserInfo.phone) {
2022-08-09 20:11:13 +08:00
uni.reLaunch({
2022-08-10 23:01:52 +08:00
url: '/pages/login/login'
2022-08-09 20:11:13 +08:00
})
return false;
}
2022-08-09 20:11:13 +08:00
// 校验提示获取手机号码
// if (!curUserInfo.phone) {
// this.$refs.vertifyPhone.showModal();
// return false;
// } else {
// this.$refs.vertifyPhone.hideModal();
// }
// 提示选择师傅类型
if (curUserInfo.type == null) {
this.$refs.vertifyWorkerType.showModal();
2022-08-09 20:11:13 +08:00
return false;
}
return true;
},
changeCurPageCode(targetPageCode) {
2022-06-22 17:40:50 +08:00
// #ifdef MP
this.$nextTick(() => {
this.$refs.moduleBar.navChangeByCode(targetPageCode, true);
})
// #endif
2022-04-29 17:23:40 +08:00
}
}
}
</script>
<style scoped>
</style>