Commit cf032fa2 authored by yanghui1's avatar yanghui1

yh

parent 5448dcfb
...@@ -15,7 +15,7 @@ ...@@ -15,7 +15,7 @@
"@spark/api-task": "^1.0.38", "@spark/api-task": "^1.0.38",
"@spark/projectx": "^2.0.5", "@spark/projectx": "^2.0.5",
"@spark/svgaplayer": "^2.0.3", "@spark/svgaplayer": "^2.0.3",
"@spark/ui": "^2.0.8", "@spark/ui": "^2.1.6",
"@spark/utils": "^2.0.17", "@spark/utils": "^2.0.17",
"axios": "^0.19.2", "axios": "^0.19.2",
"css-loader": "^3.6.0", "css-loader": "^3.6.0",
...@@ -3025,19 +3025,6 @@ ...@@ -3025,19 +3025,6 @@
"react-ticker": "^1.2.2" "react-ticker": "^1.2.2"
} }
}, },
"node_modules/@spark/ui/node_modules/@spark/utils": {
"version": "2.0.74",
"resolved": "http://npm.dui88.com:80/@spark%2futils/-/utils-2.0.74.tgz",
"integrity": "sha512-9TPetTb7eVumjOv7+NtfIFM33NNObpyw/na8s+LrFwH/WX8rMzc952kqkwWFxUsOplzQL/Y6a+1mXPhoXwwMyw==",
"license": "MIT",
"dependencies": {
"@spark/api-base": "^2.0.30",
"crypto-js": "^4.0.0",
"howler": "^2.2.1",
"html-observer": "^1.0.4",
"html-shot": "^1.0.13"
}
},
"node_modules/@spark/utils": { "node_modules/@spark/utils": {
"version": "2.0.81", "version": "2.0.81",
"resolved": "http://npm.dui88.com:80/@spark%2futils/-/utils-2.0.81.tgz", "resolved": "http://npm.dui88.com:80/@spark%2futils/-/utils-2.0.81.tgz",
...@@ -22188,20 +22175,6 @@ ...@@ -22188,20 +22175,6 @@
"db-react-helper": "^1.0.5", "db-react-helper": "^1.0.5",
"hammerjs": "^2.0.8", "hammerjs": "^2.0.8",
"react-ticker": "^1.2.2" "react-ticker": "^1.2.2"
},
"dependencies": {
"@spark/utils": {
"version": "2.0.74",
"resolved": "http://npm.dui88.com:80/@spark%2futils/-/utils-2.0.74.tgz",
"integrity": "sha512-9TPetTb7eVumjOv7+NtfIFM33NNObpyw/na8s+LrFwH/WX8rMzc952kqkwWFxUsOplzQL/Y6a+1mXPhoXwwMyw==",
"requires": {
"@spark/api-base": "^2.0.30",
"crypto-js": "^4.0.0",
"howler": "^2.2.1",
"html-observer": "^1.0.4",
"html-shot": "^1.0.13"
}
}
} }
}, },
"@spark/utils": { "@spark/utils": {
...@@ -10,6 +10,7 @@ import getShareApi from '@spark/api-share'; // 分享玩法组件包 ...@@ -10,6 +10,7 @@ import getShareApi from '@spark/api-share'; // 分享玩法组件包
import getBindPhoneApi from '@spark/api-bindPhone'; // 绑定手机号玩法组件包 import getBindPhoneApi from '@spark/api-bindPhone'; // 绑定手机号玩法组件包
import getCarouselApi from '@spark/api-carousel'; // 轮播玩法组件包 import getCarouselApi from '@spark/api-carousel'; // 轮播玩法组件包
import Swiper from 'swiper'; import Swiper from 'swiper';
import { Toast } from '@spark/ui';
import './homePage.less'; import './homePage.less';
@observer @observer
...@@ -41,9 +42,14 @@ class HomePage extends React.Component { ...@@ -41,9 +42,14 @@ class HomePage extends React.Component {
loop: true, loop: true,
}); });
}, 500) }, 500)
// 定义倒计时
this.setState({
count: 60, // 60s
})
} }
isClick = false; // 判断是否点击了“获取验证码”
// 分享 // 分享
onShare = () => { onShare = () => {
...@@ -72,13 +78,31 @@ class HomePage extends React.Component { ...@@ -72,13 +78,31 @@ class HomePage extends React.Component {
}); });
} }
// 获取验证码 // 点击“获取验证码”
getCode = () => { getCode = () => {
this.isClick = true;
const { username } = this; const { username } = this;
let phoneNumber = username.value; // 获取到手机号 let phoneNumber = username.value; // 获取到输入的手机号
const bindPhoneApi = getBindPhoneApi('Yh'); const reg_tel = /^1[3|4|5|7|8]\d{9}$/; // 手机号的正则表达式
bindPhoneApi.sendSmsCode(); if (phoneNumber == '') {
Toast('请输入手机号');
return;
}else if (!reg_tel.test(phoneNumber)) {
Toast('请输入正确的手机号格式');
return;
} else {
this.setState({
isClick: true, // true->开始倒计时
})
setTimeout(() => {
const new_count = this.state.count--;
this.setState({
count: new_count,
})
},500)
console.log(this.state.count);
const bindPhoneApi = getBindPhoneApi('Yh');
bindPhoneApi.sendSmsCode();
}
} }
render() { render() {
...@@ -89,6 +113,8 @@ class HomePage extends React.Component { ...@@ -89,6 +113,8 @@ class HomePage extends React.Component {
<div className='marginBottom'>手机号:<input ref={(e) => { this.username = e }} type="text" name="phone" /></div> <div className='marginBottom'>手机号:<input ref={(e) => { this.username = e }} type="text" name="phone" /></div>
<div>验证码:<input ref={(e) => { this.code = e }} type="text" name="verifyCode" /> <div>验证码:<input ref={(e) => { this.code = e }} type="text" name="verifyCode" />
{ {
this?.state?.isClick?
<span className="btn">{this.state.count}</span>:
<span className="btn" onClick={this.getCode}>获取验证码</span> <span className="btn" onClick={this.getCode}>获取验证码</span>
} }
</div> </div>
......
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