vip.component.ts 3.4 KB

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