|
|
<template> <view class="main" :style="{ background: `url(${imgUrl}) no-repeat`, backgroundSize: backgroundSize }"> <!-- <view class="u-back-top"> <view class="backBox"> <u-icon name="arrow-left" color="#333" size="28"></u-icon> </view> </view> --> <u-navbar title=" " :bgColor="bgColor" :autoBack="true" ></u-navbar> <view class="title">教练端短信验证码登录</view> <view class="form"> <view class="form-item"> <view class="prefix"> <view class="jia">+</view> <view class="num">86</view> <view class="" style="margin: 0 32rpx 0 12rpx;"> <u-icon name="arrow-down" color="#333" size="16" ></u-icon> </view> </view> <view class="inputBox my"> <!-- <u--input placeholder="请输入手机号" border="none" clearable type="number" maxlength="11" v-model="FormData.phone"></u--input> --> <input v-model.trim="FormData.phone" placeholder="请输入手机号" type="number" maxlength="11" > </view> </view> <view class="form-item"> <view class="inputBox my"> <!-- <u--input placeholder="请输入验证码" border="none" clearable style="height: 100%;" :clearable="false" v-model="FormData.code"></u--input> --> <input type="text" placeholder="请输入验证码" v-model.trim="FormData.code"> </view> <view class="code" @click='goSms' :class="{active: isPhone&&!codeOn}">{{codeText}}</view> </view> <view class="loginBtn" :class="{active: btnHighlight}" @click="submitFn">登 录</view> <view style="margin-top: 40rpx;"> <privacyRadion :isCheck="isCheck" @changeRadio="changeRadio"></privacyRadion> </view> <!-- <button @click="$goPage('/pages/userCenter/login/face')">进入人脸识别</button> --> </view> <u-action-sheet :actions="list" title="请选择您要登录的角色" :show="showRole" @select="selectClick" ></u-action-sheet> </view> </template>
<script> import { getLoginCode, loginSMS, coachSmsLogin } from '@/config/api.js' import privacyRadion from './comp/privacyRadion.vue' import { imgUrl } from '@/config/site.config' export default { components: {privacyRadion}, data() { return { imgUrl: imgUrl+'loginTopBg.png', backgroundSize: '100% 360rpx', isCheck:false, codeText: '获取验证码', FormData: {}, codeOn: false, bgColor: 'transparent', list: [{name: '实操教练', id: 3}, {name: '校长', id: 4}], showRole: false, } }, onLoad(options) { }, computed: { isPhone() { return uni.$u.test.mobile(this.FormData.phone) }, btnHighlight() { return this.isPhone&&this.FormData.code*1>999 } }, methods: { // 是否选择协议
changeRadio(val) { this.isCheck = val }, // 发送短信验证码
goSms() { const { FormData } = this if (!FormData.phone) return this.$u.toast('请输入手机号'); if (!this.isPhone) return this.$u.toast('手机号格式有误'); if (this.codeOn) return this.codeOn = true; getLoginCode({ scene: 11, mobile: FormData.phone, }).then(()=>{ var time = 60; this.codeText = time + "秒后重新发送" var timer = setInterval(() => { time--; this.codeText = time + "秒后重新发送" if (time == 0) { clearInterval(timer); this.codeText = "获取验证码"; this.codeOn = false; } }, 1000); }).catch(()=>{ this.codeOn = false; }) // 获取验证码
}, async submitFn() { if(!this.btnHighlight) return if(!this.isCheck) return this.$u.toast('请勾选产品协议与隐私政策'); let obj = { mobile: this.FormData.phone, code: this.FormData.code } const {data: res} = await coachSmsLogin(obj) this.$store.commit('update_vuex_loginInfo',res) await this.$store.dispatch('getUserInfo') if(res.userType==5) { this.showRole = true }else { if(res.userType==3) this.$store.commit('upDateIdentity', '实操教练') if(res.userType==4) this.$store.commit('upDateIdentity', '校长') uni.switchTab({ url: '/pages/tabbar/student/index' }) } }, selectClick(item) { this.showRole = false this.$store.commit('upDateIdentity', item.name) uni.switchTab({ url: '/pages/tabbar/student/index' }) // alert(item.name)
} } } </script>
<style lang="scss" scoped> .main { width: 100%; min-height: 100vh; // background: url('../../../static/images/userCenter/loginTopBg.png') no-repeat;
// background-size: 100% 360rpx;
.uni-input-placeholder { color: #BBBBBB !important; } .u-back-top { padding: 32rpx 0 0 0; .backBox { padding: 24rpx; } } .title { font-size: 48rpx; color: #333; padding: 202rpx 0 80rpx 0; text-align: center; font-weight: 600; } .form { padding: 0 46rpx; .form-item { height: 112rpx; background: #F4F7FF; border-radius: 16rpx; width: 100%; line-height: 112rpx; display: flex; margin-bottom: 40rpx; padding: 0 40rpx; .prefix { display: flex; align-items: center; font-size: 32rpx; color: #333; font-weight: 600; } .inputBox { flex: 1; input { display: block; width: 100%; height: 100%; display: block; line-height: 112rpx; font-size: 30rpx; } } .code { color: #BBBBBB; margin-left: 30rpx; &.active { color: $themC } } } .loginBtn { width: 100%; height: 112rpx; background: rgba(25,137,250,0.3); border-radius: 16rpx; text-align: center; line-height: 112rpx; font-size: 32rpx; font-weight: 600; color: #fff; margin-top: 100rpx; &.active { background: rgba(25,137,250,1); } } } } </style>
|