Commit c0cc703f authored by raca's avatar raca

feat: 接受pk 授权

parent e0aaaa1c
...@@ -121,11 +121,28 @@ ...@@ -121,11 +121,28 @@
padding: 32px 34px 80px 34px; padding: 32px 34px 80px 34px;
} }
.footerButton { .btn {
background-image: url(https://cdn.jkwljy.com/pk-math/wbVXwYUGCx63qjnAcoCW4mL2pvh/686x112);
background-size: 100% 100%;
height: 112px;
flex: 1; flex: 1;
background-image: url('https://cdn.jkwljy.com/pk-math/gMAFXFRRH3frGsM2wCpyLUCdiNT/343x56'); border-radius: 56px;
display: flex;
align-items: center;
justify-content: center;
font-size: 40px;
font-weight: 600;
color: #FFFFFF;
line-height: 56px;
background-color: #1786F7;
&.disabled {
background-image: none;
background-color: #E2E6ED;
color: #C2C8D1;
}
} }
.footerHoverButton { .isHover {
background-image: url('https://cdn.jkwljy.com/pk-math/3UiwFgrVHVQEcaPdxdf1XinBb64o/343x56'); background-image: url(https://cdn.jkwljy.com/pk-math/hijKKpX1GS7rJoezNKJwDFwMFQC/686x112);
} }
\ No newline at end of file
import { View, RootPortal, Image } from '@tarojs/components' import { View, RootPortal, Image, Button, ButtonProps, CommonEventFunction } from '@tarojs/components'
import classNames from 'classnames' import classNames from 'classnames'
import { useCallback, useRef, useState } from 'react' import { useCallback, useRef, useState } from 'react'
import { EyeProtectionView } from '@/components' import { EyeProtectionView } from '@/components'
import Button from '@/components/Button'
import { useBoolean } from '@/hooks' import { useBoolean } from '@/hooks'
import { useStoreActions } from '@/store/hooks'
import { getNickNameWords, type NickNameWord } from '@/api' import { getNickNameWords, type NickNameWord } from '@/api'
import assetsPk from '@/assets/oss/assets-pk' import assetsPk from '@/assets/oss/assets-pk'
import assetsGuide from '@/assets/oss/assets-guide' import assetsGuide from '@/assets/oss/assets-guide'
import { report, SkynetEvent } from '@/utils/skynet'
import styles from './modal-name.module.scss' import styles from './modal-name.module.scss'
...@@ -29,6 +30,7 @@ const ModalName = ({ ...@@ -29,6 +30,7 @@ const ModalName = ({
const [generating, { setTrue, setFalse }] = useBoolean(false) const [generating, { setTrue, setFalse }] = useBoolean(false)
const dataRef = useRef<NickNameWord>({ noun: [], adj: [] }) const dataRef = useRef<NickNameWord>({ noun: [], adj: [] })
const timerRef = useRef<NodeJS.Timer | null>(null) const timerRef = useRef<NodeJS.Timer | null>(null)
const updateNickNameAndPhone = useStoreActions(actions => actions.userModel.updateNickNameAndPhone)
const generateName = useCallback(() => { const generateName = useCallback(() => {
const { noun, adj } = dataRef.current const { noun, adj } = dataRef.current
...@@ -58,6 +60,26 @@ const ModalName = ({ ...@@ -58,6 +60,26 @@ const ModalName = ({
}, 1000) }, 1000)
}, [generateName, setTrue, setFalse, getNameWords]) }, [generateName, setTrue, setFalse, getNameWords])
const [loading, setLoading] = useState(false)
const handleGetPhone = useCallback<CommonEventFunction<ButtonProps.onGetPhoneNumberEventDetail>>((e) => {
if (loading) return
setLoading(true)
if (!e.detail.code && e.detail.errMsg) {
report(SkynetEvent.BizError, { errMsg: e.detail.errMsg, errType: 'AUTH_PHONE_ERR' })
}
updateNickNameAndPhone({ code: e.detail.code, name })
.then(() => {
setLoading(false)
onFinish()
})
.catch(err => {
setLoading(false)
console.log(err)
})
}, [onClose, updateNickNameAndPhone, onFinish, name, loading])
return ( return (
<RootPortal> <RootPortal>
<View <View
...@@ -88,10 +110,12 @@ const ModalName = ({ ...@@ -88,10 +110,12 @@ const ModalName = ({
</View> </View>
<View className={styles.footer}> <View className={styles.footer}>
<Button <Button
size="large" openType="getPhoneNumber"
image={styles.footerButton} onGetPhoneNumber={handleGetPhone}
hoverImage={styles.footerHoverButton} data-name="接收PK"
onClick={onFinish} className={styles.btn}
hoverClass={styles.isHover}
onClick={onClose}
> >
确定 确定
</Button> </Button>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment