|
@@ -0,0 +1,74 @@
|
|
|
+import {AlertController, IonicPage, NavController, NavParams, ToastController} from "ionic-angular";
|
|
|
+import {Component, Injectable} from '@angular/core';
|
|
|
+import {SystemService} from "../../app/services/system.service";
|
|
|
+import {DictionaryItemView} from "../../viewmodel/common/dictionaryItemView";
|
|
|
+import {RegistView} from "../../viewmodel/user/registView";
|
|
|
+import {UserService} from "../../app/services/user/user.service";
|
|
|
+import {HomePage} from "../home/home";
|
|
|
+import { ChangePassView } from "../../viewmodel/user/changePassView";
|
|
|
+import {LoginPage} from "../login/login";
|
|
|
+
|
|
|
+@IonicPage()
|
|
|
+@Injectable()
|
|
|
+@Component({
|
|
|
+ templateUrl: 'changepass.html'
|
|
|
+})
|
|
|
+export class ChangePassPage {
|
|
|
+ private changePass: ChangePassView = {
|
|
|
+ OldPassword: null,
|
|
|
+ Password: null,
|
|
|
+ PasswordRep: null
|
|
|
+ } as ChangePassView;
|
|
|
+
|
|
|
+ constructor(
|
|
|
+ public navCtrl: NavController,
|
|
|
+ public navParams: NavParams,
|
|
|
+ public toastCtrl: ToastController,
|
|
|
+ private userService: UserService,
|
|
|
+ private alertCtrl: AlertController) {
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ confim(valid) {
|
|
|
+ if (!valid) return;
|
|
|
+ this.userService.changePass(this.changePass).then(res => {
|
|
|
+ if (res.isSuccess) {
|
|
|
+ this.userService.unbind().then(res => {
|
|
|
+ if (res.isSuccess) {
|
|
|
+ this.alertCtrl.create({
|
|
|
+ title: '信息', message: '密码修改成功,即将重新登录。',
|
|
|
+ buttons: [{
|
|
|
+ text: '确定',
|
|
|
+ handler: () => {
|
|
|
+ localStorage.removeItem("name");
|
|
|
+ localStorage.removeItem("userID");
|
|
|
+ localStorage.removeItem("loginID");
|
|
|
+ this.navCtrl.push(LoginPage);
|
|
|
+ }
|
|
|
+ }]
|
|
|
+ }).present();
|
|
|
+ } else {
|
|
|
+ this.presentToast(res.message,"error");
|
|
|
+ }
|
|
|
+ });
|
|
|
+ } else {
|
|
|
+ this.presentToast(res.message,"error");
|
|
|
+ }
|
|
|
+ });
|
|
|
+ }
|
|
|
+
|
|
|
+ presentToast(message:string,classstyle:string) {
|
|
|
+ let toast = this.toastCtrl.create({
|
|
|
+ message: message,
|
|
|
+ duration: 2000,
|
|
|
+ position: 'middle',
|
|
|
+ cssClass: classstyle
|
|
|
+ });
|
|
|
+
|
|
|
+ toast.onDidDismiss(() => {
|
|
|
+ //console.log('Dismissed toast');
|
|
|
+ });
|
|
|
+
|
|
|
+ toast.present();
|
|
|
+ }
|
|
|
+}
|