Browse Source

更新会员权限

warrior 2 months ago
parent
commit
23662cc2bd

+ 9 - 3
projects/live-app/src/app/components/gift-modal/gift-modal.component.html

@@ -65,9 +65,15 @@
             (blur)="onChange()"
             [disabled]="!currentGift?.id"
           />
-          <div class="btn-item" (click)="sendGift()">
-            <span>赠送</span>
-          </div>
+          @if (currentGift?.type == 'vip' && !accServ.userVip?.rights?.['exclusive-gift']) {
+            <div class="btn-item btn-disabled">
+              <span>会员专享</span>
+            </div>
+          }@else {
+            <div class="btn-item" (click)="sendGift()">
+              <span>赠送</span>
+            </div>
+          }
         </div>
       </div>
     </div>

+ 5 - 2
projects/live-app/src/app/components/gift-modal/gift-modal.component.scss

@@ -87,9 +87,9 @@
     }
     .btns {
       display: flex;
-      align-items: center;
+      align-items: flex-end;
       .chang-gift {
-        font-size: 14px;
+        font-size: 12px;
       }
       .input-num {
         width: 50px;
@@ -105,6 +105,9 @@
         border-radius: 16px;
         font-size: 14px;
       }
+      .btn-disabled{
+        background-color: #dcdcdc;
+      }
     }
   }
 }

+ 3 - 1
projects/live-app/src/app/components/gift-modal/gift-modal.component.ts

@@ -9,6 +9,7 @@ import {
   AlertController,
   LoadingController,
 } from '../../../modules/ionic-standalone.modules';
