warrior 4 luni în urmă
părinte
comite
09ff1a47d6

+ 1 - 1
projects/live-app/src/app/components/upload/upload.component.ts

@@ -84,7 +84,7 @@ export class UploadComponent implements OnInit {
       this.showBlockNum = n;
     }
     this.fileList = this.files.map((item: any) => {
-      // console.log(item);
+      console.log(item);
       return {
         url: item?.url,
         name: item?.name,

+ 25 - 8
projects/live-app/src/moduls/live/room-manage/room-manage.component.html

@@ -5,23 +5,40 @@
       <div class="title">直播ID</div>
       <ion-input
         placeholder="创建房间后自动生成"
-        value="{{ formData.name }}"
+        [value]="room?.get('roomid')"
         disabled
       ></ion-input>
     </div>
     <div class="row">
-      <div class="title">标题</div>
-      <ion-input placeholder="待认证" value="{{ formData.name }}"></ion-input>
+      <div class="title">标题<span style="color: red">*</span></div>
+      <ion-input
+        placeholder="请填写标题"
+        maxlength="20"
+        [value]="formData.title"
+      ></ion-input>
     </div>
     <div class="row">
-      <div class="title">直播封面</div>
-      <ion-input placeholder="待认证" value="{{ formData.name }}"></ion-input>
+      <div class="title">直播封面<span style="color: red">*</span></div>
+      @if (!initLoad) {
+      <app-upload
+        (onChange)="saveEdit($event)"
+        #upload
+        [maxlenght]="1"
+        [files]="formData.cover ? [{ url: formData.cover }] : []"
+        [fileWidth]="100"
+        [fileHeight]="160"
+        [boxWidth]="100"
+      ></app-upload>
+      }
     </div>
     <div class="row">
       <div class="title">简介</div>
-      <ion-input placeholder="待认证" value="{{ formData.name }}"></ion-input>
+      <!-- <ion-input placeholder="待认证" value="{{ formData.name }}"></ion-input> -->
+      <ion-textarea
+        placeholder="请填写简介"
+        [value]="formData.content"
+      ></ion-textarea>
     </div>
   </div>
-
+  <button class="submit" (click)="upload.onUpload()">保存修改</button>
 </ion-content>
-<button class="submit" (click)="upload.onUpload()">保存修改</button>

+ 12 - 0
projects/live-app/src/moduls/live/room-manage/room-manage.component.scss

@@ -18,6 +18,17 @@
 			margin-bottom: 4px;
 			.title{
 				color: black;
+				margin-bottom: 4px;
+			}
+			ion-input {
+				background-color: #f3f3f3;
+				--padding-end:4px;
+				--padding-start:4px;
+			}
+			ion-textarea{
+				background-color: #f3f3f3;
+				--padding-end:4px;
+				--padding-start:4px;
 			}
 		}
 	}
@@ -32,4 +43,5 @@
 	margin: 0 10%;
 	background-color: #fe4d54;
 	border-radius: 10px;
+	z-index: 1;
 }

+ 103 - 9
projects/live-app/src/moduls/live/room-manage/room-manage.component.ts

@@ -1,31 +1,125 @@
 import { Component, OnInit, ViewChild } from '@angular/core';
-import { IonicModule, LoadingController, ToastController } from '@ionic/angular';
+import {
+  AlertController,
+  IonicModule,
+  LoadingController,
+  ToastController,
+} from '@ionic/angular';
 import { NavComponent } from '../../../app/components/nav/nav.component';
 import { LiveService } from '../../../services/live.service';
 import { UploadComponent } from '../../../app/components/upload/upload.component';
 import * as Parse from 'parse';
