| | |
| | | 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( |
| | |
| | | })()) |
| | | } |
| | | |
| | | fetch(`./${process.env.NODE_ENV === 'production' ? 'build/' : ''}options.json`) |
| | | fetch(`./options.json`) |
| | | .then(response => response.json()) |
| | | .catch(() => { |
| | | document.getElementById('root').innerHTML = '系统配置信息获取失败,请联系管理员!' |
| | |
| | | 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() |