warrior 4 tháng trước cách đây
mục cha
commit
b4bbead7a6

BIN
projects/live-app/public/img/pay_alipay.png


BIN
projects/live-app/public/img/wxpay.png


+ 50 - 0
projects/live-app/src/app/components/pay-comp/pay-comp.component.html

@@ -0,0 +1,50 @@
+<ion-modal
+  #modal
+  trigger="open-modal"
+  [isOpen]="isOpen"
+  (didDismiss)="isOpen = false"
+  [backdropDismiss]="false"
+>
+  <ng-template>
+    <div class="pay-box">
+      <div class="close" (click)="onClose()"><ion-icon name="close-outline"></ion-icon></div>
+      <div class="pay-title">支付订单</div>
+      <div class="pay-num">¥{{ price || 0 }}</div>
+      <div class="options">
+        <div class="row" (click)="onchangPay('wxpay')">
+          <div class="label">
+            <img src="img/wxpay.png" alt="" class="icon" />
+            <div class="text">微信支付</div>
+          </div>
+          <div
+            [ngClass]="{
+              'check-active': checkpay == 'wxpay',
+              chekc: true
+            }"
+          >
+            <div class="checkbox"></div>
+          </div>
+        </div>
+        <div class="bar"></div>
+        <div class="row" (click)="onchangPay('alipay')">
+          <div class="label">
+            <img src="img/pay_alipay.png" alt="" class="icon" />
+            <div class="text">支付宝</div>
+          </div>
+          <div
+            [ngClass]="{
+              'check-active': checkpay == 'alipay',
+              chekc: true
+            }"
+          >
+            <div class="checkbox"></div>
+          </div>
+        </div>
+      </div>
+      <div class="pay-footer">
+        <div class="order-num">订单编号{{orderNum}}</div>
+        <div class="pay-btn">去付款</div>
+      </div>
+    </div>
+  </ng-template>
+</ion-modal>

+ 95 - 0
projects/live-app/src/app/components/pay-comp/pay-comp.component.scss

@@ -0,0 +1,95 @@
+ion-modal {
+  --height: 320px;
+  --width: 300px;
+  --border-radius: 16px;
+  --box-shadow: 0 10px 15px -3px rgb(0 0 0 / 0.1),
+    0 4px 6px -4px rgb(0 0 0 / 0.1);
+}
+.pay-box {
+  height: 100%;
+  display: flex;
+  flex-direction: column;
+  padding: 20px 10px 10px;
+  position: relative;
+  .close {
+    position: absolute;
+    right: 10px;
+    top: 10px;
+    font-size: 20px;
+  }
+  .pay-title {
+    text-align: center;
+  }
+  .pay-num {
+    text-align: center;
+    font-size: 20px;
+    color: #d50b15;
+    margin: 6px auto;
+    font-weight: 700;
+  }
+  .options {
+    margin: 10px 0;
+    .row {
+      display: flex;
+      align-items: center;
+      justify-content: space-between;
+      .label {
+        display: flex;
+        align-items: center;
+        img {
+          width: 30px;
+          height: 30px;
+        }
+        .text{
+          font-size: 14px;
+          margin-left: 6px;
+        }
+      }
+      .chekc {
+        border: 1px solid #dfdfdf;
+        border-radius: 50%;
+        width: 20px;
+        height: 20px;
+      }
+      .check-active {
+        border: 1px solid #f66369 !important;
+        display: flex;
+        align-items: center;
+        justify-content: center;
+        .checkbox {
+          width: 16px;
+          height: 16px;
+          border-radius: 50%;
+          background: #f66369;
+        }
+      }
+    }
+    .bar {
+      margin: 10px 0;
+      height: 1px;
+      // width: calc(100% - 20px);
+      background: #dfdfdf;
+    }
+  }
+  .pay-footer {
+    display: flex;
+    flex-direction: column;
+    justify-content: end;
+    align-items: center;
+    flex: 1;
+    padding-bottom: 10px;
+    .order-num{
+      color: #636363;
+      font-size: 12px;
+      margin-bottom: 4px;
+    }
+    .pay-btn{
+      padding: 6px 0;
+      width: 100%;
+      color: white;
+      text-align: center;
+      background: #f96269;
+      border-radius: 4px;
+    }
+  }
+}

