diff --git a/App.vue b/App.vue index 5547276..17f4174 100644 --- a/App.vue +++ b/App.vue @@ -72,7 +72,14 @@ }, - onLaunch: function() {}, + onLaunch: function() { + // uni.addInterceptor('request',{ + // invoke(e){ + // console.log(e,"e") + // } + // }) + + }, onShow: function() { // #ifdef MP let accountInfo = uni.getAccountInfoSync(); @@ -135,6 +142,7 @@ } } }) + uni.getStorage({ key: 'user', success(e) { diff --git a/common/share.js b/common/share.js index 2f13c04..b603ef9 100644 --- a/common/share.js +++ b/common/share.js @@ -118,12 +118,30 @@ export default { }, + isNotDoShare(){ + /* 不做分享 */ + let arr =[ + "/subPages/shareCounpon/shareCounpon",//分享领取优惠券 + "/", + + ]; + let str = window.location.href.split('#')[1]; + str = str.split("?")[0]; + // console.log(str,"str==================================") + return arr.includes(str) + + + } }, onLoad() { // #ifdef H5 this.$nextTick(() => { + if(this.isNotDoShare()){ + return ; + } + // console.log(this.isNotDoShare(),"==================") this.doShare(); }) // #endif @@ -131,6 +149,9 @@ export default { onShow(){ // #ifdef H5 this.$nextTick(()=>{ + if(this.isNotDoShare()){ + return ; + } this.h5ShareMethod(); }) // #endif diff --git a/pages/goods/externalCoupon/externalCoupon.vue b/pages/goods/externalCoupon/externalCoupon.vue index f71c7ac..13fb42d 100644 --- a/pages/goods/externalCoupon/externalCoupon.vue +++ b/pages/goods/externalCoupon/externalCoupon.vue @@ -198,30 +198,82 @@ } }, onShow() { - uni.getStorage({ - key: 'user', - success: (res) => { - app.globalData.userInfo = res.data; - if (app.globalData.userInfo.phone) { - this.userInfo = 2; - } else { + // uni.getStorage({ + // key: 'user', + // success: (res) => { + // app.globalData.userInfo = res.data; + // if (app.globalData.userInfo.phone) { + // this.userInfo = 2; + // } else { + // this.userInfo = 1; + // } + // }, + // fail() { + // this.userInfo = 1; + // } + // }); + + + setTimeout(()=>{ + /* let res = uni.getStorageSync("user"); + app.globalData.userInfo = res; + console.log(app.globalData.userInfo,"=========app.globalData.userInfo=========") + if (app.globalData.userInfo.phone) { + this.userInfo = 2; + } else { + this.userInfo = 1; + } */ + + uni.getStorage({ + key: 'user', + success: (res) => { + app.globalData.userInfo = res.data; + if (app.globalData.userInfo.phone) { + this.userInfo = 2; + } else { + this.userInfo = 1; + } + }, + fail() { this.userInfo = 1; } - }, - fail() { - this.userInfo = 1; - } - }); - + }); + + + },0) + + // let res = uni.getStorageSync("user"); + // app.globalData.userInfo = res; + // console.log(app.globalData.userInfo,"=========app.globalData.userInfo=========") + // if (app.globalData.userInfo.phone) { + // this.userInfo = 2; + // } else { + // this.userInfo = 1; + // } + + + + + + this.getDiscountByQrCode(); }, onLoad() { - var arr1 = window.location.href; - var arr2 = arr1.split('='); - if (!app.globalData.openId) { - this.getH5AccessToken(arr2[1]); - } - this.getDiscountByQrCode(); + // var arr1 = window.location.href; + // var arr2 = arr1.split('='); + // if (!app.globalData.openId) { + // this.getH5AccessToken(arr2[1]); + // } + + // 如果没登录 + // if(!app.globalData.userInfo&&!app.globalData.token){ + // uni.navigateTo({ + // url: '/pages/login/register' + // }) + // return + // } + + }, created() { @@ -408,15 +460,31 @@ //商品跳转 toGoods(e) { if (app.globalData.userInfo) { - uni.navigateTo({ - url: '../../order/confirmation?type=2&id=' + e - }) + + if(this.couponsDetails.highDiscountAgentCode.status != 1){ + uni.navigateTo({ + url: '../../order/confirmation?type=2&id=' + e + }) + }else{ + uni.showToast({ + icon: 'none', + title: '未领取优惠券', + duration: 2000 + }) + } + + } else { uni.showToast({ icon: 'none', - title: '请点击领取后再使用', + title: '请登录后再使用', duration: 2000 }) + uni.navigateTo({ + url: '/pages/login/register' + }) + + } }, //跳转列表 @@ -569,7 +637,7 @@ } .headbgimg { - position: absolute; + position: absolute !important; } .contents { diff --git a/pages/login/register.vue b/pages/login/register.vue index 13978bd..20705bf 100644 --- a/pages/login/register.vue +++ b/pages/login/register.vue @@ -158,7 +158,8 @@ phone: this.phoneNumber, type: "SMS", platform: "H5", - smsCode: this.code + smsCode: this.code, + openIdH5:app.globalData.openId } phone(params).then(res => { uni.hideLoading(); diff --git a/pages/tabBar/user/user.vue b/pages/tabBar/user/user.vue index 97176a4..b27d93c 100644 --- a/pages/tabBar/user/user.vue +++ b/pages/tabBar/user/user.vue @@ -590,7 +590,7 @@ }, toPage(url, item) { let that = this; - if (item != '客服') { + if (item != '客服'&&url!="") { uni.navigateTo({ url: url }) diff --git a/pages/welcome/welcome.vue b/pages/welcome/welcome.vue index 192a160..9fe7c9d 100644 --- a/pages/welcome/welcome.vue +++ b/pages/welcome/welcome.vue @@ -83,6 +83,8 @@ // 0016分享的界面跳转进来 if (app.globalData.accountType == '0000011&key' && app.globalData.h5code) { + + uni.navigateTo({ url: '/pages/goods/externalCoupon/externalCoupon' }) @@ -206,29 +208,38 @@ }) }, //H5 获取openId - getH5AccessToken() { + async getH5AccessToken() { let params = { code: app.globalData.h5code } - getH5AccessToken(params).then(res => { - if (res.return_code == '000000' && res.return_data.openid) { - app.globalData.openId = res.return_data.openid; - uni.setStorage({ - key: "openId", - data: res.return_data.openid - }) - this.getH5AccessByOpenId(); - } else { - this.jumpcdx(); - } - }); + + let res = await getH5AccessToken(params); + + if (res.return_code == '000000' && res.return_data.openid) { + app.globalData.openId = res.return_data.openid; + // uni.setStorage({ + // key: "openId", + // data: res.return_data.openid + // }) + + uni.setStorageSync("openId",res.return_data.openid); + + await this.getH5AccessByOpenId(); + } else { + this.jumpcdx(); + } + }, //判断手机号 - getH5AccessByOpenId() { + async getH5AccessByOpenId() { let datas = { openId: app.globalData.openId } - getH5AccessByOpenId(datas).then(res => { + + let res = await getH5AccessByOpenId(datas); + + + if(res.return_data.object&&res.return_data.uniqueCode){ app.globalData.userInfo = res.return_data .object .highUser; @@ -243,7 +254,22 @@ key: "token", data: res.return_data.uniqueCode }) - }) + }else{ + app.globalData.userInfo = ''; + app.globalData.token = ''; + uni.setStorage({ + key: "user", + data: '' + }) + uni.setStorage({ + key: "token", + data: '' + }) + } + + + + }, jumpcdx() { let str =encodeURIComponent(app.globalData.h5url+"/index.html#/")