dev #13306
исправил ошибку отсутствия номера телефона при заказе, поправил модель данных заказа, добавил автоматическую смену даты выдачи раз в минуту
This commit is contained in:
parent
e7a389b484
commit
1960c6a7d3
@ -1,4 +1,4 @@
|
|||||||
import { Component, EventEmitter, OnInit, Output } from '@angular/core';
|
import { Component, EventEmitter, OnDestroy, OnInit, Output } from '@angular/core';
|
||||||
import { FormBuilder, FormGroup, Validators } from '@angular/forms';
|
import { FormBuilder, FormGroup, Validators } from '@angular/forms';
|
||||||
import { DeliveryData, DeliveryType, PaymentMethod, UserData } from 'src/app/interface/data';
|
import { DeliveryData, DeliveryType, PaymentMethod, UserData } from 'src/app/interface/data';
|
||||||
import { paymentMethods } from "../../app.constants";
|
import { paymentMethods } from "../../app.constants";
|
||||||
@ -24,7 +24,7 @@ import { lastValueFrom } from 'rxjs';
|
|||||||
templateUrl: './user-data-order.component.html',
|
templateUrl: './user-data-order.component.html',
|
||||||
styleUrls: ['./user-data-order.component.scss']
|
styleUrls: ['./user-data-order.component.scss']
|
||||||
})
|
})
|
||||||
export class UserDataOrderComponent implements OnInit {
|
export class UserDataOrderComponent implements OnInit, OnDestroy {
|
||||||
|
|
||||||
@Output() orderSubmitted = new EventEmitter<void>();
|
@Output() orderSubmitted = new EventEmitter<void>();
|
||||||
readonly cities = environment.cities;
|
readonly cities = environment.cities;
|
||||||
@ -40,6 +40,7 @@ export class UserDataOrderComponent implements OnInit {
|
|||||||
public showMyMessage: boolean = false;
|
public showMyMessage: boolean = false;
|
||||||
public order!: Order;
|
public order!: Order;
|
||||||
public showAuthoriztion = false;
|
public showAuthoriztion = false;
|
||||||
|
private intervalTimeDelivery!: any
|
||||||
|
|
||||||
public userData: UserData = {
|
public userData: UserData = {
|
||||||
first_name: null,
|
first_name: null,
|
||||||
@ -87,6 +88,11 @@ export class UserDataOrderComponent implements OnInit {
|
|||||||
}
|
}
|
||||||
})
|
})
|
||||||
this.deliverData.deliveryDate = moment().add(this.checkoutConfig?.timeDelivery?.changeTime?.defaultValue || 0, 'minutes').toDate()
|
this.deliverData.deliveryDate = moment().add(this.checkoutConfig?.timeDelivery?.changeTime?.defaultValue || 0, 'minutes').toDate()
|
||||||
|
this.intervalTimeDelivery = setInterval(() => {
|
||||||
|
this.mainFormGroup.controls['deliveryDataForm'].patchValue({
|
||||||
|
deliveryDate: moment().add(this.checkoutConfig?.timeDelivery?.changeTime?.defaultValue || 0, 'minutes').toDate()
|
||||||
|
})
|
||||||
|
}, 60_000)
|
||||||
this.paymentMethods = this.checkoutConfig.payments.values
|
this.paymentMethods = this.checkoutConfig.payments.values
|
||||||
this.deliverData.paymentMethod = this.paymentMethods[this.checkoutConfig.payments.default]
|
this.deliverData.paymentMethod = this.paymentMethods[this.checkoutConfig.payments.default]
|
||||||
|
|
||||||
@ -115,6 +121,7 @@ export class UserDataOrderComponent implements OnInit {
|
|||||||
}
|
}
|
||||||
|
|
||||||
phoneConfirmed() {
|
phoneConfirmed() {
|
||||||
|
this._createMainForm();
|
||||||
this.showAuthoriztion = false
|
this.showAuthoriztion = false
|
||||||
this.checkAuthorization(true)
|
this.checkAuthorization(true)
|
||||||
}
|
}
|
||||||
@ -203,7 +210,7 @@ export class UserDataOrderComponent implements OnInit {
|
|||||||
this.loading = false;
|
this.loading = false;
|
||||||
}
|
}
|
||||||
catch (e) {
|
catch (e) {
|
||||||
console.error('Erroe: ', e);
|
console.error('Error: ', e);
|
||||||
|
|
||||||
this.messageService.add({
|
this.messageService.add({
|
||||||
severity: 'error',
|
severity: 'error',
|
||||||
@ -241,5 +248,9 @@ export class UserDataOrderComponent implements OnInit {
|
|||||||
comment: [this.deliverData.comment, [Validators.maxLength(255),]]
|
comment: [this.deliverData.comment, [Validators.maxLength(255),]]
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ngOnDestroy(): void {
|
||||||
|
clearInterval(this.intervalTimeDelivery)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -44,7 +44,7 @@ export class Order {
|
|||||||
paymentsystem: this.deliveryData?.paymentMethod?.type,
|
paymentsystem: this.deliveryData?.paymentMethod?.type,
|
||||||
phone: this.phone,
|
phone: this.phone,
|
||||||
persons: 1,
|
persons: 1,
|
||||||
name: "31",
|
name: this.userData?.first_name,
|
||||||
payment: {
|
payment: {
|
||||||
delivery_price: 100,
|
delivery_price: 100,
|
||||||
products: this.products.map(product => {
|
products: this.products.map(product => {
|
||||||
@ -54,7 +54,7 @@ export class Order {
|
|||||||
subtotal: this.price,
|
subtotal: this.price,
|
||||||
delivery_comment: this.deliveryData?.comment,
|
delivery_comment: this.deliveryData?.comment,
|
||||||
delivery: this.deliveryData?.deliveryType?.type,
|
delivery: this.deliveryData?.deliveryType?.type,
|
||||||
delivery_address: this.deliveryData?.deliveryType?.type === "self_delivery" ? null : `${environment.cities[0]}, ул ${this.userData?.street}, ${this.userData?.house}`,
|
delivery_address: this.deliveryData?.deliveryType?.type === "self_delivery" ? '' : `${environment.cities[0]}, ул ${this.userData?.street}, ${this.userData?.house}`,
|
||||||
amount: this.price + 100,
|
amount: this.price + 100,
|
||||||
terminal_id: this.terminal_id
|
terminal_id: this.terminal_id
|
||||||
},
|
},
|
||||||
|
|||||||
@ -3,6 +3,7 @@
|
|||||||
[fullScreen]="isFullScreen"
|
[fullScreen]="isFullScreen"
|
||||||
[baseZIndex]="10000"
|
[baseZIndex]="10000"
|
||||||
position="right"
|
position="right"
|
||||||
|
(onHide)="hide()"
|
||||||
>
|
>
|
||||||
<div
|
<div
|
||||||
class="cart"
|
class="cart"
|
||||||
|
|||||||
@ -45,6 +45,10 @@ export class CartComponent implements OnInit {
|
|||||||
this.loadCart()
|
this.loadCart()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
hide() {
|
||||||
|
this.orderConfirmed = false;
|
||||||
|
}
|
||||||
|
|
||||||
changeDullScreenMode() {
|
changeDullScreenMode() {
|
||||||
if (this.width < 650) {
|
if (this.width < 650) {
|
||||||
this.isFullScreen = true
|
this.isFullScreen = true
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user