沈斌
2018-07-10 fec630978ad9b1ce5caff7dbc74e7d10d43a0970
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
import { NzMessageService } from 'ng-zorro-antd';
import { Component, OnInit } from '@angular/core';
import { FormBuilder, FormGroup, Validators } from '@angular/forms';
 
@Component({
  selector: 'app-extras-settings',
  templateUrl: './settings.component.html',
})
export class ExtrasSettingsComponent implements OnInit {
  active = 1;
  profileForm: FormGroup;
  pwd = {
    old_password: '',
    new_password: '',
    confirm_new_password: '',
  };
  // Email
  primary_email = 'cipchk@qq.com';
 
  constructor(fb: FormBuilder, public msg: NzMessageService) {
    this.profileForm = fb.group({
      name: [
        null,
        Validators.compose([
          Validators.required,
          Validators.pattern(`^[-_a-zA-Z0-9]{4,20}$`),
        ]),
      ],
      email: '',
      bio: [null, Validators.maxLength(160)],
      url: '',
      company: '',
      location: '',
    });
  }
 
  get name() {
    return this.profileForm.get('name');
  }
 
  profileSave(event, value) {
    console.log('profile value', value);
  }
 
  pwdSave() {
    if (!this.pwd.old_password) {
      return this.msg.error('invalid old password');
    }
    if (!this.pwd.new_password) {
      return this.msg.error('invalid new password');
    }
    if (!this.pwd.confirm_new_password) {
      return this.msg.error('invalid confirm new password');
    }
    console.log('pwd value', this.pwd);
  }
 
  ngOnInit() {
    this.profileForm.patchValue({
      name: 'cipchk',
      email: 'cipchk@qq.com',
    });
  }
}