如何使用离子平台在移动设备中获取应用历史记录

时间:2018-06-07 05:46:13

标签: angular ionic-framework

当我收到错误时,它会重叠,我该如何解决它。当我下订单并发送到数据库。当前的订单没有显示我订购的商品。

这是我的HTML代码:

<ion-header>

  <ion-navbar>
    <ion-title>History</ion-title>
  </ion-navbar>
  <ion-toolbar no-border-top>
      <ion-segment [(ngModel)]="pet">
        <ion-segment-button value="currentorders">
          Current Orders
        </ion-segment-button>
        <ion-segment-button value="history">
          History
        </ion-segment-button>
      </ion-segment>
  </ion-toolbar>
</ion-header>


<ion-content>
    <ng-container *ngIf="Cart?.CART?.length > 0; else HistoryEmpty;">
    <div [ngSwitch]="pet">
      <ion-list *ngSwitchCase="'currentorders'">
        <ion-item *ngFor="let iMenuItem of Cart.CART">
          <!-- <ion-thumbnail item-start>
            <img src="assets/img/thumbnail-puppy-1.jpg">
          </ion-thumbnail>
          <h2>Ruby</h2> -->
          <ion-label>
              <div class="label-wrapper">
                <ion-avatar item-start>
                  <img [src]="iMenuItem.imageURL">
                </ion-avatar>
                <div>
                  <h2 text-capitalize>{{iMenuItem.name}}</h2>
                  <h3 *ngIf="iMenuItem.quantity > 1">Ordered {{iMenuItem.quantity}} items</h3>
                  <p class="item-desc">
                    <ion-note>{{iMenuItem.userNotes}}</ion-note>
                  </p>
                  <div class="notes-layout">
                    <ion-note [style.width.%]="50">
                      <span *ngIf="iMenuItem.quantity > 1">Total </span>
                      <!-- <span>{{currency[iMenuItem.currency]}}.</span>&nbsp; -->
                      <span>{{iMenuItem.price}}</span>
                    </ion-note>
                    <ion-note>{{iMenuItem.size}}</ion-note>
                  </div>
                </div>
              </div>
            </ion-label>
        </ion-item>
      </ion-list>

      <ion-list *ngSwitchCase="'history'">
        <!-- <ion-item>
          <ion-thumbnail item-start>
            <img src="assets/img/thumbnail-kitten-1.jpg">
          </ion-thumbnail>
          <h2>Luna</h2>
        </ion-item>
        <ion-item>
          <ion-thumbnail item-start>
            <img src="assets/img/thumbnail-kitten-3.jpg">
          </ion-thumbnail>
          <h2>Milo</h2>
        </ion-item>
        <ion-item>
          <ion-thumbnail item-start>
            <img src="assets/img/thumbnail-kitten-4.jpg">
          </ion-thumbnail>
          <h2>Bandit</h2>
        </ion-item>
        <ion-item>
          <ion-thumbnail item-start>
            <img src="assets/img/thumbnail-kitten-2.jpg">
          </ion-thumbnail>
          <h2>Nala</h2>
        </ion-item> -->
      </ion-list>
    </div>
    </ng-container>
    <ng-template #HistoryEmpty>
        <div class="sintetic-grid" [style.height.%]="100">
          <ion-note text-center padding [style.width.%]="100">
            <h1>No items here yet...</h1>
          </ion-note>
        </div>
      </ng-template>
  </ion-content>

这是我的.ts文件,在这里我收到了错误。当我发送订单时,它不显示在当前订单选项卡中。我该怎么解决呢。

import { Component, Renderer2 } from '@angular/core';
import { IonicPage, NavController, NavParams, Events, PopoverController } from 'ionic-angular';
import { CartWidgetComponent } from '../../components';
import { Cart, IMenuItem, IDb } from '../../interfaces';
import { IDatasetIteratorLambdaObjectInfo, ShoppingCart, StorageProvider } from '../../providers';
import { APP_EV, Currency, DATABASE_TOKENS, PopoverCartMenuEventFlags, APP_QUICK_ORDER_PAGE, ANGULAR_ANIMATION_OPACITY } from '../pages.constants';

@IonicPage()
@Component({
  selector: 'page-search',
  templateUrl: 'search.html',
})
export class SearchPage {

  Cart: IDb;
  // constructor(public navCtrl: NavController, public navParams: NavParams) {
  // }

  constructor(
    private _navCtrl: NavController,
    public navParams: NavParams,
    private _renderer2: Renderer2,
    private _events: Events,
    private _popoverCtrl: PopoverController,
    public shoppingCartCtrl: ShoppingCart,
    private _storageProvider: StorageProvider) {
    this._getItems();
  }

  ionViewDidLoad() {
    console.log('ionViewDidLoad SearchPage');
  }

  pet: string = "puppies";
  isAndroid: boolean = false;

  private _setMetaProps(Cart: IDb) {
    this.shoppingCartCtrl.datasetIterator(Cart, ({ menuItem }: IDatasetIteratorLambdaObjectInfo) => {
      if (typeof menuItem.meta !== 'object') {
        menuItem.meta = { itemMarkForDelete: false };
      }
    });
  }

  private _getItems() {
    return this._storageProvider.getItem(DATABASE_TOKENS.SHOPPING_CART)
      .then((CartEntity: Cart) => {
        console.log('CartEntity => ', CartEntity);
        this.Cart = CartEntity;
        this._setMetaProps(this.Cart);
      });
  }
}

我该如何解决呢。

0 个答案:

没有答案