123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129 |
- import * as API_user from '@/apis/user'
- import {
- checkPhone,
- } from '@/utils'
- export default {
- data() {
- return {
- subFormCode: {
- phone: '',
- openId: '',
- code: ''
- },
- isSendMsgIng: false,
- sendMsgSecond: 60,
- }
- },
- methods: {
-
- codeCheckForm() {
- let phoneResult = checkPhone(this.subFormCode.phone);
- if (typeof phoneResult == 'string') {
-
-
- this.$refs.common.alert(phoneResult)
- return false;
- } else if (!this.subFormCode.code) {
-
- this.$refs.common.alert('请输入验证码')
-
- return false;
- } else {
- return true;
- }
- },
- login() {
- this.codeSubmit();
-
- },
- //验证码登录
- codeSubmit() {
- if (this.codeCheckForm()) {
- this.$refs.common.showLoading()
- API_user.userUpdatePhone(this.subFormCode).then(response => {
-
- if(response.data){
- this.user=this.carhelp.getPersonInfo();
- this.user.phone=this.subFormCode.phone;
- this.carhelp.setPersonInfo(this.user)
- this.$refs.common.setFnc(this.loginSuccess)
- this.$refs.common.alert2("变更手机号成功!")
-
- }else{
-
- this.$refs.common.showLoading(false,response.message);
- }
-
-
- }).catch(error => {
- this.$refs.common.showLoading(false,error);
-
- })
- }
- },
- //发送验证码
- sendMsg() {
-
-
- if (!this.isSendMsgIng) {
- let phoneResult = checkPhone(this.subFormCode.phone);
- if (typeof phoneResult == 'string') {
-
- this.$refs.common.alert(phoneResult)
- } else {
- this.$refs.common.showLoading()
- API_user.getVerifyCode(this.subFormCode).then(response => {
- this.$refs.common.showLoading(false)
- if(response.message){
- //倒计时
- this.msgTimeInterval();
- }else{
- this.$refs.common.alert("您的验证码已经发送[5分钟有效],请勿重复点击")
- }
-
- }).catch(error => {
-
- this.$refs.common.alert(error)
- })
- }
- }
- },
- //倒计时
- msgTimeInterval() {
- this.isSendMsgIng = true;
- var time = this.sendMsgSecond;
- var _this = this;
- this.timer = setInterval(() => {
- if (time > 0) {
- _this.sendMsgSecond = time--;
- } else {
- _this.isSendMsgIng = false;
- _this.sendMsgSecond = 60;
- clearInterval(_this.timer)
- }
- }, 1000)
- }, //登录成功
- loginSuccess() {
-
- uni.switchTab({
- url: '/pages/my/index'
- });
-
- },
- showphone(phone){
- if(!phone){
- return "";
- }
- if(phone.length!=11){
- return "";
- }
- return phone.substring(0,3)+'****'+phone.substring(8);
- },
- },
- onLoad() {
-
- }
- }
|