+ 28 - 0
projects/live-app/src/app/components/pay-comp/pay-comp.component.spec.ts

@@ -0,0 +1,28 @@
+/* tslint:disable:no-unused-variable */
+import { async, ComponentFixture, TestBed } from '@angular/core/testing';
+import { By } from '@angular/platform-browser';
+import { DebugElement } from '@angular/core';
+
+import { PayCompComponent } from './pay-comp.component';
+
+describe('PayCompComponent', () => {
+  let component: PayCompComponent;
+  let fixture: ComponentFixture<PayCompComponent>;
+
+  beforeEach(async(() => {
+    TestBed.configureTestingModule({
+      declarations: [ PayCompComponent ]
+    })
+    .compileComponents();
+  }));
+
+  beforeEach(() => {
+    fixture = TestBed.createComponent(PayCompComponent);
+    component = fixture.componentInstance;
+    fixture.detectChanges();
+  });
+
+  it('should create', () => {
+    expect(component).toBeTruthy();
+  });
+});

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

@@ -0,0 +1,205 @@
+import { Component, EventEmitter, Input, OnInit, Output } from '@angular/core';
+import { CommonModule } from '@angular/common';
+import { AlertController, IonicModule, ToastController } from '@ionic/angular';
+import { ActivatedRoute } from '@angular/router';
+import { AccountService } from '../../../services/account.service';
+import { HttpClient } from '@angular/common/http';
+declare var wx: any;
+
+@Component({
+  selector: 'app-pay-comp',
+  templateUrl: './pay-comp.component.html',
+  styleUrls: ['./pay-comp.component.scss'],
+  standalone: true,
+  imports: [IonicModule, CommonModule],
+})
+export class PayCompComponent implements OnInit {
+  @Input('price') price!: number;
+  @Input('orderNum') orderNum: string = 'C20241215050401';
+  @Output() onChange: EventEmitter<any> = new EventEmitter<any>();
+  tradeNo?: string; //支付单号
+  isOpen: boolean = false; //打开弹窗
+  checkpay: string = 'wxpay';
+  userAgent?: string; //获取当前浏览器环境
+
+  constructor(
+    private accServ: AccountService,
+    private toastController: ToastController,
+    private alertCtrl: AlertController,
+    private http: HttpClient,
+    private activRoute: ActivatedRoute
+  ) {}
+
+  ngOnInit() {
+    this.activRoute.paramMap.subscribe((params) => {
+      let ua = navigator.userAgent.toLowerCase();
+      if (ua.indexOf('micromessenger') != -1) {
+        this.userAgent = 'weixin';
+        this.accServ.getWXSignPackageInWechat();
+      } else if (ua.indexOf('windows') != -1 || ua.indexOf('Macintosh') != -1) {
+        this.userAgent = 'pc';
+      }
+    });
+  }
+  onchangPay(val: string) {
+    this.checkpay = val;
+    console.log(val);
+  }
+  async showCodeModal(type: string) {
+    switch (type) {
+      case 'wxpay':
+        this.openWxPay();
+        break;
+      default:
+        break;
+    }
+  }
+  /* 校验支付方式 */
+  openWxPay() {
+    let ua = navigator.userAgent.toLowerCase();
+    let isWeixin = ua.indexOf('micromessenger') != -1;
+    if (isWeixin) {
+      //JSAPI 支付
+      this.wxPayH5();
+    } else {
+      this.wxPay();
+    }
+  }
+  /* pc端支付 */
+  async wxPay() {
+    this.tradeNo = this.accServ.setTradeNo();
+    // this.navCtrl.navigateRoot('account/payment');
+    //console.log(this.company, this.tradeNo);
+    let params = {
+      company: this.accServ.company,
+      out_trade_no: this.tradeNo,
+      total_fee: this.price,
+      body: '充值',
+    };
+    try {
+      let _this = this;
+      Parse.Cloud.run('pay_code2', params).then(async (res) => {
+        let nonce_str = res.nonce_str;
+        let codeLink = res.code_url[0];
+        let order = await this.accServ.setOrder('service', {
+          out_trade_no: this.tradeNo,
+          payType: 'wxpay-pc',
+          total_fee: this.price,
+          code: codeLink,
+        });
+        window.open(
+          `${location.protocol}//${location.host}/account/payment/${order.objectId}/${nonce_str}`
+        );
+        this.isOpen = false;
+      });
+    } catch (error) {
+      alert(error);
+    }
+  }
+  isDisabled: boolean = false; //防抖
+
+  /* h5环境 */
+  async wxPayH5() {
+    if (this.isDisabled) return;
+    try {
+      this.isDisabled = true;
+      this.tradeNo = this.accServ.setTradeNo();
+      //console.log(this.company, this.tradeNo);
+      let wechat = Parse.User.current()?.get('wechat');
+      let openid =
+        localStorage.getItem('openid') || wechat['wxb4193c93ae9aa696']?.openid;
+      if (openid) {
+        let params = {
+          company: this.accServ.company,
+          out_trade_no: this.tradeNo,
+          total_fee: +this.price,
+          openid: openid,
+          appid: 'wxb4193c93ae9aa696',
+        };
+        await this.accServ.setOrder('service', {
+          out_trade_no: this.tradeNo,
+          payType: 'wxpay-h5',
+          total_fee: this.price,
+        });
+        let _this = this;
+        this.http
+          .post(`https://server.fmode.cn/api/wxpay/neworder`, params)
+          .subscribe((response) => {
+            let payinfo: any = response;
+            wx.chooseWXPay({
+              timestamp: payinfo.timeStamp, // 支付签名时间戳,注意微信jssdk中的所有使用timestamp字段均为小写。但最新版的支付后台生成签名使用的timeStamp字段名需大写其中的S字符
+              nonceStr: payinfo.nonceStr, // 支付签名随机串,不长于 32 位
+              package: payinfo.package, // 统一支付接口返回的prepay_id参数值,提交格式如:prepay_id=\*\*\*)
+              signType: 'MD5', // 签名方式,默认为'SHA1',使用新版支付需传入'MD5'
+              paySign: payinfo.paySign, // 支付签名
+              success: async (res: any) => {
+                // 支付成功后的回调函数
+                if (res) {
+                  let info = {
+                    out_trade_no: _this.tradeNo,
+                    nonce_str: payinfo.nonceStr,
+                    company: this.accServ.company,
+                  };
+
+                  // this.accServ.saveAccountLog(info, _this.order.objectId, _this.company, _this.message);
+                  _this.toast('支付成功', 'success');
+                  _this.isOpen = false;
+                }
+              },
+            });
+            this.isDisabled = false;
+          });
+      } else {
+        // alert('缺少openid,请重新登录')
+        this.isDisabled = false;
+        let alert = await this.alertCtrl.create({
+          header: '提示',
+          subHeader: '',
+          message: '缺少openid,请刷新页面或重新登录',
+          buttons: [
+            {
+              role: 'ok',
+              text: '确认',
+              handler: () => {
+                location.reload();
+              },
+            },
+          ],
+        });
+        alert.present();
+      }
+    } catch (err: any) {
+      this.isDisabled = false;
+      let alert = await this.alertCtrl.create({
+        header: '异常错误',
+        subHeader: '',
+        message: err.message,
+        buttons: [
+          {
+            role: 'ok',
+            text: '确认',
+            handler: () => {},
+          },
+        ],
+      });
+      alert.present();
+    }
+  }
+
+  onClose() {
+    this.isOpen = false;
+    const result = {
+      code: 0,
+      type: this.checkpay,
+    };
+    this.onChange.emit(result);
+  }
+  async toast(text: string, type?: string) {
+    const toast = await this.toastController.create({
+      message: text,
+      color: type ?? 'warning',
+      duration: 1500,
+    });
+    toast.present();
+  }
+}

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

