Commit 46613ff7 authored by wangqinghua's avatar wangqinghua

抢购

parent 3b95fc1c
#Sun Aug 18 15:09:53 CST 2019 #Sun Aug 18 17:34:03 CST 2019
base.0=/Users/ben/gitLab-project/party-build-cloud/platforms/android/app/build/intermediates/transforms/dexMerger/debug/0 base.0=/Users/ben/gitLab-project/party-build-cloud/platforms/android/app/build/intermediates/transforms/dexMerger/debug/0
renamed.0=classes.dex renamed.0=classes.dex
file.0=/Users/ben/gitLab-project/party-build-cloud/platforms/android/app/build/intermediates/transforms/dexMerger/debug/0/classes.dex file.0=/Users/ben/gitLab-project/party-build-cloud/platforms/android/app/build/intermediates/transforms/dexMerger/debug/0/classes.dex
...@@ -144,7 +144,7 @@ ...@@ -144,7 +144,7 @@
loadingSpinner="bubbles" loadingSpinner="bubbles"
loadingText="加载中"></ion-infinite-scroll-content> loadingText="加载中"></ion-infinite-scroll-content>
</ion-infinite-scroll> </ion-infinite-scroll>
<ion-fab *ngIf="canShop" right bottom> <ion-fab right bottom>
<button ion-fab color="light" (click)="buy()"> <button ion-fab color="light" (click)="buy()">
<div class="loader"> <div class="loader">
<div class="rotation"> <div class="rotation">
......
...@@ -44,12 +44,10 @@ export class FoodPage { ...@@ -44,12 +44,10 @@ export class FoodPage {
isLoad: true isLoad: true
}; };
canShop = false;
constructor(public navCtrl: NavController, public navParams: NavParams, constructor(public navCtrl: NavController, public navParams: NavParams,
private serveSer: ServeService, public datePipe: DatePipe, private serveSer: ServeService, public datePipe: DatePipe,
private commonSer: CommonService, private appMainSer: AppMainService) { private commonSer: CommonService, private appMainSer: AppMainService) {
this.getGoodsInfo();
} }
ionViewDidEnter() { ionViewDidEnter() {
...@@ -121,18 +119,6 @@ export class FoodPage { ...@@ -121,18 +119,6 @@ export class FoodPage {
) )
} }
//isPurchasing 0不再时间段 1可以抢购 2已抢完
getGoodsInfo() {
this.serveSer.getGoodsInfo().subscribe(
(res) => {
if (res.data.length > 0) {
const arr = res.data.filter(e=>e.isPurchasing = 1);
if(arr.length > 0) this.canShop = true;
}
}
)
}
getDate(e) { getDate(e) {
this.date = e; this.date = e;
this.getApply(); this.getApply();
...@@ -195,13 +181,24 @@ export class FoodPage { ...@@ -195,13 +181,24 @@ export class FoodPage {
//抢购 每天的14:00-17:00 //抢购 每天的14:00-17:00
buy() { buy() {
const nowDate = new Date().getTime(); this.serveSer.getGoodsInfo().subscribe(
const startTime = new Date(this.datePipe.transform(new Date(), 'yyyy-MM-dd') + ' 14:00:00').getTime(); (res) => {
const endTime = new Date(this.datePipe.transform(new Date(), 'yyyy-MM-dd') + ' 17:00:00').getTime(); if (res.data && res.data.length > 0) {
if (startTime < nowDate && nowDate < endTime) { const arr = res.data.filter(e=>e.isPurchasing == 0);
this.navCtrl.push(RushBuyPage); if(arr.length > 0) {
} else { this.navCtrl.push(RushBuyPage);
this.commonSer.toast("抢购时间为每天的14:00~17:00"); }else{
} this.commonSer.toast('未到抢购时间')
}
} else {
this.commonSer.toast('未到抢购时间')
}
}
)
}
//isPurchasing 0不再时间段 1可以抢购 2已抢完
getGoodsInfo() {
} }
} }
<ion-header> <ion-header>
<ion-navbar> <ion-navbar>
<ion-title>抢购</ion-title> <ion-title>抢购</ion-title>
</ion-navbar> </ion-navbar>
</ion-header> </ion-header>
<ion-content> <ion-content>
<ion-item (click)="chooseFood()"> <ion-item (click)="chooseFood()">
<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-label [ngStyle]="{'color':obj.foodText == '请选择'?'#999':'#333'}" <ion-label [ngStyle]="{'color':obj.foodText == '请选择'?'#999':'#333'}"
class="choose">{{obj.foodText}}</ion-label> class="choose">{{obj.foodText}}</ion-label>
<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>
</ion-item> </ion-item>
<div class="item-box"> <div class="item-box">
<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.peopleCount"> <input type="number" value="1" [(ngModel)]="obj.peopleCount">
<span class="add" (click)="add()">+</span> <span class="add" (click)="add()">+</span>
</div>
</div> </div>
</div> <p class="buy-remark">{{obj.remark}}</p>
<button class="submit-btn submit" (click)="save()">提交</button> <button class="submit-btn submit" (click)="save()">提交</button>
</ion-content> </ion-content>
page-rush-buy { page-rush-buy {
.num { .num {
text-align: right; text-align: right;
input { input {
width: 40px; width: 40px;
height: 24px; height: 24px;
...@@ -11,7 +12,8 @@ page-rush-buy { ...@@ -11,7 +12,8 @@ page-rush-buy {
border: 1px solid #f2f2f2; border: 1px solid #f2f2f2;
margin: 0 8px; margin: 0 8px;
} }
span{
span {
font-size: 2.5rem; font-size: 2.5rem;
font-weight: bold; font-weight: bold;
vertical-align: initial; vertical-align: initial;
...@@ -40,7 +42,8 @@ page-rush-buy { ...@@ -40,7 +42,8 @@ page-rush-buy {
text-align: right; text-align: right;
font-size: 1.4rem; font-size: 1.4rem;
} }
ion-datetime{
ion-datetime {
padding-right: 18px !important; padding-right: 18px !important;
} }
...@@ -130,4 +133,10 @@ page-rush-buy { ...@@ -130,4 +133,10 @@ page-rush-buy {
} }
} }
.buy-remark {
padding: 20px;
color: #666;
letter-spacing: 1px;
}
} }
import {Component} from '@angular/core'; import {Component} from '@angular/core';
import {ActionSheetController, IonicPage, NavController, NavParams} from 'ionic-angular'; import {ActionSheetController, IonicPage, LoadingController, NavController, NavParams} from 'ionic-angular';
import {ServeService} from "../../serve.service"; import {ServeService} from "../../serve.service";
import {CommonService} from "../../../../provide/common.service"; import {CommonService} from "../../../../provide/common.service";
...@@ -15,12 +15,14 @@ export class RushBuyPage { ...@@ -15,12 +15,14 @@ export class RushBuyPage {
foodText: '请选择', foodText: '请选择',
type: null, type: null,
unitPrice: null, unitPrice: null,
version: null version: null,
remark:null
}; };
foodList; foodList;
constructor(public navCtrl: NavController, public navParams: NavParams, private commonSer: CommonService, constructor(public navCtrl: NavController, public navParams: NavParams, private commonSer: CommonService,
private actionSheetCtrl: ActionSheetController, private serveSer: ServeService) { private actionSheetCtrl: ActionSheetController, private serveSer: ServeService,
private loadCtrl: LoadingController) {
} }
ionViewDidLoad() { ionViewDidLoad() {
...@@ -32,6 +34,11 @@ export class RushBuyPage { ...@@ -32,6 +34,11 @@ export class RushBuyPage {
this.serveSer.getGoodsInfo().subscribe( this.serveSer.getGoodsInfo().subscribe(
(res) => { (res) => {
this.foodList = res.data; this.foodList = res.data;
this.obj.foodText = this.foodList[0].goodsName;
this.obj.version = this.foodList[0].version;
this.obj.unitPrice = this.foodList[0].unitPrice;
this.obj.type = this.foodList[0].id
this.obj.remark = this.foodList[0].remark
} }
) )
} }
...@@ -79,15 +86,20 @@ export class RushBuyPage { ...@@ -79,15 +86,20 @@ export class RushBuyPage {
this.commonSer.toast('请选择物品'); this.commonSer.toast('请选择物品');
return false; return false;
} }
const loading = this.loadCtrl.create({
content: '抢购中...',
});
loading.present();
const data = { const data = {
diffFlag: '2', diffFlag: '2',
type: this.obj.type, type: this.obj.type,
peopleCount: this.obj.peopleCount, peopleCount: this.obj.peopleCount,
unitPrice: this.obj.unitPrice, unitPrice: this.obj.unitPrice,
version: this.obj.version version: this.obj.version
} };
this.serveSer.saveMeals(data).subscribe( this.serveSer.saveMeals(data).subscribe(
(res) => { (res) => {
loading.dismiss();
if (res.errcode == "1000") { if (res.errcode == "1000") {
this.commonSer.toast('抢购成功'); this.commonSer.toast('抢购成功');
this.navCtrl.pop(); this.navCtrl.pop();
......
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