index.jsx 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158
  1. import { Component } from 'react'
  2. import Taro from '@tarojs/taro'
  3. import { connect } from 'react-redux'
  4. import {View} from '@tarojs/components'
  5. import { AtButton } from 'taro-ui'
  6. import "taro-ui/dist/style/components/icon.scss";
  7. import "taro-ui/dist/style/components/button.scss";
  8. import "taro-ui/dist/style/components/loading.scss";
  9. import { add, minus, asyncAdd } from '../../actions/counter'
  10. import './index.less'
  11. @connect(({ counter }) => ({
  12. counter
  13. }), (dispatch) => ({
  14. add () {
  15. dispatch(add())
  16. },
  17. dec () {
  18. dispatch(minus())
  19. },
  20. asyncAdd () {
  21. dispatch(asyncAdd())
  22. }
  23. }))
  24. class Index extends Component {
  25. constructor(props) {
  26. super(props);
  27. this.state={
  28. list:[
  29. {
  30. icon:'bell',
  31. title:'打卡',
  32. color:'#89ec6d',
  33. buttons:[
  34. {
  35. name:'上班'
  36. },
  37. {
  38. name:'下班'
  39. }
  40. ]
  41. },
  42. {
  43. icon:'map-pin',
  44. title:'定位轨迹',
  45. color:'#3f8ae5',
  46. buttons:[
  47. {
  48. name:'我的路线'
  49. },
  50. {
  51. name:'员工分布',
  52. url:'/pages/staffDistribution/index'
  53. }
  54. ]
  55. },
  56. {
  57. icon:'calendar',
  58. title:'日报',
  59. color:'#3f8ae5',
  60. buttons:[
  61. {
  62. name:'添加日报'
  63. },
  64. ]
  65. },
  66. {
  67. icon:'shopping-bag',
  68. title:'出差',
  69. color:'#89ec6d',
  70. buttons:[
  71. {
  72. name:'填写出差单',
  73. url:'/pages/outdoorActivities/index'
  74. },
  75. ]
  76. },
  77. {
  78. icon:'camera',
  79. title:'拍照上传',
  80. color:'#3f8ae5',
  81. buttons:[
  82. {
  83. name:'添加拍照'
  84. },
  85. ]
  86. },
  87. {
  88. icon:'credit-card',
  89. title:'费用申请',
  90. color:'#b19c42',
  91. buttons:[
  92. {
  93. name:'填写申请单'
  94. },
  95. ]
  96. },
  97. ]
  98. }
  99. }
  100. componentDidShow () {
  101. let token = Taro.getStorageSync('token');
  102. if(!token){
  103. Taro.navigateTo({
  104. url: '/pages/login/index',
  105. })
  106. }
  107. }
  108. componentDidMount() {
  109. }
  110. render () {
  111. return (
  112. <View className='list'>
  113. {
  114. this.state.list.map((value,key)=>(
  115. <View key={key} className='item'>
  116. <View className='left' style={{background:value.color}}>
  117. <View className={'at-icon at-icon-'+value.icon} style={{color:'#FFF'}}/>
  118. <View className='title'>{value.title}</View>
  119. </View>
  120. <View className='right'>
  121. {
  122. value.buttons.map((v,k)=>(
  123. <AtButton
  124. key={k}
  125. type='secondary'
  126. size='small'
  127. className='button'
  128. onClick={()=>{
  129. Taro.navigateTo({
  130. url: v.url,
  131. })
  132. }}
  133. >
  134. {v.name}
  135. </AtButton>
  136. ))
  137. }
  138. </View>
  139. </View>
  140. ))
  141. }
  142. </View>
  143. )
  144. }
  145. }
  146. export default Index