瀏覽代碼

update 首页切换

warrior 4 月之前
父節點
當前提交
405ba71993

+ 7 - 7
projects/live-app/src/moduls/tabs/home/home.component.html

@@ -9,7 +9,7 @@
         mode="md"
       >
         @for (item of options; track $index) {
-        <ion-segment-button [value]="item?.value" class="tabs">
+        <ion-segment-button (click)="getRoom(item?.value)" [value]="item?.value" class="tabs">
           <ion-label>{{ item?.label }}</ion-label>
         </ion-segment-button>
         }
@@ -43,8 +43,8 @@
     @for (item of roomList; track $index) {
     <div
       class="list-row"
-      (click)="toUrl('user/profile/' + item.get('user').id)"
-      [style.background-image]="'url(' + item?.get('cover') + ')'"
+      (click)="toUrl('user/profile/' + item.uid)"
+      [style.background-image]="'url(' + item?.cover + ')'"
     >
       <div class="title-tag">在线聊天</div>
       <div class="live-tag">
@@ -55,11 +55,11 @@
       <div class="room-footer">
         <div class="user">
           {{
-            item?.get("user")?.get("nickname") ||
-              item?.get("user")?.get("mobile")
+            item?.nickname ||
+              item?.mobile
           }}
         </div>
-        <div class="desc">{{ item?.get("title") }}</div>
+        <div class="desc">{{ item?.title }}</div>
         <div class="city-block">
           <div class="row-li">
             <ion-icon name="location-outline"></ion-icon>
@@ -70,7 +70,7 @@
               src="https://file-cloud.fmode.cn/Qje9D4bqol/20241109/pctmvt110807052.png"
               alt=""
             />
-            22
+            {{item.birthdate}}
           </div>
         </div>
       </div>

+ 51 - 21
projects/live-app/src/moduls/tabs/home/home.component.ts

@@ -1,13 +1,10 @@
-import {
-  Component,
-  OnInit,
-  ViewChild,
-} from '@angular/core';
+import { Component, OnInit, ViewChild } from '@angular/core';
 import * as Parse from 'parse';
 import { IonicModule } from '@ionic/angular';
 import { Router } from '@angular/router';
 import { AuthService } from '../../../services/auth.service';
 import { Swiper } from 'swiper';
+import { AiChatService } from '../../../services/aichart.service';
 
 @Component({
   selector: 'app-home',
@@ -40,30 +37,34 @@ export class HomeComponent implements OnInit {
     },
     {
       label: '三星',
-      value: 'star3',
+      value: '三星',
       icon: 'videocam-outline',
       color: 'danger',
     },
     {
       label: '四星',
-      value: 'star4',
+      value: '四星',
       icon: 'videocam-outline',
       color: 'danger',
     },
     {
       label: '五星',
-      value: 'star5',
+      value: '五星',
       icon: 'people-outline',
     },
   ];
   currentValue: string = 'recommend';
-  oldCurrentValue:string = 'recommend';
+  oldCurrentValue: string = 'recommend';
   isOpen: boolean = false; //显示选择弹窗
   banner: Array<Parse.Object> = [];
-  roomList: Array<Parse.Object> = [];
+  roomList: Array<any> = [];
   pageSwiper: Swiper | undefined | any;
 
-  constructor(private router: Router, public authServ: AuthService) {}
+  constructor(
+    private router: Router,
+    public authServ: AuthService,
+    private aiServ: AiChatService
+  ) {}
 
   ngOnInit() {
     this.refresh();
@@ -101,13 +102,41 @@ export class HomeComponent implements OnInit {
       // console.log(event);
     });
   }
-  async getRoom() {
-    let query = new Parse.Query('Room');
-    query.equalTo('company', this.authServ.company);
-    query.equalTo('state', true);
-    query.notEqualTo('isDeleted', true);
-    let r = await query.find();
-    this.roomList = r;
+  async getRoom(type?: string) {
+    let data: Array<any> = [];
+    if (!type) type = this.currentValue;
+    console.log(type);
+    let uid = Parse.User.current()?.id;
+    switch (type) {
+      case 'follow':
+        data = await this.aiServ.getRooms({ uid: uid, follow: true });
+        break;
+      case 'recommend':
+        data = await this.aiServ.getRooms({ uid: uid, recommend: true });
+        break;
+      case 'news':
+        data = await this.aiServ.getRooms({ uid: uid });
+        break;
+      case '三星':
+        data = await this.aiServ.getRooms({ uid: uid, star: '三星' });
+        break;
+      case '四星':
+        data = await this.aiServ.getRooms({ uid: uid, star: '四星' });
+        break;
+      case '五星':
+        data = await this.aiServ.getRooms({ uid: uid, star: '五星' });
+        break;
+      default:
+        break;
+    }
+    this.roomList = data;
+    console.log(data);
+    // let query = new Parse.Query('Room');
+    // query.equalTo('company', this.authServ.company);
+    // query.equalTo('state', true);
+    // query.notEqualTo('isDeleted', true);
+    // let r = await query.find();
+    // this.roomList = r;
   }
   segmentChanged(e: any) {
     let { value } = e.detail;
@@ -123,18 +152,19 @@ export class HomeComponent implements OnInit {
   }
   cancel(type: string, value?: string) {
     console.log(type, value);
-    if(type == 'cancel'){
+    if (type == 'cancel') {
       this.currentValue = this.oldCurrentValue;
-    }else{
+    } else {
       this.oldCurrentValue = this.currentValue;
     }
     this.isOpen = false;
     this.modal.dismiss();
+    this.getRoom()
   }
   search() {
     this.router.navigate(['live/search']);
   }
-  toUrl(url: string){
+  toUrl(url: string) {
     this.router.navigate([url]);
   }
 }

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

@@ -39,7 +39,7 @@ export class AiChatService {
     WHERE "fromUser" ='${uid}'`;
     return this.http.customSQL(sql);
   }
-  async getGiftList(uid: string, limit?: number, skip?:number): Promise<any> {
+  async getGiftList(uid: string, limit?: number, skip?: number): Promise<any> {
     let where = '';
     if (limit) {
       where = `OFFSET ${skip ?? 0} LIMIT ${limit}`;
@@ -55,8 +55,8 @@ export class AiChatService {
     ORDER BY lr."createdAt" DESC
     ${where}
     `;
-    const data:any = await this.http.customSQL(sql);
-    return data.data
+    const data: any = await this.http.customSQL(sql);
+    return data.data;
   }
   getFriends(uid: string): Promise<any> {
     let sql = `SELECT u.avatar,u.nickname,u.name,u."objectId" AS uid FROM 
@@ -108,4 +108,46 @@ export class AiChatService {
     };
     return await this.http.httpRequst(baseurl, reqBody, 'POST');
   }
+
+  /** 获取房间列表
+   * @star 星级
+   * @sex 主播性别
+   * */
+  async getRooms(parse?: any): Promise<any> {
+    let { uid, star, sex, title, recommend, follow } = parse;
+    let whereSearch = title
+      ? `AND (prof.name LIKE '%${title}%' OR r."title" LIKE '%${title}%')`
+      : '';
+    let whereStar = star ? `AND prof."state" = '${star}'` : '';
+    let whereSex = sex ? `AND prof."sex" = '${sex}'` : `AND prof."sex" = '女'`;
+    let whereHot = recommend ? `AND r."isHot" = TRUE` : '';
+    let sql = `SELECT r."objectId" rid,r."title",r."isHot",r."cover",r."content",
+    prof."name",prof."idcard",prof."state",prof.sex,prof.birthdate,
+    us."mobile",us."objectId" AS uid,us.nickname,
+    (
+      SELECT prordar."objectId" FROM "ProfileRadar" AS prordar
+      WHERE prordar."toUser" = us."objectId"
+      AND prordar.name = '关注'
+      AND prordar."isDeleted" IS NOT TRUE
+      AND prordar."fromUser" = '${uid}'
+      LIMIT 1
+    ) AS follow
+    FROM "Room" AS r
+    LEFT JOIN "Profile" AS prof
+    ON prof."objectId" = r."profile"
+    LEFT JOIN "_User" AS us
+    ON us."objectId" = r."user"
+    WHERE r."company" = '${this.company}'
+    AND r."isDeleted" IS NOT TRUE
+    ${whereStar}
+    ${whereSex}
+    ${whereSearch}
+    ${whereHot}
+    `;
+    if(follow){
+      sql = follow ? `SELECT * FROM (${sql}) AS tabl WHERE follow IS NOT NULL` : ''
+    }
+    const data: any = await this.http.customSQL(sql);
+    return data.data;
+  }
 }