个人中心页面相关

This commit is contained in:
tangping 2023-05-27 22:48:40 +08:00
parent 2353101453
commit dad0452831
21 changed files with 515 additions and 269 deletions

View File

@ -222,4 +222,11 @@
.nut-popup {
background: none !important;
}
.order-empty {
width: 200px;
height: 200px;
margin-left: calc((375px - 200px)/2);
margin-top: 100px;
}

View File

@ -8,18 +8,16 @@ import { Button } from "@nutui/nutui-react-taro"
import { useState } from "react"
import Taro from "@tarojs/taro"
import backNav from '@/images/backNav.png'
import { createCard } from "../../utils/api"
import { closeLoading, errorNotice, loading, successNotice } from "../../utils/utils"
const activeEye = eye
const Login = () => {
const [account, setAccount] = useState('')
const [pwd, setPwd] = useState()
const [loginMode, setLoginMode] = useState('account')
const [mobile, setMobile] = useState('')
const [smsCode, setSmsCode] = useState('')
const [interval, setIntervalTime] = useState(0)
const [user, setUser] = useState('')
const [accountNumber, setAccountNumber] = useState()
//
@ -28,45 +26,36 @@ const Login = () => {
}
//
const loginFn = () => {
Taro.redirectTo({
url: '/pages/login/index'
const submit = () => {
if (!account || !accountNumber || !user) {
errorNotice('请完善银行卡信息')
return
}
if (account.length > 10) {
console.log(account.length, account, "dd")
errorNotice('银行名称不能超过10个字符')
return
}
if (accountNumber.length < 10) {
errorNotice('银行卡号不能小于10个字符')
return
}
loading('银行卡添加中,请稍后~')
const re = createCard({
bank_name: account,
account_number: accountNumber,
account_name: user,
bank_branch: account
})
}
//
const cleanFn = () => {
if (loginMode === 'account') {
setAccount('')
setPwd('')
return
}
setMobile('')
setSmsCode('')
}
//
const countDown = () => {
if (!mobile) {
return
}
setIntervalTime(60)
if (interval > 0) {
return
}
let start = 60
const timer = setInterval(() => {
if (start > 0) {
start--
if (start <= 0) {
clearInterval(timer)
}
setIntervalTime(start)
}
closeLoading()
if (!re) return
successNotice('银行卡添加成功')
setTimeout(() => {
backFn()
}, 1000)
}
return <View className="login-frame bg-slate-50 h-screen text-base">
<View className='addr-detail-title'>
<Image src={backNav} className="square-35 absolute left-10 nav-icon" onClick={backFn} />
@ -76,30 +65,43 @@ const Login = () => {
<View className="change-pwd-container bg-slate-50 relative">
<View>
<View className="form-item mt-22">
<View className="form-label">银行卡号</View>
<View className="form-label">银行名称</View>
<View className="form-control relative">
<Input className="form-input" placeholder="请输入银行卡号" onInput={(v) => {
<Input className="form-input" type='text' placeholder="请输入银行名称" onInput={(v) => {
setAccount(v.detail.value)
}} />
{
account && <Image className="w-6 h-6 absolute right-0 bottom-16" src={checked} />
}
</View>
</View>
<View className="form-item mt-22">
<View className="form-label">银行卡号</View>
<View className="form-control relative">
<Input className="form-input" placeholder="请输入银行卡号" onInput={(v) => {
setAccountNumber(v.detail.value)
}} />
{
accountNumber && <Image className="w-6 h-6 absolute right-0 bottom-16" src={checked} />
}
</View>
</View>
<View className="form-item mt-22">
<View className="form-label">银行名称</View>
<View className="form-label">开户人名称</View>
<View className="form-control relative">
<Input className="form-input" type='text' placeholder="请输入银行名称" onInput={(v) => {
setPwd(v.detail.value)
<Input className="form-input" placeholder="请输入账户名" onInput={(v) => {
setUser(v.detail.value)
}} />
{
pwd && <Image className="w-6 h-6 absolute right-0 bottom-16" src={checked} />
user && <Image className="w-6 h-6 absolute right-0 bottom-16" src={checked} />
}
</View>
</View>
<View className="change-phone-footer flex flex-col justify-center">
<Button className="login-btn">保存</Button>
<Button className="login-btn" onClick={submit}>保存</Button>
</View>
</View>

View File

@ -1,7 +1,7 @@
import { Image, Input, Text, View } from "@tarojs/components"
import back from '@/images/back.png'
import checked from '@/images/checked.png'
import eyeClose from '@/images/eyeClose.png'
import empty from '@/images/empty.png'
import eye from '@/images/eye.png'
import './index.scss'
import { Button } from "@nutui/nutui-react-taro"
@ -12,20 +12,50 @@ 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)
const [ref, setRef] = useState(0)
useEffect(() => {
userDetail().then(rs => {
if (!rs) return
setUser(rs)
})
}, [])
//
const backFn = () => {
Taro.getCurrentPages().length > 0 && Taro.navigateBack()
}
useEffect(() => { }, [tabKey])
useEffect(() => {
let offset = (page - 1) * limit
userLogs('score', offset, limit).then(rs => {
if (!rs) return
setList(it => [...it, ...rs.items])
setTotal(rs.total)
})
}, [tabKey, page])
const switchTab = (key) => {
if (key != tabKey) {
setPage(1)
}
setTabKey(key)
}
return <View className="cash-frame bg-slate-50 h-screen text-base">
@ -38,7 +68,7 @@ const Login = () => {
<View className="balance-amount flex-col ">
<View className="flex-between mt-22">
<Text>当前余额</Text>
<Text className="balance-amount-price">50000</Text>
<Text className="balance-amount-price">{user.score}</Text>
</View>
<View className="flex-around mt-22">
<View className="balance-btn flex-center" onClick={() => {
@ -51,40 +81,41 @@ const Login = () => {
</View>
<View className="amount-container">
<View className="amount-tabs flex-around">
<View className={'tab-pane ' + (tabKey == '0' ? 'tab-pane-active' : '')} onClick={() => setTabKey('0')}>余额流水</View>
<View className={'tab-pane ' + (tabKey == '1' ? 'tab-pane-active' : '')} onClick={() => setTabKey('1')}>充值记录</View>
<View className={'tab-pane ' + (tabKey == '2' ? 'tab-pane-active' : '')} onClick={() => setTabKey('2')}>提现记录</View>
<View className="amount-tabs flex-start">
<View className={'tab-pane ' + (tabKey == '0' ? 'tab-pane-active' : '')} onClick={() => switchTab('0')}>余额流水</View>
{/* <View className={'tab-pane ' + (tabKey == '1' ? 'tab-pane-active' : '')} onClick={() => switchTab('1')}>充值记录</View> */}
{/* <View className={'tab-pane ' + (tabKey == '2' ? 'tab-pane-active' : '')} onClick={() => switchTab('2')}>提现记录</View> */}
</View>
<View className="balanceScroll" id="balanceScroll">
<Infiniteloading
containerId="balanceScroll"
useWindow={false}
loadTxt="loading"
loadMoreTxt="没有数据啦~"
loadIcon='loading'
hasMore={false}
onLoadMore={(x) => {
setPage(p => p + 1)
x()
}}
>
<View className="amount-item flex-between">
<View className="amount-item-detail flex-col">
<View>完成每日登陆</View>
<View className="amount-item-time">2021/04/09 19:42:36</View>
</View>
<View className="amount-item-log">+1.00</View>
</View>
<View className="amount-item flex-between">
<View className="amount-item-detail flex-col">
<View>完成每日登陆</View>
<View className="amount-item-time">2021/04/09 19:42:36</View>
</View>
<View className="amount-item-log">+1.00</View>
</View>
</Infiniteloading>
{
!!list.length && <Infiniteloading
containerId="balanceScroll"
useWindow={false}
loadTxt="loading"
loadMoreTxt="没有数据啦~"
loadIcon='loading'
hasMore={total >= list.length}
onLoadMore={(x) => {
setPage(p => p + 1)
x()
}}
>
{
list.map(item => {
return <View className="amount-item flex-between" key={item.id}>
<View className="amount-item-detail flex-col">
<View>{item.memo}</View>
<View className="amount-item-time">{formatDateByStr(item.created_at)}</View>
</View>
<View className="amount-item-log">{item.amount > 0 ? `+${item.amount}` : `${item.amount}`}</View>
</View>
})
}
</Infiniteloading>
}
{
!list.length && <Image src={empty} className="order-empty" />
}
</View>
</View>

View File

@ -8,6 +8,8 @@ import { Button } from "@nutui/nutui-react-taro"
import { useState } from "react"
import Taro from "@tarojs/taro"
import backNav from '@/images/backNav.png'
import { phoneManage } from "../../utils/api"
import { closeLoading, errorNotice, loading, redirectTo, successNotice } from "../../utils/utils"
const activeEye = eye
@ -15,7 +17,7 @@ const Login = () => {
const [account, setAccount] = useState('')
const [pwd, setPwd] = useState()
const [loginMode, setLoginMode] = useState('account')
const [showPwd, setShowPwd] = useState(false)
const [mobile, setMobile] = useState('')
const [smsCode, setSmsCode] = useState('')
@ -28,27 +30,9 @@ const Login = () => {
}
//
const loginFn = () => {
Taro.redirectTo({
url: '/pages/login/index'
})
}
//
const cleanFn = () => {
if (loginMode === 'account') {
setAccount('')
setPwd('')
return
}
setMobile('')
setSmsCode('')
}
//
const countDown = () => {
if (!mobile) {
if (!account) {
return
}
setIntervalTime(60)
@ -67,6 +51,25 @@ const Login = () => {
}, 1000)
}
const submit = async () => {
if (!account || !smsCode || !pwd) {
errorNotice('请完善信息')
return
}
loading('手机号码修改中,请稍后~')
const re = await phoneManage({
new_phone: account,
password: pwd,
verification_code: smsCode
})
closeLoading()
if (!re) return
successNotice('手机号码修改成功')
setTimeout(() => {
backFn()
}, 1000)
}
return <View className="login-frame bg-slate-50 h-screen text-base">
<View className='addr-detail-title'>
<Image src={backNav} className="square-35 absolute left-10 nav-icon" onClick={backFn} />
@ -76,15 +79,25 @@ const Login = () => {
<View className="change-pwd-container bg-slate-50 relative">
<View>
<View className="form-item mt-22">
<View className="form-label">验证原手机号</View>
<View className="form-label">密码</View>
<View className="form-control relative">
<Input className="form-input" placeholder="请输入手机号" onInput={(v) => {
<Input className="form-input" type={showPwd ? 'text' : 'password'} placeholder="设置新密码" onInput={(v) => {
setPwd(v.detail.value)
}} />
<Image className="w-6 h-6 absolute right-0 bottom-16" src={showPwd ? activeEye : eyeClose} onClick={() => {
setShowPwd(v => !v)
}} />
</View>
</View>
<View className="form-item mt-22">
<View className="form-label">输入新手机号码</View>
<View className="form-control relative">
<Input className="form-input" type='text' placeholder="设置新手机号码" onInput={(v) => {
setAccount(v.detail.value)
}} />
{
account && <Image className="w-6 h-6 absolute right-0 bottom-16" src={checked} />
}
</View>
</View>
<View className="form-item mt-22">
@ -96,19 +109,8 @@ const Login = () => {
<Button className="code-btn" disabled={interval > 0} onClick={countDown}>{interval ? interval + 's' : '获取验证码'}</Button>
</View>
</View>
<View className="form-item mt-22">
<View className="form-label">输入新手机号码</View>
<View className="form-control relative">
<Input className="form-input" type='text' placeholder="设置新手机号码" onInput={(v) => {
setPwd(v.detail.value)
}} />
{
pwd && <Image className="w-6 h-6 absolute right-0 bottom-16" src={checked} />
}
</View>
</View>
<View className="change-phone-footer flex flex-col justify-center">
<Button className="login-btn">保存</Button>
<Button className="login-btn" onClick={submit}>保存</Button>
</View>
</View>

View File

@ -8,6 +8,8 @@ import { Button } from "@nutui/nutui-react-taro"
import { useState } from "react"
import Taro from "@tarojs/taro"
import backNav from '@/images/backNav.png'
import { closeLoading, errorNotice, loading, successNotice } from "../../utils/utils"
import { pwdManage } from "../../utils/api"
const activeEye = eye
@ -15,10 +17,9 @@ const Login = () => {
const [account, setAccount] = useState('')
const [pwd, setPwd] = useState()
const [confirmPwd, setConfirmPwd] = useState()
const [showPwd, setShowPwd] = useState(false)
const [loginMode, setLoginMode] = useState('account')
const [mobile, setMobile] = useState('')
const [showConfirmPwd, setShowConfirmPwd] = useState(false)
const [smsCode, setSmsCode] = useState('')
const [interval, setIntervalTime] = useState(0)
@ -28,28 +29,9 @@ const Login = () => {
Taro.getCurrentPages().length > 0 && Taro.navigateBack()
}
//
const loginFn = () => {
Taro.redirectTo({
url: '/pages/login/index'
})
}
//
const cleanFn = () => {
if (loginMode === 'account') {
setAccount('')
setPwd('')
return
}
setMobile('')
setSmsCode('')
}
//
const countDown = () => {
if (!mobile) {
if (!account) {
return
}
setIntervalTime(60)
@ -68,6 +50,30 @@ const Login = () => {
}, 1000)
}
const submit = async () => {
if (!account || !smsCode || !pwd || !confirmPwd) {
errorNotice('请完善信息')
return
}
if (pwd !== confirmPwd) {
errorNotice("两次密码不一致")
return
}
loading('密码重置中,请稍后~')
const re = await pwdManage('login_password', {
confirm_password: confirmPwd,
password: pwd,
phone: account,
verification_code: smsCode
})
closeLoading()
if (!re) return
successNotice('密码重置成功')
setTimeout(() => {
backFn()
}, 1000)
}
return <View className="login-frame bg-slate-50 h-screen text-base">
<View className='addr-detail-title'>
<Image src={backNav} className="square-35 absolute left-10 nav-icon" onClick={backFn} />
@ -77,7 +83,7 @@ const Login = () => {
<View className="change-pwd-container relative">
<View>
<View className="form-item mt-22">
<View className="form-label"></View>
<View className="form-label">手机</View>
<View className="form-control relative">
<Input className="form-input" placeholder="请输入手机号" onInput={(v) => {
setAccount(v.detail.value)
@ -109,18 +115,18 @@ const Login = () => {
</View>
</View>
<View className="form-item mt-22">
<View className="form-label">密码</View>
<View className="form-label">确认密码</View>
<View className="form-control relative">
<Input className="form-input" type={showPwd ? 'text' : 'password'} placeholder="再次确认新密码" onInput={(v) => {
setPwd(v.detail.value)
<Input className="form-input" type={showConfirmPwd ? 'text' : 'password'} placeholder="再次确认新密码" onInput={(v) => {
setConfirmPwd(v.detail.value)
}} />
<Image className="w-6 h-6 absolute right-0 bottom-16" src={showPwd ? activeEye : eyeClose} onClick={() => {
setShowPwd(v => !v)
<Image className="w-6 h-6 absolute right-0 bottom-16" src={showConfirmPwd ? activeEye : eyeClose} onClick={() => {
setShowConfirmPwd(v => !v)
}} />
</View>
</View>
<View className="change-pwd-footer flex flex-col justify-center">
<Button className="login-btn">保存</Button>
<Button className="login-btn" onClick={submit}>保存</Button>
</View>
</View>

View File

@ -7,7 +7,8 @@ import './index.scss'
import { Button } from "@nutui/nutui-react-taro"
import { useState } from "react"
import Taro from "@tarojs/taro"
import { sendCode } from "../../utils/api"
import { pwdManage, sendCode } from "../../utils/api"
import { closeLoading, errorNotice, loading, successNotice } from "../../utils/utils"
const activeEye = eye
@ -15,8 +16,9 @@ const Login = () => {
const [account, setAccount] = useState('')
const [pwd, setPwd] = useState()
const [confirmPwd, setConfirmPwd] = useState()
const [showPwd, setShowPwd] = useState(false)
const [loginMode, setLoginMode] = useState('account')
const [showConfirmPwd, setShowConfirmPwd] = useState(false)
const [mobile, setMobile] = useState('')
const [smsCode, setSmsCode] = useState('')
@ -49,7 +51,7 @@ const Login = () => {
//
const countDown = async () => {
if (!mobile) {
if (!account) {
return
}
setIntervalTime(60)
@ -71,6 +73,30 @@ const Login = () => {
Taro.showToast({ title: '验证码发送成功', icon: 'success' })
}
const submit = async () => {
if (!account || !smsCode || !pwd || !confirmPwd) {
errorNotice('请完善信息')
return
}
if (pwd !== confirmPwd) {
errorNotice("两次密码不一致")
return
}
loading('密码重置中,请稍后~')
const re = await pwdManage('login_password', {
confirm_password: confirmPwd,
password: pwd,
phone: account,
verification_code: smsCode
})
closeLoading()
if (!re) return
successNotice('密码重置成功,请重新登录')
setTimeout(() => {
backFn()
}, 2000)
}
return <View className="login-frame bg-slate-50 h-screen text-base">
<View className="login-header flex justify-center items-center text-lg font-bold">
<Image src={back} className="square-35 absolute left-7" onClick={backFn} />
@ -80,7 +106,7 @@ const Login = () => {
<View className="relative font-bold text-lg block h-6 ">忘记密码</View>
<View>
<View className="form-item mt-58">
<View className="form-label"></View>
<View className="form-label">手机</View>
<View className="form-control relative">
<Input className="form-input" placeholder="请输入手机号" onInput={(v) => {
setAccount(v.detail.value)
@ -112,13 +138,13 @@ const Login = () => {
</View>
</View>
<View className="form-item mt-22">
<View className="form-label">密码</View>
<View className="form-label">确认密码</View>
<View className="form-control relative">
<Input className="form-input" type={showPwd ? 'text' : 'password'} placeholder="再次确认新密码" onInput={(v) => {
setPwd(v.detail.value)
<Input className="form-input" type={showConfirmPwd ? 'text' : 'password'} placeholder="再次确认新密码" onInput={(v) => {
setConfirmPwd(v.detail.value)
}} />
<Image className="w-6 h-6 absolute right-0 bottom-16" src={showPwd ? activeEye : eyeClose} onClick={() => {
setShowPwd(v => !v)
<Image className="w-6 h-6 absolute right-0 bottom-16" src={showConfirmPwd ? activeEye : eyeClose} onClick={() => {
setShowConfirmPwd(v => !v)
}} />
</View>
</View>
@ -126,8 +152,7 @@ const Login = () => {
<View className="forgot-password" onClick={loginFn}>已有账号去登陆</View>
</View>
<View className="login-footer flex flex-col justify-center">
<Button className="login-btn">找回密码</Button>
<Button className="login-btn" onClick={submit}>找回密码</Button>
</View>
</View>

View File

@ -135,15 +135,22 @@ const Index = () => {
我的钱包
</View>
<View className='flex-between mt-22'>
<View className='bal-item-content flex-col items-center'>
<View className='bal-item-content flex-col items-center' onClick={() => {
navigateTo('/pages/balance/index')
}}>
<Text>{user.score}</Text>
<Text className='bal-item-helper'>余额</Text>
</View>
<View className='bal-item-content flex-col items-center'>
<View className='bal-item-content flex-col items-center' onClick={() => {
navigateTo('/pages/income/index')
}
}>
<Text>{user.profit ?? 0}</Text>
<Text className='bal-item-helper'>收益</Text>
</View>
<View className='bal-item-content flex-col items-center'>
<View className='bal-item-content flex-col items-center' onClick={() => {
navigateTo('/pages/scope/index')
}}>
<Text>{user.shopping_score}</Text>
<Text className='bal-item-helper'>购物金</Text>
</View>

View File

@ -1,7 +1,7 @@
import { Image, Input, Text, View } from "@tarojs/components"
import back from '@/images/back.png'
import checked from '@/images/checked.png'
import eyeClose from '@/images/eyeClose.png'
import empty from '@/images/empty.png'
import eye from '@/images/eye.png'
import './index.scss'
import { Button } from "@nutui/nutui-react-taro"
@ -12,20 +12,47 @@ 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"
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(() => { }, [tabKey])
useEffect(() => {
let offset = (page - 1) * limit
userLogs('shopping_score', offset, limit).then(rs => {
if (!rs) return
setList(it => [...it, ...rs.items])
setTotal(rs.total)
})
}, [tabKey, page])
const switchTab = (key) => {
if (key != tabKey) {
setPage(1)
}
setTabKey(key)
}
return <View className="profit-frame bg-slate-50 h-screen text-base">
@ -43,46 +70,47 @@ const Login = () => {
<View className="flex-around ">
<View className="profit-btn flex-center" onClick={() => {
Taro.navigateTo({ url: '/pages/transfer/index' })
Taro.navigateTo({ url: '/pages/conversion/index' })
}}>转换余额</View>
</View>
</View>
<View className="amount-container">
<View className="amount-tabs flex-around">
<View className={'tab-pane ' + (tabKey == '0' ? 'tab-pane-active' : '')} onClick={() => setTabKey('0')}>收益流水</View>
<View className={'tab-pane ' + (tabKey == '1' ? 'tab-pane-active' : '')} onClick={() => setTabKey('1')}>提现记录</View>
<View className={'tab-pane ' + (tabKey == '2' ? 'tab-pane-active' : '')} onClick={() => setTabKey('2')}>发放明细</View>
<View className="amount-tabs flex-start">
<View className={'tab-pane ' + (tabKey == '0' ? 'tab-pane-active' : '')} onClick={() => switchTab('0')}>收益流水</View>
{/* <View className={'tab-pane ' + (tabKey == '1' ? 'tab-pane-active' : '')} onClick={() => setTabKey('1')}></View>
<View className={'tab-pane ' + (tabKey == '2' ? 'tab-pane-active' : '')} onClick={() => setTabKey('2')}>发放明细</View> */}
</View>
<View className="profitScroll" id="profitScroll">
<Infiniteloading
containerId="profitScroll"
useWindow={false}
loadTxt="loading"
loadMoreTxt="没有数据啦~"
loadIcon='loading'
hasMore={false}
onLoadMore={(x) => {
setPage(p => p + 1)
x()
}}
>
<View className="amount-item flex-between">
<View className="amount-item-detail flex-col">
<View>完成每日登陆</View>
<View className="amount-item-time">2021/04/09 19:42:36</View>
</View>
<View className="amount-item-log">+1.00</View>
</View>
<View className="amount-item flex-between">
<View className="amount-item-detail flex-col">
<View>完成每日登陆</View>
<View className="amount-item-time">2021/04/09 19:42:36</View>
</View>
<View className="amount-item-log">+1.00</View>
</View>
</Infiniteloading>
{
!!list.length && <Infiniteloading
containerId="profitScroll"
useWindow={false}
loadTxt="loading"
loadMoreTxt="没有数据啦~"
loadIcon='loading'
hasMore={total >= list.length}
onLoadMore={(x) => {
setPage(p => p + 1)
x()
}}
>
{
list.map(item => {
return <View className="amount-item flex-between" key={item.id}>
<View className="amount-item-detail flex-col">
<View>{item.memo}</View>
<View className="amount-item-time">{formatDateByStr(item.created_at)}</View>
</View>
<View className="amount-item-log">{item.amount > 0 ? `+${item.amount}` : `${item.amount}`}</View>
</View>
})
}
</Infiniteloading>
}
{
!list.length && <Image src={empty} className="order-empty" />
}
</View>
</View>

View File

@ -54,7 +54,6 @@ const Login = () => {
const loginSubmit = async () => {
console.log(mobile, smsCode, "code")
if (!mobile || !smsCode) {
Taro.showToast({ title: '请完善登陆参数', icon: 'error' })
return

View File

@ -31,6 +31,21 @@ const Login = () => {
Taro.getCurrentPages().length > 0 && Taro.navigateBack()
}
//
const registerFn = () => {
Taro.navigateTo({
url: '/pages/register/index'
})
}
//
const forgotPasswordFn = () => {
Taro.navigateTo({
url: '/pages/forgot/index'
})
}
//
const countDown = async () => {
if (!mobile) {
@ -103,7 +118,10 @@ const Login = () => {
}} />
</View>
</View>
<View className="form-helper">
<View className="forgot-password" onClick={registerFn}>注册账号</View>
<View className="forgot-password" onClick={forgotPasswordFn}>忘记密码</View>
</View>
<View className="login-footer flex flex-col justify-center">
<Button className="login-btn" onClick={loginSubmit}>登录</Button>
<View className="quick-login" onClick={() => {

View File

@ -4,12 +4,30 @@ import { Button } from "@nutui/nutui-react-taro"
import { useState } from "react"
import Taro from "@tarojs/taro"
import backNav from '@/images/backNav.png'
import { useEffect } from "react"
import { cardList, deleteCard } from "../../utils/api"
import { closeLoading, loading, successNotice } from "../../utils/utils"
import { useDidShow } from "@tarojs/taro"
const Login = () => {
const [card, setCard] = useState([])
const [ref, setRef] = useState(1)
useEffect(() => {
cardList().then(rs => {
if (!rs) return
setCard(rs.items)
})
}, [ref])
useDidShow(() => {
setRef(d => d + 1)
})
//
const backFn = () => {
Taro.getCurrentPages().length > 0 && Taro.navigateBack()
@ -22,6 +40,14 @@ const Login = () => {
})
}
const del = async (id) => {
loading('银行卡解绑中')
const re = await deleteCard(id)
closeLoading()
if (!re) return
setRef(d => d + 1)
}
return <View className="login-frame bg-slate-50 h-screen text-base">
<View className='addr-detail-title'>
@ -30,13 +56,17 @@ const Login = () => {
</View>
<View className="change-pwd-container bg-slate-50 relative flex flex-col items-center">
<View className="card-item flex-col justify-center">
<View className="flex-between">
<View className="bank-name">xxx银行</View>
<View className="bank-number">123456789777</View>
</View>
<View className="card-item-des">解除绑定</View>
</View>
{
card.map(item => {
return <View className="card-item flex-col justify-center" key={item.id}>
<View className="flex-between">
<View className="bank-name">{item.account_name} {item.bank_name}</View>
<View className="bank-number">{item.account_number}</View>
</View>
<View className="card-item-des" onClick={() => { del(item.id) }}>解除绑定</View>
</View>
})
}
<View className="change-phone-footer flex flex-col justify-center">
<Button className="login-btn" onClick={navCreate}>新增银行</Button>
</View>

View File

@ -53,11 +53,12 @@
color: #FFFFFF;
font-size: 12px;
margin-top: 12px;
font-weight: 600;
}
.card-item-des {
font-size: 16px;
margin-top: 10px;
margin-top: 14px;
font-weight: 400;
word-spacing: 6px;
}

View File

@ -133,7 +133,7 @@ function Index() {
</View>
<View className="flex-between order-detail-item">
<Text>提交时间</Text>
<Text className='order-detail-item-right'>{formatDateByStr('YYYY-mm-dd HH:MM', detail.created_at)}</Text>
<Text className='order-detail-item-right'>{formatDateByStr(detail.created_at)}</Text>
</View>
<View className="flex-between order-detail-item">
<Text>支付方式</Text>

View File

@ -36,7 +36,7 @@ const Login = () => {
state = ''
}
orderList(chanel, { state, offset, limit }).then(re => {
setList(re.items)
setList(it => [...it, ...re.items])
setTotal(re.total)
})
}, [tabKey, page])

View File

@ -109,11 +109,4 @@
.order-btn-delete {
border: 1px solid rgba(0, 0, 0, 0.5);
color: #5E6272;
}
.order-empty {
width: 200px;
height: 200px;
margin-left: calc((375px - 200px)/2);
margin-top: 100px;
}

View File

@ -1,3 +1,3 @@
export default definePageConfig({
navigationBarTitleText: '我的积分'
navigationBarTitleText: '我的购物金'
})

View File

@ -1,7 +1,7 @@
import { Image, Input, Text, View } from "@tarojs/components"
import back from '@/images/back.png'
import checked from '@/images/checked.png'
import eyeClose from '@/images/eyeClose.png'
import empty from '@/images/empty.png'
import eye from '@/images/eye.png'
import './index.scss'
import { Button } from "@nutui/nutui-react-taro"
@ -12,71 +12,97 @@ 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"
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(() => { }, [tabKey])
useEffect(() => {
let offset = (page - 1) * limit
userLogs('shopping_score', offset, limit).then(rs => {
if (!rs) return
setList(it => [...it, ...rs.items])
setTotal(rs.total)
})
}, [tabKey, page])
const switchTab = (key) => {
if (key != tabKey) {
setPage(1)
}
setTabKey(key)
}
return <View className="cash-frame bg-slate-50 h-screen text-base">
<View className='addr-detail-title'>
<Image src={backNav} className="square-35 absolute left-10 nav-icon" onClick={backFn} />
我的积分
我的购物金
</View>
<View className="scope-container relative">
<View className="scope-amount flex-col ">
<View className="flex-between mt-22">
<Text>当前积分</Text>
<Text className="scope-amount-price">50000</Text>
<Text>我的余额</Text>
<Text className="scope-amount-price">{user.shopping_score}</Text>
</View>
</View>
<View className="amount-container">
<View className="amount-tabs flex-around">
<View className={'tab-pane ' + (tabKey == '0' ? 'tab-pane-active' : '')} onClick={() => setTabKey('0')}>余额流水</View>
<View className={'tab-pane ' + (tabKey == '1' ? 'tab-pane-active' : '')} onClick={() => setTabKey('1')}>充值记录</View>
<View className={'tab-pane ' + (tabKey == '2' ? 'tab-pane-active' : '')} onClick={() => setTabKey('2')}>提现记录</View>
<View className="amount-tabs flex-start">
<View className={'tab-pane ' + (tabKey == '0' ? 'tab-pane-active' : '')} onClick={() => switchTab('0')}>余额流水</View>
{/* <View className={'tab-pane ' + (tabKey == '1' ? 'tab-pane-active' : '')} onClick={() => setTabKey('1')}></View>
<View className={'tab-pane ' + (tabKey == '2' ? 'tab-pane-active' : '')} onClick={() => setTabKey('2')}>提现记录</View> */}
</View>
<View className="scopeScroll" id="scopeScroll">
<Infiniteloading
containerId="scopeScroll"
useWindow={false}
loadTxt="loading"
loadMoreTxt="没有数据啦~"
loadIcon='loading'
hasMore={false}
onLoadMore={(x) => {
setPage(p => p + 1)
x()
}}
>
<View className="amount-item flex-between">
<View className="amount-item-detail flex-col">
<View>完成每日登陆</View>
<View className="amount-item-time">2021/04/09 19:42:36</View>
</View>
<View className="amount-item-log">+1.00</View>
</View>
<View className="amount-item flex-between">
<View className="amount-item-detail flex-col">
<View>完成每日登陆</View>
<View className="amount-item-time">2021/04/09 19:42:36</View>
</View>
<View className="amount-item-log">+1.00</View>
</View>
</Infiniteloading>
{
!!list.length && <Infiniteloading
containerId="scopeScroll"
useWindow={false}
loadTxt="loading"
loadMoreTxt="没有数据啦~"
loadIcon='loading'
hasMore={total >= list.length}
onLoadMore={(x) => {
setPage(p => p + 1)
x()
}}
>
{
list.map(item => {
return <View className="amount-item flex-between" key={item.id}>
<View className="amount-item-detail flex-col">
<View>{item.memo}</View>
<View className="amount-item-time">{formatDateByStr(item.created_at)}</View>
</View>
<View className="amount-item-log">{item.amount > 0 ? `+${item.amount}` : `${item.amount}`}</View>
</View>
})
}
</Infiniteloading>
}
{
!list.length && <Image src={empty} className="order-empty" />
}
</View>
</View>

View File

@ -9,19 +9,28 @@ import { useState } from "react"
import Taro from "@tarojs/taro"
import backNav from '@/images/backNav.png'
import { Picker } from "@nutui/nutui-react-taro"
import { useEffect } from "react"
import { transferAmount, userDetail } from "../../utils/api"
import { closeLoading, errorNotice, loading, navigateTo } from "../../utils/utils"
const activeEye = eye
const Login = () => {
const [account, setAccount] = useState('')
const [confirmAccount, setConfirmAccount] = useState('')
const [num, setNum] = useState(0)
const [pwd, setPwd] = useState('')
const [showPwd, setShowPwd] = useState(false)
const [visible, setVisible] = useState(false)
const [bank, setBank] = useState({ value: 0, text: '' })
const [user, setUser] = useState({})
useEffect(() => {
userDetail().then(rs => {
if (!rs) return
setUser(rs)
})
}, [])
//
const backFn = () => {
@ -29,6 +38,36 @@ const Login = () => {
}
const submit = async () => {
if (!account || !confirmAccount || !num || !pwd) {
errorNotice("请确认转赠参数是否正确")
return
}
if (account != confirmAccount) {
errorNotice("两次账号输入不一致")
return
}
if (num == 0 || num > user.score) {
errorNotice("转赠数量不正确")
return
}
loading("正在处理中,请稍后")
const re = await transferAmount({
amount: num,
to_phone: account,
password: pwd
})
closeLoading()
if (!re) {
return
}
errorNotice("转赠成功")
setTimeout(() => {
navigateTo('/pages/balance/index')
}, 1000)
}
return <View className="transfer-frame bg-slate-50 h-screen text-base">
<View className='addr-detail-title'>
<Image src={backNav} className="square-35 absolute left-10 nav-icon" onClick={backFn} />
@ -38,7 +77,7 @@ const Login = () => {
<View className="transfer-container relative">
<View className="transfer-amount flex-col justify-center">
<Text>当前余额</Text>
<Text className="transfer-amount-price">50000</Text>
<Text className="transfer-amount-price">{user.score}</Text>
</View>
<View>
<View className="form-item mt-22">
@ -57,10 +96,10 @@ const Login = () => {
<View className="form-label">确认对方账号</View>
<View className="form-control relative">
<Input className="form-input" placeholder="再次确认对方账号" onInput={(v) => {
setAccount(v.detail.value)
setConfirmAccount(v.detail.value)
}} />
{
account && <Image className="w-6 h-6 absolute right-0 bottom-16" src={checked} />
confirmAccount && <Image className="w-6 h-6 absolute right-0 bottom-16" src={checked} />
}
</View>
@ -69,10 +108,10 @@ const Login = () => {
<View className="form-label">转赠数量</View>
<View className="form-control relative">
<Input className="form-input" type="digit" placeholder="请输入转赠数量" onInput={(v) => {
setAccount(v.detail.value)
setNum(v.detail.value)
}} />
{
account && <Image className="w-6 h-6 absolute right-0 bottom-16" src={checked} />
!!num && <Image className="w-6 h-6 absolute right-0 bottom-16" src={checked} />
}
</View>
@ -92,7 +131,7 @@ const Login = () => {
{
account &&
<View className="transfer-footer ">
<Button className="transfer-btn">立即赠送</Button>
<Button className="transfer-btn" onClick={submit}>立即赠送</Button>
</View>
}
</View>

View File

@ -93,7 +93,7 @@ function Index() {
<Image src={next} className='next-icon' />
</View>
</View>
<View className='addr-form' onClick={() => { navigateTo('/pages/change-password/index') }}>
<View className='addr-form' onClick={() => { navigateTo('/pages/change-pwd/index') }}>
<View className='addr-form-name'>修改密码</View>
<View className='flex justify-between items-center ' >

View File

@ -56,4 +56,36 @@ export const orderList = async (channel, params = {}) => {
// 当前用户信息
export const userDetail = async () => {
return await g(`/users/detail`)
}
// 我的银行卡
export const cardList = async () => {
return await g(`/users/bank-cards`)
}
export const createCard = async (data) => {
return await p(`/users/bank-cards`, data)
}
export const deleteCard = async (id) => {
return await d(`/users/bank-cards/${id}`)
}
export const pwdManage = async (type, data) => {
return await put(`/users/profile/password/${type}`, data)
}
export const phoneManage = async (data = {}) => {
return await put(`/users/profile/phone`, data)
}
export const userLogs = async (type, data = {}) => {
return await g(`/users/assets/logs/${type}`, data)
}
export const transferAmount = async (data = {}) => {
return await p(`/users/assets/score-transfer`, data)
}

View File

@ -70,7 +70,7 @@ export function dateFormat(fmt, date) {
}
export const formatDateByStr = (fmt, date) => {
export const formatDateByStr = (date) => {
const d = new Date(date)
return dateFormat(fmt, d)
return dateFormat('YYYY-mm-dd HH:MM', d)
}