+import { AuthService } from '../../../services/auth.service';
 
 @Component({
   selector: 'app-room-manage',
   templateUrl: './room-manage.component.html',
   styleUrls: ['./room-manage.component.scss'],
   standalone: true,
-  imports: [IonicModule, NavComponent,UploadComponent],
+  imports: [IonicModule, NavComponent, UploadComponent],
 })
 export class RoomManageComponent implements OnInit {
   @ViewChild('upload') upload!: UploadComponent;
-  formData:any = {
+  room?:Parse.Object
+  formData: any = {
     title: '',
-    cover: '',
+    cover: null,
+    content: null,
   };
-
+  loading: any;
+  pid: string = localStorage.getItem('profile') ?? '';
+  initLoad:boolean = true;
   constructor(
     public toastController: ToastController,
     private loadingCtrl: LoadingController,
-    private liveService: LiveService
-  ) { }
+    private liveService: LiveService,
+    private alertController: AlertController,
+    private authServ: AuthService,
+  ) {}
 
-  ngOnInit() {
+  async ngOnInit() {
+    await this.getProfile();
+    this.getRoom()
+  }
+  // 获取用户信息
+  async getProfile() {
+    if (this.pid) return;
+    let user = Parse.User.current();
+    let query = new Parse.Query('Profile');
+    query.equalTo('user', user?.id);
+    query.notEqualTo('isDeleted', true);
+    query.select('isCheck', 'isCross');
+    let r = await query.first();
+    if (r?.id) this.pid = r?.id;
+  }
+  /* 直播间 */
+  async getRoom() {
+    let query = new Parse.Query('Room');
+    query.equalTo('user', Parse.User.current()?.id);
+    query.equalTo('profile', this.pid);
+    query.notEqualTo('isDeleted', true);
+    this.room = await query.first();
+    this.formData = {
+      title: this.room?.get('title'),
+      cover: this.room?.get('cover'),
+      content: this.room?.get('content'),
+    };
+    console.log(this.formData);
+    this.initLoad = false
+  }
+  async saveEdit(e: any) {
+    let url = e[0]?.url
+    console.log(url);
+    if(!url || !this.formData.title){
+      const toast = await this.toastController.create({
+        message: '请填写完整',
+        color: 'warning',
+        duration: 1000,
+      });
+      toast.present()
+      return
+    }
+    this.loading = await this.loadingCtrl.create({
+      message: '正在保存修改',
+    });
+    this.loading.present();
+    if (!this.room?.id) {
+      let obj = Parse.Object.extend('Room');
+      this.room = new obj();
+      this.room?.set('user', Parse.User.current()?.toPointer());
+      this.room?.set('company', {
+        __type: 'Pointer',
+        className: 'Company',
+        objectId: this.authServ.company,
+      });
+      this.room?.set('profile', {
+        __type: 'Pointer',
+        className: 'Profile',
+        objectId: this.pid,
+      });
+    }
+    this.room?.set('roomid', this.pid);
+    this.room?.set('title', this.formData.title);
+    this.room?.set('cover', url);
+    this.room?.set('content', this.formData.content);
+    await this.room?.save();
+    this.room && this.liveService.getToken(this.room)
+    this.loading.dismiss();
+    this.getRoom();
+    this.presentAlert('修改成功');
+  }
+  async presentAlert(msg: string) {
+    const alert = await this.alertController.create({
+      header: '提示',
+      message: msg,
+      buttons: [
+        {
+          text: '好的',
+          role: 'confirm',
+          handler: () => {},
+        },
+      ],
+    });
+    await alert.present();
   }
-
 }

+ 1 - 1
projects/live-app/src/moduls/login/login.component.ts

@@ -507,7 +507,7 @@ export class LoginComponent implements OnInit {
           password: this.registerInfo.password,
         };
     this.http
-      .post(`https://server.fmode.cn/api/register`, data)
+      .post(`https://server.fmode.cn/api/auth/register`, data)
       .pipe(
         catchError(async (e) => {
           // 显示报错

+ 4 - 4
projects/live-app/src/moduls/user/profile/profile.component.html

@@ -27,7 +27,7 @@
               <ion-icon name="male-female-outline"></ion-icon>
             </div>
             }@else {
-            <div class="sex">未知</div>
+            <!-- <div class="sex">未知</div> -->
             }
             <div class="age">
               <img
@@ -134,7 +134,7 @@
 <ion-footer class="footer">
   <ion-toolbar class="footer-tool">
     <div class="btns">
-      @if (user?.id == uid) {
+      @if (user?.id == currentUser?.id) {
       <div class="round" (click)="onEdit()">
         <ion-icon name="create-outline"></ion-icon>编辑资料
       </div>
@@ -143,11 +143,11 @@
         <ion-icon name="gift-outline"></ion-icon>
       </div>
       @if(profile?.get('idcard')){
-      <div class="round">
+      <div class="round" (click)="toLiveContact()">
         <ion-icon name="videocam-outline"></ion-icon>直播通话
       </div>
       }
-      <div class="round">
+      <div class="round" (click)="toMsg()">
         <ion-icon name="chatbubble-outline"></ion-icon>私信
       </div>
       }

+ 1 - 0
projects/live-app/src/moduls/user/profile/profile.component.scss

@@ -62,6 +62,7 @@
                 rgba(0, 0, 0, 0.05) 0px 5px 10px;
               background: linear-gradient(to right, #156bfd, #91baff);
               margin: 0 6px;
+              font-size: 12px;
             }
             .girl {
               background: linear-gradient(to right, #fe454e, #f5a7ab);

+ 24 - 9
projects/live-app/src/moduls/user/profile/profile.component.ts

@@ -46,6 +46,8 @@ export class ProfileComponent implements OnInit {
   isFollow: boolean = false;
   giftList: Array<Parse.Object> = []; //礼物
   isOpen: boolean = false; //打开弹窗
+  room?:Parse.Object;
+
   constructor(
     private activateRoute: ActivatedRoute,
     private router: Router,
@@ -59,7 +61,8 @@ export class ProfileComponent implements OnInit {
     this.activateRoute.paramMap.subscribe(async (params) => {
       let id: any = params.get('id');
       this.uid = id;
-      this.refresh();
+      await this.refresh();
+      this.getRoom()
     });
   }
   async refresh() {
@@ -73,15 +76,21 @@ export class ProfileComponent implements OnInit {
     this.numsObject.fans = res.data[0].fans;
     this.numsObject.follow = res.data[0].follow;
     let res1 = await this.aiChatServ.getGift(this.uid);
-    this.numsObject.gift = res.data[0].gift ?? 0;
+    this.numsObject.gift = res1.data[0].gift ?? 0;
     await this.getLoveRender();
     loading.dismiss();
   }
+  async getRoom() {
+    let query = new Parse.Query('Room');
+    query.equalTo('company', this.aiChatServ.company);
+    query.equalTo('profile', this.profile?.id);
+    // query.equalTo('state', true);
+    query.notEqualTo('isDeleted', true);
+    // query.select('objectId')
+    let r = await query.first();
+    this.room = r;
+  }
   async getProfile() {
-    const loading = await this.loadingCtrl.create({
-      message: '加载中',
-    });
-    loading.present();
     let queryProfile = new Parse.Query('Profile');
     queryProfile.equalTo('user', this.uid);
     queryProfile.notEqualTo('isDeleted', true);
@@ -96,13 +105,12 @@ export class ProfileComponent implements OnInit {
       this.user = await queryUser.first();
     }
     console.log(this.user, this.profile);
-    loading.dismiss();
   }
   /* 关注状态 */
   async getFollwState() {
     let query = new Parse.Query('ProfileRadar');
-    query.equalTo('toUser', this.currentUser?.id);
-    query.equalTo('fromUser', this.uid);
+    query.equalTo('fromUser', this.currentUser?.id);
+    query.equalTo('toUser', this.uid);
     query.notEqualTo('isDeleted', true);
     query.equalTo('name', '关注');
     let r = await query.first();
@@ -143,6 +151,7 @@ export class ProfileComponent implements OnInit {
     profileRadar?.set('isDeleted', this.isFollow);
     await profileRadar?.save();
     this.isFollow = !this.isFollow;
+    this.isFollow ? this.numsObject.fans+=1 : this.numsObject.fans-=1;
   }
   onShowImg(url: string) {
     this.currenImg = url;
@@ -193,4 +202,10 @@ export class ProfileComponent implements OnInit {
       },
     });
   }
+  toMsg(){
+    this.router.navigate(['live/chat/'+this.uid]);
+  }
+  toLiveContact(){
+    this.router.navigate(['live/link-room/'+this.room?.id]);
+  }
 }

+ 2 - 2
projects/live-app/src/services/aichart.service.ts

@@ -14,8 +14,8 @@ export class AiChatService {
   ) {}
   getFansAndFollow(uid: string): Promise<any> {
     let sql = `SELECT 
-    (SELECT COUNT(*) FROM "ProfileRadar" WHERE "fromUser" = '${uid}' AND "name" = '关注') AS follow,
-    (SELECT COUNT(*) FROM "ProfileRadar" WHERE "toUser" = '${uid}' AND "name" = '关注') AS fans;`;
+    (SELECT COUNT(*) FROM "ProfileRadar" WHERE "fromUser" = '${uid}' AND "name" = '关注' AND "isDeleted" IS NOT TRUE) AS follow,
+    (SELECT COUNT(*) FROM "ProfileRadar" WHERE "toUser" = '${uid}' AND "name" = '关注' AND "isDeleted" IS NOT TRUE) AS fans;`;
     return this.http.customSQL(sql);
   }
   getGift(uid: string): Promise<any> {

+ 1 - 0
projects/live-app/src/services/live.service.ts

@@ -116,6 +116,7 @@ export class LiveService {
   }
   // 进入频道
   async join() {
+    console.log('频道:',this.options.channel);
     let data = await Promise.all([
       this.client.join(this.options.appid, this.options.channel, this.options.token, this.UID),
       /* 创建音频和视频轨道 */