修改领取优惠油券时获取不到openid问题

ymt-db-dev
游梦婷 1 year ago
parent 8fddf4e34f
commit f2b4abb72a
  1. 10
      App.vue
  2. 21
      common/share.js
  3. 84
      pages/goods/externalCoupon/externalCoupon.vue
  4. 3
      pages/login/register.vue
  5. 2
      pages/tabBar/user/user.vue
  6. 46
      pages/welcome/welcome.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) {

@ -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

@ -198,6 +198,32 @@
}
},
onShow() {
// 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) => {
@ -214,14 +240,40 @@
});
},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,16 +460,32 @@
//
toGoods(e) {
if (app.globalData.userInfo) {
if(this.couponsDetails.highDiscountAgentCode.status != 1){
uni.navigateTo({
url: '../../order/confirmation?type=2&id=' + e
})
}else{
uni.showToast({
icon: 'none',
title: '请点击领取后再使用',
title: '未领取优惠券',
duration: 2000
})
}
} else {
uni.showToast({
icon: 'none',
title: '请登录后再使用',
duration: 2000
})
uni.navigateTo({
url: '/pages/login/register'
})
}
},
//
jumpCounlist() {
@ -569,7 +637,7 @@
}
.headbgimg {
position: absolute;
position: absolute !important;
}
.contents {

@ -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();

@ -590,7 +590,7 @@
},
toPage(url, item) {
let that = this;
if (item != '客服') {
if (item != '客服'&&url!="") {
uni.navigateTo({
url: url
})

@ -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 => {
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
})
this.getH5AccessByOpenId();
// 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#/")

Loading…
Cancel
Save