<!--index.wxml-->
<import src='/template/loading/loading.wxml'></import>
<view class="loading_mask" wx:if="{{!onLoad}}">
  <template is="loading_animation"></template>
</view>
<!--头部-->

<!--店铺介绍  -->
<!-- <view class="shop_msg" bindtap="windowTouchListener">
  <view class="red_bc"></view>
  <view class='white_bc'>
    <view>
      <image src='{{storeInfo.picture}}'></image>
    </view>
    <view class='msg_title'>{{storeInfo.business_name}}</view>
    <view classs="mb10">{{storeInfo.business_address}}</view>
    <view class='time_phone mb10'>
      <text>{{storeInfo.business_phone}} </text>
      <text> 营业时间:{{storeInfo.service_time}}</text>
    </view>
    <view class='shop_introduce'>{{storeInfo.business_des}}</view>
  </view>
</view> -->

<!--  new 店铺简介  -->
<view class='shop_head'>
  <view class='shop_box_top'>
    <view class='shop_top_left'>
      <image src='{{storeInfo.picture}}'></image>
    </view>

    <view class='shop_top_middle'>
      <view class='shop_top_name'>{{storeInfo.business_name}}</view>

      <view class='shop_top_address'>
        <text class='iconfont icon-dingwei1'></text>
        <view class='shop_address_text'>{{storeInfo.business_address}}</view>
      </view>

      <view class='shop_top_time'>Operating Hours:{{storeInfo.service_time}}</view>

    </view>

    <view class='shop_top_right'>
      <view class='shop_top_phone'>
        <text class='iconfont icon-dianhua'></text>
        <text>{{storeInfo.business_phone}}</text>
      </view>
      <view class='shop_top_delivery'>Delivery Area:</view>
    </view>

  </view>

  <view class='shop_box_bottom'>
    <view class='shop_bottom_introduce'>{{storeInfo.business_des}}</view>
  </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_other {{index == activeIndex ? "active": ""}}' wx:for='{{catesArr}}' wx:key data-id='{{item.id}}' data-idx='{{index}}' bindtap='chooseGoodsType'>
        <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}}" data-index="{{index}}" wx:key>
        <block wx:for="{{catesArr[index]}}" wx:key="cateItem" wx:for-index="cateIndex" wx:if="{{index == activeIndex}}">
          <!-- <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" bindtap='showgm' 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_top'>
                  <view class="goods_name">{{item.title}}</view>
                  <!-- <text class='iconfont icon-start {{index?start1 : start2}} ' catchtap='goCollect'></text>  -->
                </view>
                <view class="goods_desc">
                  <text class="sales">sold
                   {{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 catchtap='pushCar' data-cgoodsid='{{item.id}}' data-catid='{{item.cat_id1}}' data-ctitle='{{item.title}}' data-price="{{item.price}}" class='push_car'>Select</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}}">Please Select Product</view>
  <view class="current_price" wx:else>
    <view>
      <text class="deliver_price">￥{{finalPrice||totalPrice}}</text>
      <text class="off_price">￥{{totalPrice}}</text>
    </view>
    <!-- <text wx:if="{{storeInfo.is_on_waimai == 1}}">起送价: {{'￥'+storeInfo.up_to_send}}</text>  -->
    <text wx:if="{{storeInfo.is_on_waimai == 1}}">Began to delivery: {{'￥'+storeInfo.up_to_send}}</text>
  </view>
  <view class="pay_btn" catchtap="payNav">Checkout</view>
</view>

<!--  商品浮层  -->
<view class='goods_layer' wx:if="{{goodsFlag}}" bindtap='hiddengm'>
  <view class='goods_box_layer'>
    <view class='goods_list_layer'>
      <view class='goods_list_layer_img'>
        <image src='{{goodsDetails.img}}'></image>
      </view>
      <view class='goods_info_layer'>
        <view>{{goodsDetails.title}}</view>
        <view class='layer_price'>Price: RM {{goodsDetails.price}}</view>
      </view>
      <view class='goods_recommend_layer'>
        <view class='layer_title'>Goods infomation</view>
        <view>{{goodsDetails.content}}</view>
      </view>
    </view>
  </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>Shopping Cart
    </view>
    <view wx:if="{{cart.length > 0}}" class="clear" catchtap="clearCart">
      <text class="iconfont icon-delete"></text>Empty
    </view>
  </view>
  <block wx:for="{{cart}}" wx:key="shoppingCart">
    <view class="cart_item">
      <view class="cart_item_name">{{item.title}} <text decode='true'>&nbsp;&nbsp;</text> ({{item.atitle}})</view>
      <view class="cart_item_price">RM {{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> -->

          <!--  new  -->
           <view wx:if="{{item.count > 0}}" class="{{item.count <= 0?'slideInLeft':'hidden'}} minus btn" catchtap="cartManager" data-attr="reduce" data-id="{{item.id}}"  data-index="{{index}}">-</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}}" data-index="{{index}}">+</view> 
<!-- 
          <view wx:if="{{item.count > 0}}" class="{{item.count <= 0?'slideInLeft':'hidden'}} minus btn" catchtap="carOff" 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="carAdd" data-attr="add" data-id="{{item.id}}">+</view> -->

        </view>
      </view>
    </view>
  </block>
</scroll-view>

<!--  商品属性规格  -->
<view class='goods_property ' wx:if="{{pushincar}}">
  <view class='property_box'>
    <view class='property_title'>
      <view class='title_text'>{{currentGoods.title}}</view>
      <view class='car_close' catchtap='closeCar'>
        <image src='/images/close.png'></image>
      </view>
    </view>
    <block wx:for="{{propertyData}}" wx:key="{{index}}">
      <view class='property_text'>{{item.title}}:</view>
      <view class='property_content'>
        <block wx:for="{{item.attr}}" wx:for-item="attr" wx:for-index="attrindex">
          <view class='property_list {{attr.id==item.cateAttrId?"active":""}}' catchtap='chooseProperty' data-cateattrid="{{attr.id}}" data-catetitleindex="{{index}}" data-kindid='{{item.cateattr_id}}' data-attitle='{{attr.attr_title}}' data-attrprice='{{attr.attr_price}}' >{{attr.attr_title}}</view>

        </block>
        <!-- data-cateattr_id="{{attr.cateattr_id}}" data-attr_price="{{attr.attr_price}}" -->
        <!-- <view class='property_list'>{{item.attr}}</view> -->
      </view>
    </block>
    <view class='prooerty_row'>

      <!-- 添加数量按钮 -->
      <!-- <view class="cart_item_btn" wx:if="{{ppNum>=1}}"> -->
      <view class="cart_item_btn">
        <view class="price_btn">
          <view class="minus btn" catchtap="carOff" data-attr="reduce" data-id="{{item.id}}">-</view>
          <view class="monitor">{{ppNum}}</view>
          <view class="add btn" catchtap="carAdd" data-attr="add" data-id="{{item.id}}">+</view>
        </view>
      </view>
      <!--  添加数量按钮  -->
      <view class='pp_ppPrice'>{{ppPrice}}</view>
      <!-- <view class='property_price'>¥ {{ppPrice}}</view> -->
      <!-- <view class='car_btn' wx:if="{{ppNum == 0}}"> -->
      <view class='car_btn'>
        <view class="iconfont icon-cart1 car2"></view>
        <view class='car_text' catchtap='calcppPrice' data-num="{{ppNum}}" data-title="{{item.title}}" data-ppid="{{item.id}}" data-price="{{ppPrice}}" >Add to Cart</view>
      </view>

    </view>
  </view>
</view>