| guangchao.xu | 070005a | 2020-12-07 09:56:40 +0800 | [diff] [blame] | 1 | <template> |
| 2 | <view class="login" @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="login-con"> |
| 7 | <view class="login-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="login-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="pwd" icon="lock-fill" placeholder="请输入密码" label-width="50" icon-color="#999999" maxlength="12" |
| 20 | :password="true" type="text" clear-size="40"></u-field> |
| guangchao.xu | 6cdd45e | 2021-04-16 17:44:30 +0800 | [diff] [blame^] | 21 | <view class="login-con-form-forget"><text @click="toUrl('/pages/sub_basic/forgetPwd')">忘记密码?</text></view> |
| guangchao.xu | 070005a | 2020-12-07 09:56:40 +0800 | [diff] [blame] | 22 | </view> |
| 23 | <u-button @click="login" :custom-style="loginConBtn">登录</u-button> |
| guangchao.xu | 6cdd45e | 2021-04-16 17:44:30 +0800 | [diff] [blame^] | 24 | <u-button @click="toUrl('/pages/sub_basic/register')" :custom-style="loginConBtnr">注册</u-button> |
| guangchao.xu | 070005a | 2020-12-07 09:56:40 +0800 | [diff] [blame] | 25 | <view class="login-con-youke" @click="toIndex"><text>游客登陆</text></view> |
| 26 | <view class="login-con-footer"> |
| 27 | <view class="login-con-footer-title"><text style="color: #CCCCCC;margin-right: 30rpx;">————</text> 其他登陆方式 <text |
| 28 | style="color: #CCCCCC;margin-left: 30rpx;">————</text></view> |
| 29 | <view class="login-con-footer-icon"> |
| guangchao.xu | 6cdd45e | 2021-04-16 17:44:30 +0800 | [diff] [blame^] | 30 | <!-- #ifdef MP-WEIXIN --> |
| 31 | <u-image src="/pages/sub_basic/images/login/finge.png" width="50rpx" height="50rpx" mode="aspectFit" @click="fingerIn"></u-image> |
| 32 | <!-- <u-image src="/pages/sub_basic/images/login/face.png" width="50rpx" height="50rpx" mode="aspectFit" @click="faceIn"></u-image> --> |
| 33 | <u-image src="/pages/sub_basic/images/login/hands.png" width="50rpx" height="50rpx" mode="aspectFit" @click="handsIn"></u-image> |
| 34 | <!-- #endif --> |
| 35 | <!-- #ifndef MP-WEIXIN --> |
| 36 | <u-image src="./images/login/finge.png" width="50rpx" height="50rpx" mode="aspectFit" @click="fingerIn"></u-image> |
| 37 | <!-- <u-image src="./images/login/face.png" width="50rpx" height="50rpx" mode="aspectFit" @click="faceIn"></u-image> --> |
| 38 | <u-image src="./images/login/hands.png" width="50rpx" height="50rpx" mode="aspectFit" @click="handsIn"></u-image> |
| 39 | <!-- #endif --> |
| 40 | |
| guangchao.xu | 070005a | 2020-12-07 09:56:40 +0800 | [diff] [blame] | 41 | </view> |
| 42 | </view> |
| 43 | </view> |
| 44 | </view> |
| 45 | </template> |
| 46 | |
| 47 | <script> |
| 48 | const app = getApp() |
| 49 | export default { |
| 50 | data() { |
| 51 | return { |
| 52 | pwd: "", |
| 53 | tel: "", |
| 54 | loginConBtn: { |
| 55 | backgroundColor: ' #2FA8E1', |
| 56 | padding: '50rpx 0', |
| 57 | color: '#FFFFFF', |
| 58 | width: ' 600rpx', |
| 59 | fontSize: '30rpx', |
| 60 | border: '1px solid #2FA8E1', |
| 61 | }, |
| 62 | loginConBtnr: { |
| 63 | padding: '50rpx 0', |
| 64 | color: '#2FA8E1', |
| 65 | width: ' 600rpx', |
| 66 | fontSize: '30rpx', |
| 67 | border: '1px solid #2FA8E1', |
| 68 | marginTop: '30rpx' |
| 69 | } |
| 70 | } |
| 71 | }, |
| 72 | onLoad() { |
| 73 | let routes = getCurrentPages(); |
| 74 | let tel = uni.getStorageSync("phone") |
| 75 | if (tel) { |
| 76 | this.tel = tel |
| 77 | } |
| 78 | |
| 79 | }, |
| 80 | methods: { |
| 81 | moveHandle() { |
| 82 | return |
| 83 | }, |
| 84 | toIndex() { |
| 85 | uni.clearStorageSync() |
| 86 | uni.switchTab({ |
| 87 | url: "/pages/sub_tabbar/index" |
| 88 | }) |
| 89 | }, |
| 90 | login() { |
| 91 | let that = this |
| 92 | let { |
| 93 | tel, |
| 94 | pwd |
| 95 | } = that |
| 96 | // console.log(tel,pwd) |
| 97 | if (tel == "") { |
| 98 | uni.showToast({ |
| 99 | title: "请填写正确手机号", |
| 100 | duration: 800, |
| 101 | mask: true, |
| 102 | icon: "none" |
| 103 | }) |
| 104 | return false |
| 105 | } |
| 106 | if (pwd == "") { |
| 107 | uni.showToast({ |
| 108 | title: "请填写登录密码", |
| 109 | duration: 800, |
| 110 | mask: true, |
| 111 | icon: "none" |
| 112 | }) |
| 113 | return false |
| 114 | } |
| 115 | |
| 116 | // #ifdef H5 |
| 117 | let platform = 'H5' |
| 118 | let uuid = '' |
| 119 | // #endif |
| 120 | |
| 121 | // #ifdef APP-PLUS |
| 122 | let uuid = app.globalData.clientid ? app.globalData.clientid:'' |
| 123 | let platform = uni.getStorageSync('platform') ? 'App-' + uni.getStorageSync('platform') : '' |
| 124 | // #endif |
| 125 | |
| 126 | // #ifdef MP-WEIXIN |
| 127 | let platform = uni.getStorageSync('platform') ? 'Wechat-' + uni.getStorageSync('platform') : '' |
| 128 | let uuid = '' |
| 129 | // #endif |
| 130 | |
| 131 | let params = { |
| 132 | username: tel, |
| 133 | password: pwd, |
| 134 | deviceid: uuid, |
| 135 | platform: platform |
| 136 | } |
| 137 | that.$u.post('/login',params).then(res => { |
| guangchao.xu | 070005a | 2020-12-07 09:56:40 +0800 | [diff] [blame] | 138 | uni.setStorageSync("token", res.token) |
| 139 | uni.setStorageSync("uid", res.uid) |
| 140 | uni.setStorageSync("userid", res.userid) |
| 141 | uni.setStorageSync("tenantid", res.tenantid) |
| 142 | uni.setStorageSync("tokenexpire", res.expire) |
| 143 | uni.setStorageSync("tokentime", res.now) |
| 144 | uni.setStorageSync("signed", res.signed) |
| 145 | uni.setStorageSync("paypwdset", res.paypwdset) |
| 146 | uni.setStorageSync("name", res.name) |
| 147 | uni.setStorageSync("localpwd", res.localpwd) |
| 148 | uni.setStorageSync("phone", tel) |
| 149 | uni.setStorageSync("phoneX", res.phone) |
| guangchao.xu | 50e4238 | 2021-01-04 17:53:47 +0800 | [diff] [blame] | 150 | uni.setStorageSync("imageurl", res.imageurl) |
| guangchao.xu | 070005a | 2020-12-07 09:56:40 +0800 | [diff] [blame] | 151 | uni.setStorageSync("idno", res.idno) |
| 152 | uni.setStorageSync("cardno", res.citizenCardNo) |
| 153 | uni.setStorageSync("bankcardno", res.bankCardNo) |
| guangchao.xu | 50e4238 | 2021-01-04 17:53:47 +0800 | [diff] [blame] | 154 | uni.setStorageSync("email", res.email) |
| guangchao.xu | 070005a | 2020-12-07 09:56:40 +0800 | [diff] [blame] | 155 | let ranNum = Math.ceil(Math.random() * 25) |
| 156 | let c = String.fromCharCode(65 + ranNum) |
| 157 | // #ifndef MP-WEIXIN |
| 158 | let b = c + btoa(pwd) |
| 159 | // #endif |
| 160 | // #ifdef MP-WEIXIN |
| 161 | let b = c + pwd |
| 162 | // #endif |
| 163 | uni.setStorageSync("pwd", b) |
| 164 | if(res.needcheck){ |
| 165 | uni.navigateTo({ |
| guangchao.xu | 6cdd45e | 2021-04-16 17:44:30 +0800 | [diff] [blame^] | 166 | url:'/pages/sub_basic/verification?data=' + JSON.stringify(params) |
| guangchao.xu | 070005a | 2020-12-07 09:56:40 +0800 | [diff] [blame] | 167 | }) |
| 168 | return false |
| 169 | } |
| 170 | uni.showToast({ |
| 171 | title: "登录成功", |
| 172 | icon: "none", |
| 173 | mask: true, |
| 174 | duration: 800, |
| 175 | complete(res) { |
| 176 | setTimeout(() => { |
| 177 | uni.switchTab({ |
| 178 | url: "/pages/sub_tabbar/index" |
| 179 | }) |
| 180 | }, 1500) |
| 181 | } |
| 182 | }) |
| 183 | }) |
| 184 | }, |
| 185 | fingerLogin() { |
| 186 | let that = this |
| 187 | let tel = uni.getStorageSync('phone') |
| 188 | let pwd = uni.getStorageSync('pwd') |
| 189 | // #ifdef APP-PLUS |
| 190 | let uuid = app.globalData.clientid ? app.globalData.clientid : '' |
| 191 | let platform = uni.getStorageSync('platform') ? 'App-' + uni.getStorageSync('platform') : '' |
| 192 | let a = atob(pwd.substr(1)) |
| 193 | // #endif |
| 194 | |
| 195 | // #ifdef MP-WEIXIN |
| 196 | let a = pwd.substr(1) |
| 197 | let uuid = '' |
| 198 | let platform = uni.getStorageSync('platform') ? 'Wechat-' + uni.getStorageSync('platform') : '' |
| 199 | // #endif |
| 200 | |
| 201 | // #ifdef H5 |
| 202 | let platform = 'H5' |
| 203 | let uuid = '' |
| 204 | let a= atob(pwd.substr(1)) |
| 205 | // #endif |
| 206 | |
| 207 | let params = { |
| 208 | username: tel, |
| 209 | password: a, |
| 210 | deviceid: uuid, |
| 211 | platform: platform |
| 212 | } |
| 213 | that.$u.post('/login',params).then(res => { |
| 214 | uni.setStorageSync("token", res.token) |
| 215 | uni.setStorageSync("uid", res.uid) |
| 216 | uni.setStorageSync("userid", res.userid) |
| 217 | uni.setStorageSync("tenantid", res.tenantid) |
| 218 | uni.setStorageSync("tokenexpire", res.expire) |
| 219 | uni.setStorageSync("tokentime", res.now) |
| 220 | uni.setStorageSync("signed", res.signed) |
| 221 | uni.setStorageSync("paypwdset", res.paypwdset) |
| 222 | uni.setStorageSync("name", res.name) |
| 223 | uni.setStorageSync("localpwd", res.localpwd) |
| 224 | uni.setStorageSync("phoneX", res.phone) |
| 225 | uni.setStorageSync("imgurl", res.imgurl) |
| 226 | uni.setStorageSync("idno", res.idno) |
| 227 | uni.setStorageSync("cardno", res.citizenCardNo) |
| 228 | uni.setStorageSync("bankcardno", res.bankCardNo) |
| guangchao.xu | 50e4238 | 2021-01-04 17:53:47 +0800 | [diff] [blame] | 229 | uni.setStorageSync("email", res.email) |
| guangchao.xu | 070005a | 2020-12-07 09:56:40 +0800 | [diff] [blame] | 230 | if(res.needcheck){ |
| 231 | uni.navigateTo({ |
| guangchao.xu | 6cdd45e | 2021-04-16 17:44:30 +0800 | [diff] [blame^] | 232 | url:'/pages/sub_basic/verification?data=' + JSON.stringify(params) |
| guangchao.xu | 070005a | 2020-12-07 09:56:40 +0800 | [diff] [blame] | 233 | }) |
| 234 | return false |
| 235 | } |
| 236 | uni.showToast({ |
| 237 | title: "指纹识别成功", |
| 238 | icon: "none", |
| 239 | mask: true, |
| 240 | complete(res) { |
| 241 | setTimeout(() => { |
| 242 | uni.switchTab({ |
| 243 | url: "/pages/sub_tabbar/index" |
| 244 | }) |
| 245 | }, 1500) |
| 246 | } |
| 247 | }) |
| 248 | }) |
| 249 | }, |
| 250 | fingerIn() { |
| 251 | let that = this |
| 252 | let fingerprint = uni.getStorageSync("fingerprint") |
| 253 | if (fingerprint) { |
| 254 | uni.checkIsSoterEnrolledInDevice({ |
| 255 | checkAuthMode: 'fingerPrint', |
| 256 | success(res) { |
| 257 | if (res.isEnrolled) { |
| 258 | uni.startSoterAuthentication({ |
| 259 | requestAuthModes: ['fingerPrint'], |
| 260 | authContent: '指纹解锁', |
| 261 | success(res) { |
| 262 | that.fingerLogin() |
| 263 | }, |
| 264 | fail(res) { |
| 265 | console.log(res) |
| 266 | if (res.errCode == "90010") { |
| 267 | uni.showToast({ |
| 268 | title: "错误次数过多,功能被冻结,请尝试其他登陆方式", |
| 269 | duration: 1500, |
| 270 | icon: "none", |
| 271 | mask: true, |
| 272 | }) |
| 273 | } else { |
| 274 | uni.showToast({ |
| 275 | title: res.errCode, |
| 276 | duration: 1500, |
| 277 | icon: "none", |
| 278 | mask: true, |
| 279 | }) |
| 280 | } |
| 281 | } |
| 282 | }) |
| 283 | } else { |
| 284 | uni.showToast({ |
| 285 | title: "没有录入指纹", |
| 286 | duration: 1500, |
| 287 | icon: "none", |
| 288 | mask: true, |
| 289 | }) |
| 290 | } |
| 291 | }, |
| 292 | }) |
| 293 | |
| 294 | } else { |
| 295 | uni.showToast({ |
| 296 | title: "未开启指纹登录,请使用其他方式登录", |
| 297 | duration: 1500, |
| 298 | icon: "none", |
| 299 | mask: true, |
| 300 | }) |
| guangchao.xu | 070005a | 2020-12-07 09:56:40 +0800 | [diff] [blame] | 301 | } |
| 302 | }, |
| 303 | faceIn() { |
| 304 | let face = uni.getStorageSync("face") |
| 305 | if (face) { |
| guangchao.xu | c43cf97 | 2021-01-18 13:37:55 +0800 | [diff] [blame] | 306 | uni.showToast({ |
| 307 | title: "暂不支持面容登录,请使用其他方式登录", |
| 308 | duration: 1500, |
| 309 | icon: "none", |
| 310 | mask: true, |
| 311 | }) |
| guangchao.xu | 070005a | 2020-12-07 09:56:40 +0800 | [diff] [blame] | 312 | } else { |
| 313 | uni.showToast({ |
| 314 | title: "未开启面容登录,请使用其他方式登录", |
| 315 | duration: 1500, |
| 316 | icon: "none", |
| 317 | mask: true, |
| 318 | }) |
| guangchao.xu | 070005a | 2020-12-07 09:56:40 +0800 | [diff] [blame] | 319 | } |
| 320 | }, |
| 321 | handsIn() { |
| 322 | let hands = uni.getStorageSync("hands") |
| 323 | if (hands) { |
| 324 | uni.setStorageSync("login", 1) |
| 325 | uni.navigateTo({ |
| guangchao.xu | 6cdd45e | 2021-04-16 17:44:30 +0800 | [diff] [blame^] | 326 | url: "/pages/sub_mine/lock" |
| guangchao.xu | 070005a | 2020-12-07 09:56:40 +0800 | [diff] [blame] | 327 | }) |
| 328 | } else { |
| 329 | uni.showToast({ |
| 330 | title: "未开启手势登录,请使用其他方式登录", |
| 331 | duration: 1500, |
| 332 | icon: "none", |
| 333 | mask: true, |
| 334 | }) |
| guangchao.xu | 070005a | 2020-12-07 09:56:40 +0800 | [diff] [blame] | 335 | } |
| 336 | } |
| 337 | } |
| 338 | } |
| 339 | </script> |
| 340 | |
| 341 | <style scoped lang="scss"> |
| 342 | .login { |
| 343 | width: 100vw; |
| 344 | font-family: "PingFang-SC-Medium"; |
| 345 | background-color: #FFFFFF; |
| 346 | height: 100vh; |
| 347 | position: relative; |
| 348 | |
| 349 | &-con { |
| 350 | padding: 30rpx; |
| 351 | |
| 352 | &-title { |
| 353 | display: flex; |
| 354 | justify-content: space-between; |
| 355 | align-items: center; |
| 356 | |
| 357 | text { |
| 358 | font-family: "PingFang-SC-Medium"; |
| 359 | font-size: 32rpx; |
| 360 | color: #333333; |
| 361 | } |
| 362 | } |
| 363 | |
| 364 | &-logo { |
| 365 | display: flex; |
| 366 | justify-content: center; |
| 367 | padding: 30rpx 0; |
| 368 | text-align: center; |
| 369 | align-items: center; |
| 370 | } |
| 371 | |
| 372 | &-form { |
| 373 | width: 650rpx; |
| 374 | margin: 0 auto 50rpx; |
| 375 | |
| 376 | &-forget { |
| 377 | color: #999999; |
| 378 | font-size: 28rpx; |
| 379 | display: flex; |
| 380 | justify-content: flex-end; |
| 381 | margin-top: 30rpx; |
| 382 | } |
| 383 | } |
| 384 | |
| 385 | &-btn { |
| 386 | background-color: #2FA8E1; |
| 387 | padding: 50rpx 0; |
| 388 | color: #FFFFFF; |
| 389 | width: 600rpx; |
| 390 | font-size: 30rpx; |
| 391 | border: 1px solid #2FA8E1; |
| 392 | } |
| 393 | |
| 394 | &-btnr { |
| 395 | border: 1px solid #2FA8E1; |
| 396 | padding: 50rpx 0; |
| 397 | color: #2FA8E1; |
| 398 | width: 600rpx; |
| 399 | font-size: 30rpx; |
| 400 | margin-top: 30rpx; |
| 401 | } |
| 402 | |
| 403 | &-youke { |
| 404 | display: flex; |
| 405 | justify-content: center; |
| 406 | color: #999999; |
| 407 | font-size: 28rpx; |
| 408 | margin-top: 30rpx; |
| 409 | } |
| 410 | |
| 411 | &-footer { |
| 412 | position: absolute; |
| 413 | bottom: 30rpx; |
| 414 | width: 500rpx; |
| 415 | left: 50%; |
| 416 | transform: translateX(-50%); |
| 417 | // width: 100vw; |
| 418 | display: flex; |
| 419 | justify-content: center; |
| 420 | flex-direction: column; |
| guangchao.xu | 6cdd45e | 2021-04-16 17:44:30 +0800 | [diff] [blame^] | 421 | align-items: center; |
| guangchao.xu | 070005a | 2020-12-07 09:56:40 +0800 | [diff] [blame] | 422 | &-title { |
| 423 | display: flex; |
| 424 | justify-content: center; |
| 425 | font-size: 28rpx; |
| 426 | color: #999999; |
| 427 | } |
| 428 | |
| 429 | &-icon { |
| guangchao.xu | 6cdd45e | 2021-04-16 17:44:30 +0800 | [diff] [blame^] | 430 | width: 50%; |
| guangchao.xu | 070005a | 2020-12-07 09:56:40 +0800 | [diff] [blame] | 431 | display: flex; |
| 432 | justify-content: space-around; |
| 433 | margin-top: 30rpx; |
| 434 | } |
| 435 | } |
| 436 | } |
| 437 | |
| 438 | } |
| 439 | </style> |