123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114 |
- import { Component, OnInit, ViewChild } from '@angular/core';
- import { ModalController, ToastController } 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 { AgreementComponent } from '../../login/agreement/agreement.component';
- import { PayCompComponent } from '../../../app/components/pay-comp/pay-comp.component';
- import { AccountService } from '../../../services/account.service';
- import { ionicStandaloneModules } from '../../ionic-standalone.modules';
- import { Router } from '@angular/router';
- import { AvatarComponent } from '../../../app/components/avatar/avatar.component';
- @Component({
- selector: 'app-vip',
- templateUrl: './vip.component.html',
- styleUrls: ['./vip.component.scss'],
- standalone: true,
- imports: [
- ...ionicStandaloneModules,
- NavComponent,
- CommonModule,
- FormsModule,
- PayCompComponent,
- AvatarComponent
- ],
- 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;
- currentGoods?: Parse.Object;
- showPay: boolean = false;
- price: number = 0;
- tradeNo: string = '';
- orderId?: string;
- loading: boolean = true;
- constructor(
- private modalController: ModalController,
- public toastController: ToastController,
- private authSer: AuthService,
- private accServ: AccountService,
- private router: Router,
- ) {}
- ngOnInit() {
- this.refresh();
- }
- async refresh() {
- await this.getGoods();
- await this.getUserVip();
- this.getAgreement();
- this.loading = false;
- }
-
- async getUserVip() {
- this.myVip = await this.accServ.getVip()
- }
- async getGoods() {
- let goods = new Parse.Query('ShopGoods');
- goods.equalTo('company', this.authSer.company);
- goods.equalTo('type', 'vip');
- goods.equalTo('status', true);
- goods.ascending('top');
- goods.notEqualTo('isDeleted', true);
- goods.include('services');
- this.goodsList = await goods.find();
- this.currentGoods = this.goodsList[0];
- this.price = this.currentGoods?.get('price');
- }
- getAgreement() {
- let Agreement = new Parse.Query('ContractAgreement');
- Agreement.equalTo('company', this.authSer.company);
- Agreement.equalTo('type', 'service');
- Agreement.first().then((res) => {
- console.log(res);
- this.registerAgreement = res;
- });
- }
- async showAgreement() {
- const modal = await this.modalController.create({
- component: AgreementComponent,
- cssClass: 'my-custom-class',
- componentProps: {
- agreement: this.registerAgreement,
- },
- });
- return await modal.present();
- }
- onchang(data: Parse.Object) {
- this.currentGoods = data;
- this.price = this.currentGoods?.get('price');
- }
- onComplete(evet: any) {
- console.log(evet);
-
- this.tradeNo = evet.tradeNo;
- this.getUserVip()
- }
- async openpay() {
- this.showPay = true;
- this.paycomp.isOpen = true;
- }
- toUrl(url: string){
- this.router.navigate([url]);
- }
- }
|