@@ -112,3 +112,4 @@
   </div>
   }
 </ion-content>
+<app-pay-comp #paycomp></app-pay-comp>

+ 15 - 10
projects/live-app/src/modules/goods/vip/vip.component.ts

@@ -1,27 +1,36 @@
-import { Component, OnInit } from '@angular/core';
+import { Component, OnInit, ViewChild } from '@angular/core';
 import { IonicModule, ModalController } from '@ionic/angular';
 import { NavComponent } from '../../../app/components/nav/nav.component';
 import { FormsModule } from '@angular/forms';
 import * as Parse from 'parse';
 import { AuthService } from '../../../services/auth.service';
-import { DatePipe,CommonModule } from '@angular/common';
+import { DatePipe, CommonModule } from '@angular/common';
 import { AgreementComponent } from '../../login/agreement/agreement.component';
+import { PayCompComponent } from '../../../app/components/pay-comp/pay-comp.component';
 
 @Component({
   selector: 'app-vip',
   templateUrl: './vip.component.html',
   styleUrls: ['./vip.component.scss'],
   standalone: true,
-  imports: [IonicModule, NavComponent, CommonModule,FormsModule],
+  imports: [
+    IonicModule,
+    NavComponent,
+    CommonModule,
+    FormsModule,
+    PayCompComponent,
+  ],
   providers: [DatePipe],
 })
 export class VipComponent implements OnInit {
+  @ViewChild('paycomp') paycomp!: PayCompComponent;
+
   user: any = Parse.User.current();
   profile?: Parse.Object;
   goodsList: Array<Parse.Object> = [];
   myVip: any;
   registerAgreement: any;
-  isCheck:boolean = false;
+  isCheck: boolean = false;
   currentGoods?: Parse.Object; //当前选择的会员
   constructor(
     private modalController: ModalController,
@@ -90,11 +99,7 @@ export class VipComponent implements OnInit {
   onchang(data: Parse.Object) {
     this.currentGoods = data;
   }
-  openpay(){
-    if(this.isCheck){
-      // this.authSer.openPay(this.currentGoods);
-    }else{
-      this.showAgreement();
-    }
+  openpay() {
+    this.paycomp.isOpen = true;
   }
 }

+ 14 - 2
projects/live-app/src/modules/live/room-manage/room-manage.component.html

@@ -14,9 +14,21 @@
       <ion-input
         placeholder="请填写标题"
         maxlength="20"
-        [value]="formData.title"
+        [(ngModel)]="formData.title"
       ></ion-input>
     </div>
+    <div class="row">
+      <div class="title">点播费用(元/分钟)<span style="color: red">*</span></div>
+      <input
+        placeholder="请填写标题"
+        min="0.5"
+        maxlength="3"
+        type="number"
+        (blur)="onChange()"
+        [(ngModel)]="formData.price"
+        class="input-num"
+      >
+    </div>
     <div class="row">
       <div class="title">直播封面<span style="color: red">*</span></div>
       @if (!initLoad) {
@@ -36,7 +48,7 @@
       <!-- <ion-input placeholder="待认证" value="{{ formData.name }}"></ion-input> -->
       <ion-textarea
         placeholder="请填写简介"
-        [value]="formData.content"
+        [(ngModel)]="formData.content"
       ></ion-textarea>
     </div>
   </div>

+ 6 - 0
projects/live-app/src/modules/live/room-manage/room-manage.component.scss

@@ -30,6 +30,12 @@
 				--padding-end:4px;
 				--padding-start:4px;
 			}
+			.input-num{
+				border: none;
+				background: #f3f3f3;
+				padding: 4px;
+				outline: none;
+			}
 		}
 	}
 }

