| guangchao.xu | 070005a | 2020-12-07 09:56:40 +0800 | [diff] [blame] | 1 | <template> |
| 2 | <view class="register" @touchmove.stop.prevent="moveHandle"> |
| 3 | <!-- #ifndef MP-WEIXIN --> |
| 4 | <u-navbar title="注册" :border-bottom="false" :is-back="false"></u-navbar> |
| 5 | <!-- #endif --> |
| 6 | <view class="register-con"> |
| 7 | <view class="register-con-logo"> |
| guangchao.xu | 6cdd45e | 2021-04-16 17:44:30 +0800 | [diff] [blame^] | 8 | <!-- #ifdef MP-WEIXIN --> |
| 9 | <u-image src="/pages/sub_basic/images/login/logo.png" width="300rpx" mode="widthFix"></u-image> |
| 10 | <!-- #endif --> |
| 11 | <!-- #ifndef MP-WEIXIN --> |
| 12 | <u-image src="./images/login/logo.png" width="300rpx" mode="widthFix"></u-image> |
| 13 | <!-- #endif --> |
| guangchao.xu | 070005a | 2020-12-07 09:56:40 +0800 | [diff] [blame] | 14 | </view> |
| 15 | <view class="register-con-form"> |
| 16 | <u-field v-model="tel" placeholder="请输入手机号" label-width="50" maxlength="11" type="number"clear-size="40"> |
| 17 | <u-icon slot="icon" name="shouji" custom-prefix="custom-icon" color="#999999"></u-icon> |
| 18 | </u-field> |
| 19 | <u-field v-model="code" placeholder="请输入验证码" label-width="50" maxlength="6" type="number"clear-size="40"> |
| 20 | <u-icon slot="icon" name="code" custom-prefix="custom-icon" color="#999999"></u-icon> |
| 21 | <u-button slot="right" @click="getCode" size="mini" :disabled="isChecked" :custom-style="btn">{{codeText}}</u-button> |
| 22 | </u-field> |
| 23 | <u-field v-model="pwd" icon="lock-fill" placeholder="请设置6-12位密码" label-width="50" icon-color="#999999" maxlength="12" |
| 24 | :password="true" type="number"clear-size="40"></u-field> |
| 25 | </view> |
| 26 | <view class="register-con-agreement"> |
| guangchao.xu | 6cdd45e | 2021-04-16 17:44:30 +0800 | [diff] [blame^] | 27 | <u-checkbox v-model="checked" shape="circle" label-size="26" icon-size="16"><text style="margin-left: 20rpx;">我已同意<text class="register-con-agreement-text" @click="toUrl('/pages/sub_mine/agreement')">《用户协议》</text></text></u-checkbox> |
| guangchao.xu | 070005a | 2020-12-07 09:56:40 +0800 | [diff] [blame] | 28 | </view> |
| 29 | <u <u-button @click="register" :custom-style="registerConBtn">立即注册</u-button> |
| 30 | </view> |
| 31 | </view> |
| 32 | </template> |
| 33 | |
| 34 | <script> |
| 35 | export default { |
| 36 | data() { |
| 37 | return { |
| 38 | codeText: "获取验证码", |
| 39 | pwd: "", |
| 40 | tel: "", |
| 41 | code: "", |
| 42 | isChecked: false, |
| 43 | timer: "", |
| 44 | checked: false, |
| 45 | registerConBtn:{ |
| 46 | width: '600rpx', |
| 47 | backgroundColor: '#2FA8E1', |
| 48 | color: '#FFFFFF', |
| 49 | fontFamily: "PingFang-SC-Medium", |
| 50 | fontSize: '30rpx', |
| 51 | marginTop: '100rpx', |
| 52 | padding: '50rpx 0' |
| 53 | }, |
| 54 | btn:{ |
| 55 | color: '#2FA8E1', |
| 56 | backgroundColor: '#FFFFFF', |
| 57 | borderColor:'#2FA8E1', |
| 58 | borderWidth: '1rpx', |
| 59 | borderStyle: 'solid', |
| 60 | fontFamily: "PingFang-SC-Regular" |
| 61 | } |
| 62 | } |
| 63 | }, |
| 64 | methods: { |
| 65 | moveHandle(){ |
| 66 | return |
| 67 | }, |
| 68 | getCode() { |
| 69 | let that = this |
| 70 | let tel = that.tel |
| 71 | if (tel == "") { |
| 72 | uni.showToast({ |
| 73 | title: "请输入正确手机号", |
| 74 | icon: "none", |
| 75 | duration: 800 |
| 76 | }) |
| 77 | return false |
| 78 | } |
| 79 | uni.removeStorageSync('token') |
| 80 | that.$u.post('/i/code', { |
| 81 | phone: tel |
| 82 | }).then(res => { |
| 83 | uni.showToast({ |
| 84 | title: res.msg, |
| 85 | icon: "none", |
| 86 | duration: 800 |
| 87 | }) |
| 88 | let i = 60 |
| 89 | that.isChecked = true |
| 90 | that.timer = setInterval(() => { |
| 91 | if (i != 0) { |
| 92 | i-- |
| 93 | that.codeText = i + "s" |
| 94 | } else { |
| 95 | clearInterval(that.timer) |
| 96 | that.codeText = "重新获取" |
| 97 | that.isChecked = false |
| 98 | } |
| 99 | }, 1000) |
| 100 | }) |
| 101 | }, |
| 102 | async register() { |
| 103 | let that = this |
| 104 | let { |
| 105 | tel, |
| 106 | pwd, |
| 107 | code, |
| 108 | checked |
| 109 | } = that |
| 110 | if (tel == "") { |
| 111 | uni.showToast({ |
| 112 | title: "请输入正确手机号", |
| 113 | icon: "none", |
| 114 | duration: 800 |
| 115 | }) |
| 116 | return false |
| 117 | } |
| 118 | if (code == "") { |
| 119 | uni.showToast({ |
| 120 | title: "请输入验证码", |
| 121 | icon: "none", |
| 122 | duration: 800 |
| 123 | }) |
| 124 | return false |
| 125 | } |
| 126 | if (pwd == "") { |
| 127 | uni.showToast({ |
| 128 | title: "请设置您的密码", |
| 129 | icon: "none", |
| 130 | duration: 800 |
| 131 | }) |
| 132 | return false |
| 133 | } |
| 134 | if (!checked) { |
| 135 | uni.showToast({ |
| 136 | title: "请先阅读并同意用户协议", |
| 137 | icon: "none", |
| 138 | duration: 800 |
| 139 | }) |
| 140 | return false |
| 141 | } |
| 142 | let param = { |
| 143 | phone: tel, |
| 144 | code: code, |
| 145 | } |
| 146 | let ret = await that.$u.post("/i/checkcode", param) |
| 147 | if (ret.code === 200) { |
| 148 | let { |
| 149 | randcode, |
| 150 | uid |
| 151 | } = ret |
| 152 | let params = { |
| 153 | "pwd": pwd, |
| 154 | "repwd": pwd, |
| 155 | "id": uid, |
| 156 | "random": randcode |
| 157 | // "id":"2c9b808573b4eff001740fccd23c63fc", |
| 158 | // "random":"r5m7anoef7ku5gdsz6o4gi2rkk5enf" |
| 159 | } |
| 160 | that.$u.post("/i/register", params).then((res) => { |
| 161 | uni.setStorageSync("token", res.token) |
| 162 | uni.setStorageSync("userid", res.userid) |
| 163 | uni.setStorageSync("tenantid", res.tenantid) |
| 164 | uni.setStorageSync("tokenexpire", res.expire) |
| 165 | uni.setStorageSync("tokentime", res.now) |
| 166 | uni.setStorageSync("signed", res.signed) |
| 167 | uni.setStorageSync("paypwdset", res.paypwdset) |
| 168 | uni.showToast({ |
| 169 | title: "注册成功", |
| 170 | icon: "none", |
| 171 | duration: 800, |
| 172 | complete(res) { |
| 173 | setTimeout(() => { |
| 174 | uni.reLaunch({ |
| guangchao.xu | 6cdd45e | 2021-04-16 17:44:30 +0800 | [diff] [blame^] | 175 | url: "/pages/sub_basic/login" |
| guangchao.xu | 070005a | 2020-12-07 09:56:40 +0800 | [diff] [blame] | 176 | }) |
| 177 | }, 1500) |
| 178 | } |
| 179 | }) |
| 180 | }) |
| 181 | } |
| 182 | } |
| 183 | |
| 184 | |
| 185 | |
| 186 | }, |
| 187 | onUnload() { |
| 188 | let that = this |
| 189 | clearInterval(that.timer) |
| 190 | } |
| 191 | } |
| 192 | </script> |
| 193 | |
| 194 | <style scoped lang="scss"> |
| 195 | .btn { |
| 196 | border-radius: 50rpx; |
| 197 | width: 150rpx; |
| 198 | color: #2FA8E1; |
| 199 | border: 2rpx #2FA8E1 solid; |
| 200 | font-size: 25rpx; |
| 201 | } |
| 202 | |
| 203 | .register { |
| 204 | width: 100vw; |
| 205 | font-family: "PingFang-SC-Medium"; |
| 206 | background-color: #FFFFFF; |
| 207 | height: 100vh; |
| 208 | |
| 209 | &-con { |
| 210 | padding: 30rpx; |
| 211 | |
| 212 | &-agreement { |
| 213 | font-family: "PingFang-SC-Medium"; |
| 214 | margin-left: 50rpx; |
| 215 | margin-top: 15rpx; |
| 216 | color: #999999; |
| 217 | &-text { |
| 218 | color: #2FA8E1; |
| 219 | } |
| 220 | } |
| 221 | |
| 222 | &-title { |
| 223 | display: flex; |
| 224 | justify-content: space-between; |
| 225 | align-items: center; |
| 226 | |
| 227 | text { |
| 228 | font-family: "PingFang-SC-Medium"; |
| 229 | font-size: 32rpx; |
| 230 | color: #333333; |
| 231 | } |
| 232 | } |
| 233 | |
| 234 | &-logo { |
| 235 | display: flex; |
| 236 | justify-content: center; |
| 237 | padding: 30rpx 0; |
| 238 | align-items: center; |
| 239 | text-align: center; |
| 240 | } |
| 241 | |
| 242 | &-form { |
| 243 | width: 650rpx; |
| 244 | margin: auto; |
| 245 | } |
| 246 | |
| 247 | &-btn { |
| 248 | background-color: #2FA8E1; |
| 249 | padding: 50rpx 0; |
| 250 | color: #FFFFFF; |
| 251 | width: 600rpx; |
| 252 | font-size: 30rpx; |
| 253 | margin-top: 100rpx; |
| 254 | } |
| 255 | } |
| 256 | |
| 257 | } |
| 258 | </style> |