123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138 |
- import * as API_user from '@/apis/user'
- import {
- checkPhone,
- } from '@/utils'
- export default {
- data() {
- return {
- openId:"",
- subFormCode: {
- phone: '',
- openId: '',
- verifyCode: ''
- },
- isSendMsgIng: false,
- sendMsgSecond: 60,
- back:false,
- }
- },
- methods: {
- gotoHome(){
- uni.switchTab({
- url: '/pages/index/index'
- });
- },
- codeCheckForm() {
- let phoneResult = checkPhone(this.subFormCode.phone);
- if (typeof phoneResult == 'string') {
-
-
- this.$refs.common.alert(phoneResult)
- return false;
- } else if (!this.subFormCode.verifyCode) {
-
- this.$refs.common.alert('请输入验证码')
-
- return false;
- } else {
- return true;
- }
- },
- login() {
- this.codeSubmit();
-
- },
- //验证码登录
- codeSubmit() {
- if (this.codeCheckForm()) {
- this.$refs.common.showLoading()
- API_user.validateCode(this.subFormCode).then(response => {
-
- if(response.data){
- var token = response.data ? response.data.token : '';
- this.carhelp.setToken(token);
- this.carhelp.setPersonInfo(response.data.userInfo)
-
- this.loginSuccess();
- }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'
- });
- },
- },
- onLoad(temp) {
-
- var ob=this.carhelp.getPersonInfo()
- if(ob){
- this.loginSuccess()
- }
- if(temp.back){
- this.back=true;
- }
- console.log(ob)
- this.subFormCode.openId = this.carhelp.getOpenId();
-
- if (process.car.SIMPLE_RUN) {
- this.subFormCode.openId = "test";
-
- }
- console.log(this.carhelp.getPrefix())
-
-
- }
- }
|