index.js 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101
  1. import Taro, { Component } from '@tarojs/taro'
  2. // import { View } from '@tarojs/components'
  3. import { AtTabBar } from 'taro-ui'
  4. import './index.scss'
  5. export default class Footer extends Component {
  6. constructor (props) {
  7. super(props)
  8. const bg1 = require('./img/i_f_1.png')
  9. const bg1c = require('./img/i_f_1c.png')
  10. const bg2 = require('./img/i_f_2.png')
  11. const bg2c = require('./img/i_f_2c.png')
  12. const bg3 = require('./img/i_f_3.png')
  13. const bg3c = require('./img/i_f_3c.png')
  14. const bg4 = require('./img/i_f_4.png')
  15. const bg4c = require('./img/i_f_4c.png')
  16. const bg5 = require('./img/i_f_5.png')
  17. const bg5c = require('./img/i_f_5c.png')
  18. this.state = {
  19. current: props.current || 0,
  20. tabList: [
  21. { title: '首页', image: bg1, selectedImage: bg1c, url: '/pages/index/index' },
  22. { title: '找房', image: bg2, selectedImage: bg2c, url: '/pagesHouse/index' },
  23. { title: '洪楼圈', image: bg3, selectedImage: bg3c, url: '/pagesQa/index' },
  24. { title: '学区', image: bg4, selectedImage: bg4c, url: '/pagesSchool/area' },
  25. { title: '我的', image: bg5, selectedImage: bg5c, url: '/pagesMore/center/index', text: '', max: 99 },
  26. ]
  27. }
  28. }
  29. componentWillMount () {
  30. const needUserName = Taro.getStorageSync('APP_needUsername')
  31. const appToken = Taro.getStorageSync('APP_token')
  32. const appUserInfo = Taro.getStorageSync('APP_userInfo')
  33. if (needUserName && needUserName === 'yes' && appToken && appUserInfo.avatarUrl && appUserInfo.nickName) {
  34. Taro.api.base.apiwxuseredit({
  35. avatar: appUserInfo.avatarUrl,
  36. nickname: appUserInfo.nickName,
  37. }).then(res => {
  38. Taro.removeStorageSync('APP_needUsername')
  39. })
  40. }
  41. Taro.api.other.notifycount().then(res => {
  42. const notify = res.count || ''
  43. const { getNotify } = this.props
  44. if (getNotify) getNotify(notify)
  45. if (notify) {
  46. let { tabList } = this.state
  47. tabList[4].text = notify
  48. const newsDot = Taro.getStorageSync('APP_newsDot')
  49. if (newsDot) {
  50. tabList[2].dot = true
  51. } else {
  52. tabList[2].dot = false
  53. }
  54. this.setState({
  55. tabList
  56. })
  57. } else {
  58. let { tabList } = this.state
  59. const newsDot = Taro.getStorageSync('APP_newsDot')
  60. if (newsDot) {
  61. tabList[2].dot = true
  62. } else {
  63. tabList[2].dot = false
  64. }
  65. this.setState({
  66. tabList
  67. })
  68. }
  69. })
  70. }
  71. handleClick (value) {
  72. const { tabList } = this.state
  73. if (!tabList[value].url || tabList[value].dev) {
  74. Taro.$msg('开发中~')
  75. return
  76. }
  77. this.setState({
  78. current: value
  79. })
  80. if (Taro.getEnv() === Taro.ENV_TYPE.WEB) {
  81. Taro.navigateTo({url: tabList[value].url})
  82. } else {
  83. Taro.reLaunch({url: tabList[value].url})
  84. }
  85. }
  86. render () {
  87. const { tabList } = this.state
  88. return (
  89. <AtTabBar
  90. selectedColor="#369af7"
  91. color= "#999"
  92. fixed
  93. tabList={tabList}
  94. onClick={this.handleClick.bind(this)}
  95. current={this.state.current}
  96. />
  97. )
  98. }
  99. }