123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216 |
- <template>
- <view class="other-box">
- <en-nav @navHeight="setNavHeight" :right-show="true" right-text="密码登录" @rightClick="goToPass"></en-nav>
- <view class="login-box" :style="{'height':'calc(100vh - '+navHeight+'px)'}">
- <view class="login-top">
- <view class="login-title">
- <text class="title-item sys-color-black sys-weight-600">验证登录</text>
- </view>
- <view class="login-from">
- <view class="from-text" :class="{'apply-shake':phoneShake}">
- <input type="tel" class="from-input sys-color-gray-3" max="11" v-model="phone" placeholder="请输入手机号"></input>
- </view>
- <view class="from-code" :class="{'apply-shake':codeShake}">
- <view class="from-text">
- <input type="tel" class="from-input sys-color-gray-3" v-model="code" placeholder="请输入验证码"></input>
- </view>
- <view class="code-text">
- <text class="sys-color-gray-3" v-if="time<=0" @click="senCode">获取验证码</text>
- <text class="sys-color-gray-3" v-else>{{time}} s</text>
- </view>
- </view>
- </view>
- <view class="login-but sys-color-white sys-background-black sys-selected-but" @click="login" :class="{'sys-unselected-but':!isLogin}">登录</view>
- <view class="local-txt sys-color-gray-9">若长时间未收到验证码,请使用以下方式快速登录</view>
- </view>
- </view>
- <view class="login-bottom">
- <other-login></other-login>
- </view>
- </view>
- </template>
- <script>
- import EnNav from "@/components/en-utils/en-nav/en-nav";
- import tools from "@/service/tools";
- import OtherLogin from "@/pages/login/model/otherLogin";
- import {forgetPassword, login} from "@/api/login";
- export default {
- name:'otherPhoneLogin',
- components: {OtherLogin, EnNav},
- data() {
- return {
- navHeight:40,
- isLogin:false,
- phoneShake:false,
- codeShake:false,
- phone:'',
- code:'',
- time:0,
- }
- },
- watch:{
- 'phone':function (){
- this.verifyIsLogin()
- },
- 'code':function (){
- this.verifyIsLogin()
- },
- },
- methods: {
- login(){
- if(this.phone.length !== 11){
- tools.error('请输入手机号码')
- this.setShake(1)
- tools.vibrate()
- return false
- }
- if(this.code ===''){
- tools.error('请输入验证码')
- this.setShake(2)
- tools.vibrate()
- return false
- }
- this.oneClickLogin(this.phone)
- // forgetPassword({'mobile':this.phone,'code':this.code}).then((res)=>{
- // if(res.code===0){
- // tools.success('登陆成功')
- // setTimeout(()=>{
- // uni.switchTab({
- // 'url':'/pages/index/index'
- // })
- // },1500)
- // }else {
- // tools.error(res.msg)
- // }
- // })
- },
- oneClickLogin(mobile){
- login({'mobile':mobile,'grant_type':'mobile','scope':'server'}).then((res)=>{
- tools.setLoginData(res)
- if(res.isNewUser){
- uni.switchTab({
- 'url':'/pages/index/index'
- })
- }else {
- setTimeout(()=>{
- uni.navigateTo({
- 'url':'/pages/perfect/sexAndAge'
- })
- },1500)
- }
- }).catch((e)=>{
- console.log(e)
- })
- },
- setShake(type){
- if(type===1){
- this.phoneShake=true
- }else {
- this.codeShake=true
- }
- setTimeout(()=>{
- this.phoneShake=false
- this.codeShake=false
- },500)
- },
- setNavHeight(navHeight){
- this.navHeight=navHeight
- },
- verifyIsLogin(){
- this.isLogin = this.phone.length === 11 && this.code !== '';
- },
- senCode(){
- if(this.phone.length !== 11){
- tools.error('请输入手机号码')
- this.setShake(1)
- tools.vibrate()
- return false
- }
- this.time=60
- let timeServe=setInterval(()=>{
- --this.time
- if(this.time<=0){
- clearInterval(timeServe)
- }
- },1000)
- },
- goToPass(){
- uni.navigateTo({
- 'url':'/pages/login/passLogin'
- })
- }
- }
- }
- </script>
- <style scoped lang="scss">
- .other-box{
- padding: 82rpx 80rpx 0 80rpx;
- box-sizing: border-box;
- position: relative;
- .login-top{
- .login-title{
- padding-bottom: 60rpx;
- .title-item{
- font-size: 48rpx;
- }
- }
- .login-from{
- .from-text{
- width: 100%;
- padding-bottom: 40rpx;
- border-bottom: 1rpx solid #E0E0E0;
- .from-input{
- font-size: 32rpx;
- height: 44rpx;
- line-height: 44rpx;
- }
- .from-input::placeholder{
- color: #999999;
- }
- }
- .from-code{
- margin-top: 60rpx;
- display: flex;
- justify-content: space-between;
- .from-text{
- width: 344rpx;
- }
- .code-text{
- width: 180rpx;
- height: 44rpx;
- line-height: 44rpx;
- text-align: center;
- text{
- font-size: 32rpx;
- }
- }
- }
- }
- .login-but{
- margin-top: 120rpx;
- }
- .local-txt{
- padding-top: 32rpx;
- font-size: 24rpx;
- text-align: center;
- }
- }
- .login-bottom{
- padding-bottom: calc(186rpx + env(safe-area-inset-bottom));
- position: absolute;
- bottom: 0;
- left: 80rpx;
- width:calc(100vw - 160rpx);
- }
- }
- </style>
|