app.js 1.0KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. import { Component } from 'react'
  2. import Taro from '@tarojs/taro'
  3. import preFetchData from '@/utils/preFetchData'
  4. import store, { StoreRoot } from './store'
  5. import './app.less'
  6. class App extends Component {
  7. onLaunch(options) {
  8. console.group('APP Launch')
  9. console.debug(options)
  10. console.groupEnd()
  11. const { login} = store.getModel('person').getState()
  12. // 预拉取数据
  13. preFetchData().then((fetchData) => {
  14. const { fromType, recommender, scene : qrCodeId } = options.query
  15. // 登录获取人员信息
  16. Taro.login({
  17. success: (res) => {
  18. const { code } = res;
  19. login({ code, personId: fetchData.personId, fromType, recommender, qrCodeId })
  20. }
  21. })
  22. }).catch(() => {
  23. Taro.showToast({
  24. title: '网络异常, 请退出重试',
  25. icon: 'none',
  26. })
  27. })
  28. }
  29. // this.props.children 是将要会渲染的页面
  30. render () {
  31. return (
  32. <StoreRoot>
  33. {this.props.children}
  34. </StoreRoot>
  35. )
  36. }
  37. }
  38. export default App