// pages/merchant_page/index.js
Page({

  /**
   * 页面的初始数据
   */
  data: {
    foods: [{
        id: 0,
        foodsImg: 'https://bpic.588ku.com/back_origin_min_pic/20/11/05/a7438bbf54ace893e790545815e14ef3.jpg',
        foodsName: '麻烫',
        foodsDesc: '包含香菜、菠菜、面、豆芽、海带',
        initPrice: 28.80,
        nowPrice: 10.98

      },
      {
        id: 1,
        foodsImg: 'https://bpic.588ku.com/back_origin_min_pic/20/11/05/a7438bbf54ace893e790545815e14ef3.jpg',
        foodsName: '麻辣',
        foodsDesc: '包含香菜、菠菜、面、豆芽、海带',
        initPrice: 28.80,
        nowPrice: 10.98
      },
      {
        id: 2,
        foodsImg: 'https://bpic.588ku.com/back_origin_min_pic/20/11/05/a7438bbf54ace893e790545815e14ef3.jpg',
        foodsName: '麻辣烫',
        foodsDesc: '包含香菜、菠菜、面、豆芽、海带',
        initPrice: 28.80,
        nowPrice: 10.98

      },
      {
        id: 3,
        foodsImg: 'https://bpic.588ku.com/back_origin_min_pic/20/11/05/a7438bbf54ace893e790545815e14ef3.jpg',
        foodsName: '麻辣烫',
        foodsDesc: '包含香菜、菠菜、面、豆芽、海带',
        initPrice: 28.80,
        nowPrice: 10.98

      },
      {
        id: 4,
        foodsImg: 'https://bpic.588ku.com/back_origin_min_pic/20/11/05/a7438bbf54ace893e790545815e14ef3.jpg',
        foodsName: '麻辣烫',
        foodsDesc: '包含香菜、菠菜、面、豆芽、海带',
        initPrice: 28.80,
        nowPrice: 10.98

      },
      {
        id: 5,
        foodsImg: 'https://bpic.588ku.com/back_origin_min_pic/20/11/05/a7438bbf54ace893e790545815e14ef3.jpg',
        foodsName: '麻辣烫',
        foodsDesc: '包含香菜、菠菜、面、豆芽、海带',
        initPrice: 28.80,
        nowPrice: 10.98

      },
      {
        id: 6,
        foodsImg: 'https://bpic.588ku.com/back_origin_min_pic/20/11/05/a7438bbf54ace893e790545815e14ef3.jpg',
        foodsName: '麻辣烫',
        foodsDesc: '包含香菜、菠菜、面、豆芽、海带',
        initPrice: 28.80,
        nowPrice: 10.98

      },
      {
        id: 7,
        foodsImg: 'https://bpic.588ku.com/back_origin_min_pic/20/11/05/a7438bbf54ace893e790545815e14ef3.jpg',
        foodsName: '麻辣烫',
        foodsDesc: '包含香菜、菠菜、面、豆芽、海带',
        initPrice: 28.80,
        nowPrice: 10.98

      }
    ],
    show: false,
    totalPrice: 0,
    info: ''
  },
  onInput(e) {
    this.setData({
      info: e.detail.value
    })
  },
  onChange(e) {
    let id = e.currentTarget.dataset.id;
    let count = e.detail;
    let foodsPrice = this.data.foods[id].nowPrice;
    // console.log(id,foodsPrice);
  },
  onSearch() {
    let list = this.data.foods;
    let arr=[];
    list.forEach(res=>{
     if(this.data.info===res.foodsName)
     {
      arr.push(res)
     }
    })
    console.log(arr);
    this.setData({
      show: !this.data.show,
    })
  },
  /**
   * 生命周期函数--监听页面加载
   */
  onLoad(options) {
  },

  /**
   * 生命周期函数--监听页面初次渲染完成
   */
  onReady() {

  },

  /**
   * 生命周期函数--监听页面显示
   */
  onShow() {

  },

  /**
   * 生命周期函数--监听页面隐藏
   */
  onHide() {

  },

  /**
   * 生命周期函数--监听页面卸载
   */
  onUnload() {

  },

  /**
   * 页面相关事件处理函数--监听用户下拉动作
   */
  onPullDownRefresh() {

  },

  /**
   * 页面上拉触底事件的处理函数
   */
  onReachBottom() {

  },

  /**
   * 用户点击右上角分享
   */
  onShareAppMessage() {

  }
})