Commit e243da46 authored by wangqinghua's avatar wangqinghua

抢购

parent 717c0366
......@@ -53,6 +53,7 @@ export class FoodPage {
ionViewDidEnter() {
this.myApply();
this.getApply();
this.getGoodsInfo();
}
ionViewDidLoad() {
......@@ -119,6 +120,14 @@ export class FoodPage {
)
}
getGoodsInfo(){
this.serveSer.getGoodsInfo().subscribe(
(res)=>{
}
)
}
getDate(e) {
this.date = e;
this.getApply();
......@@ -182,7 +191,7 @@ export class FoodPage {
//抢购 每天的14:00-17:00
buy() {
const nowDate = new Date().getTime();
const startTime = new Date(this.datePipe.transform(new Date(), 'yyyy-MM-dd') + ' 13:00:00').getTime();
const startTime = new Date(this.datePipe.transform(new Date(), 'yyyy-MM-dd') + ' 10:00:00').getTime();
const endTime = new Date(this.datePipe.transform(new Date(), 'yyyy-MM-dd') + ' 17:00:00').getTime();
if(startTime < nowDate && nowDate < endTime){
this.commonSer.toast('开始抢购');
......
......@@ -21,8 +21,9 @@
<div class="left">数量:</div>
<div class="right num">
<span class="reduce" (click)="reduce()">-</span>
<input type="number" value="1" [(ngModel)]="obj.amount">
<input type="number" value="1" [(ngModel)]="obj.peopleCount">
<span class="add" (click)="add()">+</span>
</div>
</div>
<button class="submit-btn submit" (click)="save()">提交</button>
</ion-content>
import {Component} from '@angular/core';
import {ActionSheetController, IonicPage, NavController, NavParams} from 'ionic-angular';
import {ServeService} from "../../serve.service";
import {CommonService} from "../../../../provide/common.service";
@Component({
selector: 'page-rush-buy',
......@@ -8,28 +10,42 @@ import {ActionSheetController, IonicPage, NavController, NavParams} from 'ionic-
export class RushBuyPage {
obj = {
amount: null,
peopleCount: 10,
food: '',
foodText: '请选择',
type: null,
unitPrice: null,
version: null
};
foodList;
constructor(public navCtrl: NavController, public navParams: NavParams,
private actionSheetCtrl: ActionSheetController) {
constructor(public navCtrl: NavController, public navParams: NavParams, private commonSer: CommonService,
private actionSheetCtrl: ActionSheetController, private serveSer: ServeService) {
}
ionViewDidLoad() {
console.log('ionViewDidLoad RushBuyPage');
this.getGoodsInfo();
}
getGoodsInfo() {
this.serveSer.getGoodsInfo().subscribe(
(res) => {
this.foodList = res.data;
}
)
}
chooseFood() {
const btnArr = this.foodList.map(e => {
const data = {
text: e.name,
text: e.goodsName,
role: e.id,
handler: () => {
// this.obj.orgId = e.id;
// this.obj.orgText = e.name;
this.obj.foodText = e.goodsName;
this.obj.version = e.version;
this.obj.unitPrice = e.unitPrice;
this.obj.type = e.id
}
};
return data;
......@@ -50,12 +66,32 @@ export class RushBuyPage {
//增加
add() {
if (this.obj.amount < 10) this.obj.amount ++;
if (this.obj.peopleCount < 10) this.obj.peopleCount++;
}
//减少
reduce() {
if (this.obj.amount > 1) this.obj.amount --;
if (this.obj.peopleCount > 1) this.obj.peopleCount--;
}
save() {
const data = {
diffFlag: '2',
type: this.obj.type,
peopleCount: this.obj.peopleCount,
unitPrice: this.obj.unitPrice,
version: this.obj.version
}
this.serveSer.saveMeals(data).subscribe(
(res) => {
if (res.errcode == "1000") {
this.commonSer.toast('抢购成功');
this.navCtrl.pop();
} else {
this.commonSer.toast(res.errmsg);
}
}
)
}
}
This diff is collapsed.
......@@ -11,9 +11,9 @@
<div class="padding-6">
<ion-item>
<ion-label class="item-left"><span class="color-red">*</span>用车时间:</ion-label>
<ion-datetime [disabled]="type == 'deal' " cancelText="取消" doneText="确认" displayFormat="YYYY-MM-DD HH:mm"
pickerFormat="YYYY MM DD HH mm" placeholder="请选择" [max]="obj.endTime" [min]="nowDate"
[(ngModel)]="obj.startTime"></ion-datetime>
<ion-datetime (ionChange)="changeStartTime($event)" [disabled]="type == 'deal' " cancelText="取消" doneText="确认" displayFormat="YYYY-MM-DD HH:mm"
pickerFormat="YYYY MM DD HH mm" placeholder="请选择" [max]="obj.endTimeChange" [min]="nowDate"
[(ngModel)]="obj.startTimeChange"></ion-datetime>
<ion-label class="right-arrow">
<ion-icon name="arrow-forward"></ion-icon>
</ion-label>
......@@ -21,9 +21,9 @@
</ion-item>
<ion-item>
<ion-label class="item-left"><span class="color-red">*</span>还车时间:</ion-label>
<ion-datetime [disabled]="type == 'deal' " cancelText="取消" doneText="确认" displayFormat="YYYY-MM-DD HH:mm"
pickerFormat="YYYY MM DD HH mm" placeholder="请选择" [min]="obj.startTime"
[(ngModel)]="obj.endTime"></ion-datetime>
<ion-datetime (ionChange)="changeEndTime($event)" [disabled]="type == 'deal' " cancelText="取消" doneText="确认" displayFormat="YYYY-MM-DD HH:mm"
pickerFormat="YYYY MM DD HH mm" placeholder="请选择" [min]="obj.startTimeChange"
[(ngModel)]="obj.endTimeChange"></ion-datetime>
<ion-label class="right-arrow">
<ion-icon name="arrow-forward"></ion-icon>
</ion-label>
......
......@@ -14,7 +14,9 @@ export class CarApplyPage {
obj = {
startTime: null,
startTimeChange: null,
endTime: null,
endTimeChange: null,
carUser: '',
useReason: '',
useText: '请选择',
......@@ -59,11 +61,8 @@ export class CarApplyPage {
if (data) {
} else {
this.obj.startTime = this.datePipe.transform(new Date(), 'yyyy-MM-ddTHH:mm');
this.obj.startTimeChange = this.datePipe.transform(new Date(), 'yyyy-MM-ddTHH:mm');
this.nowDate = this.datePipe.transform(new Date(), 'yyyy-MM-ddTHH:mm');
console.log(this.obj)
console.log(this.nowDate)
}
}
......@@ -91,6 +90,18 @@ export class CarApplyPage {
)
}
changeStartTime(e) {
const minute = e.minute > 9 ? e.minute : '0' + e.minute;
const hour = e.hour > 9 ? e.hour : '0' + e.hour;
this.obj.startTime = e.year + '-' + e.month + '-' + e.day + " " + hour + ":" + minute + ":00";
}
changeEndTime(e) {
const minute = e.minute > 9 ? e.minute : '0' + e.minute;
const hour = e.hour > 9 ? e.hour : '0' + e.hour;
this.obj.endTime = e.year + '-' + e.month + '-' + e.day + " " + hour + ":" + minute + ":00";
}
//选择事由
chooseReason() {
const buttonsArr = [
......@@ -200,14 +211,15 @@ export class CarApplyPage {
carUser.push(e.id);
});
const data = <any>{
startTime: new Date(this.obj.startTime).getTime() - 8 * 60 * 60 * 1000,
endTime: new Date(this.obj.endTime).getTime() - 8 * 60 * 60 * 1000,
startTime: new Date(this.obj.startTime).getTime(),
endTime: new Date(this.obj.endTime).getTime(),
passengerCount: this.obj.passengerCount,
carUser: carUser.join(","),
useReason: this.obj.useReason,
fromTo: this.obj.fromTo,
};
if (this.applyId) data.id = this.applyId;
console.log(data);
this.commonSer.alert('确认提交?', () => {
this.serveSer.saveCarApply(data).subscribe(
(res) => {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment