12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152 |
- import { Component } from '@angular/core';
- import { Router } from '@angular/router';
- import * as Parse from "parse";
- @Component({
- selector: 'app-page-add',
- templateUrl: './page-add.component.html',
- styleUrls: ['./page-add.component.scss']
- })
- export class PageAddComponent {
- userAdd: any = {
- name: '',
- tag: '',
- desc: ''
- };
- selectedImage: string | ArrayBuffer | null = null;
- constructor(
- private router: Router
- ) {}
- async saveAdd() {
- const Contact = Parse.Object.extend('Contact');
- const newContact = new Contact();
- newContact.set('name', this.userAdd.name);
- newContact.set('tag', this.userAdd.tag);
- newContact.set('desc', this.userAdd.desc);
- newContact.set('img', this.userAdd.img);
- // 设置其他联系人信息...
- try {
- await newContact.save();
- console.log('New contact saved successfully');
- this.router.navigate(['/lesson/me/userFollow']); // 导航到联系人列表页面
- } catch (error) {
- console.error('Error while saving new contact', error);
- }
- }
- onFileSelected(event: Event) {
- const inputElement = event.target as HTMLInputElement;
- if (inputElement.files && inputElement.files[0]) {
- const file = inputElement.files[0];
- const reader = new FileReader();
- reader.onload = () => {
- this.selectedImage = reader.result;
- };
- reader.readAsDataURL(file);
- }
- }
- }
|