🎈 perf(邀请码): 添加错误❌处理机制

This commit is contained in:
xuan
2022-12-01 15:14:57 +08:00
parent 7d3f6e22c5
commit 836120ddba
4 changed files with 68 additions and 26 deletions
-1
View File
@@ -9,7 +9,6 @@ const Loading = ({ width = 60, color = '#6190e8' }: { width?: number; color?: st
if (color) { obj = { ...obj, borderColor: `${color} transparent transparent` } }
return obj
}, [width, color])
console.log('loading:::')
return (
<View className={style.loading}
style={styleObj}
@@ -10,6 +10,7 @@
text-align: center;
color: #fff;
box-sizing: border-box;
&--normal {
height: 72px;
font-size: $font_size_medium;
@@ -69,10 +70,19 @@
}
}
&--text {
position: relative;
display: flex;
flex-flow: row nowrap;
align-items: center;
color: currentColor;
.loading {
position: absolute;
pointer-events: none;
left: -40px;
top: 50%;
transform: translateY(-50%);
z-index: 1;
}
}
// active 伪类
&--primary:active {
+7 -2
View File
@@ -1,6 +1,7 @@
import { Text, View } from '@tarojs/components'
import { View } from '@tarojs/components'
import type { FC, ReactNode } from 'react'
import classnames from 'classnames'
import Loading from '../loading'
import styles from './index.module.scss'
type ButtonType = 'primary' | 'danger' | 'warning' | 'info'
@@ -18,6 +19,7 @@ interface PropsType {
customClassName?: string
customStyles?: React.CSSProperties
customTextClassName?: string
loading?: boolean
}
const NormalButton: FC<PropsType> = (props) => {
@@ -33,6 +35,7 @@ const NormalButton: FC<PropsType> = (props) => {
customStyles = {},
customClassName = '',
customTextClassName = '',
loading = false,
} = props
const getClassName = () => {
const classObject = {
@@ -55,7 +58,9 @@ const NormalButton: FC<PropsType> = (props) => {
return (
<View className={classnames(styles.button, getClassName(), customClassName)} style={customStyles} onClick={handleClick}>
<View className={classnames(styles['button--text'], customTextClassName)}>{children}</View>
<View className={classnames(styles['button--text'], customTextClassName)}>
<View className={styles.loading}>{loading && <Loading width={30} />}</View>
{children}</View>
</View>
)
}