feat:hash模式
This commit is contained in:
@@ -27,17 +27,26 @@ const Index = () => {
|
||||
const getWxid = () => {
|
||||
let newparams = Taro.getCurrentInstance().router.params;
|
||||
let urlopenid = newparams.openid;
|
||||
|
||||
// hash模式
|
||||
// http://192.168.31.245:10086/?openid=o7LFAwR32hWGq9XOpd7ZxK1wZxq8#/pages/index/index
|
||||
let hashopenid=null
|
||||
if(window.location.href.includes('openid')){
|
||||
hashopenid=(window.location.href).split('#')[0].split('?')[1].split('=')[1]
|
||||
}
|
||||
|
||||
// window.alert(urlopenid)
|
||||
let newOpenid = window.localStorage.getItem("openid");
|
||||
// window.alert(newOpenid)
|
||||
|
||||
if (!!newOpenid && newOpenid!= 'undefined' || !!urlopenid&& urlopenid!= 'undefined' ) {
|
||||
if (!!newOpenid && newOpenid!= 'undefined' || !!hashopenid&& hashopenid!= 'undefined' ) {
|
||||
// window.alert('存在')
|
||||
window.localStorage.setItem("openid", urlopenid);
|
||||
window.localStorage.setItem("openid", hashopenid);
|
||||
// window.alert(urlopenid);
|
||||
} else {
|
||||
// window.alert('不存在')
|
||||
let nowUrl = window.location.href;
|
||||
|
||||
// window.alert(nowUrl)
|
||||
let payUrl = `https://payjs.cn/api/openid?mchid=1561724891&callback_url=${nowUrl}`;
|
||||
window.location.href = payUrl;
|
||||
|
||||
Reference in New Issue
Block a user