|
|
|
@ -114,7 +114,8 @@ |
|
|
|
|
HandleCode, |
|
|
|
|
WXlogin, |
|
|
|
|
getCouponList, |
|
|
|
|
getH5UserInfo |
|
|
|
|
getH5UserInfo, |
|
|
|
|
getH5AccessToken |
|
|
|
|
} from "../../../Utils/Api.js"; //您的api路径 |
|
|
|
|
let app = getApp(); |
|
|
|
|
export default { |
|
|
|
@ -174,10 +175,13 @@ |
|
|
|
|
// #ifdef H5 |
|
|
|
|
var arr1 = window.location.href; |
|
|
|
|
var arr2 = arr1.split('='); |
|
|
|
|
console.log(arr2); |
|
|
|
|
if (!app.globalData.userInfo && arr2[1] != undefined) { |
|
|
|
|
if (!app.globalData.userInfo && arr2[1] != undefined && arr2[2] == '2#/') { |
|
|
|
|
this.getH5UserInfo(arr2[1]); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
if (app.globalData.userInfo && arr2[1] != undefined && arr2[2] == '1#/') { |
|
|
|
|
this.getH5AccessToken(arr2[1]); |
|
|
|
|
} |
|
|
|
|
// #endif |
|
|
|
|
}, |
|
|
|
|
onLoad() { |
|
|
|
@ -185,7 +189,6 @@ |
|
|
|
|
//微信内核支付 |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// 1.wx获取登录用户code |
|
|
|
|
// #ifdef MP |
|
|
|
|
uni.login({ |
|
|
|
@ -219,6 +222,15 @@ |
|
|
|
|
}, |
|
|
|
|
fail: res => {} |
|
|
|
|
}) |
|
|
|
|
// #ifdef H5 |
|
|
|
|
uni.getStorage({ |
|
|
|
|
key: "openId", |
|
|
|
|
success(e) { |
|
|
|
|
app.globalData.openId = e.data |
|
|
|
|
}, |
|
|
|
|
fail: res => {} |
|
|
|
|
}) |
|
|
|
|
// #endif |
|
|
|
|
|
|
|
|
|
}, |
|
|
|
|
methods: { |
|
|
|
@ -258,6 +270,22 @@ |
|
|
|
|
} |
|
|
|
|
}) |
|
|
|
|
}, |
|
|
|
|
//H5 获取openId |
|
|
|
|
getH5AccessToken(item) { |
|
|
|
|
let params = { |
|
|
|
|
code: item |
|
|
|
|
} |
|
|
|
|
getH5AccessToken(params).then(res => { |
|
|
|
|
if (res.return_code == '000000') { |
|
|
|
|
app.globalData.openId = res.return_data.openid; |
|
|
|
|
uni.setStorage({ |
|
|
|
|
key: "openId", |
|
|
|
|
data: res.return_data.openid |
|
|
|
|
}) |
|
|
|
|
} |
|
|
|
|
}); |
|
|
|
|
}, |
|
|
|
|
|
|
|
|
|
//微信内核浏览器 |
|
|
|
|
isWeiXinLogin() { |
|
|
|
|
var ua = navigator.userAgent.toLowerCase(); |
|
|
|
@ -288,6 +316,12 @@ |
|
|
|
|
key: "token", |
|
|
|
|
data: res.return_data.uniqueCode |
|
|
|
|
}) |
|
|
|
|
uni.setStorage({ |
|
|
|
|
key: "openId", |
|
|
|
|
data: res.return_data |
|
|
|
|
.object |
|
|
|
|
.highUser.openIdH5 |
|
|
|
|
}) |
|
|
|
|
app.globalData.openId = res.return_data |
|
|
|
|
.object |
|
|
|
|
.highUser.openIdH5; |
|
|
|
|