Browse Source

修复声网元数据问题

warrior 2 months ago
parent
commit
2e38134448

+ 4 - 2
projects/live-app/src/modules/ionic-standalone.modules.ts

@@ -32,7 +32,8 @@ import {
   AlertController,
   ToastController,
   LoadingController,
-  ScrollDetail
+  ScrollDetail,
+  ModalController
 } from '@ionic/angular/standalone';
 
 export const ionicStandaloneModules = [
@@ -71,5 +72,6 @@ export {
   AlertController,
   ToastController,
   LoadingController,
-  ScrollDetail
+  ScrollDetail,
+  ModalController
 }

+ 25 - 8
projects/live-app/src/modules/login/login.component.ts

@@ -5,20 +5,24 @@ import { ActivatedRoute } from '@angular/router';
 import { HttpClient, HttpHeaders } from '@angular/common/http';
 import { catchError } from 'rxjs/operators';
 import { AgreementComponent } from './agreement/agreement.component';
-import { IonInput,IonCheckbox,IonContent,IonButtons, IonIcon ,
-  AlertController,
-  ToastController,
-} from '@ionic/angular/standalone';
+
 import { FormsModule, ReactiveFormsModule } from '@angular/forms';
 import { CommonModule } from '@angular/common';
-import { ModalController } from '@ionic/angular/standalone';
+import {
+  ionicStandaloneModules,
+  AlertController,
+  ToastController,
+  ModalController,
+  LoadingController,
+} from '../ionic-standalone.modules';
 
 @Component({
   standalone: true,
   imports: [
     CommonModule,
-    FormsModule,ReactiveFormsModule,
-    IonInput,IonCheckbox,IonContent,IonButtons,IonIcon,
+    FormsModule,
+    ReactiveFormsModule,
+    ...ionicStandaloneModules,
   ],
   selector: 'app-login',
   templateUrl: './login.component.html',
@@ -37,7 +41,8 @@ export class LoginComponent implements OnInit {
     private activatedRoute: ActivatedRoute,
     private http: HttpClient,
     private modalCtrl: ModalController,
-    private alertController: AlertController
+    private alertController: AlertController,
+    private loadingCtrl: LoadingController
   ) {
     this.company = authServ.company;
   }
@@ -182,8 +187,13 @@ export class LoginComponent implements OnInit {
   }
 
   async login() {
+    const loading = await this.loadingCtrl.create({
+      message: '正在登录,请稍等',
+    });
+    loading.present();
     console.log(this.loginInfo);
     if (this.loginInfo.mobile == undefined || this.loginInfo.mobile == '') {
+      loading.dismiss();
       const toast = await this.toastController.create({
         message: '请输入手机号',
         color: 'warning',
@@ -194,6 +204,7 @@ export class LoginComponent implements OnInit {
     }
     let a = /^1[3456789]\d{9}$/;
     if (!String(this.loginInfo.mobile).match(a)) {
+      loading.dismiss();
       const toast = await this.toastController.create({
         message: '请填写正确手机号',
         color: 'warning',
@@ -204,6 +215,7 @@ export class LoginComponent implements OnInit {
     }
     if (this.type == 'password') {
       if (this.loginInfo.password == '' || this.loginInfo.password.trim == '') {
+        loading.dismiss();
         const toast = await this.toastController.create({
           message: '请填写密码',
           color: 'warning',
@@ -220,8 +232,10 @@ export class LoginComponent implements OnInit {
         )
         .then((data) => {
           console.log(data);
+          loading.dismiss();
         })
         .catch(async (err) => {
+          loading.dismiss();
           const toast = await this.toastController.create({
             message: err,
             color: 'danger',
@@ -231,6 +245,7 @@ export class LoginComponent implements OnInit {
         });
     } else if (this.type == 'code') {
       if (!this.loginInfo.code) {
+        loading.dismiss();
         const toast = await this.toastController.create({
           message: '请填写有效验证码',
           color: 'warning',
@@ -248,8 +263,10 @@ export class LoginComponent implements OnInit {
         )
         .then((data) => {
           console.log(data);
+          loading.dismiss();
         })
         .catch(async (err) => {
+          loading.dismiss();
           const toast = await this.toastController.create({
             message: err,
             color: 'danger',

+ 1 - 1
projects/live-app/src/modules/tabs/my/my.component.ts

@@ -22,7 +22,7 @@ export class MyComponent implements OnInit {
   profile?: Parse.Object; //身份信息
   user: Parse.Object = Parse.User.current()!;
   constructor(
-    public loadingCtrl: LoadingController,
+    private loadingCtrl: LoadingController,
     private modalController: ModalController,
     private alertController: AlertController,
     public authServ: AuthService,

+ 13 - 11
projects/live-app/src/modules/user/profile/profile.component.html

@@ -26,12 +26,12 @@
             }@else {
             <!-- <div class="sex">未知</div> -->
             }
-            <div class="age">
+            <div [ngClass]="{ gril: user?.get('sex') == '女', age: true }">
               <img
                 src="https://file-cloud.fmode.cn/Qje9D4bqol/20241109/pctmvt110807052.png"
                 alt=""
               />
-              {{ profile?.get("age") || "未知" }}
+              {{ profile?.get("birthdate") || "未知" }}
             </div>
           </div>
         </div>
@@ -49,7 +49,9 @@
           </div>
           <!-- } -->
           @if (profile?.get('identyType') === 'anchor') {
-            <div class="video-unit">通话:{{profile?.get('laborCosts')}}钻石/分钟</div>
+          <div class="video-unit">
+            通话:{{ profile?.get("laborCosts") }}钻石/分钟
+          </div>
           }
         </div>
       </div>
@@ -89,8 +91,8 @@
     <div class="data-row">
       <div class="title-text">个人资料</div>
       <div class="tags">
-        <span class="label">生日:{{birthdat}}</span>
-        <span class="label">星座:{{constellation}}</span>
+        <span class="label">生日:{{ birthdat }}</span>
+        <span class="label">星座:{{ constellation }}</span>
         <span class="label">城市:未知</span>
       </div>
       <div class="motto">{{ profile?.get("remark") }}</div>
@@ -132,12 +134,12 @@
         }
       </div>
     </div>
-    }
-    @if (uid !== currentUser?.id && !accServ.userVip?.rights?.['view-profile']) {
-      <div class="view-auth">
-        <ion-icon name="lock-closed"></ion-icon>
-        <div class="auth-text">开通高级会员查看更多</div>
-      </div>
+    } @if (uid !== currentUser?.id &&
+    !accServ.userVip?.rights?.['view-profile']) {
+    <div class="view-auth">
+      <ion-icon name="lock-closed"></ion-icon>
+      <div class="auth-text">开通高级会员查看更多</div>
+    </div>
     }
   </div>
 </ion-content>

+ 4 - 0
projects/live-app/src/modules/user/profile/profile.component.scss

@@ -43,6 +43,7 @@
             height: 60px;
             margin-top: -38px;
             z-index: 1;
+            border-radius: 50%;
           }
           .top-right-block {
             display: flex;
@@ -82,6 +83,9 @@
                 margin-right: 4px;
               }
             }
+            .gril{
+              background: linear-gradient(to right, #fe454e, #f5a7ab) !important;
+            }
           }
         }
         .user-status {

+ 6 - 0
projects/live-app/src/modules/user/profile/profile.component.ts

@@ -245,6 +245,12 @@ export class ProfileComponent implements OnInit {
       this.friends?.set('company', this.aiChatServ.company);
       this.friends?.set('channel', this.user?.id + '-' + this.currentUser?.id);
       await this.friends?.save();
+      const toast = await this.toastController.create({
+        message: '已申请,等待对方同意',
+        color: 'warning',
+        duration: 1500,
+      });
+      toast.present();
     }
   }
 

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

@@ -37,6 +37,7 @@ export class AuthService {
             Parse.User.become(authData)
               .then(async (data) => {
                 // console.log(data);
+                await this.getProfile()
                 await this.connectTask.init();
                 this.redirectUrl = this.redirectUrl ? this.redirectUrl : 'tabs';
                 this.router.navigate([this.redirectUrl]);
@@ -56,6 +57,17 @@ export class AuthService {
         });
     });
   }
+  async getProfile() {
+    if (localStorage.getItem('profile')) return;
+    let queryProfile = new Parse.Query('Profile');
+    queryProfile.equalTo('user', Parse.User.current()?.id);
+    queryProfile.notEqualTo('isDeleted', true);
+    queryProfile.equalTo('isCross', true);
+    let res = await queryProfile.first();
+    if (res?.id) {
+      localStorage.setItem('profile', JSON.stringify(res?.toJSON()));
+    }
+  }
   clearReWechat(cid: string) {
     // 清楚过期登录状态,重新登陆
     localStorage.clear(); // 清楚过期登录状态,重新登陆
@@ -64,8 +76,8 @@ export class AuthService {
   logout(): void {
     localStorage.clear(); // 清楚过期登录状态,重新登陆
     Parse.User.logOut().then((user) => {
-      this.msgSer.logOutRTM();
-      this.connectTask.reset()
+      this.msgSer?.logOutRTM();
+      this.connectTask?.reset();
       this.router.navigate(['login']);
     });
   }

+ 12 - 12
projects/live-app/src/services/message.service.ts

@@ -135,8 +135,8 @@ export class MessageService {
 
   /* 呼叫事件 */
   async callPresence(message: string, publisher: string, channelName: string) {
-    console.log(message);
     let userData = await this.getUserMetadata(publisher);
+    console.log('发出消息用户:',userData);
     let toast;
     if(message.indexOf('ONUSERSENDGIFT_') > -1){
       let arr = message.split('_')
@@ -152,11 +152,11 @@ export class MessageService {
     switch (message) {
       case 'USERCALLINVITATION':
         await this.setConnectState(this.userId, 'CONNECTING');
-        console.log(`收到${userData.nickname.value ?? '未知用户'}通话邀请`);
+        console.log(`收到${userData?.nickname?.value ?? '未知用户'}通话邀请`);
         this.alert = await this.alertController.create({
           cssClass: 'my-custom-class',
           header: '通话邀请',
-          message: `收到${userData.nickname.value ?? '未知用户'}通话邀请`,
+          message: `收到${userData?.nickname?.value ?? '未知用户'}通话邀请`,
           backdropDismiss: false,
           buttons: [
             {
@@ -188,7 +188,7 @@ export class MessageService {
         break;
       case 'CLOASEINVITATION':
         await this.setConnectState(this.userId, 'ONLINE');
-        console.log(`${userData.nickname.value ?? '未知用户'}取消通话`);
+        console.log(`${userData?.nickname?.value ?? '未知用户'}取消通话`);
         this.alert?.dismiss();
         toast = await this.toastController.create({
           message: '对方已取消通话邀请',
@@ -198,13 +198,13 @@ export class MessageService {
         toast.present();
         break;
       case 'REFUSEINVITATION_' + this.userId:
-        console.log(`${userData.nickname.value ?? '未知用户'}拒绝通话`);
+        console.log(`${userData?.nickname?.value ?? '未知用户'}拒绝通话`);
         this.alert?.dismiss();
         this.eventSource.next(false);
         break;
       case 'RESPONSEINVITOIN_' + this.userId:
         console.log(
-          `${userData.nickname.value ?? '未知用户'}同意通话,进入视频通话`
+          `${userData?.nickname?.value ?? '未知用户'}同意通话,进入视频通话`
         );
         this.alert?.dismiss();
         this.eventSource.next(true);
@@ -260,7 +260,7 @@ export class MessageService {
       });
       this.options.connectState = true; // 登录成功
       let userMateData = await this.getUserMetadata(this.userId);
-      if (!userMateData) {
+      if (!userMateData?.nickname?.value || !userMateData?.avatar?.value) {
         let user = Parse.User.current();
         const metadata = [
           {
@@ -371,14 +371,14 @@ export class MessageService {
         from_id: this.userId,
         from_username: Parse.User.current()?.get('nickname') ?? '未知用户',
         target_id: param.channelName,
-        // target_name: userData.nickname.value ?? '未知用户',
+        // target_name: userData?.nickname?.value ?? '未知用户',
         channel: param.channelName,
         content: {
           avatar:
-            userData.avatar.value ??
+            userData?.avatar?.value ??
             'https://file-cloud.fmode.cn/DXNgcD6zo6/20221202/j6p8kb034039.png',
           msg_type: 1,
-          name: userData.nickname.value ?? '未知用户',
+          name: userData?.nickname?.value ?? '未知用户',
           content: message?.text ?? '',
           publisher: param.publisher,
           timestamp: param.timestamp,
@@ -388,10 +388,10 @@ export class MessageService {
     let data: any = {
       is_self: is_self,
       avatar:
-        userData.avatar.value ??
+        userData?.avatar?.value ??
         'https://file-cloud.fmode.cn/DXNgcD6zo6/20221202/j6p8kb034039.png',
       msg_type: 1,
-      name: userData.nickname.value ?? '未知用户',
+      name: userData?.nickname?.value ?? '未知用户',
       content: message?.text ?? '',
       publisher: param.publisher,
       timestamp: new Date(param.timestamp),