You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
139 lines
3.1 KiB
139 lines
3.1 KiB
<template>
|
|
<view :style="{'border-radius': '5rpx','height': '65rpx','width': '160rpx','text-align': 'center','line-height': '65rpx','font-size': '26rpx',
|
|
'background-color': background,'color': 'white'}"
|
|
@click="click">
|
|
{{textDetail}}
|
|
</view>
|
|
</template>
|
|
|
|
<script>
|
|
//引入bus
|
|
import bus from '@/common/bus';
|
|
export default {
|
|
data() {
|
|
return {
|
|
'background': '#2fa1f0',
|
|
"isCanClick": true,
|
|
"textDetail": "获取验证码",
|
|
"countdown": 60,
|
|
'cookie': '',
|
|
pageData:{
|
|
phone:"",
|
|
type:"4"
|
|
}
|
|
};
|
|
},
|
|
methods: {
|
|
getCookie() {
|
|
return this.cookie;
|
|
},
|
|
click() {
|
|
|
|
|
|
if (!this.isCanClick) {
|
|
return
|
|
}
|
|
|
|
if (this.phoneNum.length != 11 || !this.phoneNum.startsWith("1")) {
|
|
this.Toast("请输入合法的手机号")
|
|
} else {
|
|
|
|
// 更改样式并且不可点击
|
|
this.background = "gray"
|
|
|
|
this.isCanClick = false
|
|
|
|
let timeOut = setInterval(() => {
|
|
|
|
if (this.countdown == 1) {
|
|
this.textDetail = "获取验证码"
|
|
this.countdown = 60
|
|
clearInterval(timeOut)
|
|
this.background = "#2fa1f0"
|
|
|
|
this.isCanClick = true
|
|
} else {
|
|
this.countdown = this.countdown - 1;
|
|
this.textDetail = this.countdown + "s"
|
|
}
|
|
}, 1000)
|
|
|
|
let _this = this
|
|
|
|
_this.pageData.phone = _this.phoneNum
|
|
|
|
// if (this.sendByCookie != null) {
|
|
|
|
// // 此方法会判断是否是小程序,小程序才执行cookie
|
|
// this.HttpCookie({
|
|
// 'url': this.url,
|
|
// 'data': {
|
|
// "mobile": this.phoneNum
|
|
// },
|
|
// cookie: this.sendByCookie,
|
|
// loading: true
|
|
// }).then((res) => {
|
|
// _this.cookie = res.data
|
|
// }, (err) => {
|
|
// clearInterval(timeOut)
|
|
// this.countdown = 60
|
|
// // 失败重置状态
|
|
// this.background = "#2fa1f0"
|
|
|
|
// this.isCanClick = true
|
|
// this.textDetail = "获取验证码"
|
|
// })
|
|
|
|
// } else {
|
|
|
|
_this.$api.sendVerificationCode(_this.pageData).then((resp) => {
|
|
// if (resp.success) {
|
|
console.log('1111', resp)
|
|
|
|
bus.$emit('isShow', true);
|
|
|
|
}).catch(e => {
|
|
console.log('eeeee', e)
|
|
|
|
bus.$emit('isShow', false);
|
|
|
|
clearInterval(timeOut)
|
|
_this.countdown = 60
|
|
// 失败重置状态
|
|
_this.background = "#2fa1f0"
|
|
|
|
_this.isCanClick = true
|
|
_this.textDetail = "获取验证码"
|
|
})
|
|
|
|
// _this.HTTP({
|
|
// url: _this.url+"/"+_this.phoneNum+"/4",
|
|
// data: {},
|
|
// method: 'GET',
|
|
// paramsType: "FORM",
|
|
// loading: true
|
|
// }).then((res) => {
|
|
// _this.cookie = res.data
|
|
// console.log('=======', res)
|
|
// }, (err) => {
|
|
// clearInterval(timeOut)
|
|
// this.countdown = 60
|
|
// // 失败重置状态
|
|
// this.background = "#2fa1f0"
|
|
|
|
// this.isCanClick = true
|
|
// this.textDetail = "获取验证码"
|
|
// })
|
|
|
|
// }
|
|
}
|
|
}
|
|
},
|
|
props: ['phoneNum',"type", 'url', 'data', 'sendByCookie'],
|
|
|
|
}
|
|
</script>
|
|
|
|
<style>
|
|
|
|
</style>
|
|
|