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
renamed.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 @@
loadingSpinner="bubbles"
loadingText="加载中"></ion-infinite-scroll-content>
</ion-infinite-scroll>
<ion-fab *ngIf="canShop" right bottom>
<ion-fab right bottom>
<button ion-fab color="light" (click)="buy()">
<div class="loader">
<div class="rotation">
......
......@@ -44,12 +44,10 @@ export class FoodPage {
isLoad: true
};
canShop = false;
constructor(public navCtrl: NavController, public navParams: NavParams,
private serveSer: ServeService, public datePipe: DatePipe,
private commonSer: CommonService, private appMainSer: AppMainService) {
this.getGoodsInfo();
}
ionViewDidEnter() {
......@@ -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) {
this.date = e;
this.getApply();
......@@ -195,13 +181,24 @@ 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') + ' 14: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.serveSer.getGoodsInfo().subscribe(
(res) => {
if (res.data && res.data.length > 0) {
const arr = res.data.filter(e=>e.isPurchasing == 0);
if(arr.length > 0) {
this.navCtrl.push(RushBuyPage);
}else{
this.commonSer.toast('未到抢购时间')
}
} else {
this.commonSer.toast("抢购时间为每天的14:00~17:00");
this.commonSer.toast('未到抢购时间')
}
}
)
}
//isPurchasing 0不再时间段 1可以抢购 2已抢完
getGoodsInfo() {
}
}
<ion-header>
<ion-navbar>
......@@ -25,5 +24,6 @@
<span class="add" (click)="add()">+</span>
</div>
</div>
<p class="buy-remark">{{obj.remark}}</p>
<button class="submit-btn submit" (click)="save()">提交</button>
</ion-content>
page-rush-buy {
.num {
text-align: right;
input {
width: 40px;
height: 24px;
......@@ -11,7 +12,8 @@ page-rush-buy {
border: 1px solid #f2f2f2;
margin: 0 8px;
}
span{
span {
font-size: 2.5rem;
font-weight: bold;
vertical-align: initial;
......@@ -40,7 +42,8 @@ page-rush-buy {
text-align: right;
font-size: 1.4rem;
}
ion-datetime{
ion-datetime {
padding-right: 18px !important;
}
......@@ -130,4 +133,10 @@ page-rush-buy {
}
}
.buy-remark {
padding: 20px;
color: #666;
letter-spacing: 1px;
}
}
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 {CommonService} from "../../../../provide/common.service";
......@@ -15,12 +15,14 @@ export class RushBuyPage {
foodText: '请选择',
type: null,
unitPrice: null,
version: null
version: null,
remark:null
};
foodList;
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() {
......@@ -32,6 +34,11 @@ export class RushBuyPage {
this.serveSer.getGoodsInfo().subscribe(
(res) => {
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 {
this.commonSer.toast('请选择物品');
return false;
}
const loading = this.loadCtrl.create({
content: '抢购中...',
});
loading.present();
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) => {
loading.dismiss();
if (res.errcode == "1000") {
this.commonSer.toast('抢购成功');
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