diff --git a/App.vue b/App.vue index 4c15131..b761e0a 100644 --- a/App.vue +++ b/App.vue @@ -4,11 +4,28 @@ projectname:'', // 项目名称 lat:'', // 公司地址维度 lng:'' ,// 公司地址经度 - hostapi:'https://www.baidu.com' // 域名配置 + hostapi:'http://caimall.scdxtc.cn' // 域名配置 }, // 优先于show方法 onLaunch: function() { - + uni.login({ + success: (res) => { + uni.request({ + url: this.globalData.hostapi +'/api/user/login', + data:{code:res.code}, + success: (result) => { + console.log(result); + uni.setStorageSync('userId',result.data.account_id); + uni.setStorageSync('token',result.data.data.token);//缓存token + uni.setStorageSync('openid',result.data.data.openid);//缓存openid + uni.setStorageSync('expire',result.data.data.expire);//缓存失效时间(时间戳格式) + uni.setStorageSync('phone_active',result.data.data.phone_active);//是否授权手机号 + uni.setStorageSync('is_active',result.data.data.is_active);//是否授权头像和昵称 + uni.setStorageSync('invite_code',result.data.data.invite_code);//缓存邀请码 + } + }) + } + }) }, onShow: function() { if(uni.getStorageSync('token')){ diff --git a/components/foot-tabs/foot-tab.vue b/components/foot-tabs/foot-tab.vue index a1cab8f..b97aa47 100644 --- a/components/foot-tabs/foot-tab.vue +++ b/components/foot-tabs/foot-tab.vue @@ -109,7 +109,7 @@ if(index==0){ uni.reLaunch({url:'/pages/tabbar/pagehome/pagehome'}) } else { - // if(!this.$toolAll.tools.judgeAuth()) { + if(this.$toolAll.tools.judgeAuth()) { // 已授权 switch (index){ case 1: @@ -122,12 +122,7 @@ uni.reLaunch({url:'/pages/tabbar/my/my'}) break; } - // } else { - // // 未授权 - // uni.navigateTo({ - // url:'/pages/login/login' - // }) - // } + } } } } diff --git a/jsFile/tools.js b/jsFile/tools.js index 5b0723a..5fe4a07 100644 --- a/jsFile/tools.js +++ b/jsFile/tools.js @@ -383,10 +383,11 @@ const tools = { judgeAuth(){ let auth = false; clearTimeout(this.authTimer); + console.log(uni.getStorageSync('token'),1234); if(!uni.getStorageSync('token')) { - this.showToast('请登录'); + this.showToast('请授权登录'); this.authTimer = setTimeout(()=>{ - uni.navigateTo({url:'/pages/login/login'}); + uni.reLaunch({url:'/pagesB/login/login'}); },2000) } else { auth = true; diff --git a/pages/tabbar/pagehome/pagehome.vue b/pages/tabbar/pagehome/pagehome.vue index 2106d97..5350685 100644 --- a/pages/tabbar/pagehome/pagehome.vue +++ b/pages/tabbar/pagehome/pagehome.vue @@ -45,16 +45,16 @@ padt:uni.getSystemInfoSync().statusBarHeight + 50, headHeight:'',//头部导航高 list:[ - {url:'/pages/tabbar/cate/cate?index=0',iconsrc:'/static/deleteImg/icon-ge-01.png',iconWidth:60,iconHeight:60,title:'推荐套装'}, - {url:'/pages/tabbar/cate/cate?index=1',iconsrc:'/static/deleteImg/icon-ge-02.png',iconWidth:60,iconHeight:60,title:'喜糖组合'}, - {url:'/pages/tabbar/cate/cate?index=2',iconsrc:'/static/deleteImg/icon-ge-03.png',iconWidth:60,iconHeight:60,title:'喜盒自选'}, - {url:'/pages/tabbar/cate/cate?index=3',iconsrc:'/static/deleteImg/icon-ge-04.png',iconWidth:60,iconHeight:60,title:'喜糖自选'}, - {url:'/pages/tabbar/cate/cate?index=4',iconsrc:'/static/deleteImg/icon-ge-05.png',iconWidth:60,iconHeight:60,title:'迎宾糖散糖'}, - {url:'/pages/tabbar/cate/cate?index=5',iconsrc:'/static/deleteImg/icon-ge-06.png',iconWidth:60,iconHeight:60,title:'瓜子花生'}, - {url:'/pages/tabbar/cate/cate?index=6',iconsrc:'/static/deleteImg/icon-ge-07.png',iconWidth:60,iconHeight:60,title:'伴手礼'}, - {url:'/pagesB/buy-read/buy-read',iconsrc:'/static/deleteImg/icon-ge-08.png',iconWidth:60,iconHeight:60,title:'购买须知'}, - {url:'/pagesB/business-profile/business-profile',iconsrc:'/static/deleteImg/icon-ge-09.png',iconWidth:60,iconHeight:60,title:'商家简介'}, - {url:'/pages/tabbar/cate/cate?index=0',iconsrc:'/static/deleteImg/icon-ge-10.png',iconWidth:60,iconHeight:60,title:'其他推荐'}, + {url:'/pages/tabbar/cate/cate?index=0',iconsrc:'/static/deleteImg/icon-ge-01.png',iconWidth:48,iconHeight:50,title:'推荐套装'}, + {url:'/pages/tabbar/cate/cate?index=1',iconsrc:'/static/deleteImg/icon-ge-02.png',iconWidth:56,iconHeight:54,title:'喜糖组合'}, + {url:'/pages/tabbar/cate/cate?index=2',iconsrc:'/static/deleteImg/icon-ge-03.png',iconWidth:64,iconHeight:46,title:'喜盒自选'}, + {url:'/pages/tabbar/cate/cate?index=3',iconsrc:'/static/deleteImg/icon-ge-04.png',iconWidth:48,iconHeight:48,title:'喜糖自选'}, + {url:'/pages/tabbar/cate/cate?index=4',iconsrc:'/static/deleteImg/icon-ge-05.png',iconWidth:56,iconHeight:58,title:'迎宾糖散糖'}, + {url:'/pages/tabbar/cate/cate?index=5',iconsrc:'/static/deleteImg/icon-ge-06.png',iconWidth:58,iconHeight:52,title:'瓜子花生'}, + {url:'/pages/tabbar/cate/cate?index=6',iconsrc:'/static/deleteImg/icon-ge-07.png',iconWidth:48,iconHeight:54,title:'伴手礼'}, + {url:'/pagesB/buy-read/buy-read',iconsrc:'/static/deleteImg/icon-ge-08.png',iconWidth:44,iconHeight:56,title:'购买须知'}, + {url:'/pagesB/business-profile/business-profile',iconsrc:'/static/deleteImg/icon-ge-09.png',iconWidth:54,iconHeight:50,title:'商家简介'}, + {url:'/pages/tabbar/cate/cate?index=0',iconsrc:'/static/deleteImg/icon-ge-10.png',iconWidth:52,iconHeight:52,title:'其他推荐'}, ], keyword:'', isplay:false, diff --git a/pagesB/login/login.vue b/pagesB/login/login.vue index 6883869..5e4eb4b 100644 --- a/pagesB/login/login.vue +++ b/pagesB/login/login.vue @@ -1,15 +1,15 @@