+ 16 - 8
projects/live-app/src/modules/live/room-manage/room-manage.component.ts

@@ -10,13 +10,14 @@ 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';
+import { FormsModule } from '@angular/forms';
 
 @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,FormsModule],
 })
 export class RoomManageComponent implements OnInit {
   @ViewChild('upload') upload!: UploadComponent;
@@ -25,9 +26,10 @@ export class RoomManageComponent implements OnInit {
     title: '',
     cover: null,
     content: null,
+    price: 0.5,
   };
   loading: any;
-  pid: string = localStorage.getItem('profile') ?? '';
+  profile?: Parse.Object
   initLoad:boolean = true;
   constructor(
     public toastController: ToastController,
@@ -43,34 +45,38 @@ export class RoomManageComponent implements OnInit {
   }
   // 获取用户信息
   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;
+    this.profile = r;
   }
   /* 直播间 */
   async getRoom() {
     let query = new Parse.Query('Room');
     query.equalTo('user', Parse.User.current()?.id);
-    query.equalTo('profile', this.pid);
+    query.equalTo('profile', this.profile?.id);
     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'),
+      price: this.profile?.get('laborCosts') || 1,
     };
     console.log(this.formData);
     this.initLoad = false
   }
+  onChange() {
+    this.formData.price = Math.max(0.5, parseFloat(this.formData.price.toFixed(1)));
+    console.log(this.formData.price);
+  }
   async saveEdit(e: any) {
     let url = e[0]?.url
     console.log(url);
-    if(!url || !this.formData.title){
+    if(!url || !this.formData.title || !this.formData.price){
       const toast = await this.toastController.create({
         message: '请填写完整',
         color: 'warning',
@@ -83,6 +89,8 @@ export class RoomManageComponent implements OnInit {
       message: '正在保存修改',
     });
     this.loading.present();
+    this.profile?.set('laborCosts', this.formData.price);
+    await this.profile?.save();
     if (!this.room?.id) {
       let obj = Parse.Object.extend('Room');
       this.room = new obj();
@@ -95,10 +103,10 @@ export class RoomManageComponent implements OnInit {
       this.room?.set('profile', {
         __type: 'Pointer',
         className: 'Profile',
-        objectId: this.pid,
+        objectId: this.profile?.id,
       });
+      this.room?.set('roomid', this.profile?.id,);
     }
-    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);

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

@@ -106,6 +106,7 @@ export class HomeComponent implements OnInit {
     // });
   }
   async refresh() {
+    await this.connectTask.init();
     await this.getBanner();
     await this.getRoom();
     setTimeout(() => {

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

@@ -49,7 +49,7 @@ export class MyComponent implements OnInit {
     },
     {
       icon: 'img/访客.png',
-      title: '访客',
+      title: '访客记录',
       path: 'user/browse',
     },
     {

+ 3 - 4
projects/live-app/src/modules/tabs/tabs/tabs.component.ts

@@ -8,7 +8,7 @@ import { IonicModule } from '@ionic/angular';
 import { OnInit } from '@angular/core';
 import { AlertController } from '@ionic/angular';
 // import { MessageService } from '../../../services/message.service';
-import { ConnectTaskService } from '../../../services/connectTask.service';
+// import { ConnectTaskService } from '../../../services/connectTask.service';
 
 @Component({
   selector: 'live-tabs',
@@ -20,17 +20,16 @@ import { ConnectTaskService } from '../../../services/connectTask.service';
 export class TabsComponent implements OnInit {
   @Input('tabsOption') tabsOption: any = {};
   company: any = window.localStorage.getItem('company');
-  // @ViewChild('tabs',{static:true}) tabs;
   constructor(
     private router: Router,
     private alertController: AlertController,
     private activateRoute: ActivatedRoute,
-    private connectTask: ConnectTaskService
+    // private connectTask: ConnectTaskService
   ) {
     this.activateRoute.paramMap.subscribe(async (params) => {
       this.active = Number(localStorage.getItem('active')) || 0;
       await this.presentAlert();
-      this.connectTask.init();
+      // this.connectTask.init();
     });
   }
 

+ 1 - 1
projects/live-app/src/modules/user/browse/browse.component.scss

@@ -10,6 +10,6 @@
     // padding: 0 3.2vw;
     // position: sticky;
     // top: 0;
-    border: 1px solid #e5e5e5;
+    border-bottom: 1px solid #e5e5e5;
   }
 }

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

@@ -175,7 +175,7 @@
         (onChange)="onSaveBackGround($event)"
         #upload
         [maxlenght]="1"
-        [files]="[{ url: profile?.get('image') }]"
+        [files]="profile?.get('image') ? [{ url: profile?.get('image') }] : []"
         [boxWidth]="320"
         [fileWidth]="300"
         [fileHeight]="180"

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

@@ -0,0 +1,236 @@
+import { Injectable } from '@angular/core';
+import Parse from 'parse';
+import { HttpClient } from '@angular/common/http';
+import { AuthService } from './auth.service';
+declare var wx: any;
+
+@Injectable({
+  providedIn: 'root',
+})
+export class AccountService {
+  company: string = '';
+  wxAppId = '';
+  wxpayEnabled: boolean = false;
+  appid: string = localStorage.getItem('WECHAT_APP_ID') || 'wxb4193c93ae9aa696';
+  shareInfo: any;
+  constructor(private authServ: AuthService, private http: HttpClient) {
+    this.company = this.authServ.company;
+    this.getUserOpenid();
+  }
+
+  /* 如果是微信内置浏览器,获取登录code */
+  async getUserOpenid() {
+    let ua = navigator.userAgent.toLowerCase();
+    let isWeixin = ua.indexOf('micromessenger') != -1;
+    let code = this.getQueryStringByName('code');
+    let openid = localStorage.getItem('openid');
+    if (!openid) {
+      if (!Parse.User.current()) return;
+      let wechat = Parse.User.current()?.get('wechat');
+      openid = wechat?.[this.appid]?.openid;
+      if (isWeixin) {
+        if (!code) {
+          this.authWechat();
+        } else {
+          await this.getwechat(code);
+        }
+      }
+    }
+  }
+  authWechat(url: string = '/account/billing') {
+    if (!localStorage.getItem('openid')) {
+      // let REDIRECT_URI = "https://ai.fmode.cn" + url;
+      let REDIRECT_URI = window.location.href;
+      REDIRECT_URI = encodeURIComponent(REDIRECT_URI);
+      // console.log(REDIRECT_URI);
+      // console.log(
+      //   "https://open.weixin.qq.com/connect/oauth2/authorize?appid=" +
+      //     this.appid +
+      //     "&redirect_uri=" +
+      //     REDIRECT_URI +
+      //     "&response_type=code&scope=snsapi_base&state=STATE#wechat_redirect"
+      // );
+      window.location.href =
+        'https://open.weixin.qq.com/connect/oauth2/authorize?appid=' +
+        this.appid +
+        '&redirect_uri=' +
+        REDIRECT_URI +
+        '&response_type=code&scope=snsapi_userinfo&state=STATE#wechat_redirect';
+      return;
+    }
+  }
+  //根据QueryString参数名称获取值
+  getQueryStringByName(name: string) {
+    let result = location.search.match(
+      new RegExp('[?&]' + name + '=([^&]+)', 'i')
+    );
+    if (result == null || result.length < 1) {
+      return '';
+    }
+    return result[1];
+  }
+  async getwechat(
+    code: string,
+    url: string = '/account/billing'
+  ): Promise<boolean> {
+    return new Promise(async (resolve, reject) => {
+      this.http
+        .post(`https://server.fmode.cn/api/wechat/get_wx`, {
+          company: this.company,
+          code: code,
+        })
+        .subscribe(
+          async (res: any) => {
+            console.log(res);
+            if (res && res.code == 200 && res.data.openid) {
+              let openid = res.data.openid;
+              // localStorage.setItem('authData', JSON.stringify(res.data))
+              localStorage.setItem('openid', openid);
+              localStorage.removeItem('code');
+              let wxopts: any = {};
+              (wxopts[this.appid] = {
+                openid: openid,
+              }),
+                Parse.User.current()?.set('wechat', wxopts);
+              await Parse.User.current()?.save();
+              resolve(true);
+            }
+          },
+          async (err) => {
+            console.log('Error updating items', err);
+            this.authWechat(url);
+            reject(false);
+          }
+        );
+    });
+  }
+  /* 获取微信签名 */
+  getWXSignPackageInWechat() {
+    let params = {
+      company: this.company,
+      href: encodeURIComponent(location.href.split('?')[0]),
+    };
+    this.http
+      .post(`https://server.fmode.cn/api/wechat/getconfig`, params)
+      .subscribe((response) => {
+        // 返回的签名信息
+        let res: any = response;
+        const signPackage = res.data;
+        this.wxAppId = signPackage.appid;
+        this.wxpayEnabled = true;
+
+        wx.config({
+          debug: false, // 开启调试模式
+          appId: signPackage.appid, // 必填,公众号的唯一标识
+          timestamp: signPackage.timestamp, // 必填,生成签名的时间戳
+          nonceStr: signPackage.nonceStr, // 必填,生成签名的随机串
+          signature: signPackage.signature, // 必填,签名,见附录1
+          jsApiList: [
+            'chooseWXPay', // JSAPI微信支付
+            'onMenuShareTimeline', //分享到微信朋友圈
+            'onMenuShareAppMessage', //分享给微信朋友
+            'onMenuShareQQ', //分享到QQ
+            'onMenuShareQZone', //分享到QQ空间
+            'updateAppMessageShareData', //分享到微信及QQ(新接口)
+            'updateTimelineShareData', //分享到朋友圈”及“分享到QQ空间(新接口
+          ], // 必填,需要使用的JS接口列表,所有JS接口列表见附录2
+        });
+
+        let url = 'https://ai.fmode.cn';
+        let pathname = location.pathname;
+        url + pathname + '?invite=' + Parse.User.current()?.id;
+        let shareInfo = this.shareInfo || {
+          title: '爱聊', // 分享标题
+          desc: '全新互动1:1视频直播娱乐体验', // 分享描述
+          link: url, // 分享链接,该链接域名或路径必须与当前页面对应的公众号JS安全域名一致
+          type: 'link', //分享类型,music、video或link,不填默认为link
+          imgUrl:
+            'https://file-cloud.fmode.cn/E4KpGvTEto/20230822/3mkf41033623275.png', // 分享图标
+          success: function () {
+            // 设置成功
+            console.log('分享成功');
+          },
+          error: function () {
+            console.log('分享失败');
+          },
+          cancel: function () {
+            console.log('取消分享');
+          },
+        };
+
+        wx.ready(() => {
+          wx.updateAppMessageShareData(shareInfo); //分享到微信好友或者qq好友
+          wx.updateTimelineShareData(shareInfo); //分享到朋友圈或者qq空间
+        });
+        wx.error(() => {});
+      });
+  }
+
+  async saveAccountLog(
+    info: object,
+    orderid: string,
+    company: string,
+    message: any
+  ) {
+    let url = 'https://test.fmode.cn/api/apig/saveAccountLog';
+    return new Promise((res, rej) => {
+      this.http
+        .post(url, {
+          company: company,
+          uid: Parse.User.current()?.id,
+          orderid: orderid,
+          info: info,
+        })
+        .subscribe(
+          (data: any) => {
+            console.log(data);
+            res(true);
+          },
+          (err) => {
+            console.warn(err);
+            message && message.error('请求超时,请稍后再试');
+            rej();
+          }
+        );
+    });
+  }
+  setTradeNo() {
+    let now = new Date();
+    let tradeNo =
+      'C' +
+      this.company +
+      String(now.getFullYear()) +
+      (now.getMonth() + 1) +
+      now.getDate() +
+      now.getHours() +
+      now.getMinutes() +
+      now.getSeconds() +
+      now.getMilliseconds();
+    return tradeNo;
+  }
+
+  // 存支付记录
+  async setOrder(type: string, params: any, message?: any): Promise<any> {
+    let url = 'https://server.fmode.cn/api/apig/created-order';
+    return new Promise((res, rej) => {
+      this.http
+        .post(url, {
+          fcompany: this.company,
+          type: type,
+          gid: params.id,
+          uid: Parse.User.current()?.id,
+          params: params,
+        })
+        .subscribe(
+          (data: any) => {
+            //console.log(data);
+            res(data.data);
+          },
+          (err) => {
+            message?.error('网络错误,订单创建失败');
+            rej(err);
+          }
+        );
+    });
+  }
+}