onLoad(option) {
let userid = this.getUrlParam('userid')
let code = this.getUrlParam('code')
let state = this.getUrlParam('state')
if (state) {
this.state = state
}
const wx_url =
`https://open.weixin.qq.com/connect/oauth2/authorize?appid=wx6ed69c271583d8d7&redirect_uri=http%3A%2F%2Fholemp.huawaiyin.net%2F&response_type=code&scope=snsapi_userinfo&state=${userid}#wechat_redirect`
this.code = code
if (code == null || code == '') {
// console.log('重新定向到这个页面')
window.location.href = wx_url
// uni.setStorageSync('userId', 4);
} else {
// 发送code
console.log('code 不等于null')
}
this.Index();
},
methods: {
// 解析URL 参数
getUrlParam(name) {
let reg = new RegExp('(^|&)' + name + '=([^&]*)(&|$)')
let r = window.location.search.substr(1).match(reg)
if (r != null) {
return unescape(r[2])
}
return null
//判断使用的手机是android还是IOS
isAndroidFun() {
var u = navigator.userAgent;
var isAndroid = u.indexOf('Android') > -1 || u.indexOf('Linux') > -1;
var isIOS = !!u.match(/\(i[^;]+;( U;)? CPU.+Mac OS X/);
if (isAndroid) {
uni.setStorage({
key: 'phone',
data: 'isAndroid',
});
console.log('isAndroid')
// return true;
}
if (isIOS) {
console.log('isIOS')
uni.setStorage({
key: 'phone',
data: 'isIOS',
});
// window.location.reload();
// return false;
}
},
}
微信公众号重定向
于 2022-08-16 10:44:29 首次发布