Commit 89a1ff17 by 李嘉林

优化加载

parent 8051a704
<template>
<div class="domain" :style="{'--main-color':themeColor['--main-color'],'--minor-color':themeColor['--minor-color']}">
<pageLoading v-if="pageLoading"></pageLoading>
<!-- 自定义导航头 -->
<div style="position:relative;">
<div v-if="showSpokesManHome">
<!-- <div v-if="showSpokesManHome">
<get-index-homepage class="getIndexHomePage"></get-index-homepage>
</div>
</div> -->
<CustomNav :customBgOpacity="customBgOpacity"></CustomNav>
<StoreAddr @toUpdate="reloadEnterShopRule" @toPageLoading="toPageLoading" ref="StoreAddr"></StoreAddr>
<StoreAddr v-if="showStoreAddr" @toUpdate="reloadEnterShopRule" @toPageLoading="toPageLoading" ref="StoreAddr"></StoreAddr>
<ThemeDataPlant></ThemeDataPlant>
<div v-for="(item,index) in pageData" :key="index">
<div v-if="item.componentCode=='banner' && item.componentInfo.visible == 1">
......@@ -126,6 +125,7 @@
<template>
</template>
</div>
<pageLoading v-if="pageLoading"></pageLoading>
<share-popup></share-popup>
<div v-if="showMyCard">
<my-card></my-card>
......@@ -235,9 +235,11 @@ export default {
pageLoading: true,
firstOpenPage: true, //首次打开页面
h5Params: {}, //params
pageOptions: {},
fromPage: "",
customBgOpacity: true, // 沉浸式风格
reloadPage: false, // 切换门店进入首页重新获取相关配置
showStoreAddr: false,
};
},
components:{
......@@ -359,168 +361,10 @@ export default {
if(this.$options) {
Object.assign(this.$data, this.$options.data());
}
this.pageOptions = options;
console.log(new Date().getTime(),'load-----home-onLoad')
console.log(options,this.firstOpenPage,'---------home----options')
log.info(options, '---------home----options')
let h5Params = options && options.params ? JSON.parse(decodeURIComponent(options.params)) : {};
this.h5Params = h5Params;
console.log(h5Params,'--h5Params')
if (Object.keys(h5Params).length > 0 && h5Params.offlineShopCode) {
console.log("设置切换的门店", h5Params.offlineShopCode, getStoreInfo().offlineShopCode);
// 判断是否等于缓存门店,非缓存门店重新设置并初始化
if (h5Params.offlineShopCode != getStoreInfo().offlineShopCode) {
// 存储h5url门店信息
setStoreInfo({
offlineShopCode:h5Params.offlineShopCode,
offlineShopName:h5Params.offlineShopName,
});
this.reloadPage = true;
}
} else {
this.reloadPage = false;
}
console.log(this.reloadPage,'-reloadPage1')
//进页面存储需要绑定的信息
if(options.userId||options.spokesmanRelId) {
wx.setStorage({
key: "becomeInfo",
data: JSON.stringify(options)
});
log.info(wx.getStorageSync("becomeInfo"),'home---wx.getStorageSync("becomeInfo")')
}
if(options.scene){
wx.setStorageSync("firstView", 1);
this.reloadPage = true;
//新二维码扫码进入
let res = await indexApi.getShareSceneRecord(options.scene);
log.info(res,'onLoad-getShareSceneRecord');
if(res.data.code == '200'){
this.page = res.data.data.pageUri;
let sceneObj = JSON.parse(res.data.data.scene);
if(sceneObj.spokesmanRelId){
wx.setStorage({
key: "becomeInfo",
data: JSON.stringify(sceneObj)
});
}
let paramsObj = sceneObj && sceneObj.params ? JSON.parse(decodeURIComponent(sceneObj.params)) : sceneObj;
this.h5Params = paramsObj;
console.log('app-mounted-paramsObj', paramsObj)
if (paramsObj.offlineShopCode) {
// 存在门店参数
setStoreInfo({
offlineShopCode:paramsObj.offlineShopCode,
offlineShopName:paramsObj.offlineShopName,
});
}
wx.setStorageSync('attractingCustomerChannelId',sceneObj.attractingCustomerChannelId);
wx.setStorageSync(this.$store.state.mixid+'storeId',sceneObj.storeId);
wx.setStorageSync(this.$store.state.mixid+'sellerId',sceneObj.sellerId);
log.info(res.data.data,'getShareSceneRecord')
console.log(res.data.data,'----getShareSceneRecord')
log.info(wx.getStorageSync("openid"),'onLoad-openid');
if(wx.getStorageSync("openid")) {
indexApi.addRecord(
{
attractingCustomersChannelId: paramsObj.attractingCustomerChannelId,
miniOpenId: wx.getStorageSync("openid"),
registerFlag: 1,
newRegisterFlag: 0,
}
).then(ele=>{
//清空引客渠道id
if(ele.data.data) {
wx.setStorageSync('attractingCustomerChannelId','');
}
})
}
}
wx.nextTick(() => {
});
}
if (options.from && options.from == "logout") {
//来自用户登出
wx.removeStorage({
key: "sessionid"
});
wx.removeStorage({
key: "openid"
});
wx.removeStorage({
key: "enterpriseAccount"
});
}
this.options = wx.getStorageSync("becomeInfo");
this.changeLocation = options.changeLocation || ''
if(this.changeLocation == 1){
log.info('this.$store.state.extConfig',this.$store.state.extConfig)
app.getShopInfo(this.$store.state.extConfig);
this.getThemeList();
}
let that = this;
if(wx.getStorageSync("sessionid")) {
//获取个人名片入口
app.fenxiaoModel.getHomePageQuickAccess().then(res=>{
that.showMyCard = res;
})
//获取分销信息
log.info(wx.getStorageSync("becomeInfo")?JSON.parse(wx.getStorageSync("becomeInfo")):'','becomeInfo--358')
this.getSpokesmanInit(wx.getStorageSync("becomeInfo")?JSON.parse(wx.getStorageSync("becomeInfo")):'')
}
// 来源
if (options.from == "logout") {
//来自用户登出
wx.removeStorage({
key: "sessionid"
});
wx.removeStorage({
key: "openid"
});
wx.removeStorage({
key: "enterpriseAccount"
});
}
// 获取页面数据
if (this.mpApp.globalData.pageList && !this.reloadPage) {
console.log("获取页面数据-1")
that.init(this.mpApp.globalData.pageList);
} else {
this.mpApp.pageCallBack = function (params) {
console.log("获取页面数据-2",params)
that.init(params);
};
}
if(themeColor['--main-color']!='#ffffff'){
this.themeColor = themeColor
}else {
this.mpApp.themeColorCallBack=(res)=>{
this.themeColor = res
}
}
// 新人有礼弹窗
this.newUserFun();
// 新店调试
this.debugShopFun();
//清除商品列表组件懒加载缓存
// 需清除的缓存keyList
let keyList = ['pageGoodsList','storageDatasList','datasIndex','ids','loadingFlag','pageNumList'];
wx.getStorageInfo({
success (res) {
if(res.keys) {
res.keys.forEach((item,index)=>{
keyList.forEach((item1,index1)=>{
if(item.includes(item1)){
wx.removeStorage({
key: item
})
}
})
})
}
}
})
this.pageInit(options);
},
onShow() {
console.log(new Date().getTime(),'load-----home-onShow')
......@@ -557,6 +401,169 @@ export default {
},200),
methods: {
async pageInit(options) {
log.info(options, '---------home----options')
let h5Params = options && options.params ? JSON.parse(decodeURIComponent(options.params)) : {};
this.h5Params = h5Params;
console.log(h5Params,'--h5Params')
if (Object.keys(h5Params).length > 0 && h5Params.offlineShopCode) {
console.log("设置切换的门店", h5Params.offlineShopCode, getStoreInfo().offlineShopCode);
// 判断是否等于缓存门店,非缓存门店重新设置并初始化
if (h5Params.offlineShopCode != getStoreInfo().offlineShopCode) {
// 存储h5url门店信息
setStoreInfo({
offlineShopCode:h5Params.offlineShopCode,
offlineShopName:h5Params.offlineShopName,
});
this.reloadPage = true;
}
} else {
this.reloadPage = false;
}
console.log(this.reloadPage,'-reloadPage1')
//进页面存储需要绑定的信息
if(options.userId||options.spokesmanRelId) {
wx.setStorage({
key: "becomeInfo",
data: JSON.stringify(options)
});
log.info(wx.getStorageSync("becomeInfo"),'home---wx.getStorageSync("becomeInfo")')
}
if(options.scene){
wx.setStorageSync("firstView", 1);
this.reloadPage = true;
//新二维码扫码进入
let res = await indexApi.getShareSceneRecord(options.scene);
log.info(res,'onLoad-getShareSceneRecord');
if(res.data.code == '200'){
this.page = res.data.data.pageUri;
let sceneObj = JSON.parse(res.data.data.scene);
if(sceneObj.spokesmanRelId){
wx.setStorage({
key: "becomeInfo",
data: JSON.stringify(sceneObj)
});
}
let paramsObj = sceneObj && sceneObj.params ? JSON.parse(decodeURIComponent(sceneObj.params)) : sceneObj;
this.h5Params = paramsObj;
console.log('app-mounted-paramsObj', paramsObj)
if (paramsObj.offlineShopCode) {
// 存在门店参数
setStoreInfo({
offlineShopCode:paramsObj.offlineShopCode,
offlineShopName:paramsObj.offlineShopName,
});
}
this.showStoreAddr = true;
wx.setStorageSync('attractingCustomerChannelId',sceneObj.attractingCustomerChannelId);
wx.setStorageSync(this.$store.state.mixid+'storeId',sceneObj.storeId);
wx.setStorageSync(this.$store.state.mixid+'sellerId',sceneObj.sellerId);
log.info(res.data.data,'getShareSceneRecord')
console.log(res.data.data,'----getShareSceneRecord')
log.info(wx.getStorageSync("openid"),'onLoad-openid');
if(wx.getStorageSync("openid")) {
indexApi.addRecord(
{
attractingCustomersChannelId: paramsObj.attractingCustomerChannelId,
miniOpenId: wx.getStorageSync("openid"),
registerFlag: 1,
newRegisterFlag: 0,
}
).then(ele=>{
//清空引客渠道id
if(ele.data.data) {
wx.setStorageSync('attractingCustomerChannelId','');
}
})
}
}
} else {
this.showStoreAddr = true;
}
if (options.from && options.from == "logout") {
//来自用户登出
wx.removeStorage({
key: "sessionid"
});
wx.removeStorage({
key: "openid"
});
wx.removeStorage({
key: "enterpriseAccount"
});
}
this.options = wx.getStorageSync("becomeInfo");
this.changeLocation = options.changeLocation || ''
if(this.changeLocation == 1){
log.info('this.$store.state.extConfig',this.$store.state.extConfig)
app.getShopInfo(this.$store.state.extConfig);
this.getThemeList();
}
let that = this;
if(wx.getStorageSync("sessionid")) {
//获取个人名片入口
app.fenxiaoModel.getHomePageQuickAccess().then(res=>{
that.showMyCard = res;
})
//获取分销信息
log.info(wx.getStorageSync("becomeInfo")?JSON.parse(wx.getStorageSync("becomeInfo")):'','becomeInfo--358')
this.getSpokesmanInit(wx.getStorageSync("becomeInfo")?JSON.parse(wx.getStorageSync("becomeInfo")):'')
}
// 来源
if (options.from == "logout") {
//来自用户登出
wx.removeStorage({
key: "sessionid"
});
wx.removeStorage({
key: "openid"
});
wx.removeStorage({
key: "enterpriseAccount"
});
}
// 获取页面数据
if (this.mpApp.globalData.pageList && !this.reloadPage) {
console.log("获取页面数据-1")
that.init(this.mpApp.globalData.pageList);
} else {
this.mpApp.pageCallBack = function (params) {
console.log("获取页面数据-2",params)
that.init(params);
};
}
if(themeColor['--main-color']!='#ffffff'){
this.themeColor = themeColor
}else {
this.mpApp.themeColorCallBack=(res)=>{
this.themeColor = res
}
}
// 新人有礼弹窗
this.newUserFun();
// 新店调试
this.debugShopFun();
//清除商品列表组件懒加载缓存
// 需清除的缓存keyList
let keyList = ['pageGoodsList','storageDatasList','datasIndex','ids','loadingFlag','pageNumList'];
wx.getStorageInfo({
success (res) {
if(res.keys) {
res.keys.forEach((item,index)=>{
keyList.forEach((item1,index1)=>{
if(item.includes(item1)){
wx.removeStorage({
key: item
})
}
})
})
}
}
})
},
setPageLoading() {
setTimeout(() => {
this.pageLoading = false;
......@@ -564,7 +571,6 @@ export default {
},
reloadEnterShopRule() {
console.log('eloadEnterShopRule', this.h5Params)
// 进店规则--首次进店调用
if (this.h5Params && this.h5Params.offlineShopCode) {
console.log("refreshInit--------2")
this.refreshInit();
......@@ -572,6 +578,7 @@ export default {
return;
};
console.log('home-methods-reloadEnterShopRule')
// 进店规则--首次进店调用
if (wx.getStorageSync("firstView") == 1) {
console.log('reloadEnterShopRule-------1')
wx.removeStorageSync("firstView");
......
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