Newer
Older
import {Component} from '@angular/core';
import {IonicPage, NavController, NavParams} from 'ionic-angular';
import {Response} from "@angular/http";
import {AppService} from "../../service/http.service";
import {TabsService} from "../tabs/tabs.service";
@IonicPage()
@Component({
selector: 'page-forget-pwd',
templateUrl: 'forget-pwd.html',
})
export class ForgetPwdPage {
user = {
phone: '',
code: ""
};
passwordInfo = {
modifyPassword: '',
sureModifyPassword: ''
};
disabledClick = false;
verifyText = '获取验证码';
nextClick = false;
constructor(public navCtrl: NavController, public navParams: NavParams, private commonSer: CommonService,
private appService: AppService, private tabSer: TabsService) {
}
ionViewDidLoad() {
}
//发送验证码
sendCode() {
if (this.user.phone.length !== 11 || !Number(this.user.phone)) {
this.commonSer.toast('请输入正确的手机号码');
return false;
}
this.commonSer.toast('验证码发送成功');
} else {
this.commonSer.toast(res.errmsg);
nextCheck() {
if (this.user.phone.length > 0 && this.user.code.length > 0) {
this.nextClick = false;
}
}
//倒计时
countTime() {
let totalTime = 60;
this.disabledClick = true;
this.verifyText = totalTime + 's后重新发送';
let clock = window.setInterval(() => {
totalTime--;
this.verifyText = totalTime + 's后重新发送';
if (totalTime < 0) {
window.clearInterval(clock);
this.verifyText = "重新发送验证码";
this.disabledClick = false;
}
}, 1000)
}
sureModifyPassword() {
if (!this.check()) {
return false;
}
const data = {
"password": this.passwordInfo.modifyPassword
};
this.tabSer.updatePassword(data).subscribe(
(res) => {
logoutApp() {
this.appService.ObserverHttpGet("/wisdomgroup/app/logout", null)
.subscribe((res: Response) => {
let data = res.json();
}, error => {
}
);
}
check() {
if (this.passwordInfo.modifyPassword == '' ||
this.passwordInfo.sureModifyPassword == '') {
this.appService.popToastView("请输入完整信息!", 'top', 2000);
return false;
}
if (!this.myreg.test(this.passwordInfo.modifyPassword)) {
this.appService.popToastView('新密码以英文字母开头,同时包含数字,长度8-20位!', 'top', 2000);