function strToObj(val) { let obj = {} let str = val.substr(1) let arr = str.split('&') for (let i = 0; i < arr.length; i++) { let newArr = arr[i].split('=') obj[newArr[0]] = newArr[1] } return obj } // if (location.search&&strToObj(location.search).code) { // let reqdata = { // url: location.href, // type: 1 // } // console.log(reqdata); // postHttps('manage/wx/getWxConfig',{reqdata}).then(r => { // alert(JSON.stringify(r)) // let {object:{ // agentId:agentid, // appId: corpid, // nonceStr, // signature, // timestamp, // }} = r // wx.agentConfig({ // corpid, // timestamp, // nonceStr, // signature, // agentid, // jsApiList: ['openUserProfile','selectEnterpriseContact','openEnterpriseChat','hideOptionMenu','hideMenuItems'], // success: function() { // // 回调 // alert('success') // let { code } = strToObj(location.search) // let reqdata = { // code, // type:1, // loginType: window.screen.width>1000?2:1 // } // // let {object:{userId}} = await postHttps('manage/wx/getWxUserInfo',{reqdata}) // // globalUserId = userId // // app.username = username // // app.avatar = avatar // postHttps('manage/wx/getWxUserInfo',{reqdata}).then(r => { // let {object:{userId}} = r // Cookies.set('userId', userId) // location.href=location.href.split('?')[0] + (window.screen.width > 1000 ? '/repair/#/pc-list' : '/repair/#/home') // }) // }, // fail: function(res) { // alert(JSON.stringify(res)) // if(res.errMsg.indexOf('function not exist') > -1){ // alert('版本过低请升级') // } // } // }) // }) // } else { // getHttps('/manage/wx/getUrl/1').then(r => { // location.href = r.object // }) // } window.addEventListener('load', async () => { if (location.search&&strToObj(location.search).code) { let reqdata = { url: location.href, type: 1 } let {object:{ agentId:agentid, appId: corpid, nonceStr, signature, timestamp, }} = await postHttps('manage/wx/getWxConfig',{reqdata}) wx.agentConfig({ corpid, timestamp, nonceStr, signature, agentid, jsApiList: ['openUserProfile','selectEnterpriseContact','openEnterpriseChat'], success: async function(res) { // 回调 let { code } = strToObj(location.search) let reqdata = { code, type:1, loginType: window.screen.width>1000?2:1 } let {object:{userId,avatar,username}} = await postHttps('manage/wx/getWxUserInfo',{reqdata}) let {state} = strToObj(location.search) // localStorage.setItem('avatar',avatar) //2 // localStorage.setItem('username',username) //2 let orderId = state.split('-')[1] - 0 Cookies.set('userId', userId) // location.href=location.href.split('?')[0] + (window.screen.width > 1000 ? '/pc' : orderId?'/front/#/detail/'+orderId:'/front/#/index') //2 location.href=location.href.split('?')[0] + (window.screen.width > 1000 ? (orderId?'/repair1/#/pc-detail/'+orderId:'/repair1/#/pc-list') : (orderId?'/repair1/#/detail/'+orderId:'/repair1/#/home')) // location.href=location.href.split('?')[0] + (window.screen.width > 1000 ? '/repair1/#/pc-form' : '/repair1/#/info') }, fail: function(res) { alert(JSON.stringify(res)) if(res.errMsg.indexOf('function not exist') > -1){ alert('版本过低请升级') } } }) } else { let url = '/manage/wx/getUrl/1/' + (strToObj(location.search).orderId||0) alert(url) let {object} = await getHttps(url) location.href = object } }) window.addEventListener('pageshow', function (e) {     if(e.persisted || (window.performance && window.performance.navigation.type === 2)){         window.location.reload();     } },false);