<!--index.wxml-->
 <import src='../../template/loading/loading.wxml'></import> 
 <view class="loading_mask" wx:if="{{!onLoad}}">
   <template is="loading_animation"></template> 
</view>  
<!--头部-->
<view class="store" bindtap="windowTouchListener">
  <view class="store_general">
    <view class="store_img">
      <image src="{{storeInfo.picture}}"></image>
    </view>
    <view class="store_info">
      <view class="store_name">{{storeInfo.business_name}}</view>
       <view class="store_delivery" wx:if="{{storeInfo.is_on_waimai == 1}}">{{checkHack.deliveryName}}: ￥{{storeInfo.delivery}}  {{checkHack.packageName}}: ￥{{storeInfo.boxes}}</view> 
      <view class="store_address">地址: {{storeInfo.business_address}}</view>
      <view class='store_phone'>电话：{{storeInfo.business_phone}}</view>
    </view>
  </view>
  <view class="store_des">{{storeInfo.business_des}}</view>
  <view class='view_order'  bindtap='view_order'>查看订单</view>
</view>
<!--商品-->
<view class="goods_box" bindtap="windowTouchListener">
  <!--分类-->
  <view class="goods_cate">
    <scroll-view scroll-y class="goods_cate_scroll" style="height:{{scrollHeight}}px">
      <view class="goods_cate_item {{index == activeIndex?'active':''}}" wx:for="{{catesArr}}" wx:key="{{catesArr}}" data-index="{{index}}" bindtap="selectCate">
        <block wx:for="{{catesArr[index]}}" wx:key="cateName">{{index}}</block>
      </view>
    </scroll-view>
  </view>
  <!--商品列表-->
  <view class="goods_list">
    <scroll-view scroll-y scroll-with-animation class="goods_list_scroll" style="height:{{scrollHeight}}px">
      <view class="goods_cate_item" wx:for="{{catesArr}}" wx:key="goodsCate" id="{{'cate'+index}}">
        <block wx:for="{{catesArr[index]}}" wx:key="cateItem" wx:for-index="cateIndex" wx:if="{{index == activeIndex}}">
          <view class="goods_cate_title">
            <block wx:for="{{catesArr[index]}}" wx:key="goodsItem">{{index}}</block>
          </view>
          <view class="goods_item" wx:key="currentGoods" data-cate-index="{{index}}" data-item-index="{{itemIndex}}" wx:for="{{item}}" wx:for-index="itemIndex">
            <view class="goods_left">
              <image src="{{item.img}}" mode="aspectFill"></image>
            </view>
            <view class="goods_right">
              <view class="goods_info">
                <view class="goods_name">{{item.title}}</view>
                <view class="goods_desc">
                  <text class="sales">已售 {{item.sales}}</text>
                  <text wx:if="{{item.max_buy>0}}">限购 {{item.max_buy}}件</text>
                </view>
              </view>
              <view class="price">
                <view class="price_num">{{'￥'+item.price}}</view>
                <view class="price_btn">
                  <view wx:if="{{item.count > 0}}"
                  class="{{item.count <= 0?'slideInLeft':'hidden'}} minus btn"
                  catchtap="reduceCount"
                  data-id="{{item.id}}"
                  data-index="{{itemIndex}}">-</view>
                  <view wx:if="{{item.count > 0}}"
                  class="{{item.count <= 0?'slideInLeft':'hidden'}} monitor">{{item.count}}</view>
                  <view class="add btn"
                  catchtap="addCount"
                  data-id="{{item.id}}"
                  data-index="{{itemIndex}}">+</view>
                </view>
              </view>
            </view>
          </view>
        </block>
      </view>
    </scroll-view>
  </view>
</view>

<!--底部-->
<view class="footer" bindtap="showCart">
  <view class="cart {{cartCount > 0?'active':''}}">
    <view class="iconfont icon-cart1"></view>
    <view class="bubble" wx:if="{{cartCount > 0}}">{{cartCount}}</view>
  </view>
  <view class="to_txt" wx:if="{{cart.length <= 0}}">请选择商品</view>
  <view class="current_price" wx:else>
    <text class="deliver_price">{{'￥'+totalPrice}}</text>
    <text wx:if="{{storeInfo.is_on_waimai == 1}}">起送价: {{'￥'+storeInfo.up_to_send}}</text> 
  </view>
  <view class="pay_btn" catchtap="payNav">预 约</view>
</view>


<!--浮层-->
<scroll-view 
  wx:if="{{cartFlag}}"
  class="layer"
  scroll-y
  data-attr="content"
  bindtap="windowTouchListener"
  style="height:{{cartHeight}}">
  <view class="layer_header">
    <view class="cart_title">
      <text class="cart_title_icon"></text>购物车
    </view>
    <view wx:if="{{cart.length > 0}}" class="clear" catchtap="clearCart">
      <text class="iconfont icon-delete"></text>清空
    </view>
  </view>
  <block wx:for="{{cart}}" wx:key="shoppingCart">
    <view class="cart_item">
      <view class="cart_item_name">{{item.title}}</view>
      <view class="cart_item_price">￥{{item.price}}</view>
      <view class="cart_item_btn">
        <view class="price_btn">
          <view wx:if="{{item.count > 0}}"
            class="{{item.count <= 0?'slideInLeft':'hidden'}} minus btn"
            catchtap="cartManager"
            data-attr="reduce"
            data-id="{{item.id}}">-</view>
              <view wx:if="{{item.count > 0}}"
                class="{{item.count <= 0?'slideInLeft':'hidden'}} monitor">{{item.count}}</view>
          <view class="add btn"
            catchtap="cartManager"
            data-attr="add"
            data-id="{{item.id}}">+</view>
          </view>
      </view>
    </view>
  </block>
</scroll-view>

<!--商品详情-->
<view class="goods_detail_mask" wx:if="{{infoFlag}}" bindtap="hideInfo" data-area="mask">
  <view class="goods_detail">
    <view class="goods_detail_img">
      <image src="{{goodsArr[cateIndex][goodsInfoIndex].thumb}}"></image>
    </view>
    <view class="goods_detail_name">{{goodsArr[cateIndex][goodsInfoIndex].goods_name}}</view>
    <view class="goods_detail_desc goods_detail_row"><text style="color:#f39500">简介：</text>{{goodsArr[cateIndex][goodsInfoIndex].des}}</view>
    <view class="goods_detail_row">
      <text style="color:#f39500">规格：</text>{{goodsArr[cateIndex][goodsInfoIndex].parameter}}
    </view>
    <view class="goods_detail_row">
      <text style="color:#f39500">详情：</text>{{goodsArr[cateIndex][goodsInfoIndex].intro}}
    </view>
    <view class="goods_detail_price">
      单价:
      <text style="color:#f39500">￥</text>
      <text style="font-size:18px;color:#f39500">{{goodsArr[cateIndex][goodsInfoIndex].goods_price}}</text>
    </view>
  </view>
</view>