123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100 |
- import { Component, OnInit } 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 { AgreementComponent } from '../../login/agreement/agreement.component';
- @Component({
- selector: 'app-vip',
- templateUrl: './vip.component.html',
- styleUrls: ['./vip.component.scss'],
- standalone: true,
- imports: [IonicModule, NavComponent, CommonModule,FormsModule],
- providers: [DatePipe],
- })
- export class VipComponent implements OnInit {
- user: any = Parse.User.current();
- profile?: Parse.Object;
- goodsList: Array<Parse.Object> = [];
- myVip: any;
- registerAgreement: any;
- isCheck:boolean = false;
- currentGoods?: Parse.Object; //当前选择的会员
- constructor(
- private modalController: ModalController,
- private authSer: AuthService,
- private datePipe: DatePipe
- ) {}
- ngOnInit() {
- this.refresh();
- }
- refresh() {
- this.getGoods();
- this.getUserVip();
- this.getAgreement();
- }
- //获取当前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;
- }
- }
- 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];
- }
- getAgreement() {
- let Agreement = new Parse.Query('ContractAgreement');
- Agreement.equalTo('company', this.authSer.company);
- Agreement.equalTo('type', 'register');
- 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;
- }
- openpay(){
- if(this.isCheck){
- // this.authSer.openPay(this.currentGoods);
- }else{
- this.showAgreement();
- }
- }
- }
|