index.jsx 4.2KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111
  1. import React, { useState, useEffect } from 'react'
  2. import NavHeader from '@/components/NavHeader/index'
  3. import Taro from '@tarojs/taro'
  4. import request, { apis } from '@/utils/request'
  5. import { store, useModel } from '@/store'
  6. import '@/assets/css/reset.less'
  7. import '@/assets/css/iconfont.less'
  8. import './index.less'
  9. export default function WoDe (props) {
  10. const { setUser } = store.getModel('user').getState()
  11. const { user } = useModel('user')
  12. const [IsPull, setIsPull] = useState(false)
  13. const [UserTab] = useState([
  14. { icon: 'iconrenzheng1', name: '业主认证', id: 1, router: '/pages/WoDe/YeZhuRenZheng/index' },
  15. { icon: 'iconjifenguize', name: '积分明细', id: 2, router: null },
  16. { icon: 'iconjiaofei', name: '物业缴费', id: 3, router: null },
  17. { icon: 'iconfuwu1', name: '物业服务', id: 4, router: null }
  18. ])
  19. const [MoreUserTab] = useState([
  20. { icon: 'iconerweima', name: '推荐二维码', id: 5, router: '/pages/WoDe/TuiJianErWeiMa/index' },
  21. { icon: 'iconfenxiang', name: '推荐分享', id: 6, router: '/pages/WoDe/TuiJianFenXiang/index' },
  22. { icon: 'iconhuodong', name: '参与活动', id: 7, router: '/pages/WoDe/WoDeHuoDong/index' }
  23. ])
  24. const [DataLock, setDataLock] = useState(false)
  25. useEffect(() => {
  26. if (user !== null) {
  27. request({ ...apis.getOwnerVerifyList }).then(() => {
  28. }).catch((res) => {
  29. Taro.showToast({ title: res, icon: 'none' })
  30. })
  31. }
  32. }, [])
  33. const ToSign = () => { // 签到
  34. if (DataLock) return
  35. setDataLock(true)
  36. request({ ...apis.userSign }).then(() => {
  37. Taro.showToast({ title: '签到成功', icon: 'none' })
  38. setUser({ ...user, isSignup: 1 })
  39. setDataLock(false)
  40. }).catch((res) => {
  41. Taro.showToast({ title: res, icon: 'none' })
  42. setDataLock(false)
  43. })
  44. }
  45. const OnRefresh = () => { // 页面下拉刷新
  46. setIsPull(true)
  47. const t = setTimeout(() => {
  48. setIsPull(false)
  49. clearTimeout(t)
  50. }, 1000)
  51. }
  52. return (
  53. <view className='WoDe'>
  54. <NavHeader BgColor='none' Title='我的' IsFixed={true}></NavHeader>
  55. <scroll-view scroll-y='true' style='height: 100%;' refresher-enabled={true} onrefresherrefresh={OnRefresh} refresher-triggered={IsPull} refresher-background='#F35844'>
  56. <view className='WoDeContent'>
  57. {/* 顶部背景图 */}
  58. <view className='TopBg'>
  59. <view className='ColorBg'></view>
  60. <view className='UserInfo flex-h'>
  61. <view className='Icon' onClick={() => { Taro.navigateTo({ url: '/pages/WoDe/GeRenXinXi/index' }) }}>
  62. <image mode='aspectFill' src={null} class='centerLabel'></image>
  63. </view>
  64. <view className='flex-item' onClick={() => { Taro.navigateTo({ url: '/pages/WoDe/GeRenXinXi/index' }) }}>
  65. <text>{user.nickname || '暂未授权用户信息'}</text>
  66. <text>{user.phone || '暂未授权手机号'}</text>
  67. </view>
  68. <text onClick={ToSign}>{user.isSignup ? '已签到' : '签到'}</text>
  69. </view>
  70. </view>
  71. {/* 用户选项 */}
  72. <view className='UserTab'>
  73. {
  74. UserTab.map((item, index) => (
  75. <view key={`UserTab-${index}`} className='flex-h' onClick={() => { Taro.navigateTo({ url: item.router }) }}>
  76. <text className={`iconfont ${item.icon}`}></text>
  77. <view className='flex-h flex-item'>
  78. <text className='flex-item'>{item.name}</text>
  79. <text className='iconfont iconjiantouright'></text>
  80. </view>
  81. </view>
  82. ))
  83. }
  84. <view className='Line'></view>
  85. {
  86. MoreUserTab.map((item, index) => (
  87. <view key={`UserTab-${index}`} className='flex-h' onClick={() => { Taro.navigateTo({ url: item.router }) }}>
  88. <text className={`iconfont ${item.icon}`}></text>
  89. <view className='flex-h flex-item'>
  90. <text className='flex-item'>{item.name}</text>
  91. <text className='iconfont iconjiantouright'></text>
  92. </view>
  93. </view>
  94. ))
  95. }
  96. </view>
  97. </view>
  98. </scroll-view>
  99. </view>
  100. )
  101. }