Profile.tsx 2.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586
  1. import Buttons from "@/components/Buttons";
  2. import { delSession } from "@/services/common";
  3. import { clear, logout } from "@/services/user";
  4. import { View, Text,Image } from "@tarojs/components";
  5. import Taro from "@tarojs/taro";
  6. import { useDispatch, useSelector } from "react-redux";
  7. import './Profile.scss'
  8. export default function Page() {
  9. const dispatch = useDispatch();
  10. const user = useSelector((state: any) => state.user);
  11. function tapLogin() {
  12. Taro.navigateTo({
  13. url: '/pages/ChooseAuth'
  14. })
  15. }
  16. function reset() {
  17. delSession({ type: 'WX_MP' })
  18. }
  19. function tapProfile() {
  20. if (user.isLogin){
  21. Taro.navigateTo({
  22. url: '/pages/ProfileSetting'
  23. })
  24. }
  25. else {
  26. Taro.navigateTo({
  27. url: '/pages/ChooseAuth'
  28. })
  29. }
  30. }
  31. function tapBalance() {
  32. if (user.isLogin){
  33. }
  34. else {
  35. Taro.navigateTo({
  36. url: '/pages/ChooseAuth'
  37. })
  38. }
  39. }
  40. function goSetting(){
  41. Taro.navigateTo({
  42. url: '/pages/Setting'
  43. })
  44. }
  45. return <View className="container">
  46. <View style={{height:20}}/>
  47. <View className="profile_card card" onClick={tapProfile}>
  48. <View className="avatar" style={{ opacity: user.isLogin ? 1 : 0.4 }}>
  49. {
  50. user.isLogin?<Image src={user.avatar} className="avatar" />:<Image src={require('@/assets/images/user.png')} className="avatar_placeholder" />
  51. }
  52. </View>
  53. <Text className="nickname">{user.isLogin ? user.nickname : '未登录'}</Text>
  54. <Text className="username">{user.isLogin ? '用户名未设置' : ''}</Text>
  55. </View>
  56. <View className="card" onClick={tapBalance}>
  57. <Text className="title">逆龄石</Text>
  58. <Text className="desc">{'会员体系升级中,期间指标记录限时免逆龄石记录\n敬请期待'}</Text>
  59. </View>
  60. {user.isLogin && <View className="card" onClick={goSetting}>
  61. <Text className="title">设置</Text>
  62. </View>}
  63. {/* {
  64. user.isLogin && <Text>用户名:{user.nickname}</Text>
  65. }
  66. {
  67. user.isLogin && <Text>id:{user.id}</Text>
  68. }
  69. {
  70. user.isLogin && <Buttons title='重置session' onClick={reset} style={{ width: 289, marginBottom: 30 }} />
  71. } */}
  72. </View>
  73. }