From e003a8ee8843aa60b0b7135f413b2b99857acff9 Mon Sep 17 00:00:00 2001 From: king <18310653075@163.com> Date: 星期三, 30 十二月 2020 18:49:43 +0800 Subject: [PATCH] 2020-12-30 --- src/index.js | 60 +++++++++++++++++++++++++++++++++--------------------------- 1 files changed, 33 insertions(+), 27 deletions(-) diff --git a/src/index.js b/src/index.js index ed10535..401188c 100644 --- a/src/index.js +++ b/src/index.js @@ -1,13 +1,13 @@ -import React from 'react'; -import ReactDOM from 'react-dom'; +import React from 'react' +import ReactDOM from 'react-dom' import {Provider} from 'react-redux' -import md5 from 'md5' -import moment from 'moment' import Route from './router' import store from '@/store' -import Api from '@/api' -import './index.css'; -import * as serviceWorker from './serviceWorker'; +import './index.css' +import * as serviceWorker from './serviceWorker' +// import VConsole from 'vconsole/dist/vconsole.min.js' + +// new VConsole() const render = Component => { ReactDOM.render( @@ -29,7 +29,7 @@ })()) } -fetch(`./${process.env.NODE_ENV === 'production' ? 'build/' : ''}options.json`) +fetch(`./options.json`) .then(response => response.json()) .catch(() => { document.getElementById('root').innerHTML = '绯荤粺閰嶇疆淇℃伅鑾峰彇澶辫触锛岃鑱旂郴绠$悊鍛橈紒' @@ -43,27 +43,33 @@ window.GLOB.mainSystemApi = config.mainSystemApi || '' window.GLOB.filter = config.filter || '' window.GLOB.appkey = config.appkey + window.GLOB.systemType = 'H5' - let param = { - func: 's_visitor_login', - timestamp: moment().format('YYYY-MM-DD HH:mm:ss') + '.000', - SessionUid: localStorage.getItem('SessionUid'), - TypeCharOne: 'mob' + let agent = navigator.userAgent.toLowerCase() + console.log(agent) + if (agent.indexOf('android') > -1) { + window.GLOB.systemType = 'android' + } else if (agent.indexOf('iphone') > -1 || agent.indexOf('ipad') > -1) { + window.GLOB.systemType = 'ios' } - - param.LText = md5(window.btoa(localStorage.getItem('SessionUid') + param.timestamp)) - param.secretkey = md5(param.LText + 'mingke' + param.timestamp) - Api.getTouristMsg(param).then((res) => { - if (res.status) { - sessionStorage.setItem('UserID', res.UserID) - sessionStorage.setItem('LoginUID', res.LoginUID) - render(Route) - } else { - document.getElementById('root').innerHTML = res.message - document.getElementById('root').className = 'config-error' - } - }) + if (window.wx && window.wx.miniProgram && agent.match(/MicroMessenger/i) === 'micromessenger') { + window.wx.miniProgram.getEnv((res) => { + if (res.miniprogram) { + window.GLOB.systemType = 'miniProgram' + } + }) + } + + console.log('systemType: ' + window.GLOB.systemType) + + if (process.env.NODE_ENV === 'production') { // 鐢ㄤ簬鏍¢獙鏄惁瀛樺湪寮�鍙戞潈闄� + window.GLOB.service = window.location.href.replace(/\/mob(.*)/ig, '').replace(new RegExp(document.location.origin + '/?', 'ig'), '') + } else { + window.GLOB.service = 'mkwms/' + } + + render(Route) }) -serviceWorker.unregister(); +serviceWorker.unregister() -- Gitblit v1.8.0