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

ymt-db-dev
游梦婷 1 year ago
parent 8fddf4e34f
commit f2b4abb72a
  1. 10
      App.vue
  2. 21
      common/share.js
  3. 114
      pages/goods/externalCoupon/externalCoupon.vue
  4. 3
      pages/login/register.vue
  5. 2
      pages/tabBar/user/user.vue
  6. 58
      pages/welcome/welcome.vue

@ -72,7 +72,14 @@
}, },
onLaunch: function() {}, onLaunch: function() {
// uni.addInterceptor('request',{
// invoke(e){
// console.log(e,"e")
// }
// })
},
onShow: function() { onShow: function() {
// #ifdef MP // #ifdef MP
let accountInfo = uni.getAccountInfoSync(); let accountInfo = uni.getAccountInfoSync();
@ -135,6 +142,7 @@
} }
} }
}) })
uni.getStorage({ uni.getStorage({
key: 'user', key: 'user',
success(e) { 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() { onLoad() {
// #ifdef H5 // #ifdef H5
this.$nextTick(() => { this.$nextTick(() => {
if(this.isNotDoShare()){
return ;
}
// console.log(this.isNotDoShare(),"==================")
this.doShare(); this.doShare();
}) })
// #endif // #endif
@ -131,6 +149,9 @@ export default {
onShow(){ onShow(){
// #ifdef H5 // #ifdef H5
this.$nextTick(()=>{ this.$nextTick(()=>{
if(this.isNotDoShare()){
return ;
}
this.h5ShareMethod(); this.h5ShareMethod();
}) })
// #endif // #endif

@ -198,30 +198,82 @@
} }
}, },
onShow() { onShow() {
uni.getStorage({ // uni.getStorage({
key: 'user', // key: 'user',
success: (res) => { // success: (res) => {
app.globalData.userInfo = res.data; // app.globalData.userInfo = res.data;
if (app.globalData.userInfo.phone) { // if (app.globalData.userInfo.phone) {
this.userInfo = 2; // this.userInfo = 2;
} else { // } 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; 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() { onLoad() {
var arr1 = window.location.href; // var arr1 = window.location.href;
var arr2 = arr1.split('='); // var arr2 = arr1.split('=');
if (!app.globalData.openId) { // if (!app.globalData.openId) {
this.getH5AccessToken(arr2[1]); // this.getH5AccessToken(arr2[1]);
} // }
this.getDiscountByQrCode();
//
// if(!app.globalData.userInfo&&!app.globalData.token){
// uni.navigateTo({
// url: '/pages/login/register'
// })
// return
// }
}, },
created() { created() {
@ -408,15 +460,31 @@
// //
toGoods(e) { toGoods(e) {
if (app.globalData.userInfo) { 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 { } else {
uni.showToast({ uni.showToast({
icon: 'none', icon: 'none',
title: '请点击领取后再使用', title: '请登录后再使用',
duration: 2000 duration: 2000
}) })
uni.navigateTo({
url: '/pages/login/register'
})
} }
}, },
// //
@ -569,7 +637,7 @@
} }
.headbgimg { .headbgimg {
position: absolute; position: absolute !important;
} }
.contents { .contents {

@ -158,7 +158,8 @@
phone: this.phoneNumber, phone: this.phoneNumber,
type: "SMS", type: "SMS",
platform: "H5", platform: "H5",
smsCode: this.code smsCode: this.code,
openIdH5:app.globalData.openId
} }
phone(params).then(res => { phone(params).then(res => {
uni.hideLoading(); uni.hideLoading();

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

@ -83,6 +83,8 @@
// 0016 // 0016
if (app.globalData.accountType == '0000011&key' && app.globalData.h5code) { if (app.globalData.accountType == '0000011&key' && app.globalData.h5code) {
uni.navigateTo({ uni.navigateTo({
url: '/pages/goods/externalCoupon/externalCoupon' url: '/pages/goods/externalCoupon/externalCoupon'
}) })
@ -206,29 +208,38 @@
}) })
}, },
//H5 openId //H5 openId
getH5AccessToken() { async getH5AccessToken() {
let params = { let params = {
code: app.globalData.h5code code: app.globalData.h5code
} }
getH5AccessToken(params).then(res => {
if (res.return_code == '000000' && res.return_data.openid) { let res = await getH5AccessToken(params);
app.globalData.openId = res.return_data.openid;
uni.setStorage({ if (res.return_code == '000000' && res.return_data.openid) {
key: "openId", app.globalData.openId = res.return_data.openid;
data: res.return_data.openid // uni.setStorage({
}) // key: "openId",
this.getH5AccessByOpenId(); // data: res.return_data.openid
} else { // })
this.jumpcdx();
} uni.setStorageSync("openId",res.return_data.openid);
});
await this.getH5AccessByOpenId();
} else {
this.jumpcdx();
}
}, },
// //
getH5AccessByOpenId() { async getH5AccessByOpenId() {
let datas = { let datas = {
openId: app.globalData.openId 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 app.globalData.userInfo = res.return_data
.object .object
.highUser; .highUser;
@ -243,7 +254,22 @@
key: "token", key: "token",
data: res.return_data.uniqueCode data: res.return_data.uniqueCode
}) })
}) }else{
app.globalData.userInfo = '';
app.globalData.token = '';
uni.setStorage({
key: "user",
data: ''
})
uni.setStorage({
key: "token",
data: ''
})
}
}, },
jumpcdx() { jumpcdx() {
let str =encodeURIComponent(app.globalData.h5url+"/index.html#/") let str =encodeURIComponent(app.globalData.h5url+"/index.html#/")

Loading…
Cancel
Save