Commit a16c22b4f08f531ee9a51a5bbc63f6c10fecac8f

Authored by yvan.ni
1 parent 17db6221

白屏的处理

@@ -132,24 +132,33 @@ App({ @@ -132,24 +132,33 @@ App({
132 th.globalData.config2 = o.data.data; 132 th.globalData.config2 = o.data.data;
133 //有配置成要验证过期,因为过期的小程序没有办法审核 133 //有配置成要验证过期,因为过期的小程序没有办法审核
134 if(th.globalData.config2.is_overdue){ 134 if(th.globalData.config2.is_overdue){
135 - 135 +
136 //要开始验证,小程序有没有购买和过期 136 //要开始验证,小程序有没有购买和过期
137 - if(!currentPage || currentPage.route.indexOf('error/error')==-1){ 137 + if(!currentPage || currentPage.route.indexOf('error/error')==-1 || currentPage.route.indexOf('index/index')==-1){
138 var tt=this.globalData.wxapp_buy_obj; 138 var tt=this.globalData.wxapp_buy_obj;
139 if (!tt){ 139 if (!tt){
140 this.get_isbuy(function (){ 140 this.get_isbuy(function (){
141 tt=th.globalData.wxapp_buy_obj; 141 tt=th.globalData.wxapp_buy_obj;
142 if (tt.isout == 1){ 142 if (tt.isout == 1){
143 th.promiseGet('/api/weshop/store/get/'+t.stoid,{}).then(res=>{ 143 th.promiseGet('/api/weshop/store/get/'+t.stoid,{}).then(res=>{
144 - wx.reLaunch({  
145 - url: "/pages/error/error?msg=该商城已到期,暂停浏览!\r\n可联系:"+res.data.data.store_tel,  
146 - }); 144 +
  145 + if(!th.err_going){
  146 + wx.reLaunch({
  147 + url: "/pages/error/error?msg=该商城已到期,暂停浏览1!\r\n可联系:"+res.data.data.store_tel,
  148 + });
  149 + }
147 }) 150 })
148 } 151 }
149 - else if (tt.isbuy == 0)  
150 - wx.reLaunch({  
151 - url: "/pages/error/error?msg=还未购买小程序",  
152 - }); 152 + else if (tt.isbuy == 0){
  153 +
  154 + if(!th.err_going){
  155 + wx.reLaunch({
  156 + url: "/pages/error/error?msg=还未购买小程序",
  157 + });
  158 + }
  159 +
  160 + }
  161 +
153 }) 162 })
154 } 163 }
155 } 164 }
pages/error/error.js
@@ -6,7 +6,8 @@ Page({ @@ -6,7 +6,8 @@ Page({
6 msg:"", 6 msg:"",
7 }, 7 },
8 8
9 - onLoad:function(t){ 9 + onLoad:function(t){
  10 + getApp().err_going=1;
10 var th=this,app = getApp(); 11 var th=this,app = getApp();
11 app.getConfig(function(e){ 12 app.getConfig(function(e){
12 th.setData({ store:e,msg:t.msg}); 13 th.setData({ store:e,msg:t.msg});
pages/index/index/index.js
@@ -108,33 +108,45 @@ Page({ @@ -108,33 +108,45 @@ Page({
108 108
109 109
110 var th = this; 110 var th = this;
111 - if(getApp().globalData.config2.is_overdue==1){  
112 - getApp().promiseGet("/store/storemoduleendtime/page?store_id=" +stoid + "&type=5",{}).then(res=>{  
113 - var o=res;  
114 - if (o.data.code == 0) {  
115 - var ob = { isout: 0, isbuy: 1 };  
116 - var arr = o.data.data.pageData;  
117 - var isbuy = 0;  
118 - //----如果数组不为空----  
119 - if (arr.length > 0) {  
120 - arr.forEach(function (val, ind) {  
121 - if (val.is_sy == 0 && val.type == 5) {  
122 - isbuy = 1;  
123 - var now = ut.gettimestamp();  
124 - if (now > val.end_time) ob.isout = 1;  
125 - return false;  
126 - }  
127 - })  
128 - }  
129 - ob.isbuy = isbuy;  
130 - th.setappdata(ob);  
131 - }  
132 - })  
133 -  
134 -  
135 - }  
136 -  
137 111
  112 + getApp().getConfig2(function(){
  113 + if(getApp().globalData.config2.is_overdue==1){
  114 + getApp().promiseGet("/store/storemoduleendtime/page?store_id=" +os.stoid + "&type=5",{}).then(res=>{
  115 + var o=res;
  116 + if (o.data.code == 0) {
  117 + var ob = { isout: 0, isbuy: 1 };
  118 + var arr = o.data.data.pageData;
  119 + var isbuy = 0;
  120 + //----如果数组不为空----
  121 + if (arr.length > 0) {
  122 + arr.forEach(function (val, ind) {
  123 + if (val.is_sy == 0 && val.type == 5) {
  124 + isbuy = 1;
  125 + var now = ut.gettimestamp();
  126 + if (now > val.end_time) ob.isout = 1;
  127 + return false;
  128 + }
  129 + })
  130 + }
  131 + ob.isbuy = isbuy;
  132 +
  133 + var pages = getCurrentPages(); //获取加载的页面
  134 + var currentPage = pages[pages.length - 1]; //获取当前页面的对象
  135 +
  136 + console.log("当前路由");
  137 + console.log(currentPage.route);
  138 +
  139 +
  140 + th.setappdata(ob);
  141 +
  142 + if(ob.isbuy && !ob.isout){
  143 + th.onload_init();
  144 + }
  145 + }
  146 + })
  147 +
  148 + }
  149 + })
138 150
139 if(first_leader){ 151 if(first_leader){
140 //-- user_id代过来免登录 -- 152 //-- user_id代过来免登录 --
@@ -192,71 +204,74 @@ Page({ @@ -192,71 +204,74 @@ Page({
192 //getApp().globalData.url=th.data.url 204 //getApp().globalData.url=th.data.url
193 //t.editTabBar(th,o.stoid,th.data.url); 205 //t.editTabBar(th,o.stoid,th.data.url);
194 206
195 - await this.init_load();  
196 -  
197 - //显示的时候要开启计时器  
198 - this.data.is_timer = 1;  
199 - //如果是自定义模板  
200 - if (this.data.isTemplate) {  
201 - //---先获取会员---  
202 - t.getUserFir(function() {  
203 - th.is_festival();  
204 - var new_nav = th.data.new_nav;  
205 - if (new_nav == "") {  
206 - th.is_new();  
207 - }  
208 - setTimeout(function () {  
209 - if (getApp().globalData.user_id) getApp().requestCardNum(th);  
210 - },500)  
211 -  
212 - });  
213 - } else {  
214 - await this.init_fir();  
215 - wx.setNavigationBarColor({  
216 - frontColor: '#ffffff', // 必写项  
217 - backgroundColor: '#ff7295', // 必写项  
218 - })  
219 - }  
220 -  
221 - //--正再拼团中的处理--  
222 - var url = "/api/weshop/order/pageTuan?pt_status=2&is_pt=1&store_id=" + os.stoid + "&pageSize=6&page=1"  
223 - await getApp().request.promiseGet(url, {}).then(res => {  
224 - if (res.data.code == 0 && res.data.data && res.data.data.pageData) {  
225 - th.data.pt_timer_arr = res.data.data.pageData;  
226 - }  
227 - })  
228 - if (th.data.pt_timer_arr && th.data.pt_timer_arr.length > 0) {  
229 - for (var i in th.data.pt_timer_arr) {  
230 - var p_item = th.data.pt_timer_arr[i];  
231 - await getApp().request.promiseGet("/api/weshop/users/get/" + os.stoid + "/" + p_item.user_id, {  
232 - 1: 1  
233 - }).then(res => {  
234 - th.data.pt_timer_arr[i].head_pic = res.data.data.head_pic;  
235 - th.data.pt_timer_arr[i].nickname = res.data.data.nickname;  
236 - })  
237 - }  
238 - th.Interval_pt();  
239 - }  
240 -  
241 - //---处理正在6个分类----  
242 - await getApp().request.promiseGet("/api/weshop/goodscategory/page", {  
243 - data: {  
244 - store_id: os.stoid,  
245 - pageSize: 5,  
246 - is_show: 1,  
247 - level:1  
248 - }  
249 - }).then(res => {  
250 - if (res.data.data) {  
251 - var gd_category = res.data.data.pageData;  
252 - th.setData({  
253 - gd_category: gd_category  
254 - });  
255 - }  
256 - })  
257 -  
258 -  
259 }, 207 },
  208 +
  209 + async onload_init(){
  210 + var th=this;
  211 + await this.init_load();
  212 + //显示的时候要开启计时器
  213 + this.data.is_timer = 1;
  214 + //如果是自定义模板
  215 + if (this.data.isTemplate) {
  216 + //---先获取会员---
  217 + t.getUserFir(function() {
  218 + th.is_festival();
  219 + var new_nav = th.data.new_nav;
  220 + if (new_nav == "") {
  221 + th.is_new();
  222 + }
  223 + setTimeout(function () {
  224 + if (getApp().globalData.user_id) getApp().requestCardNum(th);
  225 + },500)
  226 +
  227 + });
  228 + } else {
  229 + await this.init_fir();
  230 + wx.setNavigationBarColor({
  231 + frontColor: '#ffffff', // 必写项
  232 + backgroundColor: '#ff7295', // 必写项
  233 + })
  234 + }
  235 +
  236 + //--正再拼团中的处理--
  237 + var url = "/api/weshop/order/pageTuan?pt_status=2&is_pt=1&store_id=" + os.stoid + "&pageSize=6&page=1"
  238 + await getApp().request.promiseGet(url, {}).then(res => {
  239 + if (res.data.code == 0 && res.data.data && res.data.data.pageData) {
  240 + th.data.pt_timer_arr = res.data.data.pageData;
  241 + }
  242 + })
  243 + if (th.data.pt_timer_arr && th.data.pt_timer_arr.length > 0) {
  244 + for (var i in th.data.pt_timer_arr) {
  245 + var p_item = th.data.pt_timer_arr[i];
  246 + await getApp().request.promiseGet("/api/weshop/users/get/" + os.stoid + "/" + p_item.user_id, {
  247 + 1: 1
  248 + }).then(res => {
  249 + th.data.pt_timer_arr[i].head_pic = res.data.data.head_pic;
  250 + th.data.pt_timer_arr[i].nickname = res.data.data.nickname;
  251 + })
  252 + }
  253 + th.Interval_pt();
  254 + }
  255 +
  256 + //---处理正在6个分类----
  257 + await getApp().request.promiseGet("/api/weshop/goodscategory/page", {
  258 + data: {
  259 + store_id: os.stoid,
  260 + pageSize: 5,
  261 + is_show: 1,
  262 + level:1
  263 + }
  264 + }).then(res => {
  265 + if (res.data.data) {
  266 + var gd_category = res.data.data.pageData;
  267 + th.setData({
  268 + gd_category: gd_category
  269 + });
  270 + }
  271 + })
  272 + },
  273 +
  274 +
260 //关闭新用户领取广告 275 //关闭新用户领取广告
261 close_disgraceful: function() { 276 close_disgraceful: function() {
262 var th = this; 277 var th = this;
@@ -339,7 +354,7 @@ Page({ @@ -339,7 +354,7 @@ Page({
339 354
340 //同步初始加载 355 //同步初始加载
341 async init_load() { 356 async init_load() {
342 - 357 + var th=this;
343 //因为营销版本的功能包含了自定义模板的功能,是同时的 358 //因为营销版本的功能包含了自定义模板的功能,是同时的
344 //读取全局是否有弄自定义模板 359 //读取全局是否有弄自定义模板
345 await api.get_template_fir(o.stoid).then(res => { 360 await api.get_template_fir(o.stoid).then(res => {