fengxiang
2018-02-24 9d731840aff22ce68756fb70f50dcf90432bbe67
src/app/routes/passport/login/login.component.ts
@@ -7,11 +7,12 @@
import { NzMessageService } from 'ng-zorro-antd';
import { SocialService, SocialOpenType, ITokenService, DA_SERVICE_TOKEN } from '@delon/auth';
import { environment } from '@env/environment';
import { CookieService } from 'angular2-cookie/services/cookies.service';
@Component({
    selector: 'passport-login',
    templateUrl: './login.component.html',
    styleUrls: [ './login.component.less' ],
    providers: [ SocialService]
    providers: [ SocialService,CookieService]
})
export class UserLoginComponent implements OnDestroy {
@@ -27,6 +28,7 @@
        private settingsService: SettingsService,
        private socialService: SocialService,
        private loginService:LoginService,
        private _cookieService:CookieService,
        @Inject(DA_SERVICE_TOKEN) private tokenService: ITokenService) {
        this.form = fb.group({
            userName: [null, [Validators.required, Validators.minLength(5)]],
@@ -35,6 +37,9 @@
            captcha: [null, [Validators.required]],
            remember: [true]
        });
        let nowTime = new Date();
        nowTime.setDate(nowTime.getDate()+1);
        this._cookieService.put('test','test',{expires:nowTime});
    }
    // region: fields
@@ -86,12 +91,12 @@
                           name: this.userName.value,
                           time: +new Date
                       });
                       this.validateError = true;
                       this.validateError = {};
                       this.router.navigate(['/']);
                   }
                },
                (err) => {
                    console.log(err);
                    // console.log(err);
                    if(err instanceof ProgressEvent){
                        const error = <ProgressEvent>err;
                        let xmlHttp = error.target;
@@ -100,8 +105,11 @@
                            console.log(xmlHttpRequest.response);                           
                            const response = JSON.parse(xmlHttpRequest.response);                                                  
                            if(response.status == 401&&response.errorCode==10){                                
                                 this.validateError = true;
                                 this.validateError["password_incorrect"]=true;
                                 this.loading = false;
                            } else if(response.status == 401&&response.errorCode==12) {
                                this.validateError["account_expired"]=true;
                                this.loading = false;
                            }
                        }
                    }
@@ -109,7 +117,7 @@
           );
    }
    public validateError:boolean;
    public validateError:{[s:string]:boolean} = {};
    // region: social
    open(type: string, openType: SocialOpenType = 'href') {