blob: f3050b05d285cf654cca2c5360dfd8fa13581225 [file] [log] [blame]
<template>
<view class="verification">
<view class="verification-list">
<u-field v-model="code" label="短信验证" placeholder="请输入验证码" placeholder-style="color:#999999" clear-size="40">
<u-button size="mini" slot="right" type="primary" @click="getCode" shape="circle" class="btn" :disabled="disabled">{{codeText}}</u-button>
</u-field>
</view>
<u-button :custom-style="btn" @click="submit">验证</u-button>
</view>
</template>
<script>
export default{
data(){
return{
btn:{
width: '600rpx',
backgroundColor: '#2FA8E1',
color: '#FFFFFF',
fontFamily: "PingFang-SC-Medium",
fontSize: '30rpx',
marginTop: '100rpx',
padding: '50rpx 0'
},
codeText: "获取验证码",
code: "",
disabled: false,
obj:{}
}
},
methods:{
//获取验证码
getCode() {
let that = this
let param = {
phone: that.obj.username,
type: 'check'
}
uni.removeStorageSync('token')
that.$u.post('/i/code',param).then(res => {
uni.showToast({
title: res.msg,
icon: "none",
duration: 800
})
let i = 60
that.disabled = true
that.timer = setInterval(() => {
if (i != 0) {
i--
that.codeText = i + "s"
} else {
clearInterval(that.timer)
that.codeText = "重新获取"
that.disabled = false
}
}, 1000)
})
},
submit() {
let that = this
let code = that.code
if (code == "") {
uni.showToast({
title: "请输入验证码",
duration: 800,
icon: "none"
})
return false
}
let params = {
phone:that.obj.username,
code: code,
deviceid: that.obj.deviceid,
platform: that.obj.platform
}
that.$u.post("/sms/login",params).then((res) => {
uni.setStorageSync("token", res.token)
uni.setStorageSync("uid", res.uid)
uni.setStorageSync("userid", res.userid)
uni.setStorageSync("tenantid", res.tenantid)
uni.setStorageSync("tokenexpire", res.expire)
uni.setStorageSync("tokentime", res.now)
uni.setStorageSync("signed", res.signed)
uni.setStorageSync("paypwdset", res.paypwdset)
uni.setStorageSync("name", res.name)
uni.setStorageSync("localpwd", res.localpwd)
uni.setStorageSync("phoneX", res.phone)
uni.setStorageSync("imgurl", res.imgurl)
uni.setStorageSync("idno", res.idno)
uni.setStorageSync("cardno", res.citizenCardNo)
uni.setStorageSync("bankcardno", res.bankCardNo)
uni.setStorageSync("email", res.email)
uni.showToast({
title: "验证成功",
icon: "none",
complete(res) {
setTimeout(() => {
uni.reLaunch({
url: "/pages/sub_tabbar/index"
})
}, 1500)
}
})
})
}
},
onLoad(options) {
let data = JSON.parse(options.data)
this.obj = data
this.getCode()
}
}
</script>
<style lang="scss" scoped>
.verification {
width: 100vw;
overflow: hidden;
padding-bottom: 30rpx;
&-list {
margin-top: 30rpx;
background-color: #FFFFFF;
}
}
</style>