"use strict"; function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { Promise.resolve(value).then(_next, _throw); } } function _asyncToGenerator(fn) { return function () { var self = this, args = arguments; return new Promise(function (resolve, reject) { var gen = fn.apply(self, args); function _next(value) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value); } function _throw(err) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err); } _next(undefined); }); }; } function strToObj(val) { var obj = {}; var str = val.substr(1); var arr = str.split('&'); for (var i = 0; i < arr.length; i++) { var 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', /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee2() { var reqdata, _yield$postHttps, _yield$postHttps$obje, agentid, corpid, nonceStr, signature, timestamp, url, _yield$getHttps, object; return regeneratorRuntime.wrap(function _callee2$(_context2) { while (1) { switch (_context2.prev = _context2.next) { case 0: if (!(location.search && strToObj(location.search).code)) { _context2.next = 14; break; } reqdata = { url: location.href, type: 1 }; _context2.next = 4; return postHttps('manage/wx/getWxConfig', { reqdata: reqdata }); case 4: _yield$postHttps = _context2.sent; _yield$postHttps$obje = _yield$postHttps.object; agentid = _yield$postHttps$obje.agentId; corpid = _yield$postHttps$obje.appId; nonceStr = _yield$postHttps$obje.nonceStr; signature = _yield$postHttps$obje.signature; timestamp = _yield$postHttps$obje.timestamp; wx.agentConfig({ corpid: corpid, timestamp: timestamp, nonceStr: nonceStr, signature: signature, agentid: agentid, jsApiList: ['openUserProfile', 'selectEnterpriseContact', 'openEnterpriseChat'], success: function () { var _success = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee(res) { var _strToObj, code, reqdata, _yield$postHttps2, _yield$postHttps2$obj, userId, avatar, username, _strToObj2, state, orderId; return regeneratorRuntime.wrap(function _callee$(_context) { while (1) { switch (_context.prev = _context.next) { case 0: // 回调 _strToObj = strToObj(location.search), code = _strToObj.code; reqdata = { code: code, type: 1, loginType: window.screen.width > 1000 ? 2 : 1 }; _context.next = 4; return postHttps('manage/wx/getWxUserInfo', { reqdata: reqdata }); case 4: _yield$postHttps2 = _context.sent; _yield$postHttps2$obj = _yield$postHttps2.object; userId = _yield$postHttps2$obj.userId; avatar = _yield$postHttps2$obj.avatar; username = _yield$postHttps2$obj.username; _strToObj2 = strToObj(location.search), state = _strToObj2.state; localStorage.setItem('avatar', avatar); //2 localStorage.setItem('username', username); //2 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') case 15: case "end": return _context.stop(); } } }, _callee); })); function success(_x) { return _success.apply(this, arguments); } return success; }(), fail: function fail(res) { alert(JSON.stringify(res)); if (res.errMsg.indexOf('function not exist') > -1) { alert('版本过低请升级'); } } }); _context2.next = 21; break; case 14: url = '/manage/wx/getUrl/1/' + (strToObj(location.search).orderId || 0); alert(url); _context2.next = 18; return getHttps(url); case 18: _yield$getHttps = _context2.sent; object = _yield$getHttps.object; location.href = object; case 21: case "end": return _context2.stop(); } } }, _callee2); }))); window.addEventListener('pageshow', function (e) { if (e.persisted || window.performance && window.performance.navigation.type === 2) { window.location.reload(); } }, false);