vip.component.ts 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107
  1. import { Component, OnInit, ViewChild } from '@angular/core';
  2. import { ModalController, ToastController } from '@ionic/angular';
  3. import { NavComponent } from '../../../app/components/nav/nav.component';
  4. import { FormsModule } from '@angular/forms';
  5. import * as Parse from 'parse';
  6. import { AuthService } from '../../../services/auth.service';
  7. import { DatePipe, CommonModule } from '@angular/common';
  8. import { AgreementComponent } from '../../login/agreement/agreement.component';
  9. import { PayCompComponent } from '../../../app/components/pay-comp/pay-comp.component';
  10. import { AccountService } from '../../../services/account.service';
  11. import { ionicStandaloneModules } from '../../ionic-standalone.modules';
  12. @Component({
  13. selector: 'app-vip',
  14. templateUrl: './vip.component.html',
  15. styleUrls: ['./vip.component.scss'],
  16. standalone: true,
  17. imports: [
  18. ...ionicStandaloneModules,
  19. NavComponent,
  20. CommonModule,
  21. FormsModule,
  22. PayCompComponent,
  23. ],
  24. providers: [DatePipe],
  25. })
  26. export class VipComponent implements OnInit {
  27. @ViewChild('paycomp') paycomp!: PayCompComponent;
  28. user: any = Parse.User.current();
  29. profile?: Parse.Object;
  30. goodsList: Array<Parse.Object> = [];
  31. myVip: any;
  32. registerAgreement: any;
  33. isCheck: boolean = false;
  34. currentGoods?: Parse.Object; //当前选择的会员
  35. showPay: boolean = false;
  36. price: number = 0;
  37. tradeNo: string = ''; //支付单号
  38. orderId?: string;
  39. constructor(
  40. private modalController: ModalController,
  41. public toastController: ToastController,
  42. private authSer: AuthService,
  43. private datePipe: DatePipe,
  44. private accServ: AccountService
  45. ) {}
  46. ngOnInit() {
  47. this.refresh();
  48. }
  49. refresh() {
  50. this.getGoods();
  51. this.getUserVip();
  52. this.getAgreement();
  53. }
  54. //获取当前VIP等级
  55. async getUserVip() {
  56. this.myVip = await this.accServ.getVip()
  57. console.log(this.myVip);
  58. }
  59. async getGoods() {
  60. let goods = new Parse.Query('ShopGoods');
  61. goods.equalTo('company', this.authSer.company);
  62. goods.equalTo('type', 'vip');
  63. goods.equalTo('status', true);
  64. goods.ascending('top');
  65. goods.notEqualTo('isDeleted', true);
  66. goods.include('services');
  67. this.goodsList = await goods.find();
  68. this.currentGoods = this.goodsList[0];
  69. this.price = this.currentGoods?.get('price');
  70. }
  71. getAgreement() {
  72. let Agreement = new Parse.Query('ContractAgreement');
  73. Agreement.equalTo('company', this.authSer.company);
  74. Agreement.equalTo('type', 'register');
  75. Agreement.first().then((res) => {
  76. console.log(res);
  77. this.registerAgreement = res;
  78. });
  79. }
  80. async showAgreement() {
  81. const modal = await this.modalController.create({
  82. component: AgreementComponent,
  83. cssClass: 'my-custom-class',
  84. componentProps: {
  85. agreement: this.registerAgreement,
  86. },
  87. });
  88. return await modal.present();
  89. }
  90. onchang(data: Parse.Object) {
  91. this.currentGoods = data;
  92. this.price = this.currentGoods?.get('price');
  93. }
  94. onComplete(evet: any) {
  95. console.log(evet);
  96. // this.showPay = false;
  97. this.tradeNo = evet.tradeNo;
  98. this.getUserVip()
  99. }
  100. async openpay() {
  101. this.showPay = true;
  102. this.paycomp.isOpen = true;
  103. }
  104. }