king
2020-07-21 fe6e87bacbb4be97260427346321edeeee26258e
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
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';
 
const render  = Component => {
  ReactDOM.render(
    <Provider store={store}>
      <Component/>
    </Provider>,
    document.getElementById('root')
  )
}
 
if (!localStorage.getItem('SessionUid')) {
  localStorage.setItem('SessionUid', (() => {
    let uuid = []
    let _options = '0123456789abcdefghigklmnopqrstuv'
    for (let i = 0; i < 32; i++) {
      uuid.push(_options.substr(Math.floor(Math.random() * 0x20), 1))
    }
    return uuid.join('')
  })())
}
 
fetch(`./${process.env.NODE_ENV === 'production' ? 'build/' : ''}options.json`)
  .then(response => response.json())
  .catch(() => {
    document.getElementById('root').innerHTML = '系统配置信息获取失败,请联系管理员!'
    document.getElementById('root').className = 'config-error'
  })
  .then(config => {
    if (!config) return
 
    window.GLOB = {}
    window.GLOB.appId = config.appId || ''
    window.GLOB.mainSystemApi = config.mainSystemApi || ''
    window.GLOB.filter = config.filter || ''
    window.GLOB.appkey = config.appkey
 
    let param = {
      func: 's_visitor_login',
      timestamp: moment().format('YYYY-MM-DD HH:mm:ss') + '.000', 
      SessionUid: localStorage.getItem('SessionUid'),
      TypeCharOne: 'mob'
    }
    
    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'
      }
    })
  })
 
serviceWorker.unregister();