123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128 |
- 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
- }
- 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)
-
-
- let orderId = state.split('-')[1] - 0
- Cookies.set('userId', userId)
-
-
- location.replace(location.href.split('?')[0] + (window.screen.width > 1000 ? (orderId?'/repair1/#/pc-detail/'+orderId:'/repair1/#/pc-list') : (orderId?'/repair1/#/detail/'+orderId:'/repair1/#/home')))
-
- },
- 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);
|