blob: f3050b05d285cf654cca2c5360dfd8fa13581225 [file] [log] [blame]
guangchao.xu070005a2020-12-07 09:56:40 +08001<template>
2 <view class="verification">
3 <view class="verification-list">
4 <u-field v-model="code" label="短信验证" placeholder="请输入验证码" placeholder-style="color:#999999" clear-size="40">
5 <u-button size="mini" slot="right" type="primary" @click="getCode" shape="circle" class="btn" :disabled="disabled">{{codeText}}</u-button>
6 </u-field>
7 </view>
8 <u-button :custom-style="btn" @click="submit">验证</u-button>
9 </view>
10</template>
11
12<script>
13 export default{
14 data(){
15 return{
16 btn:{
17 width: '600rpx',
18 backgroundColor: '#2FA8E1',
19 color: '#FFFFFF',
20 fontFamily: "PingFang-SC-Medium",
21 fontSize: '30rpx',
22 marginTop: '100rpx',
23 padding: '50rpx 0'
24 },
25 codeText: "获取验证码",
26 code: "",
27 disabled: false,
28 obj:{}
29 }
30 },
31 methods:{
32 //获取验证码
33 getCode() {
34 let that = this
35 let param = {
36 phone: that.obj.username,
37 type: 'check'
38 }
39 uni.removeStorageSync('token')
40 that.$u.post('/i/code',param).then(res => {
41 uni.showToast({
42 title: res.msg,
43 icon: "none",
44 duration: 800
45 })
46 let i = 60
47 that.disabled = true
48 that.timer = setInterval(() => {
49 if (i != 0) {
50 i--
51 that.codeText = i + "s"
52 } else {
53 clearInterval(that.timer)
54 that.codeText = "重新获取"
55 that.disabled = false
56 }
57 }, 1000)
58 })
59 },
60 submit() {
61 let that = this
62 let code = that.code
63 if (code == "") {
64 uni.showToast({
65 title: "请输入验证码",
66 duration: 800,
67 icon: "none"
68 })
69 return false
70 }
71 let params = {
72 phone:that.obj.username,
73 code: code,
74 deviceid: that.obj.deviceid,
75 platform: that.obj.platform
76 }
77
78 that.$u.post("/sms/login",params).then((res) => {
79 uni.setStorageSync("token", res.token)
80 uni.setStorageSync("uid", res.uid)
81 uni.setStorageSync("userid", res.userid)
82 uni.setStorageSync("tenantid", res.tenantid)
83 uni.setStorageSync("tokenexpire", res.expire)
84 uni.setStorageSync("tokentime", res.now)
85 uni.setStorageSync("signed", res.signed)
86 uni.setStorageSync("paypwdset", res.paypwdset)
87 uni.setStorageSync("name", res.name)
88 uni.setStorageSync("localpwd", res.localpwd)
89 uni.setStorageSync("phoneX", res.phone)
90 uni.setStorageSync("imgurl", res.imgurl)
91 uni.setStorageSync("idno", res.idno)
92 uni.setStorageSync("cardno", res.citizenCardNo)
93 uni.setStorageSync("bankcardno", res.bankCardNo)
guangchao.xu50e42382021-01-04 17:53:47 +080094 uni.setStorageSync("email", res.email)
guangchao.xu070005a2020-12-07 09:56:40 +080095 uni.showToast({
96 title: "验证成功",
97 icon: "none",
98 complete(res) {
99 setTimeout(() => {
100 uni.reLaunch({
101 url: "/pages/sub_tabbar/index"
102 })
103 }, 1500)
104 }
105 })
106 })
107 }
108 },
109 onLoad(options) {
110 let data = JSON.parse(options.data)
111 this.obj = data
112 this.getCode()
113 }
114 }
115</script>
116
117<style lang="scss" scoped>
118 .verification {
119 width: 100vw;
120 overflow: hidden;
121 padding-bottom: 30rpx;
122 &-list {
123 margin-top: 30rpx;
124 background-color: #FFFFFF;
125 }
126 }
127</style>