diff --git a/app.js b/app.js index a188f0a..8bd28a0 100644 --- a/app.js +++ b/app.js @@ -132,24 +132,33 @@ App({ th.globalData.config2 = o.data.data; //有配置成要验证过期,因为过期的小程序没有办法审核 if(th.globalData.config2.is_overdue){ - + //要开始验证,小程序有没有购买和过期 - if(!currentPage || currentPage.route.indexOf('error/error')==-1){ + if(!currentPage || currentPage.route.indexOf('error/error')==-1 || currentPage.route.indexOf('index/index')==-1){ var tt=this.globalData.wxapp_buy_obj; if (!tt){ this.get_isbuy(function (){ tt=th.globalData.wxapp_buy_obj; if (tt.isout == 1){ th.promiseGet('/api/weshop/store/get/'+t.stoid,{}).then(res=>{ - wx.reLaunch({ - url: "/pages/error/error?msg=该商城已到期,暂停浏览!\r\n可联系:"+res.data.data.store_tel, - }); + + if(!th.err_going){ + wx.reLaunch({ + url: "/pages/error/error?msg=该商城已到期,暂停浏览1!\r\n可联系:"+res.data.data.store_tel, + }); + } }) } - else if (tt.isbuy == 0) - wx.reLaunch({ - url: "/pages/error/error?msg=还未购买小程序", - }); + else if (tt.isbuy == 0){ + + if(!th.err_going){ + wx.reLaunch({ + url: "/pages/error/error?msg=还未购买小程序", + }); + } + + } + }) } } diff --git a/pages/error/error.js b/pages/error/error.js index 5f0b0b5..7129986 100644 --- a/pages/error/error.js +++ b/pages/error/error.js @@ -6,7 +6,8 @@ Page({ msg:"", }, - onLoad:function(t){ + onLoad:function(t){ + getApp().err_going=1; var th=this,app = getApp(); app.getConfig(function(e){ th.setData({ store:e,msg:t.msg}); diff --git a/pages/index/index/index.js b/pages/index/index/index.js index 4c57402..d4775ab 100644 --- a/pages/index/index/index.js +++ b/pages/index/index/index.js @@ -108,33 +108,45 @@ Page({ var th = this; - if(getApp().globalData.config2.is_overdue==1){ - getApp().promiseGet("/store/storemoduleendtime/page?store_id=" +stoid + "&type=5",{}).then(res=>{ - var o=res; - if (o.data.code == 0) { - var ob = { isout: 0, isbuy: 1 }; - var arr = o.data.data.pageData; - var isbuy = 0; - //----如果数组不为空---- - if (arr.length > 0) { - arr.forEach(function (val, ind) { - if (val.is_sy == 0 && val.type == 5) { - isbuy = 1; - var now = ut.gettimestamp(); - if (now > val.end_time) ob.isout = 1; - return false; - } - }) - } - ob.isbuy = isbuy; - th.setappdata(ob); - } - }) - - - } - + getApp().getConfig2(function(){ + if(getApp().globalData.config2.is_overdue==1){ + getApp().promiseGet("/store/storemoduleendtime/page?store_id=" +os.stoid + "&type=5",{}).then(res=>{ + var o=res; + if (o.data.code == 0) { + var ob = { isout: 0, isbuy: 1 }; + var arr = o.data.data.pageData; + var isbuy = 0; + //----如果数组不为空---- + if (arr.length > 0) { + arr.forEach(function (val, ind) { + if (val.is_sy == 0 && val.type == 5) { + isbuy = 1; + var now = ut.gettimestamp(); + if (now > val.end_time) ob.isout = 1; + return false; + } + }) + } + ob.isbuy = isbuy; + + var pages = getCurrentPages(); //获取加载的页面 + var currentPage = pages[pages.length - 1]; //获取当前页面的对象 + + console.log("当前路由"); + console.log(currentPage.route); + + + th.setappdata(ob); + + if(ob.isbuy && !ob.isout){ + th.onload_init(); + } + } + }) + + } + }) if(first_leader){ //-- user_id代过来免登录 -- @@ -192,71 +204,74 @@ Page({ //getApp().globalData.url=th.data.url //t.editTabBar(th,o.stoid,th.data.url); - await this.init_load(); - - //显示的时候要开启计时器 - this.data.is_timer = 1; - //如果是自定义模板 - if (this.data.isTemplate) { - //---先获取会员--- - t.getUserFir(function() { - th.is_festival(); - var new_nav = th.data.new_nav; - if (new_nav == "") { - th.is_new(); - } - setTimeout(function () { - if (getApp().globalData.user_id) getApp().requestCardNum(th); - },500) - - }); - } else { - await this.init_fir(); - wx.setNavigationBarColor({ - frontColor: '#ffffff', // 必写项 - backgroundColor: '#ff7295', // 必写项 - }) - } - - //--正再拼团中的处理-- - var url = "/api/weshop/order/pageTuan?pt_status=2&is_pt=1&store_id=" + os.stoid + "&pageSize=6&page=1" - await getApp().request.promiseGet(url, {}).then(res => { - if (res.data.code == 0 && res.data.data && res.data.data.pageData) { - th.data.pt_timer_arr = res.data.data.pageData; - } - }) - if (th.data.pt_timer_arr && th.data.pt_timer_arr.length > 0) { - for (var i in th.data.pt_timer_arr) { - var p_item = th.data.pt_timer_arr[i]; - await getApp().request.promiseGet("/api/weshop/users/get/" + os.stoid + "/" + p_item.user_id, { - 1: 1 - }).then(res => { - th.data.pt_timer_arr[i].head_pic = res.data.data.head_pic; - th.data.pt_timer_arr[i].nickname = res.data.data.nickname; - }) - } - th.Interval_pt(); - } - - //---处理正在6个分类---- - await getApp().request.promiseGet("/api/weshop/goodscategory/page", { - data: { - store_id: os.stoid, - pageSize: 5, - is_show: 1, - level:1 - } - }).then(res => { - if (res.data.data) { - var gd_category = res.data.data.pageData; - th.setData({ - gd_category: gd_category - }); - } - }) - - }, + + async onload_init(){ + var th=this; + await this.init_load(); + //显示的时候要开启计时器 + this.data.is_timer = 1; + //如果是自定义模板 + if (this.data.isTemplate) { + //---先获取会员--- + t.getUserFir(function() { + th.is_festival(); + var new_nav = th.data.new_nav; + if (new_nav == "") { + th.is_new(); + } + setTimeout(function () { + if (getApp().globalData.user_id) getApp().requestCardNum(th); + },500) + + }); + } else { + await this.init_fir(); + wx.setNavigationBarColor({ + frontColor: '#ffffff', // 必写项 + backgroundColor: '#ff7295', // 必写项 + }) + } + + //--正再拼团中的处理-- + var url = "/api/weshop/order/pageTuan?pt_status=2&is_pt=1&store_id=" + os.stoid + "&pageSize=6&page=1" + await getApp().request.promiseGet(url, {}).then(res => { + if (res.data.code == 0 && res.data.data && res.data.data.pageData) { + th.data.pt_timer_arr = res.data.data.pageData; + } + }) + if (th.data.pt_timer_arr && th.data.pt_timer_arr.length > 0) { + for (var i in th.data.pt_timer_arr) { + var p_item = th.data.pt_timer_arr[i]; + await getApp().request.promiseGet("/api/weshop/users/get/" + os.stoid + "/" + p_item.user_id, { + 1: 1 + }).then(res => { + th.data.pt_timer_arr[i].head_pic = res.data.data.head_pic; + th.data.pt_timer_arr[i].nickname = res.data.data.nickname; + }) + } + th.Interval_pt(); + } + + //---处理正在6个分类---- + await getApp().request.promiseGet("/api/weshop/goodscategory/page", { + data: { + store_id: os.stoid, + pageSize: 5, + is_show: 1, + level:1 + } + }).then(res => { + if (res.data.data) { + var gd_category = res.data.data.pageData; + th.setData({ + gd_category: gd_category + }); + } + }) + }, + + //关闭新用户领取广告 close_disgraceful: function() { var th = this; @@ -339,7 +354,7 @@ Page({ //同步初始加载 async init_load() { - + var th=this; //因为营销版本的功能包含了自定义模板的功能,是同时的 //读取全局是否有弄自定义模板 await api.get_template_fir(o.stoid).then(res => {