This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
import { View, Text, Image, Button, Checkbox, CheckboxGroup, RichText } from '@tarojs/components'
|
||||
import Taro, { useDidShow } from '@tarojs/taro'
|
||||
import Taro, { useDidShow, usePullDownRefresh } from '@tarojs/taro'
|
||||
import { useState } from 'react'
|
||||
import { login as silentLogin } from '../../utils/request'
|
||||
import './index.scss'
|
||||
|
||||
export default function UserIndex() {
|
||||
@@ -14,6 +15,19 @@ export default function UserIndex() {
|
||||
if (info) setUserInfo(info)
|
||||
})
|
||||
|
||||
usePullDownRefresh(async () => {
|
||||
try {
|
||||
const res = await silentLogin()
|
||||
if (res) {
|
||||
setUserInfo(res)
|
||||
}
|
||||
Taro.stopPullDownRefresh()
|
||||
} catch (e) {
|
||||
Taro.stopPullDownRefresh()
|
||||
Taro.showToast({ title: '刷新失败', icon: 'none' })
|
||||
}
|
||||
})
|
||||
|
||||
const goOrders = () => Taro.navigateTo({ url: '/pages/order/list' })
|
||||
const goDistributor = () => Taro.navigateTo({ url: '/subpackages/distributor/index' })
|
||||
const goInvite = () => Taro.navigateTo({ url: '/subpackages/distributor/invite' })
|
||||
@@ -296,6 +310,33 @@ export default function UserIndex() {
|
||||
</View>
|
||||
<View className='info-col'>
|
||||
<Text className='nickname' onClick={handleNicknameClick}>{userInfo?.nickname || '未登录用户'}</Text>
|
||||
|
||||
{userInfo && (
|
||||
<View className='badges-row'>
|
||||
{/* 明星技术用户 */}
|
||||
{userInfo.is_star && (
|
||||
<View className='badge star'>
|
||||
<Text className='badge-icon'>🌟</Text>
|
||||
<Text className='badge-text'>技术专家</Text>
|
||||
</View>
|
||||
)}
|
||||
|
||||
{/* 管理员 */}
|
||||
{userInfo.is_admin && (
|
||||
<View className='badge admin'>
|
||||
<Text className='badge-icon'>🛡️</Text>
|
||||
<Text className='badge-text'>管理员</Text>
|
||||
</View>
|
||||
)}
|
||||
|
||||
{/* 网页用户 */}
|
||||
<View className={`badge web ${userInfo.has_web_account ? 'active' : 'disabled'}`}>
|
||||
<Text className='badge-icon'>🌐</Text>
|
||||
<Text className='badge-text'>网页用户</Text>
|
||||
</View>
|
||||
</View>
|
||||
)}
|
||||
|
||||
<Text className='uid'>ID: {userInfo ? (userInfo.phone_number || userInfo.id || '----') : '----'}</Text>
|
||||
{!userInfo && (
|
||||
<View className='login-btns'>
|
||||
|
||||
Reference in New Issue
Block a user