From 1f196a5a9cff40dcefa9aec70a6bb3482f8bc44c Mon Sep 17 00:00:00 2001 From: Sliverber <2622874537@qq.com> Date: Wed, 28 Feb 2024 16:04:00 +0800 Subject: [PATCH] =?UTF-8?q?h5=E9=85=8D=E7=BD=AE=E4=BB=A5=E5=8F=8A=E5=BE=AE?= =?UTF-8?q?=E4=BF=A1=E5=85=AC=E4=BC=97=E5=8F=B7=E5=BD=B1=E8=97=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- App.vue | 10 +++---- pages/index/index.vue | 56 ++++++++++++++++++++++++++----------- pages/users/login/index.vue | 7 +++++ 3 files changed, 52 insertions(+), 21 deletions(-) diff --git a/App.vue b/App.vue index 5922ca2..fe76236 100644 --- a/App.vue +++ b/App.vue @@ -143,7 +143,10 @@ } else { this.globalData.isIframe = false; } - + if(option.query.channelId){ + uni.setStorageSync('channelId', option.query.channelId); + + } // wx公众号自动授权登录 let snsapiBase = 'snsapi_base'; let urlData = location.pathname + location.search; @@ -155,10 +158,7 @@ scope } = option.query; console.log(option.query,'option.queryoption.queryoption.query'); - if(option.query.channelId){ - uni.setStorageSync('channelId', option.query.channelId); - - } + if (code && code != uni.getStorageSync('snsapiCode') && location.pathname.indexOf( '/pages/users/wechat_login/index') === -1) { diff --git a/pages/index/index.vue b/pages/index/index.vue index 550fc69..ed46711 100644 --- a/pages/index/index.vue +++ b/pages/index/index.vue @@ -5,7 +5,7 @@ - + @@ -378,7 +378,7 @@ this.setTabList() }, onLoad(options) { - + this.getipdz() // const env = uni.getEnv(); // 获取系统信息 @@ -473,7 +473,8 @@ if (this.isLogin && parseInt(options.channelId) > 0) { silenceBindingChannelId() } - this.getipdz() + + // #ifdef H5 var app_type = this.isWeiXin() ? 'weixinh5' : 'h5'; var app_type_name = this.isWeiXin() ? '微信公众号' : 'H5'; @@ -499,21 +500,14 @@ // #endif uni.showTabBar(); - let currentUrl = window.location.href; - - // 解析URL,提取参数 - let urlParams = new URLSearchParams(currentUrl); - - // 获取名为code的参数的值 - // let codeValue = urlParams.get('code'); - // console.log(codeValue,'codeValuecodeValuecodeValue'); + // console.log('进入了首页'); // const id = uni.getStorageSync('openid'); // if(codeValue){ // console.log('登陆成功',id); // uni.setStorageSync('openid', codeValue); - // let stause= uni.getStorageSync('loginstause'); + // // if(stause){ // console.log('进入判断1'); @@ -541,7 +535,7 @@ uni.showTabBar(); // 调用记录ip - // this.getip() + // this.getipdz() }, methods: { isWeiXin() { @@ -557,9 +551,39 @@ }, // 获取IP地址 getipdz(){ - getip().then(res => { - console.log(res,111) - }) + let codeValue= uni.getStorageSync('channelId'); + if(uni.getStorageSync('channelcs')){ + + }else{ + let cs=false + uni.setStorageSync('channelcs', cs); + } + let acc =uni.getStorageSync('channelcs'); + console.log(acc,'&&acc&&acc'); + if(this.isLogin){ + getip().then(res => { + console.log(res,111) + }) + } + if(codeValue&&acc==false){ + console.log(codeValue,'codeValuecodeValuecodeValue'); + + uni.request({ + url: 'https://yruibao.com/prod/api/front/channel/record?channelId='+codeValue, + // url: 'http://192.168.2.26:20411/api/front/channel/record?channelId='+codeValue, //仅为示例,并非真实接口地址。 + // data: data, + method:'GET', + + success: (res) => { + let add=true + uni.setStorageSync('channelcs', add); + }, + fail:(err)=>{ + + } + }); + } + }, diff --git a/pages/users/login/index.vue b/pages/users/login/index.vue index 3bbbd8f..e847e0e 100644 --- a/pages/users/login/index.vue +++ b/pages/users/login/index.vue @@ -312,10 +312,17 @@ uni.showLoading({ title: '登录中' }) + let channelId=0 + let abb=uni.getStorageSync('channelId') + + if(abb!=undefined){ + channelId=parseInt(abb); + } loginMobile({ phone: that.account, captcha: that.captcha, spread_spid: that.$Cache.get("spread"), + channelId:channelId, })