<view @click="sendCode" :class="phone.length == 11 ? 'btn2' : ''" class="btn">获取短信验证码</view>
*******************************************************************************************************************************************************
1.调接口获取验证码
2.跳转至输入验证码的页面
3.调接口loginByCode判断验证码是否正确
4.保存用户信息和token到vuex保存token供request使用
5.返回2级页面//发送验证码
return{phone: '',}sendCode() { const { phone } = this;if (!this.xieyi) {this.toast('请勾选和阅读《Uplay用户协议》《用户隐私政策》');return;}if (phone.length != 11) {this.toast('请输入正确的手机号');return;}getMsgCode({ phone }).then(res => {this.toast('发送成功!注意查收');console.log(res)//{//"msg": "操作成功",// "code": 200// }setTimeout(() => {uni.navigateTo({ url: '/pages/login/codeLogin?phone=' + this.phone }); //将手机号带过去}, 1500);});}*********************************************************************************************************************************************************************<view class="box"><view class="content">请输入验证码</view><view class="tip">验证码已发送至<text>{{phone}}</text></view><view class="uni-height"></view><view style="height: 100rpx;"></view><myp-one v-model="test" @finish="finishedOne" class="code_box"></myp-one></view></view>**********************************************************************************************************************************************************************import { loginByCode,verificationCode ,teacherAuthInfo,loginRtm} from '../../common/apis.js';/*** 验证验证码* @param {Object} data*/export function verificationCode(data) {uni.showLoading()return request({requestType: 'post',method: 'app/user/verificationCode',sendmsg: data,})}/*** 验证码登录* @param {Object} data*/export function loginByCode(data) {uni.showLoading()return request({requestType: 'post',method: 'app/user/loginByCode',sendmsg: data,})}methods:{//校验验证码verificationCode() {const { phone, code } = this;if (code == '') {uni.showToast({title: '请输入验证码',icon: 'none'});return;}verificationCode({phone,msgCode:code}).then(res => {console.log(97,res);this.openUrl(`/pages/login/newPwd?phone=${phone}&code=${code}`)});},finishedOne(val) {console.log(102,val) //当你输完之后的值this.code = valif(this.type==1){ //忘记密码走这里this.verificationCode()}else{this.login()}},toClear() {this.test = ''this.$refs.hi.clear()},//验证码登录login() {const { phone, code } = this;if (code == '') {uni.showToast({title: '请输入验证码',icon: 'none'});return;}loginByCode({phone,code}).then(res => {console.log(44,res)//{//"msg": "操作成功",//"code": 200,//"data": {// "id": 98,// "token": "181e63a3a7e4439a9adfa67cf727fcfa",// "userAvatar": "common/20210425/head@3x.png",// "userName": "小U985",// "userPhone": "18119685985",// "userType": 1// }// }//老师端if (this.$store.state.environment == 'teacher') {//老师登录if (res.data.userType == 2) {this.toast('登录成功');this.saveUser(res.data);this.saveToken(res.data.token);setTimeout(() => {uni.navigateBack({delta: 2});}, 2000);} else {this.saveUser(res.data);this.saveToken(res.data.token);teacherAuthInfo().then(res => {if (res.data.certificationStatus == -1) {this.openUrlRedirect('/pages/recommend/teacherCert/teacherCert');} else {this.openUrlRedirect('/pages/recommend/certDetail/certDetail?certificationStatus=' + res.data.certificationStatus);}});}} else {this.toast('登录成功',2000,'success');this.saveUser(res.data);this.saveToken(res.data.token);loginRtm()setTimeout(()=>{uni.navigateBack({delta:2})},2000)setTimeout(()=>{uni.$emit('score')},3500)}});},},