feat(pages): 添加多个页面配置和功能模块
- 新增 .editorconfig、.eslintrc、.gitignore 配置文件 - 添加管理员文章管理页面配置和功能实现 - 添加经销商申请注册页面配置和功能实现 - 添加经销商银行卡管理页面配置和功能实现 - 添加经销商客户管理页面配置和功能实现 - 添加用户地址管理页面配置和功能实现 - 添加用户聊天消息页面配置和功能实现 - 添加用户礼品管理页面配置和功能实现
This commit is contained in:
3
src/dealer/capital/detail.config.ts
Normal file
3
src/dealer/capital/detail.config.ts
Normal file
@@ -0,0 +1,3 @@
|
||||
export default definePageConfig({
|
||||
navigationBarTitleText: '详情'
|
||||
})
|
||||
79
src/dealer/capital/detail.tsx
Normal file
79
src/dealer/capital/detail.tsx
Normal file
@@ -0,0 +1,79 @@
|
||||
import {useState, useEffect} from 'react'
|
||||
import {View, Text} from '@tarojs/components'
|
||||
import {Empty, Loading} from '@nutui/nutui-react-taro'
|
||||
import {useRouter} from '@tarojs/taro'
|
||||
import {getShopDealerCapital} from '@/api/shop/shopDealerCapital'
|
||||
import type {ShopDealerCapital} from '@/api/shop/shopDealerCapital/model'
|
||||
|
||||
const DealerCapitalDetail = () => {
|
||||
const {params} = useRouter();
|
||||
const [loading, setLoading] = useState<boolean>(false)
|
||||
const [item, setItem] = useState<ShopDealerCapital>()
|
||||
|
||||
// 获取订单数据
|
||||
const reload = async () => {
|
||||
const data = await getShopDealerCapital(Number(params.id))
|
||||
setItem(data)
|
||||
}
|
||||
|
||||
const getFlowType = (index?: number) => {
|
||||
if (index === 10) return '电费收益'
|
||||
if (index === 20) return '提现支出'
|
||||
if (index === 30) return '转账支出'
|
||||
if (index === 40) return '转账收入'
|
||||
if (index === 50) return '新注册奖励'
|
||||
return 'warning'
|
||||
}
|
||||
|
||||
// 初始化加载数据
|
||||
useEffect(() => {
|
||||
reload().then(() => {
|
||||
setLoading(true)
|
||||
})
|
||||
}, [])
|
||||
|
||||
return (
|
||||
<View className="min-h-screen bg-gray-50">
|
||||
<View className="p-4">
|
||||
{loading && !item ? (
|
||||
<View className="text-center py-8">
|
||||
<Loading/>
|
||||
<Text className="text-gray-500 mt-2">加载中...</Text>
|
||||
</View>
|
||||
) : item ? (
|
||||
<View key={item.id} className="bg-white rounded-lg p-4 mb-3 shadow-sm">
|
||||
<View className="flex flex-col justify-center items-center py-8">
|
||||
<Text className="text-lg text-gray-300">
|
||||
{getFlowType(item.flowType)}
|
||||
</Text>
|
||||
<View className="text-4xl mt-1 font-semibold flex justify-start">
|
||||
<Text className={'subscript text-xl mt-1'}>¥</Text>
|
||||
<Text className={'text-4xl'}>{Number(item.money).toFixed(2)}</Text>
|
||||
</View>
|
||||
</View>
|
||||
|
||||
<View className="flex flex-col justify-between mb-1">
|
||||
<Text className="text-sm my-1 text-gray-500">
|
||||
收益描述:{item.comments}
|
||||
</Text>
|
||||
{item.orderNo && (
|
||||
<Text className="text-sm my-1 text-gray-500">
|
||||
订单编号:{item.orderNo}
|
||||
</Text>
|
||||
)}
|
||||
<Text className="text-sm my-1 text-gray-500">
|
||||
创建时间:{item.createTime}
|
||||
</Text>
|
||||
</View>
|
||||
</View>
|
||||
) : (
|
||||
<Empty description="账单不存在" style={{
|
||||
backgroundColor: 'transparent'
|
||||
}}/>
|
||||
)}
|
||||
</View>
|
||||
</View>
|
||||
)
|
||||
}
|
||||
|
||||
export default DealerCapitalDetail
|
||||
3
src/dealer/capital/index.config.ts
Normal file
3
src/dealer/capital/index.config.ts
Normal file
@@ -0,0 +1,3 @@
|
||||
export default definePageConfig({
|
||||
navigationBarTitleText: '收益明细'
|
||||
})
|
||||
216
src/dealer/capital/index.tsx
Normal file
216
src/dealer/capital/index.tsx
Normal file
@@ -0,0 +1,216 @@
|
||||
import React, {useState, useEffect, useCallback} from 'react'
|
||||
import {View, Text, ScrollView} from '@tarojs/components'
|
||||
import {ArrowDown} from '@nutui/icons-react-taro'
|
||||
import {Empty, PullToRefresh, DatePicker, Loading} from '@nutui/nutui-react-taro'
|
||||
import Taro from '@tarojs/taro'
|
||||
import {pageShopDealerCapital} from '@/api/shop/shopDealerCapital'
|
||||
import {useDealerUser} from '@/hooks/useDealerUser'
|
||||
import type {ShopDealerCapital} from '@/api/shop/shopDealerCapital/model'
|
||||
import navTo from "@/utils/common";
|
||||
|
||||
const DealerCapital: React.FC = () => {
|
||||
const [loading, setLoading] = useState<boolean>(false)
|
||||
const d = new Date()
|
||||
const currMonth = `${d.getFullYear()}${d.getMonth() + 1}`;
|
||||
const currDate = `${d.getFullYear()}-${d.getMonth() + 1}-${d.getDate()}`;
|
||||
const [date, setDate] = useState(currMonth)
|
||||
const [show1, setShow1] = useState(false)
|
||||
const [refreshing, setRefreshing] = useState<boolean>(false)
|
||||
const [loadingMore, setLoadingMore] = useState<boolean>(false)
|
||||
const [capital, setCapital] = useState<ShopDealerCapital[]>([])
|
||||
const [currentPage, setCurrentPage] = useState<number>(1)
|
||||
const [hasMore, setHasMore] = useState<boolean>(true)
|
||||
const [totayMoney, setTotayMoney] = useState<number>(0)
|
||||
|
||||
const {dealerUser} = useDealerUser()
|
||||
|
||||
// 获取订单数据
|
||||
const fetchCapital = useCallback(async (page: number = 1, isRefresh: boolean = false) => {
|
||||
// if (!dealerUser?.userId) return
|
||||
|
||||
try {
|
||||
if (isRefresh) {
|
||||
setRefreshing(true)
|
||||
} else if (page === 1) {
|
||||
setLoading(true)
|
||||
} else {
|
||||
setLoadingMore(true)
|
||||
}
|
||||
|
||||
const result = await pageShopDealerCapital({
|
||||
page,
|
||||
limit: 10,
|
||||
month: date,
|
||||
userId: Taro.getStorageSync('UserId')
|
||||
})
|
||||
|
||||
if (result?.list) {
|
||||
const newCapital = result.list.map(item => ({
|
||||
...item,
|
||||
orderNo: item.orderNo
|
||||
}))
|
||||
// 通过result.list 返回的数据统计totalMoney
|
||||
setTotayMoney(newCapital.reduce((acc, cur) => acc + Number(cur.money), 0))
|
||||
|
||||
// 本月收益汇总
|
||||
// setTotayMoney(result.totalMoney)
|
||||
|
||||
|
||||
if (page === 1) {
|
||||
setCapital(newCapital)
|
||||
} else {
|
||||
setCapital(prev => [...prev, ...newCapital])
|
||||
}
|
||||
|
||||
setHasMore(newCapital.length === 10)
|
||||
setCurrentPage(page)
|
||||
}
|
||||
|
||||
} catch (error) {
|
||||
console.error('获取分销订单失败:', error)
|
||||
Taro.showToast({
|
||||
title: '获取订单失败',
|
||||
icon: 'error'
|
||||
})
|
||||
} finally {
|
||||
setLoading(false)
|
||||
setRefreshing(false)
|
||||
setLoadingMore(false)
|
||||
}
|
||||
}, [dealerUser?.userId,date])
|
||||
|
||||
// 下拉刷新
|
||||
const handleRefresh = async () => {
|
||||
await fetchCapital(1, true)
|
||||
}
|
||||
|
||||
// 加载更多
|
||||
const handleLoadMore = async () => {
|
||||
if (!loadingMore && hasMore) {
|
||||
await fetchCapital(currentPage + 1)
|
||||
}
|
||||
}
|
||||
|
||||
const getFlowType = (index?: number) => {
|
||||
if (index === 10) return '电费收益'
|
||||
if (index === 20) return '提现支出'
|
||||
if (index === 30) return '转账支出'
|
||||
if (index === 40) return '转账收入'
|
||||
return 'warning'
|
||||
}
|
||||
|
||||
// 初始化加载数据
|
||||
useEffect(() => {
|
||||
if (dealerUser?.userId) {
|
||||
fetchCapital(1)
|
||||
}
|
||||
}, [fetchCapital,date])
|
||||
|
||||
const renderCapitalItem = (item: ShopDealerCapital) => (
|
||||
<View key={item.id} className="bg-white rounded-lg p-4 mb-3 shadow-sm"
|
||||
onClick={() => navTo(`/dealer/capital/detail?id=${item.id}`)}>
|
||||
<View className="flex justify-between items-start mb-1">
|
||||
<Text className="font-semibold text-gray-800">
|
||||
{getFlowType(item.flowType)}
|
||||
</Text>
|
||||
<Text className="text-lg text-orange-500 font-semibold">
|
||||
¥{Number(item.money).toFixed(2)}
|
||||
</Text>
|
||||
</View>
|
||||
|
||||
{item.orderNo && (
|
||||
<View className="flex justify-between items-center mb-1">
|
||||
<Text className="text-sm text-gray-400">
|
||||
{item.orderNo}
|
||||
</Text>
|
||||
</View>
|
||||
)}
|
||||
|
||||
<View className="flex justify-between items-center mb-1">
|
||||
<Text className="text-sm text-gray-400">
|
||||
{item.createTime}
|
||||
</Text>
|
||||
<Text className="text-sm text-gray-400">
|
||||
我的收益:{item.money}
|
||||
</Text>
|
||||
</View>
|
||||
|
||||
</View>
|
||||
)
|
||||
|
||||
return (
|
||||
<View className="min-h-screen bg-gray-50">
|
||||
<PullToRefresh
|
||||
onRefresh={handleRefresh}
|
||||
disabled={refreshing}
|
||||
pullingText="下拉刷新"
|
||||
canReleaseText="释放刷新"
|
||||
refreshingText="刷新中..."
|
||||
completeText="刷新完成"
|
||||
>
|
||||
<ScrollView
|
||||
scrollY
|
||||
className={'h-screen'}
|
||||
onScrollToLower={handleLoadMore}
|
||||
lowerThreshold={50}
|
||||
>
|
||||
{/*筛选工具条*/}
|
||||
<View
|
||||
className={'px-4 mt-4 flex flex-1 items-center justify-between'}
|
||||
>
|
||||
<View>
|
||||
<Text className={'text-sm mr-1'} onClick={() => setShow1(true)}>{date ? `${date}` : '请选择'}</Text>
|
||||
<ArrowDown size={10} className={'text-gray-400'} onClick={() => setShow1(true)}/>
|
||||
</View>
|
||||
<View className={'text-center'}>本月收益汇总¥{totayMoney}</View>
|
||||
</View>
|
||||
{/*账单列表*/}
|
||||
<View className="p-4">
|
||||
{loading && capital.length === 0 ? (
|
||||
<View className="text-center py-8">
|
||||
<Loading/>
|
||||
<Text className="text-gray-500 mt-2">加载中...</Text>
|
||||
</View>
|
||||
) : capital.length > 0 ? (
|
||||
<>
|
||||
{capital.map(renderCapitalItem)}
|
||||
{loadingMore && (
|
||||
<View className="text-center py-4">
|
||||
<Loading/>
|
||||
<Text className="text-gray-500 mt-1 text-sm">加载更多...</Text>
|
||||
</View>
|
||||
)}
|
||||
{!hasMore && capital.length > 0 && (
|
||||
<View className="text-center py-4">
|
||||
<Text className="text-gray-400 text-sm">没有更多数据了</Text>
|
||||
</View>
|
||||
)}
|
||||
</>
|
||||
) : (
|
||||
<Empty description="暂无收益" style={{
|
||||
backgroundColor: 'transparent'
|
||||
}}/>
|
||||
)}
|
||||
</View>
|
||||
</ScrollView>
|
||||
</PullToRefresh>
|
||||
<DatePicker
|
||||
title="日期选择"
|
||||
visible={show1}
|
||||
pickerProps={{
|
||||
popupProps: {zIndex: 1220},
|
||||
}}
|
||||
type={'year-month'}
|
||||
defaultValue={new Date(`${currDate}`)}
|
||||
showChinese
|
||||
onCancel={() => setShow1(false)}
|
||||
onConfirm={(_, values) => {
|
||||
setShow1(false)
|
||||
setDate(`${values[0]}${values[1]}`)
|
||||
}}
|
||||
/>
|
||||
</View>
|
||||
)
|
||||
}
|
||||
|
||||
export default DealerCapital
|
||||
3
src/dealer/capital/record.config.ts
Normal file
3
src/dealer/capital/record.config.ts
Normal file
@@ -0,0 +1,3 @@
|
||||
export default definePageConfig({
|
||||
navigationBarTitleText: '收益明细'
|
||||
})
|
||||
180
src/dealer/capital/record.tsx
Normal file
180
src/dealer/capital/record.tsx
Normal file
@@ -0,0 +1,180 @@
|
||||
import React, {useState, useEffect, useCallback} from 'react'
|
||||
import {View, Text, ScrollView} from '@tarojs/components'
|
||||
import {Empty, PullToRefresh, Loading} from '@nutui/nutui-react-taro'
|
||||
import Taro from '@tarojs/taro'
|
||||
import {pageShopDealerCapital} from '@/api/shop/shopDealerCapital'
|
||||
import {useDealerUser} from '@/hooks/useDealerUser'
|
||||
import type {ShopDealerCapital} from '@/api/shop/shopDealerCapital/model'
|
||||
import navTo from "@/utils/common";
|
||||
// import {pushByUpdateAdmin} from "@/api/sdy/sdyTemplateMessage";
|
||||
|
||||
const DealerCapital: React.FC = () => {
|
||||
const [loading, setLoading] = useState<boolean>(false)
|
||||
const [refreshing, setRefreshing] = useState<boolean>(false)
|
||||
const [loadingMore, setLoadingMore] = useState<boolean>(false)
|
||||
const [capital, setCapital] = useState<ShopDealerCapital[]>([])
|
||||
const [currentPage, setCurrentPage] = useState<number>(1)
|
||||
const [hasMore, setHasMore] = useState<boolean>(true)
|
||||
|
||||
const {dealerUser} = useDealerUser()
|
||||
|
||||
// 获取订单数据
|
||||
const fetchCapital = useCallback(async (page: number = 1, isRefresh: boolean = false) => {
|
||||
// if (!dealerUser?.userId) return
|
||||
|
||||
try {
|
||||
if (isRefresh) {
|
||||
setRefreshing(true)
|
||||
} else if (page === 1) {
|
||||
setLoading(true)
|
||||
} else {
|
||||
setLoadingMore(true)
|
||||
}
|
||||
|
||||
const result = await pageShopDealerCapital({
|
||||
page,
|
||||
limit: 10,
|
||||
userId: Taro.getStorageSync('UserId')
|
||||
})
|
||||
|
||||
if (result?.list) {
|
||||
const newCapital = result.list.map(item => ({
|
||||
...item,
|
||||
orderNo: item.orderNo
|
||||
}))
|
||||
|
||||
if (page === 1) {
|
||||
setCapital(newCapital)
|
||||
} else {
|
||||
setCapital(prev => [...prev, ...newCapital])
|
||||
}
|
||||
|
||||
setHasMore(newCapital.length === 10)
|
||||
setCurrentPage(page)
|
||||
}
|
||||
|
||||
} catch (error) {
|
||||
console.error('获取分销订单失败:', error)
|
||||
Taro.showToast({
|
||||
title: '获取订单失败',
|
||||
icon: 'error'
|
||||
})
|
||||
} finally {
|
||||
setLoading(false)
|
||||
setRefreshing(false)
|
||||
setLoadingMore(false)
|
||||
}
|
||||
}, [dealerUser?.userId])
|
||||
|
||||
// 下拉刷新
|
||||
const handleRefresh = async () => {
|
||||
await fetchCapital(1, true)
|
||||
}
|
||||
|
||||
// 加载更多
|
||||
const handleLoadMore = async () => {
|
||||
if (!loadingMore && hasMore) {
|
||||
await fetchCapital(currentPage + 1)
|
||||
}
|
||||
}
|
||||
|
||||
const getFlowType = (index?: number) => {
|
||||
if (index === 10) return '电费收益'
|
||||
if (index === 20) return '提现支出'
|
||||
if (index === 30) return '转账支出'
|
||||
if (index === 40) return '转账收入'
|
||||
if (index === 50) return '新注册奖励'
|
||||
return 'warning'
|
||||
}
|
||||
|
||||
// 初始化加载数据
|
||||
useEffect(() => {
|
||||
if (dealerUser?.userId) {
|
||||
fetchCapital(1)
|
||||
}
|
||||
// pushByUpdateAdmin(34423).then()
|
||||
}, [fetchCapital])
|
||||
|
||||
const renderCapitalItem = (item: ShopDealerCapital) => (
|
||||
<View key={item.id} className="bg-white rounded-lg p-4 mb-3 shadow-sm"
|
||||
onClick={() => navTo(`/dealer/capital/detail?id=${item.id}`)}>
|
||||
<View className="flex justify-between items-start mb-1">
|
||||
<Text className="font-semibold text-gray-800">
|
||||
{getFlowType(item.flowType)}
|
||||
</Text>
|
||||
<Text className="text-lg text-orange-500 font-semibold">
|
||||
¥{Number(item.money).toFixed(2)}
|
||||
</Text>
|
||||
</View>
|
||||
|
||||
{item.orderNo && (
|
||||
<View className="flex justify-between items-center mb-1">
|
||||
<Text className="text-sm text-gray-400">
|
||||
{item.orderNo}
|
||||
</Text>
|
||||
</View>
|
||||
)}
|
||||
|
||||
<View className="flex justify-between items-center mb-1">
|
||||
<Text className="text-sm text-gray-400">
|
||||
{item.createTime}
|
||||
</Text>
|
||||
<Text className="text-sm text-gray-400">
|
||||
我的收益:{item.money}
|
||||
</Text>
|
||||
</View>
|
||||
|
||||
</View>
|
||||
)
|
||||
|
||||
return (
|
||||
<View className="min-h-screen bg-gray-50">
|
||||
<PullToRefresh
|
||||
onRefresh={handleRefresh}
|
||||
disabled={refreshing}
|
||||
pullingText="下拉刷新"
|
||||
canReleaseText="释放刷新"
|
||||
refreshingText="刷新中..."
|
||||
completeText="刷新完成"
|
||||
>
|
||||
<ScrollView
|
||||
scrollY
|
||||
className={'h-screen'}
|
||||
onScrollToLower={handleLoadMore}
|
||||
lowerThreshold={50}
|
||||
>
|
||||
{/*账单列表*/}
|
||||
<View className="p-4">
|
||||
{loading && capital.length === 0 ? (
|
||||
<View className="text-center py-8">
|
||||
<Loading/>
|
||||
<Text className="text-gray-500 mt-2">加载中...</Text>
|
||||
</View>
|
||||
) : capital.length > 0 ? (
|
||||
<>
|
||||
{capital.map(renderCapitalItem)}
|
||||
{loadingMore && (
|
||||
<View className="text-center py-4">
|
||||
<Loading/>
|
||||
<Text className="text-gray-500 mt-1 text-sm">加载更多...</Text>
|
||||
</View>
|
||||
)}
|
||||
{!hasMore && capital.length > 0 && (
|
||||
<View className="text-center py-4">
|
||||
<Text className="text-gray-400 text-sm">没有更多数据了</Text>
|
||||
</View>
|
||||
)}
|
||||
</>
|
||||
) : (
|
||||
<Empty description="暂无收益" style={{
|
||||
backgroundColor: 'transparent'
|
||||
}}/>
|
||||
)}
|
||||
</View>
|
||||
</ScrollView>
|
||||
</PullToRefresh>
|
||||
</View>
|
||||
)
|
||||
}
|
||||
|
||||
export default DealerCapital
|
||||
Reference in New Issue
Block a user