+import { AccountService } from '../../../services/account.service';
 @Component({
   selector: 'app-gift-modal',
   templateUrl: './gift-modal.component.html',
@@ -47,7 +48,8 @@ export class GiftModalComponent implements OnInit {
     private aiServ: AiChatService,
     private alertController: AlertController,
     public liveService: LiveService,
-    private loadingCtrl: LoadingController
+    private loadingCtrl: LoadingController,
+    public accServ: AccountService,
   ) {}
 
   async ngOnInit() {

+ 2 - 2
projects/live-app/src/app/components/pay-comp/pay-comp.component.ts

@@ -239,8 +239,8 @@ export class PayCompComponent implements OnInit {
         payType: 'wxpay',
       });
       console.log(resulte);
-      if (resulte?.id) {
-        this.orderId = resulte.id;
+      if (resulte?.objectId) {
+        this.orderId = resulte.objectId;
       }
     } else if (this.orderType == 'recharge') {
       this.accountLog = await this.accServ.updataOrder({

+ 6 - 6
projects/live-app/src/modules/goods/vip/vip.component.html

@@ -4,22 +4,22 @@
   <div class="combo_index">
     <div class="combo-info">
       <img class="img" [src]="user?.get('avatar')" mode="aspectFill" />
-      <div class="name">{{ user.get("nickname") || user.get("mobile") }}</div>
+      <div class="name">{{ user.get("nickname") || user.get("name") || user.get("mobile") }}</div>
       <div class="text-info">
-        @if (myVip) {
+        @if (myVip?.expiredAt) {
         <div class="text-top">
           <div class="text-span">
-            {{ myVip.validity ? myVip.grade : "会员已过期" }}
+            {{ myVip.name }}<img src="img/VIP.png" alt="" />
           </div>
           <div class="text-span">
-            <div class="date">有效期至:{{ myVip.expiredAt }}</div>
+            <div class="date">有效期至:{{ myVip.expiredAt | date:"yyyy年MM月dd日" }}</div>
           </div>
-          <div class="text-span">开通记录</div>
         </div>
         } @else{
-        <div class="text-top">未开通</div>
+        <div class="text-top" style="color:#fff">到期或未开通</div>
         }
       </div>
+      <div class="alink">开通记录</div>
     </div>
     @for (item of goodsList; track $index) {
     <div

+ 18 - 2
projects/live-app/src/modules/goods/vip/vip.component.scss

@@ -18,7 +18,7 @@
 
       .name {
         font-size: 14px;
-        color: #ffffff;
+        // color: #ffffff;
         text-align: center;
         margin-top: 10px;
       }
@@ -27,13 +27,22 @@
         width: 300px;
         display: flex;
         flex-wrap: inherit;
-        color: white;
+        // color: white;
         flex-direction: column;
         font-size: 12px;
         margin: 10px auto 5px;
+        // background-color: white;
         .text-top {
           display: flex;
           justify-content: space-evenly;
+          .text-span{
+            display: flex;
+            align-items: center;
+            img{
+              width: 20px;
+              height: 20px;
+            }
+          }
         }
         .text-bot {
           font-size: 12px;
@@ -42,6 +51,13 @@
           color: #e6e6e6;
         }
       }
+      .alink{
+        color: #737373;
+        position: absolute;
+        right: 10px;
+        font-size: 14px;
+        border-bottom: 1px solid;
+      }
     }
 
     .combo_box1 {

+ 3 - 17
projects/live-app/src/modules/goods/vip/vip.component.ts

@@ -56,23 +56,8 @@ export class VipComponent implements OnInit {
   }
   //获取当前VIP等级
   async getUserVip() {
-    let vip = new Parse.Query('UserVip');
-    vip.equalTo('user', Parse.User.current()?.id);
-    vip.equalTo('company', this.authSer.company);
-    let reqVip = await vip.first();
-    if (reqVip && reqVip.id) {
-      let myVip = reqVip.toJSON();
-      let now = new Date().getTime();
-      let lastDate = new Date(myVip?.['expiredAt'].iso).getTime();
-      myVip['expiredAt'] = this.datePipe.transform(
-        myVip?.['expiredAt'].iso,
-        'yyyy-MM-dd'
-      );
-      if (lastDate >= now) {
-        myVip['validity'] = true;
-      }
-      this.myVip;
-    }
+    this.myVip = await this.accServ.getVip()
+    console.log(this.myVip);
   }
   async getGoods() {
     let goods = new Parse.Query('ShopGoods');
@@ -113,6 +98,7 @@ export class VipComponent implements OnInit {
     console.log(evet);
     // this.showPay = false;
     this.tradeNo = evet.tradeNo;
+    this.getUserVip()
   }
   async openpay() {
     this.showPay = true;

+ 8 - 6
projects/live-app/src/modules/live/chat/chat.component.html

@@ -8,7 +8,9 @@
     </ion-buttons>
     <ion-title class="title">{{
       uid
-        ? targetUser?.get("nickname") || targetUser?.get("name") || '用户' + targetUser?.id
+        ? targetUser?.get("nickname") ||
+          targetUser?.get("name") ||
+          "用户" + targetUser?.id
         : "世界频道"
     }}</ion-title>
     <ion-buttons slot="end" id="option-trigger">
@@ -52,10 +54,10 @@
       msgServe.messageMapList[channle][$index-1].timestamp > 600) {
       <div class="time-box">
         @if (item.istoday) {
-        <div class="time">{{ item.timestamp | showDate}}</div>
+        <div class="time">{{ item.timestamp | showDate }}</div>
         }@else {
         <div class="time">
-          {{ item.timestamp | showDate}}
+          {{ item.timestamp | showDate }}
         </div>
         }
       </div>
@@ -130,15 +132,15 @@
       slot="start"
       labelPlacement="stacked"
       [clearInput]="true"
-      placeholder="和ta说点什么"
+      [placeholder]="!uid && !accServ.userVip?.rights?.['all-chat'] ? '请开通会员享受世界频道畅聊' : '文明发言'"
       [(ngModel)]="text"
       (keydown)="comfirmText($event)"
+      [disabled]="!uid && !accServ.userVip?.rights?.['all-chat']"
     >
     </ion-input>
     <div
       [ngClass]="{
-        'tools-maxwid':
-          uid && profile?.get('identyType') === 'anchor',
+        'tools-maxwid': uid && profile?.get('identyType') === 'anchor',
         tools: true
       }"
       slot="end"

+ 5 - 1
projects/live-app/src/modules/live/chat/chat.component.ts

@@ -18,6 +18,7 @@ import {
   ToastController,
 } from '../../ionic-standalone.modules';
 import { AiChatService } from '../../../services/aichart.service';
+import { AccountService } from '../../../services/account.service';
 
 @Component({
   selector: 'app-chat',
@@ -47,6 +48,7 @@ export class ChatComponent implements OnInit {
   timer: any;
   currentScroll: number = 0; //滚动条位置
   disabled: boolean = false;
+  level:any //权益
   constructor(
     private router: Router,
     private http: HttpClient,
@@ -56,7 +58,8 @@ export class ChatComponent implements OnInit {
     private activateRoute: ActivatedRoute,
     public msgServe: MessageService,
     public aiServ: AiChatService,
-  ) {
+    public accServ: AccountService
+    ) {
     msgServe.pageFun = this.updatePage;
     msgServe.pageFun();
   }
@@ -151,6 +154,7 @@ export class ChatComponent implements OnInit {
   }
   //调起表情
   changeShowEmoji(isClose?: boolean) {
+    if(!this.uid && !this.accServ.userVip?.rights?.['all-chat']) return
     this.showEmoji = isClose ? false : !this.showEmoji;
     this.height = 0;
   }

+ 12 - 0
projects/live-app/src/modules/tabs/my/my.component.html

@@ -48,11 +48,23 @@
     </div>
   </div>
   <div class="ad" [style.background-image]="'url(img/ad-banner.png)'">
+    @if (userObj.vip?.expiredAt) {
+    <div class="my-vip">
+      <div class="lable">
+        {{ userObj.vip?.name }}<img src="img/VIP.png" alt="" />
+      </div>
+      <div class="vip-date" (click)="toUrl('goods/vip')">
+        到期时间:{{ userObj.vip?.expiredAt | date : "yyyy年MM月dd日"
+        }}<ion-icon name="chevron-forward"></ion-icon>
+      </div>
+    </div>
+    }@else {
     <div class="ad-left">
       <div class="text">爱聊 <span>VIP</span></div>
       <p>开通爱聊VIP,解锁海量专属主播聊天。</p>
     </div>
     <div class="btn" (click)="toUrl('goods/vip')">立即开通</div>
+    }
   </div>
   <div class="tool">
     @for (item of tools; track $index) {

+ 19 - 0
projects/live-app/src/modules/tabs/my/my.component.scss

@@ -130,6 +130,25 @@
       padding: 2px 4px;
       border-radius: 4px;
     }
+    .my-vip{
+      display: flex;
+      justify-content: space-between;
+      width: 100%;
+      .lable{
+        display: flex;
+        align-items: center;
+        img{
+          width: 20px;
+          height: 20px;
+          margin-left: 6px;
+        }
+      }
+      .vip-date{
+        color: #434343;
+        display: flex;
+        align-items: center;
+      }
+    }
   }
   .tool {
     display: grid;

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

@@ -1,8 +1,5 @@
 import { Component, OnInit } from '@angular/core';
-import {
-  LoadingController,
-  ToastController,
-} from '@ionic/angular';
+import { LoadingController, ToastController } from '@ionic/angular';
 
 import * as Parse from 'parse';
 import { AgreementComponent } from '../../login/agreement/agreement.component';
@@ -12,14 +9,14 @@ import { AuthService } from '../../../services/auth.service';
 import { AiChatService } from '../../../services/aichart.service';
 import { AccountService } from '../../../services/account.service';
 import { ionicStandaloneModules } from '../../ionic-standalone.modules';
+import { DatePipe, CommonModule } from '@angular/common';
 @Component({
   selector: 'app-my',
   templateUrl: './my.component.html',
   styleUrls: ['./my.component.scss'],
   standalone: true,
-  imports: [
-    ...ionicStandaloneModules
-  ],
+  imports: [...ionicStandaloneModules, CommonModule],
+  providers: [DatePipe],
 })
 export class MyComponent implements OnInit {
   profile?: Parse.Object; //身份信息
@@ -33,7 +30,7 @@ export class MyComponent implements OnInit {
     private activateRoute: ActivatedRoute,
     private router: Router,
     private aiServ: AiChatService,
-    private accServ: AccountService,
+    private accServ: AccountService
   ) {}
   tools: Array<{ icon: string; title: string; path: string }> = [
     {
@@ -69,23 +66,30 @@ export class MyComponent implements OnInit {
     fans: 0,
     follow: 0,
     friendly_degree: 0,
+    vip: null,
   };
-  orderList:Array<any> = [];
+  orderList: Array<any> = [];
   ngOnInit() {
     this.activateRoute.paramMap.subscribe(async (params) => {
       this.refresh();
     });
   }
   async refresh() {
+    const loading = await this.loadingCtrl.create({
+      message: '加载中',
+    });
+    loading.present();
     this.user = Parse.User.current()!;
-    this.getProfile();
+    await this.getProfile();
     this.getAgreement();
     const data = await this.aiServ.getFansAndFollow(this.user.id);
     // console.log(data);
-    this.orderList = await this.aiServ.getOrderAnchor()
+    this.orderList = await this.aiServ.getOrderAnchor();
     console.log(this.orderList);
-    const { fans, follow } = data.data[0]
-    this.userObj = { fans, follow, friendly_degree: 0 }
+    const { fans, follow } = data.data[0];
+    this.userObj = { fans, follow, friendly_degree: 0 };
+    this.userObj.vip = await this.accServ.userVip;
+    loading.dismiss();
   }
   // 获取用户信息
   async getProfile() {
@@ -162,7 +166,10 @@ export class MyComponent implements OnInit {
   }
   /* 进入直播间 */
   async goRoom() {
-    if (!this.profile?.get('isCross') || this.profile?.get('identyType') !== 'anchor') {
+    if (
+      !this.profile?.get('isCross') ||
+      this.profile?.get('identyType') !== 'anchor'
+    ) {
       const alert = await this.alertController.create({
         header: '提示',
         message: '你还未认证主播身份,请认证后再进入直播间',

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

@@ -133,6 +133,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>
+    }
   </div>
 </ion-content>
 <ion-footer class="footer">

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

@@ -92,11 +92,11 @@
           .id {
             color: #1e1e1e;
           }
-          .state{
+          .state {
             display: flex;
             align-items: center;
             margin-left: 10px;
-            .spot{
+            .spot {
               width: 8px;
               height: 8px;
               border-radius: 50%;
@@ -109,7 +109,7 @@
               // margin-left: 10px;
             }
           }
-          .video-unit{
+          .video-unit {
             margin-left: 10px;
           }
         }
@@ -137,6 +137,25 @@
   .user-data {
     width: 100%;
     padding: 6px 10px;
+    position: relative;
+    .view-auth {
+      position: absolute;
+      left: 0;
+      top: 50px;
+      width: 100%;
+      height: 100%;
+      background: linear-gradient(
+        to bottom,
+        rgb(255 255 255 / 0%),
+        #ffffff,
+        #ffffff,
+        #ffffff
+      );
+      display: flex;
+      align-items: center;
+      justify-content: center;
+      min-height: 450px;
+    }
     .tabs {
       display: flex;
       justify-content: space-evenly;
@@ -341,7 +360,7 @@ ion-modal {
       transform: translate(-50%, -50%) rotate(360deg);
     }
   }
-  .close{
+  .close {
     margin-top: 150px;
     font-size: 14px;
     color: #004acd;

+ 3 - 1
projects/live-app/src/modules/user/profile/profile.component.ts

@@ -17,6 +17,7 @@ import {
   LoadingController,
   ToastController,
 } from '../../ionic-standalone.modules';
+import { AccountService } from '../../../services/account.service';
 
 @Component({
   selector: 'app-profile',
@@ -66,7 +67,8 @@ export class ProfileComponent implements OnInit {
     private aiChatServ: AiChatService,
     private alertController: AlertController,
     private connectTask: ConnectTaskService,
-    private msgSer: MessageService
+    private msgSer: MessageService,
+    public accServ: AccountService,
   ) {
     this.msgSer.event$.subscribe((data) => {
       this.inviteCallback(data);

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

@@ -3,6 +3,7 @@ import Parse from 'parse';
 import { HttpClient } from '@angular/common/http';
 import { AuthService } from './auth.service';
 import { ToastController } from '@ionic/angular';
+import { HttpService } from './http.service';
 declare var wx: any;
 
 @Injectable({
@@ -14,13 +15,16 @@ export class AccountService {
   wxpayEnabled: boolean = false;
   appid: string = localStorage.getItem('WECHAT_APP_ID') || 'wx86a6c35812a41d41';
   shareInfo: any;
+  userVip:any //会员权益
   constructor(
     public toast: ToastController,
     private authServ: AuthService,
-    private http: HttpClient
+    private http: HttpClient,
+    private httpSver: HttpService
   ) {
     this.company = this.authServ.company;
     this.getUserOpenid();
+    this.getVip()
   }
 
   /* 如果是微信内置浏览器,获取登录code */
@@ -390,4 +394,11 @@ export class AccountService {
     await accountLog?.save();
     return accountLog;
   }
+
+  async getVip():Promise<any>{
+    const url = 'https://server.fmode.cn/api/user/vip'
+    let data = await this.httpSver.httpRequst(url,{uid: Parse.User.current()?.id},'POST');
+    this.userVip = data.data
+    return data.data
+  }
 }