import { Image, Input, Text, View } from "@tarojs/components" import back from '@/images/back.png' import checked from '@/images/checked.png' import empty from '@/images/empty.png' import eye from '@/images/eye.png' import './index.scss' import { Button } from "@nutui/nutui-react-taro" import { useState } from "react" import Taro from "@tarojs/taro" import backNav from '@/images/backNav.png' import { Picker } from "@nutui/nutui-react-taro" import { Tabs, TabPane } from "@nutui/nutui-react-taro" import { Infiniteloading } from "@nutui/nutui-react-taro" import { useEffect } from "react" import { userDetail, userLogs } from "../../utils/api" import { formatDateByStr } from "../../utils/utils" const activeEye = eye const Login = () => { const limit = 20 const [tabKey, setTabKey] = useState('0') const [page, setPage] = useState(1) const [user, setUser] = useState({}) const [list, setList] = useState([]) const [total, setTotal] = useState(0) useEffect(() => { userDetail().then(rs => { if (!rs) return setUser(rs) }) }, []) // 返回页面 const backFn = () => { Taro.getCurrentPages().length > 0 && Taro.navigateBack() } useEffect(() => { if (total <= list.length && list.length > 0) return let offset = (page - 1) * limit userLogs('shopping_score', { offset, limit }).then(rs => { if (!rs || rs.items.length == 0) return setList(it => [...it, ...rs.items]) setTotal(rs.total) }) }, [tabKey, page]) const switchTab = (key) => { if (key != tabKey) { setPage(1) } setTabKey(key) } return 我的购物金 我的余额 {user.shopping_score} switchTab('0')}>余额流水 {/* setTabKey('1')}>充值记录 setTabKey('2')}>提现记录 */} { !!list.length && = list.length} onLoadMore={(x) => { setPage(p => p + 1) x() }} > { list.map(item => { return {item.memo} {formatDateByStr(item.created_at)} {item.amount > 0 ? `+${item.amount}` : `${item.amount}`} }) } } { !list.length && } } export default Login