forked from gxwebsoft/mp-10550
refactor(api): 更新 API调用以使用 request-legacy- 将多个 API 文件中的 request 引用更新为 request-legacy
- 修改了部分 API调用的错误处理方式 - 更新了部分函数参数名称
This commit is contained in:
@@ -1,45 +1,17 @@
|
||||
import {Cell} from '@nutui/nutui-react-taro'
|
||||
import navTo from "@/utils/common";
|
||||
import Taro from '@tarojs/taro'
|
||||
import {View, Text} from '@tarojs/components'
|
||||
import {ArrowRight, Reward, Setting} from '@nutui/icons-react-taro'
|
||||
import {useUser} from '@/hooks/useUser'
|
||||
import {useEffect, useState} from "react";
|
||||
import {pageShopDealerUser} from "@/api/shop/shopDealerUser";
|
||||
import {useEffect} from "react";
|
||||
import {useDealerUser} from "@/hooks/useDealerUser";
|
||||
|
||||
const UserCell = () => {
|
||||
const {isSuperAdmin} = useUser();
|
||||
const [isDealer, setIsDealer] = useState<boolean>(false)
|
||||
|
||||
const reload = async () => {
|
||||
const userId = Taro.getStorageSync('UserId')
|
||||
|
||||
console.log('当前用户ID:', userId)
|
||||
|
||||
const params = {
|
||||
userId: Number(userId),
|
||||
page: 1,
|
||||
limit: 1
|
||||
}
|
||||
|
||||
console.log('查询分销商参数:', params)
|
||||
|
||||
try {
|
||||
const res = await pageShopDealerUser(params)
|
||||
console.log('分销商查询结果:', res)
|
||||
if (res?.count && res?.count > 0) {
|
||||
setIsDealer(true)
|
||||
} else {
|
||||
setIsDealer(false)
|
||||
}
|
||||
} catch (error) {
|
||||
console.error('查询分销商信息失败:', error)
|
||||
setIsDealer(false)
|
||||
}
|
||||
}
|
||||
const {dealerUser} = useDealerUser()
|
||||
|
||||
useEffect(() => {
|
||||
reload().then()
|
||||
|
||||
}, [])
|
||||
|
||||
/**
|
||||
@@ -70,7 +42,7 @@ const UserCell = () => {
|
||||
/**
|
||||
* 分销中心
|
||||
*/
|
||||
if (isDealer) {
|
||||
if (dealerUser) {
|
||||
return (
|
||||
<>
|
||||
<View className={'px-4'}>
|
||||
@@ -82,8 +54,9 @@ const UserCell = () => {
|
||||
title={
|
||||
<View style={{display: 'inline-flex', alignItems: 'center'}} onClick={() => navTo('/dealer/index', true)}>
|
||||
<Reward className={'text-orange-100 '} size={16}/>
|
||||
<Text style={{fontSize: '16px'}} className={'pl-3 text-orange-100 font-medium'}>分销中心</Text>
|
||||
<Text className={'text-white opacity-80 pl-3'}>门店核销</Text>
|
||||
<Text style={{fontSize: '16px'}}
|
||||
className={'pl-3 text-orange-100 font-medium'}>分销中心</Text>
|
||||
{/*<Text className={'text-white opacity-80 pl-3'}>门店核销</Text>*/}
|
||||
</View>
|
||||
}
|
||||
extra={<ArrowRight color="#cccccc" size={18}/>}
|
||||
@@ -94,7 +67,7 @@ const UserCell = () => {
|
||||
}
|
||||
|
||||
/**
|
||||
* 分销中心
|
||||
* 普通用户
|
||||
*/
|
||||
return (
|
||||
<>
|
||||
|
||||
Reference in New Issue
Block a user