John Doe 4 tháng trước cách đây
mục cha
commit
39fddf8ac5

+ 4 - 4
server/REST.js

@@ -1,6 +1,6 @@
 
 //get请求 获取全部
-fetch("http://web2023.fmode.cn:9999/parse/classes/WyContact?", {
+fetch("https://web2023.fmode.cn/parse/classes/WyContact?", {
     "headers": {
       "accept": "*/*",
       "accept-language": "zh-CN,zh;q=0.9,en;q=0.8,en-GB;q=0.7,en-US;q=0.6,zh-TW;q=0.5",
@@ -16,7 +16,7 @@ fetch("http://web2023.fmode.cn:9999/parse/classes/WyContact?", {
   });
 
   //post 创建
-  fetch("http://web2023.fmode.cn:9999/parse/classes/WyContact", {
+  fetch("https://web2023.fmode.cn/parse/classes/WyContact", {
     "headers": {
       "accept": "*/*",
       "accept-language": "zh-CN,zh;q=0.9,en;q=0.8,en-GB;q=0.7,en-US;q=0.6,zh-TW;q=0.5",
@@ -32,7 +32,7 @@ fetch("http://web2023.fmode.cn:9999/parse/classes/WyContact?", {
   });
 
   //put 修改
-  fetch("http://web2023.fmode.cn:9999/parse/classes/WyContact/68q4JeSDGh", {
+  fetch("https://web2023.fmode.cn/parse/classes/WyContact/68q4JeSDGh", {
     "headers": {
       "accept": "*/*",
       "accept-language": "zh-CN,zh;q=0.9,en;q=0.8,en-GB;q=0.7,en-US;q=0.6,zh-TW;q=0.5",
@@ -48,7 +48,7 @@ fetch("http://web2023.fmode.cn:9999/parse/classes/WyContact?", {
   });
 
   //delete 
-  fetch("http://web2023.fmode.cn:9999/parse/classes/WyContact/68q4JeSDGh", {
+  fetch("https://web2023.fmode.cn/parse/classes/WyContact/68q4JeSDGh", {
     "headers": {
       "accept": "*/*",
       "accept-language": "zh-CN,zh;q=0.9,en;q=0.8,en-GB;q=0.7,en-US;q=0.6,zh-TW;q=0.5",

+ 1 - 1
server/fmode-parse copy.js

@@ -1,7 +1,7 @@
 class ParseObject{
     className
     id
-    serverURL = "http://web2023.fmode.cn:9999/parse"
+    serverURL = "https://web2023.fmode.cn/parse"
     data = {}
     toJSON(){
         return this.data

+ 1 - 1
server/fmode-parse.js

@@ -1,7 +1,7 @@
 class ParseObject{
     className
     id
-    serverURL = "http://web2023.fmode.cn:9999/parse"
+    serverURL = "https://web2023.fmode.cn/parse"
     data = {}
     toJSON(){
         return this.data

+ 5 - 5
server/rest copy.js

@@ -1,7 +1,7 @@
 
 //Items GET 获取全部内容
 async function getPet(){
-  let response = await fetch("http://web2023.fmode.cn:9999/parse/classes/Items?", {
+  let response = await fetch("https://web2023.fmode.cn/parse/classes/Items?", {
     "headers": {
       "accept": "*/*",
       "accept-language": "zh-CN,zh;q=0.9",
@@ -39,7 +39,7 @@ main()
 
 // 通过函数封装,实现多个表的查询
 async function ClassesGet(className){
-  let response = await fetch("http://web2023.fmode.cn:9999/parse/classes/"+className, {
+  let response = await fetch("https://web2023.fmode.cn/parse/classes/"+className, {
     "headers": {
       "accept": "*/*",
       "accept-language": "zh-CN,zh;q=0.9",
@@ -65,7 +65,7 @@ async function ClassesGet(className){
 }
 
 // //Items Post 创建数据
-// fetch("http://web2023.fmode.cn:9999/parse/classes/Items", {
+// fetch("https://web2023.fmode.cn/parse/classes/Items", {
 //   "headers": {
 //     "accept": "*/*",
 //     "accept-language": "zh-CN,zh;q=0.9,en;q=0.8,en-GB;q=0.7,en-US;q=0.6",
@@ -81,7 +81,7 @@ async function ClassesGet(className){
 // });
 
 // //Items Put 添加数据
-// fetch("http://web2023.fmode.cn:9999/parse/classes/Items/l3XZKsAIPO", {
+// fetch("https://web2023.fmode.cn/parse/classes/Items/l3XZKsAIPO", {
 //   "headers": {
 //     "accept": "*/*",
 //     "accept-language": "zh-CN,zh;q=0.9,en;q=0.8,en-GB;q=0.7,en-US;q=0.6",
@@ -97,7 +97,7 @@ async function ClassesGet(className){
 // });
 
 // //Items Detele 删除数据
-// fetch("http://web2023.fmode.cn:9999/parse/classes/Items/l3XZKsAIPO", {
+// fetch("https://web2023.fmode.cn/parse/classes/Items/l3XZKsAIPO", {
 //   "headers": {
 //     "accept": "*/*",
 //     "accept-language": "zh-CN,zh;q=0.9,en;q=0.8,en-GB;q=0.7,en-US;q=0.6",

+ 18 - 1
src/app/app-routing.module.ts

@@ -10,6 +10,10 @@ const routes: Routes = [
     path: 'tab4',
     loadChildren: () => import('./tab4/tab4.module').then( m => m.Tab4PageModule)
   },
+  {
+    path:'tab2',
+    loadChildren: () => import('./tab2/tab2.module').then( m => m.Tab2PageModule)
+  },
   {
         path: 'tab3',
         loadChildren: () => import('./tab3/tab3.module').then(m => m.Tab3PageModule)
@@ -49,7 +53,20 @@ const routes: Routes = [
   {
     path: 'edit-info',
     loadChildren: () => import('./tab3/edit-info/edit-info.module').then( m => m.EditInfoPageModule)
-  }
+  },
+  {
+    path: 'contact',
+    children:[
+      {
+        path: 'chat',
+        loadChildren: () => import('./contact/chat/chat.module').then(m => m.ChatPageModule)
+      },
+      {
+        path: 'chat/:userid',
+        loadChildren: () => import('./contact/chat/chat.module').then(m => m.ChatPageModule)
+      },
+    ]
+  },
 ];
 @NgModule({
   imports: [

+ 2 - 2
src/app/app.component.ts

@@ -1,8 +1,8 @@
 import { Component } from '@angular/core';
 import * as Parse from "parse";
 Parse.initialize("dev");
-(Parse as any).serverURL = 'http://web2023.fmode.cn:9999/parse';
-(Parse as any).liveQueryServerURL = 'http://web2023.fmode.cn:9999/parse';
+(Parse as any).serverURL = 'https://web2023.fmode.cn/parse';
+(Parse as any).liveQueryServerURL = 'https://web2023.fmode.cn/parse';
 
 @Component({
   selector: 'app-root',

+ 3 - 3
src/app/contact/chat/chat.page.html

@@ -1,7 +1,7 @@
 <ion-header>
   <ion-toolbar color="primary">
     <ion-buttons slot="start">
-      <ion-back-button defaultHref="/tabs/session"></ion-back-button>
+      <ion-back-button defaultHref="/session"></ion-back-button>
     </ion-buttons>
     <ion-title>{{ contact?.get('name') || contact?.get('to')?.get("nickname") ||contact?.get('to')?.get('username') }}</ion-title>
   </ion-toolbar>
@@ -23,10 +23,10 @@
         </div>
       </ion-label>
       <ion-avatar slot="end" *ngIf="message?.get('sendUser')?.id === user?.id" class="message-avatar sent-avatar">
-        <img [src]="'/assets/img/clock.png'">
+        <!-- <img [src]="'/assets/img/clock.png'"> -->
       </ion-avatar>
       <ion-avatar slot="start" *ngIf="message?.get('receiveUser')?.id === targetId" class="message-avatar received-avatar">
-        <img [src]="'/assets/img/clock.png'">
+        <img style="margin-top: 18px;" [src]="'/assets/img/clock.png'">
       </ion-avatar>
     </ion-item>
   </ion-list>

+ 2 - 0
src/app/contact/chat/chat.page.scss

@@ -52,6 +52,8 @@ ion-avatar[_ngcontent-ng-c914708361]{
 .list-md{
   width: 123%;
 }
+
+
 .received-message-container[_ngcontent-ng-c914708361]{
   max-width: 100%;
 }

+ 2 - 4
src/app/contact/chat/chat.page.ts

@@ -14,10 +14,8 @@ import Parse from "parse";
 export class ChatPage implements OnInit{
   userid: string;
   messageList:any = []
-  messages = [
-    { type: 'received', avatar: '/assets/img/female.png', time: '10:30 AM', text: 'Hi there!' },
-    { type: 'sent', avatar: '/assets/img/female.png', time: '10:31 AM', text: 'Hey! How are you?' },
-    // Add more messages as needed
+  messages:any = [
+    
   ];
   
   newMessage: string = '';

+ 2 - 2
src/app/contact/session/session.page.html

@@ -11,7 +11,7 @@
   <ion-list lines="full">
     <ion-item *ngFor="let session of sessionList" (click)="goSession(session)">
       <ion-avatar slot="start">
-        <img [src]="'/assets/img/clock.png'">
+        <img [src]="targetUser(session)?.get('avatarUrl')">
       </ion-avatar>
       <ion-label>
         <h2>{{targetUser(session) | userName}}</h2>
@@ -34,4 +34,4 @@
       </ion-label>
     </ion-item>
   </ion-list>
-</ion-content>
+</ion-content>

+ 3 - 3
src/app/tab3/edit-info/edit-info.page.html

@@ -12,14 +12,14 @@
   </ion-header>
   <div >
     <ion-item>
-      <ion-label position="stacked">用户名</ion-label>
-      <ion-input [(ngModel)]="editedUser.name" type="text"></ion-input>
+      <ion-label position="stacked">昵称</ion-label>
+      <ion-input [(ngModel)]="editedUser.nickname" type="text"></ion-input>
     </ion-item>
     <ion-item (click)="fileInput.click()">
       <ion-label position="stacked">上传新头像</ion-label>
       <input type="file" #fileInput style="display: none;" (change)="onFileSelected($event)">
       <ion-avatar class="avatar-right" style="cursor: pointer;">
-        <!-- <img [src]="editedUser.avatarUrl || user.avatarUrl" alt="Avatar"> -->
+        <img [src]="editedUser.avatarUrl || editedUser.avatarUrl" alt="Avatar">
       </ion-avatar>
     </ion-item>
     <ion-item>

+ 12 - 13
src/app/tab3/edit-info/edit-info.page.ts

@@ -7,14 +7,14 @@ import Parse from "parse";
   styleUrls: ['./edit-info.page.scss'],
 })
 export class EditInfoPage implements OnInit {
-  userInfo:any = {
-    name: '',
-    avatarUrl: 'assets/美津未.jpg',
-    campus: '',
-    building: '',
-    gender: ''
-  };
-  editedUser = { ...this.userInfo }; // Clone of user for editing
+
+  editedUser:any = {
+    nickname:"",
+    building:"",
+    campus:"",
+    gender:"",
+    avatarUrl:""
+  }; // Clone of user for editing
   editing = false;
   currentUser:Parse.User|undefined
   // navController: any;
@@ -25,13 +25,12 @@ export class EditInfoPage implements OnInit {
     if (this.currentUser) {
       // 修改uesrInfo赋值逻辑,仅加载被编辑的字段属性值
       let json = this.currentUser.toJSON();
-      for (const key in json) {
-        if (this.userInfo.hasOwnProperty(key)) {
-          this.userInfo[key] = json[key]
-        }
+      console.log(json)
+      for (const key in this.editedUser) {
+          this.editedUser[key] = json[key]
       }
+      console.log(this.editedUser)
     }
-    console.log(this.userInfo)
   }
   onFileSelected(event: any) {
     const file: File = event.target.files[0];

+ 1 - 1
src/app/tab3/login/login.page.html

@@ -24,7 +24,7 @@
      
     </ion-card-content>
   
-    <ion-button (click)="login()" fill="clear">登录</ion-button>
+    <ion-button (click)="login()"  fill="clear">登录</ion-button>
     <ion-button (click)="register()" fill="clear">注册</ion-button>
   </ion-card>
 

+ 4 - 2
src/app/tab3/login/login.page.ts

@@ -29,9 +29,9 @@ export class LoginPage implements OnInit {
     let user
     try {
       user = await Parse.User.logIn(this.username,this.password)
-      // this.isLoggedin = true;
+      
       if (user?.id) {
-        this.navCtrl.navigateForward(['/tabs/tab3', { isLoggedIn: true }]);
+        this.navCtrl.navigateForward(['/tabs/tab3']);
       }
     } catch (error:any) {
       let message:string = ""
@@ -52,7 +52,9 @@ export class LoginPage implements OnInit {
     if(user?.id){
       this.navCtrl.back()
     }
+    // this.refreshPage();
   }
+  
   async register(){
     let user = new Parse.User()
     user.set("username",this.username)

+ 2 - 1
src/app/tab3/tab3.page.html

@@ -23,7 +23,8 @@
         </label>
       </div>
       <div class="profile-details">
-        <div class="username">{{user.name}}</div>
+        
+        <div class="username">{{user.nickname}}</div>
         <div class="campus-building">
           <div class="campus">{{ user.campus }}</div>
           <div class="building">{{ user.building }}</div>

+ 30 - 11
src/app/tab3/tab3.page.ts

@@ -1,6 +1,7 @@
 import { Component } from '@angular/core';
 import { Router } from '@angular/router';
 import { AlertController } from '@ionic/angular';
+import { ChangeDetectorRef } from '@angular/core';
 // import { AuthService } from './AuthService';
 import Parse from "parse"
 
@@ -13,7 +14,7 @@ export class Tab3Page {
   isLoggedIn: boolean = false; 
   // isLoggedIn: boolean = false;
   user = {
-    name: 'John Doe',
+    nickname: 'John Doe',
     avatarUrl: 'assets/美津未.jpg',
     campus: 'Main Campus',
     building: 'A',
@@ -25,30 +26,37 @@ export class Tab3Page {
 
   constructor(
     private router: Router,
-    private alertController: AlertController
+    private alertController: AlertController,private cdr: ChangeDetectorRef
   ) {
     const navigation = this.router.getCurrentNavigation();
     const state = navigation?.extras.state;
     if (state && state['isLoggedIn']) {
       this.isLoggedIn = true;
-    }
+    };
+    
   }
   
-
+  refreshView() {
+    // 执行变化检测并刷新视图
+    this.cdr.detectChanges();
+  };
   currentUser:Parse.User|undefined
 
   async ngOnInit() {
     this.currentUser = await Parse.User.current();
+    setInterval(()=>{
+      this.refreshPage()
+    },1000)
     if (this.currentUser) {
       // 如果有当前用户信息,则更新user对象
-      this.user.name = this.currentUser.get("name");
+      this.user.nickname = this.currentUser.get("nickname");
       this.user.gender=this.currentUser.get("gender");
       // 根据你的数据库字段来更新其他用户信息
-      // this.user.avatarUrl = this.currentUser.get("avatarUrl");
+      this.user.avatarUrl = this.currentUser.get("avatarUrl");
       this.user.campus = this.currentUser.get("campus");
       this.user.building = this.currentUser.get("building");
       // this.user.gender = this.username.get("gender");
-      console.log(this.user.name);
+      console.log(this.user.nickname);
       //detectChanges();
     }
   }
@@ -58,7 +66,17 @@ export class Tab3Page {
   //   this.username = await Parse.User.current()
   // },1000)
 
-
+  async refreshPage() {
+    this.currentUser = await Parse.User.current();
+    if (this.currentUser) {
+      this.user.nickname = this.currentUser.get("nickname");
+      this.user.gender = this.currentUser.get("gender");
+      this.user.campus = this.currentUser.get("campus");
+      this.user.building = this.currentUser.get("building");
+      // detectChanges( );
+      // 可根据需要更新其他用户信息
+    }
+  }
   onFileSelected(event: any) {
     const file: File = event.target.files[0];
     const reader = new FileReader();
@@ -66,6 +84,7 @@ export class Tab3Page {
       this.editedUser.avatarUrl = reader.result as string;
     };
     reader.readAsDataURL(file);
+    this.refreshPage();
   }
 
   startEditing() {
@@ -93,11 +112,11 @@ export class Tab3Page {
   logout() {
     // Handle logout logic here
      Parse.User.logOut();
+     this.refreshPage();
+    //  detectChanges();
      console.log("退出登入!");
      
   }
 }
 
-function detectChanges() {
-  throw new Error('Function not implemented.');
-}
+

+ 1 - 1
src/app/tab4/tab4.page.ts

@@ -4,7 +4,7 @@ import { ItemsService } from './items.service';
 // 引用Parse JS SDK
 import Parse from "parse";
 Parse.initialize("dev"); // 设置applicationId
-Parse.serverURL = "http://web2023.fmode.cn:9999/parse"; // 设置serverURL
+Parse.serverURL = "https://web2023.fmode.cn/parse"; // 设置serverURL
 
 @Component({
   selector: 'app-tab4',

+ 5 - 1
src/app/tabs/tabs-routing.module.ts

@@ -9,7 +9,7 @@ const routes: Routes = [
     children: [
       {
         path: 'tab1',
-        loadChildren: () => import('../tab1/tab1.module').then(m => m.Tab1PageModule)
+        loadChildren: () => import('../contact/session/session.module').then(m => m.SessionPageModule)
       },
       {
         path: 'tab2',
@@ -23,6 +23,10 @@ const routes: Routes = [
         path: 'tab4',
         loadChildren: () => import('../tab4/tab4.module').then(m => m.Tab4PageModule)
       },
+      {
+        path: 'tab5',
+        loadChildren: () => import('../contact/contact-list/contact-list.module').then(m => m.ContactListPageModule)
+      },
       {
         path: '',
         redirectTo: '/tabs/tab1',

+ 16 - 14
src/app/tabs/tabs.page.html

@@ -1,30 +1,32 @@
 <ion-tabs>
 
   <ion-tab-bar slot="bottom">
-    <ion-tab-button tab="tab1" href="/tabs/tab1">
-      <ion-icon aria-hidden="true" name="triangle"></ion-icon>
-      <ion-label>Tab 1</ion-label>
+
+    <ion-tab-button tab="tab4" href="/tabs/tab4">
+      <ion-icon aria-hidden="true" name="square"></ion-icon>
+      <ion-label>首页</ion-label>
+    </ion-tab-button>
+
+    <ion-tab-button tab="tab1" href="../contact/chat">
+      <ion-icon aria-hidden="true" name="people"></ion-icon>
+      <ion-label>消息</ion-label>
     </ion-tab-button>
 
     <ion-tab-button tab="tab2" href="/tabs/tab2">
       <ion-icon aria-hidden="true" name="ellipse"></ion-icon>
-      <ion-label>Tab 2</ion-label>
+      <ion-label>发布</ion-label>
     </ion-tab-button>
 
-    <ion-tab-button tab="tab3" href="/tabs/tab3">
-      <ion-icon aria-hidden="true" name="square"></ion-icon>
-      <ion-label>Tab 3</ion-label>
+    <ion-tab-button tab="tab5" href="../contact/contact-list">
+      <ion-icon aria-hidden="true" name="person"></ion-icon>
+      <ion-label>联系人</ion-label>
     </ion-tab-button>
 
-    <ion-tab-button tab="tab4" href="/tabs/tab4">
-      <ion-icon aria-hidden="true" name="square"></ion-icon>
-      <ion-label>Tab 4</ion-label>
+    <ion-tab-button tab="tab3" href="/tabs/tab3">
+      <ion-icon aria-hidden="true" name="person"></ion-icon>
+      <ion-label>我的</ion-label>
     </ion-tab-button>
 
-    <!-- <ion-tab-button tab="test1" href="/src/app/test1">
-      <ion-icon aria-hidden="true" name="square"></ion-icon>
-      <ion-label>test 1</ion-label>
-    </ion-tab-button> -->
   </ion-tab-bar>
 
 </ion-tabs>

+ 1 - 1
src/app/wy-contact.service.ts

@@ -9,7 +9,7 @@ export class WyContactService {
 
   constructor() {
     const Parse = require("parse/node")
-Parse.serverURL = "http://web2023.fmode.cn:9999/parse" // 配置服务器地址
+Parse.serverURL = "https://web2023.fmode.cn/parse" // 配置服务器地址
 Parse.initialize("dev") // 配置应用名称
   }