|
|
|
@ -1,5 +1,6 @@ |
|
|
|
|
<template> |
|
|
|
|
<view> |
|
|
|
|
<view v-if="type == 1"> |
|
|
|
|
<image mode="widthFix" class="width90 mart20" v-if="user && user.infoCompleteStatus == 1" |
|
|
|
|
:src="imagewxUrl+imgadres"></image> |
|
|
|
|
<image mode="widthFix" class="width90 mart20" v-if="!user" :src="imagewxUrl+imgadres1"></image> |
|
|
|
@ -9,6 +10,7 @@ |
|
|
|
|
授权并登录</view> |
|
|
|
|
<button class="mart30 width90 height50 fcorfff backcor008 fotct btns font16 fontlet" v-if="!user" |
|
|
|
|
open-type="getPhoneNumber" @getphonenumber="loginByPhone">授权手机号</button> |
|
|
|
|
<view class="mart20 width90 font15 fcor666 fotct" @click="updateStu(2)">手机短信登录</view> |
|
|
|
|
<!-- <button class="mart30 width90 height50 fcorfff backcor008 fotct btns font16" v-if="user.phone && user" |
|
|
|
|
@click="reqmessage">授权获取消息通知</button> --> |
|
|
|
|
<!-- #endif --> |
|
|
|
@ -17,6 +19,27 @@ |
|
|
|
|
@click="getH5userinfo">授权并登录</button> |
|
|
|
|
<!-- #endif --> |
|
|
|
|
</view> |
|
|
|
|
<view v-if="type == 2"> |
|
|
|
|
<view class="logo"> |
|
|
|
|
<view class="img"> |
|
|
|
|
<image mode="widthFix" |
|
|
|
|
src=""> |
|
|
|
|
</image> |
|
|
|
|
</view> |
|
|
|
|
</view> |
|
|
|
|
<view class="form re" style="top:200rpx;"> |
|
|
|
|
<view class="username"> |
|
|
|
|
<view class="get-code" style="color: #676767;" @click.stop="getCode()">{{getCodeText}}</view> |
|
|
|
|
<input placeholder="请输入手机号" v-model="phoneNumber" placeholder-style="color: #676767;" /> |
|
|
|
|
</view> |
|
|
|
|
<view class="code"> |
|
|
|
|
<input placeholder="请输入验证码" v-model="code" placeholder-style="color: #676767;" /> |
|
|
|
|
</view> |
|
|
|
|
<view class="btn mart50" @tap="doReg">立即登录</view> |
|
|
|
|
<view class="width90 marb20 font15 fcor666 fotct" @click="updateStu(1)">微信授权登录</view> |
|
|
|
|
</view> |
|
|
|
|
</view> |
|
|
|
|
</view> |
|
|
|
|
</template> |
|
|
|
|
|
|
|
|
|
<script> |
|
|
|
@ -24,7 +47,9 @@ |
|
|
|
|
import { |
|
|
|
|
getUserInfo, |
|
|
|
|
loginByPhone, |
|
|
|
|
HandleCode |
|
|
|
|
HandleCode, |
|
|
|
|
loginByTel, |
|
|
|
|
sendSmsCode |
|
|
|
|
} from "../../Utils/Api.js" |
|
|
|
|
export default { |
|
|
|
|
data() { |
|
|
|
@ -33,6 +58,11 @@ |
|
|
|
|
imagewxUrl: app.globalData.imageWxImg, |
|
|
|
|
imgadres: 'login.png', |
|
|
|
|
imgadres1: 'loginphone.png', |
|
|
|
|
phoneNumber: "", |
|
|
|
|
code: '', |
|
|
|
|
getCodeText: '获取验证码', |
|
|
|
|
getCodeisWaiting: false, |
|
|
|
|
type: 1 // 区分登录方式 |
|
|
|
|
} |
|
|
|
|
}, |
|
|
|
|
onLoad() { |
|
|
|
@ -160,11 +190,116 @@ |
|
|
|
|
url: '/pages/login/register' |
|
|
|
|
}) |
|
|
|
|
}, |
|
|
|
|
//改变登录方式 |
|
|
|
|
updateStu(item) { |
|
|
|
|
this.type = item; |
|
|
|
|
}, |
|
|
|
|
//发送短信 |
|
|
|
|
getCode() { |
|
|
|
|
uni.hideKeyboard() |
|
|
|
|
if (this.getCodeisWaiting) { |
|
|
|
|
return; |
|
|
|
|
} |
|
|
|
|
if (!(/^1(3|4|5|6|7|8|9)\d{9}$/.test(this.phoneNumber))) { |
|
|
|
|
uni.showToast({ |
|
|
|
|
title: '请填写正确手机号码', |
|
|
|
|
icon: "none" |
|
|
|
|
}); |
|
|
|
|
return false; |
|
|
|
|
} |
|
|
|
|
uni.showLoading({ |
|
|
|
|
title: '发送中...' |
|
|
|
|
}) |
|
|
|
|
let params = { |
|
|
|
|
phone: this.phoneNumber |
|
|
|
|
} |
|
|
|
|
sendSmsCode(params).then(res => { |
|
|
|
|
if (res.return_code == '000000') { |
|
|
|
|
this.getCodeisWaiting = true; |
|
|
|
|
uni.showToast({ |
|
|
|
|
title: '验证码已发送', |
|
|
|
|
icon: "none" |
|
|
|
|
}); |
|
|
|
|
this.setTimer(); |
|
|
|
|
} else { |
|
|
|
|
uni.hideLoading() |
|
|
|
|
} |
|
|
|
|
}) |
|
|
|
|
}, |
|
|
|
|
setTimer() { |
|
|
|
|
let holdTime = 60; |
|
|
|
|
this.getCodeText = "重新获取(60)" |
|
|
|
|
this.Timer = setInterval(() => { |
|
|
|
|
if (holdTime <= 0) { |
|
|
|
|
this.getCodeisWaiting = false; |
|
|
|
|
this.getCodeBtnColor = "#ffffff"; |
|
|
|
|
this.getCodeText = "获取验证码" |
|
|
|
|
clearInterval(this.Timer); |
|
|
|
|
return; |
|
|
|
|
} |
|
|
|
|
this.getCodeText = "重新获取(" + holdTime + ")" |
|
|
|
|
holdTime--; |
|
|
|
|
|
|
|
|
|
}, 1000) |
|
|
|
|
}, |
|
|
|
|
//手机短信登录 |
|
|
|
|
doReg() { |
|
|
|
|
uni.hideKeyboard() |
|
|
|
|
//模板示例部分验证规则 |
|
|
|
|
if (!(/^1(3|4|5|6|7|8|9)\d{9}$/.test(this.phoneNumber))) { |
|
|
|
|
uni.showToast({ |
|
|
|
|
title: '请填写正确手机号码', |
|
|
|
|
icon: "none" |
|
|
|
|
}); |
|
|
|
|
return false; |
|
|
|
|
} |
|
|
|
|
if (!this.code) { |
|
|
|
|
uni.showToast({ |
|
|
|
|
title: '请填写验证码', |
|
|
|
|
icon: "none" |
|
|
|
|
}); |
|
|
|
|
return false; |
|
|
|
|
} |
|
|
|
|
uni.showLoading({ |
|
|
|
|
title: '提交中...' |
|
|
|
|
}) |
|
|
|
|
let params = { |
|
|
|
|
phone: this.phoneNumber, |
|
|
|
|
smsCode: this.code |
|
|
|
|
} |
|
|
|
|
loginByTel(params).then(res => { |
|
|
|
|
uni.hideLoading() |
|
|
|
|
if (res.return_code == '000000') { |
|
|
|
|
app.globalData.token = res.return_data.uniqueCode; |
|
|
|
|
app.globalData.userInfo = res.return_data |
|
|
|
|
.object |
|
|
|
|
.highUser; |
|
|
|
|
uni.setStorage({ |
|
|
|
|
key: "user", |
|
|
|
|
data: res.return_data |
|
|
|
|
.object |
|
|
|
|
.highUser |
|
|
|
|
}) |
|
|
|
|
uni.setStorage({ |
|
|
|
|
key: "token", |
|
|
|
|
data: res.return_data.uniqueCode |
|
|
|
|
}) |
|
|
|
|
uni.navigateBack({}) |
|
|
|
|
} else { |
|
|
|
|
uni.showToast({ |
|
|
|
|
title: res.return_msg, |
|
|
|
|
icon: "none" |
|
|
|
|
}); |
|
|
|
|
} |
|
|
|
|
}) |
|
|
|
|
}, |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
</script> |
|
|
|
|
|
|
|
|
|
<style lang="scss"> |
|
|
|
|
@import "../../static/css/login.scss"; |
|
|
|
|
|
|
|
|
|
.btns { |
|
|
|
|
border-radius: 6px; |
|
|
|
|
} |
|
|
|
|