Commit e243da46 authored by wangqinghua's avatar wangqinghua

抢购

parent 717c0366
...@@ -53,6 +53,7 @@ export class FoodPage { ...@@ -53,6 +53,7 @@ export class FoodPage {
ionViewDidEnter() { ionViewDidEnter() {
this.myApply(); this.myApply();
this.getApply(); this.getApply();
this.getGoodsInfo();
} }
ionViewDidLoad() { ionViewDidLoad() {
...@@ -119,6 +120,14 @@ export class FoodPage { ...@@ -119,6 +120,14 @@ export class FoodPage {
) )
} }
getGoodsInfo(){
this.serveSer.getGoodsInfo().subscribe(
(res)=>{
}
)
}
getDate(e) { getDate(e) {
this.date = e; this.date = e;
this.getApply(); this.getApply();
...@@ -182,7 +191,7 @@ export class FoodPage { ...@@ -182,7 +191,7 @@ export class FoodPage {
//抢购 每天的14:00-17:00 //抢购 每天的14:00-17:00
buy() { buy() {
const nowDate = new Date().getTime(); 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(); const endTime = new Date(this.datePipe.transform(new Date(), 'yyyy-MM-dd') + ' 17:00:00').getTime();
if(startTime < nowDate && nowDate < endTime){ if(startTime < nowDate && nowDate < endTime){
this.commonSer.toast('开始抢购'); this.commonSer.toast('开始抢购');
......
...@@ -21,8 +21,9 @@ ...@@ -21,8 +21,9 @@
<div class="left">数量:</div> <div class="left">数量:</div>
<div class="right num"> <div class="right num">
<span class="reduce" (click)="reduce()">-</span> <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> <span class="add" (click)="add()">+</span>
</div> </div>
</div> </div>
<button class="submit-btn submit" (click)="save()">提交</button>
</ion-content> </ion-content>
import {Component} from '@angular/core'; import {Component} from '@angular/core';
import {ActionSheetController, IonicPage, NavController, NavParams} from 'ionic-angular'; import {ActionSheetController, IonicPage, NavController, NavParams} from 'ionic-angular';
import {ServeService} from "../../serve.service";
import {CommonService} from "../../../../provide/common.service";
@Component({ @Component({
selector: 'page-rush-buy', selector: 'page-rush-buy',
...@@ -8,28 +10,42 @@ import {ActionSheetController, IonicPage, NavController, NavParams} from 'ionic- ...@@ -8,28 +10,42 @@ import {ActionSheetController, IonicPage, NavController, NavParams} from 'ionic-
export class RushBuyPage { export class RushBuyPage {
obj = { obj = {
amount: null, peopleCount: 10,
food: '', food: '',
foodText: '请选择', foodText: '请选择',
type: null,
unitPrice: null,
version: null
}; };
foodList; foodList;
constructor(public navCtrl: NavController, public navParams: NavParams, constructor(public navCtrl: NavController, public navParams: NavParams, private commonSer: CommonService,
private actionSheetCtrl: ActionSheetController) { private actionSheetCtrl: ActionSheetController, private serveSer: ServeService) {
} }
ionViewDidLoad() { ionViewDidLoad() {
console.log('ionViewDidLoad RushBuyPage'); console.log('ionViewDidLoad RushBuyPage');
this.getGoodsInfo();
}
getGoodsInfo() {
this.serveSer.getGoodsInfo().subscribe(
(res) => {
this.foodList = res.data;
}
)
} }
chooseFood() { chooseFood() {
const btnArr = this.foodList.map(e => { const btnArr = this.foodList.map(e => {
const data = { const data = {
text: e.name, text: e.goodsName,
role: e.id, role: e.id,
handler: () => { handler: () => {
// this.obj.orgId = e.id; this.obj.foodText = e.goodsName;
// this.obj.orgText = e.name; this.obj.version = e.version;
this.obj.unitPrice = e.unitPrice;
this.obj.type = e.id
} }
}; };
return data; return data;
...@@ -50,12 +66,32 @@ export class RushBuyPage { ...@@ -50,12 +66,32 @@ export class RushBuyPage {
//增加 //增加
add() { add() {
if (this.obj.amount < 10) this.obj.amount ++; if (this.obj.peopleCount < 10) this.obj.peopleCount++;
} }
//减少 //减少
reduce() { 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 @@ ...@@ -11,9 +11,9 @@
<div class="padding-6"> <div class="padding-6">
<ion-item> <ion-item>
<ion-label class="item-left"><span class="color-red">*</span>用车时间:</ion-label> <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" <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.endTime" [min]="nowDate" pickerFormat="YYYY MM DD HH mm" placeholder="请选择" [max]="obj.endTimeChange" [min]="nowDate"
[(ngModel)]="obj.startTime"></ion-datetime> [(ngModel)]="obj.startTimeChange"></ion-datetime>
<ion-label class="right-arrow"> <ion-label class="right-arrow">
<ion-icon name="arrow-forward"></ion-icon> <ion-icon name="arrow-forward"></ion-icon>
</ion-label> </ion-label>
...@@ -21,9 +21,9 @@ ...@@ -21,9 +21,9 @@
</ion-item> </ion-item>
<ion-item> <ion-item>
<ion-label class="item-left"><span class="color-red">*</span>还车时间:</ion-label> <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" <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.startTime" pickerFormat="YYYY MM DD HH mm" placeholder="请选择" [min]="obj.startTimeChange"
[(ngModel)]="obj.endTime"></ion-datetime> [(ngModel)]="obj.endTimeChange"></ion-datetime>
<ion-label class="right-arrow"> <ion-label class="right-arrow">
<ion-icon name="arrow-forward"></ion-icon> <ion-icon name="arrow-forward"></ion-icon>
</ion-label> </ion-label>
......
...@@ -14,7 +14,9 @@ export class CarApplyPage { ...@@ -14,7 +14,9 @@ export class CarApplyPage {
obj = { obj = {
startTime: null, startTime: null,
startTimeChange: null,
endTime: null, endTime: null,
endTimeChange: null,
carUser: '', carUser: '',
useReason: '', useReason: '',
useText: '请选择', useText: '请选择',
...@@ -59,11 +61,8 @@ export class CarApplyPage { ...@@ -59,11 +61,8 @@ export class CarApplyPage {
if (data) { if (data) {
} else { } 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'); 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 { ...@@ -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() { chooseReason() {
const buttonsArr = [ const buttonsArr = [
...@@ -200,14 +211,15 @@ export class CarApplyPage { ...@@ -200,14 +211,15 @@ export class CarApplyPage {
carUser.push(e.id); carUser.push(e.id);
}); });
const data = <any>{ const data = <any>{
startTime: new Date(this.obj.startTime).getTime() - 8 * 60 * 60 * 1000, startTime: new Date(this.obj.startTime).getTime(),
endTime: new Date(this.obj.endTime).getTime() - 8 * 60 * 60 * 1000, endTime: new Date(this.obj.endTime).getTime(),
passengerCount: this.obj.passengerCount, passengerCount: this.obj.passengerCount,
carUser: carUser.join(","), carUser: carUser.join(","),
useReason: this.obj.useReason, useReason: this.obj.useReason,
fromTo: this.obj.fromTo, fromTo: this.obj.fromTo,
}; };
if (this.applyId) data.id = this.applyId; if (this.applyId) data.id = this.applyId;
console.log(data);
this.commonSer.alert('确认提交?', () => { this.commonSer.alert('确认提交?', () => {
this.serveSer.saveCarApply(data).subscribe( this.serveSer.saveCarApply(data).subscribe(
(res) => { (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