|
@@ -1,41 +0,0 @@
|
|
|
-import { Component, OnInit } from '@angular/core';
|
|
|
-import { Parse } from 'parse';
|
|
|
-
|
|
|
-@Component({
|
|
|
- selector: 'app-login',
|
|
|
- templateUrl: './login.page.html',
|
|
|
- styleUrls: ['./login.page.scss'],
|
|
|
-})
|
|
|
-export class LoginPage implements OnInit {
|
|
|
- registerUsername: string = '';
|
|
|
- registerPassword: string = '';
|
|
|
- loginUsername: string = '';
|
|
|
- loginPassword: string = '';
|
|
|
-
|
|
|
- constructor() {private navCtrl: NavController }
|
|
|
-
|
|
|
- register() {
|
|
|
- Parse.User.signUp(this.registerUsername, this.registerPassword).then((user) => {
|
|
|
- console.log('User signed up', user);
|
|
|
- // 注册成功后可以自动登录
|
|
|
- this.login();
|
|
|
- }).catch((error) => {
|
|
|
- console.error('Error signing up', error);
|
|
|
- });
|
|
|
- }
|
|
|
-
|
|
|
- login() {
|
|
|
- Parse.User.logIn(this.loginUsername, this.loginPassword).then((user) => {
|
|
|
- console.log('User logged in', user);
|
|
|
- // 登录成功后导航到“我的”页面
|
|
|
- this.navCtrl.navigateForward('/tabs/tab4');
|
|
|
- }).catch((error) => {
|
|
|
- console.error('Error logging in', error);
|
|
|
- });
|
|
|
- }
|
|
|
-}
|
|
|
-
|
|
|
- ngOnInit() {
|
|
|
- }
|
|
|
-
|
|
|
-}
|