<!-- pages/category_v2/category_v2.wxml -->
<wxs module="m1">
  var getindexof = function (num, id) {
    if (num.indexOf(id) >= 0) {
      return true
    } else {
      return flase
    }
  }

  module.exports.getindexof = getindexof;

</wxs>
<wxs module="m2">
  var _isTextEmpty = function (str) {
    if ((str == null) || (str == '') || (str == undefined)) {
      return true
    } else {
      return false
    }
  }
  module.exports._isTextEmpty = _isTextEmpty;
</wxs>
<view class="category" wx:if="{{showCate}}">
  <view class="search-box">
    <view class="search-content" catchtap="gotosearch">
      <icon class="iconfont icon-sousuo1"></icon>
      {{language.category['搜索商品']}}
    </view>
  </view>

  <scroll-view scroll-y style="float:right;background: #eee;" class="category-content" wx:if='{{category_template=="02"}}' throttle="{{false}}" bindscrolltolower="bindscrolltolower02">
    <view class="err" wx:if='{{err}}'>{{language.category['未检测到子分类数据']}}!</view>
    <cCarcontent state="{{state}}" list="{{contentlist_one}}"></cCarcontent>
  </scroll-view>

  <scroll-view scroll-y style="float:right;" class="category-content" wx:if="{{(!m2._isTextEmpty(list)&&category_template=='01')||(!m2._isTextEmpty(list)&&category_template=='03')||(!m2._isTextEmpty(list)&&category_template=='04')||(!m2._isTextEmpty(list)&&category_template=='05')||err}}" upper-threshold="0" lower-threshold="50" throttle="{{false}}" bindscrolltolower="bindscrolltolower" bindscrolltoupper="upper" bindscroll="changeScroll">
    <view class="err" wx:if='{{err}}'>{{language.category['未检测到子分类数据']}}!</view>
    <view class="carcontent2" wx:if='{{!err}}'>
      <view class="branch" wx:if="{{ADImg && category_template != '05'}}">
        <view class="a" style="max-height: 40vh;" catchtap="clickADTo">
          <image style="width:100%;height:100%;max-height: 40vh;" src="{{ADImg}}" mode="widthFix" />
        </view>
      </view>
      <view class="branch_no" wx:if="{{category_template=='05' && webdesImage.length > 0}}">
        <swiper class="branchSwiper">
          <block wx:for="{{webdesImage}}" wx:key="index">
            <swiper-item>
              <view class="branch_img" catchtap="tapUrl" data-item="{{item}}">
                <image src="{{item.img_url}}"></image>
              </view>
            </swiper-item>
          </block>
        </swiper>
      </view>
      <!-- 分类下拉框 -->
      <view wx:if="{{flxShow}}" style="height: 36rpx;background:#fff;position:fixed;top:66rpx;width: 100%;z-index: 2;"></view>
      <view class="catagoryBox {{flxShow?'topnavFixed ':''}}" wx:if="{{category_template != '05'}}">
        <van-collapse value="{{activeName}}" bind:change="onChange" border="{{false}}">
          <van-collapse-item name="1">
            <view slot="title" class="activetitle">
              <!-- 自定义标题 -->
              <view class="dl" wx:if="{{!m2._isTextEmpty(showTitle)}}">
                <view class="dt" wx:for="{{showTitle}}" wx:key="index" wx:for-item="o" class="{{o.id == secondaryId ? 'addClass dt' : 'removeClass dt'}}" data-item="{{o}}" catchtap="clickActive">
                  {{ o.name }}
                </view>
              </view>
              <view class="span" style="text-align:center;" wx:if="{{m2._isTextEmpty(showTitle)}}">
                {{language.category['选择分类']}}
              </view>
            </view>
            <view style="max-height: 32vh;overflow-y: auto;">
              <view class="dl">
                <view wx:for="{{list.recommend}}" wx:key="index" wx:for-item="Secondary" data-item="{{Secondary}}" class="{{ Secondary.id == secondaryId ? 'addClass1 dt' : 'removeClass1 dt'}}" catchtap="chooseSecondary">
                  {{ Secondary.name }}
                </view>
                <view wx:if="{{isCategoryMore}}" class="more-btn-class" catchtap="getMoreData02">查看更多<icon class="iconfont icon-member-bottom"></icon>
                </view>
              </view>
              <block wx:if="{{list.set.cat_level == '3' && !m2._isTextEmpty(threeInfo)}}">
                <view class="threeTitle p">{{language.category['三级分类']}}</view>
                <view class="dl">
                  <view wx:for="{{threeInfo}}" wx:for-item="three" wx:key="index" class="{{three.id == threeId ? 'addClass1 dt' : 'removeClass1 dt'}}" data-id="{{three.id}}" catchtap="chooseThree">
                    {{ three.name }}
                  </view>
                </view>
              </block>
            </view>
            <view class="p" wx:if="{{m2._isTextEmpty(list.recommend)}}">{{language.category['暂无其他分类']}}</view>
          </van-collapse-item>
        </van-collapse>
      </view>
      <view class="catagoryBox {{flxShow?'topnavFixed ':''}}" wx:if="{{list.set.cat_level == '3' && category_template=='05'}}">
        <!-- 模板5下拉框 -->
        <van-collapse value="{{activeName}}" bind:change="onChange" border="{{false}}">
          <van-collapse-item name="1">
            <view slot="title" class="activetitle">
              <view class="dl" wx:if="{{!m2._isTextEmpty(showTitle)}}">
                <view class="dt" wx:if="{{active != 9999}}" wx:for="{{threeInfo}}" wx:key="index" wx:for-item="o" class="{{o.id == threeId ? 'addClass_no dt_no' : 'removeClass dt_no_c'}}" data-item="{{o}}" data-id="{{o.id}}" catchtap="chooseThree">
                  {{ o.name }}
                </view>
                <view class="dt" wx:if="{{active == 9999}}" wx:for="{{showTitle}}" wx:key="index" wx:for-item="o" class="{{o.id == secondaryId ? 'addClass dt' : 'removeClass dt'}}" data-item="{{o}}" catchtap="clickActive">
                  {{ o.name }}
                </view>
              </view>
              <view class="span" style="text-align:{{category_template=='05'?'left':'center'}};" wx:if="{{m2._isTextEmpty(showTitle)}}">
                {{language.category['选择分类']}}
              </view>
            </view>
            <view style="max-height: 32vh;overflow-y: auto;">
              <view class="dl asss" wx:if="{{active == 9999}}">
                <view wx:for="{{list.recommend}}" wx:key="index" wx:for-item="Secondary" data-item="{{Secondary}}" class="{{ Secondary.id == secondaryId ? 'addClass1 dt' : 'removeClass1 dt'}}" catchtap="chooseSecondary">
                  {{ Secondary.name }}
                </view>
                <view wx:if="{{isCategoryMore}}" class="more-btn-class" catchtap="getMoreData02">查看更多<icon class="iconfont icon-member-bottom"></icon>
                </view>
              </view>
              <block wx:if="{{!m2._isTextEmpty(threeInfo)}}">
                <view class="threeTitle p" wx:if="{{active == 9999}}">{{language.category['三级分类']}}</view>
                <view class="dl">
                  <view wx:for="{{threeInfo}}" wx:for-item="three" wx:key="index" class="{{three.id == threeId ? 'addClass5 dt05' : 'removeClass1 dt05'}}" data-id="{{three.id}}" catchtap="chooseThree">
                    {{ three.name }}
                  </view>
                </view>
              </block>
            </view>
            <view class="p" wx:if="{{m2._isTextEmpty(list.recommend)}}">{{language.category['暂无其他分类']}}</view>
          </van-collapse-item>
        </van-collapse>
      </view>
      <view class="goodsList {{category_template=='04'?(category_template=='05'?'category_template01':'category_template04'):'category_template01'}}" style="margin-top: 30rpx;margin-left:3%;">
        <view class="coverLayer" wx:if="{{activeName == '1'}}"></view>
        <view>
          <view class="goodWrapper" wx:if="{{!m2._isTextEmpty(foodInfo)}}">
            <view class="list ul" wx:for="{{foodInfo}}" wx:for-item="good" wx:key="index">
              <view class="img">
                <image src="{{good.thumb}}" data-id="{{good.goods_id}}" catchtap="gotoGoods" data-good="{{good}}" />
              </view>
              <view class="goods-info li">
                <view class="info-class ul">
                  <view class="{{category_template=='05'?'info_a_five':'info_a'}} li" style="-webkit-box-orient: vertical;" data-id="{{good.goods_id}}" catchtap="gotoGoods" data-good="{{good}}">
                    <view class="goods-title">{{ good.title }}</view>
                    <view class="goods-label-box">
                      <text class="goods-label" wx:for="{{good.label_list}}" wx:for-item="labelItem" wx:key="{{labelItem.id}}">{{labelItem.name}}</text>
                    </view>
                  </view>
                  <!-- 模板05 指定样式 -->
                  <block wx:if="{{category_template=='05'}}">
                    <view class="info_c li info_c_five">
                      <view>
                        <view>
                          <view class="price span" style="color: #ff9500;" wx:if="{{good.point_goods}}" data-id="{{good.goods_id}}" catchtap="gotoGoods" data-good="{{good}}">
                            {{ good.has_option == 1 ? ((!good.point_goods.max_point || good.point_goods.min_point == good.point_goods.max_point) ? good.point_goods.min_point : good.point_goods.min_point + "-" + good.point_goods.max_point) : good.point_goods.min_point
                            }}{{integral}}
                          </view>
                          <view class="price span" wx:elif="{{!good.has_option}}" data-id="{{good.goods_id}}" catchtap="gotoGoods" data-good="{{good}}">
                            <text class="small">{{language['money']}}</text>
                            {{ good.vip_level_status&&good.vip_level_status.status==1?good.vip_level_status.word:good.price }}
                          </view>
                          <view class="price span" wx:elif="{{good.has_option && (!good.vip_level_status || good.vip_level_status.status == 0)}}" data-id="{{good.goods_id}}" catchtap="gotoGoods" data-good="{{good}}">
                            <text class="small">{{language['money']}}</text>
                            <text>{{ good.min_price }}</text>
                          </view>
                          <view class="price span" wx:elif="{{good.has_option && (good.vip_level_status && good.vip_level_status.status == 1)}}" data-id="{{good.goods_id}}" catchtap="gotoGoods" data-good="{{good}}">
                            <text class="small">{{language['money']}}</text>
                            {{good.vip_level_status.word}}
                          </view>
                        </view>
                        <!-- 已售 -->
                        <view class="info_b li" data-id="{{good.goods_id}}" catchtap="gotoGoods" data-good="{{good}}">
                          {{language.category['已售']}}{{ good.show_sales + good.virtual_sales}}{{ good.sku }}
                        </view>
                        <view class="pass_price" wx:if="{{good.pass_price}}">{{good.pass_price.name}}:{{good.pass_price.price}}
                        </view>
                      </view>
                      <view wx:if="{{category_template!='04' && good.is_special != 1}}">
                        <!--good.is_special 特殊商品加入购物车隐藏-->
                        <view class="select leaseBox_five" wx:if="{{good.has_option != 1&&good.plugin_id != 40}}">
                          <!-- <van-transition show="{{  goodsCarts[good.id] }}" custom-class="block">
                            <icon wx:if="{{goodsCarts[good.id]}}" class="iconfont icon-life-game-sign" data-id="{{good.id}}" catchtap="numberLeft"></icon>
                          </van-transition>
                          <input type="tel" title="number" wx:if="{{goodsCarts[good.id] && !goodsCarts[good.id].option_str	}}" value="{{goodsCartsTotal[good.id].total}}" data-id="{{goodsCarts[good.id].id}}" data-stock='{{good.stock}}' data-total="{{goodsCartsTotal[good.id].total}}" bind:blur="changeblur" />
                          <icon data-id="{{good.id}}" data-stock='{{good.stock}}' data-good='{{good}}' catchtap="numberRight" class="iconfont icon-life-game-plus"></icon> -->
                          <view class="p" catchtap="numberRight" data-id="{{good.id}}" data-stock='{{good.stock}}' data-good='{{good}}'>
                            <image src="https://mini-app-img-1251768088.cos.ap-guangzhou.myqcloud.com/btn_cart@2x.png"></image>
                          </view>
                        </view>
                        <!-- 分类页返回了plugin_id:0||商城商品，plugin_id：40||租赁，plugin_id：92||供应商商品 -->
                        <view class="select optionClass leaseBox leaseBox_five" wx:if="{{good.has_option == 1 && good.plugin_id != 40 && good.plugin_id != 140}}">
                          <!-- <view data-item="{{good}}" class="p" catchtap="addGood">{{language.category['选规格']}}</view> -->
                          <view data-item="{{good}}" class="p" catchtap="addGood">
                            <image src="https://mini-app-img-1251768088.cos.ap-guangzhou.myqcloud.com/btn_cart@2x.png"></image>
                          </view>
                          <!-- {{goodsCartsTotal[good.id].total+'有数字'}}{{good.id}} -->
                          <icon wx:if="{{!m2._isTextEmpty(goodsCartsTotal[good.id])}}">
                            {{goodsCartsTotal[good.id].total}}
                          </icon>
                        </view>
                        <view class="select leaseBox span" wx:if="{{good.plugin_id == 40}}">{{language.category['去租赁']}}</view>
                      </view>
                      <view wx:if="{{category_template=='04'}}">
                        <view class="select" catchtap="gotoGoods" data-id="{{good.goods_id}}" data-good="{{good}}">
                          <icon class="iconfont icon-life-game-plus"></icon>
                        </view>
                      </view>
                    </view>
                    
                  </block>
                  <block wx:else>
                    <view class="info_b li" data-id="{{good.goods_id}}" catchtap="gotoGoods" data-good="{{good}}">
                      {{language.category['已售']}}{{ good.show_sales + good.virtual_sales}}{{ good.sku }}
                    </view>
                    <view class="info_c li">
                      <block wx:if="{{good.point_mall_goods}}">
                        <view class="price span">

                          <text wx:if="{{good.point_mall_goods.use_money > 0}}">{{good.point_mall_goods.use_money}}元 + </text>
                          <text>{{good.point_mall_goods.point}}积分</text>

                        </view>
                      </block>
                      <block wx:else>
                        <view class="price span" style="color: #ff9500;" wx:if="{{good.point_goods}}" data-id="{{good.goods_id}}" catchtap="gotoGoods" data-good="{{good}}">
                          {{ good.has_option == 1 ? ((!good.point_goods.max_point || good.point_goods.min_point == good.point_goods.max_point) ? good.point_goods.min_point : good.point_goods.min_point + "-" + good.point_goods.max_point) : good.point_goods.min_point
                          }}{{integral}}
                        </view>
                        <view class="price span" wx:elif="{{!good.has_option}}" data-id="{{good.goods_id}}" catchtap="gotoGoods" data-good="{{good}}">
                          <text class="small">{{language['money']}}</text>
                          {{ good.vip_level_status&&good.vip_level_status.status==1?good.vip_level_status.word:good.price }}
                        </view>
                        <view class="price span" wx:elif="{{good.has_option && (!good.vip_level_status || good.vip_level_status.status == 0)}}" data-id="{{good.goods_id}}" catchtap="gotoGoods" data-good="{{good}}">
                          <text class="small">{{language['money']}}</text>
                          <text>{{ good.min_price }}</text>
                        </view>
                        <view class="price span" wx:elif="{{good.has_option && (good.vip_level_status && good.vip_level_status.status == 1)}}" data-id="{{good.goods_id}}" catchtap="gotoGoods" data-good="{{good}}">
                          <text class="small">{{language['money']}}</text>
                          {{good.vip_level_status.word}}
                        </view>
                        <view wx:if="{{category_template!='04' && good.is_special != 1}}">
                          <!--good.is_special 特殊商品加入购物车隐藏-->
                          <view class="select" wx:if="{{good.has_option != 1&&good.plugin_id != 40}}">
                            <van-transition show="{{  goodsCarts[good.id] }}" custom-class="block">
                              <icon wx:if="{{goodsCarts[good.id]}}" class="iconfont icon-life-game-sign" data-id="{{good.id}}" catchtap="numberLeft"></icon>
                            </van-transition>
                            <input type="tel" title="number" wx:if="{{goodsCarts[good.id] && !goodsCarts[good.id].option_str	}}" value="{{goodsCartsTotal[good.id].total}}" data-id="{{goodsCarts[good.id].id}}" data-stock='{{good.stock}}' data-total="{{goodsCartsTotal[good.id].total}}" bind:blur="changeblur" />
                            <icon data-id="{{good.id}}" data-stock='{{good.stock}}' data-good='{{good}}' catchtap="numberRight" class="iconfont icon-life-game-plus"></icon>
                          </view>
                          <!-- 分类页返回了plugin_id:0||商城商品，plugin_id：40||租赁，plugin_id：92||供应商商品 -->
                          <view class="select optionClass leaseBox" wx:if="{{good.has_option == 1 && good.plugin_id != 40}}">
                            <view data-item="{{good}}" class="p" catchtap="addGood">{{language.category['选规格']}}</view>
                            <!-- {{goodsCartsTotal[good.id].total+'有数字'}}{{good.id}} -->
                            <icon wx:if="{{!m2._isTextEmpty(goodsCartsTotal[good.id])}}">
                              {{goodsCartsTotal[good.id].total}}
                            </icon>
                          </view>
                          <view class="select leaseBox span" wx:if="{{good.plugin_id == 40}}">{{language.category['去租赁']}}</view>
                        </view>
                        <view wx:if="{{category_template=='04'}}">
                          <view class="select" catchtap="gotoGoods" data-id="{{good.goods_id}}" data-good="{{good}}">
                            <icon class="iconfont icon-life-game-plus"></icon>
                          </view>
                        </view>
                      </block>
                    </view>
                  </block>

                  <view class="price" wx:if="{{good.is_open_micro=='1'}}">会员价:{{language['money']}}{{good.price_level==1?good.vip_price:good.vip_next_price}}</view>
                  <view class="pass_price" wx:if="{{good.pass_price}}">{{good.pass_price.name}}:{{good.pass_price.price}}</view>
                </view>
              </view>
            </view>
            <view class="space">{{LoadMoreTest}}</view>
          </view>
          <view style="text-align:center;margin-top:16rpx;" wx:if="{{m2._isTextEmpty(foodInfo)}}">
            <image src="https://mini-app-img-1251768088.cos.ap-guangzhou.myqcloud.com/no-more-product.png" alt="" style="width: 150rpx;height:150rpx;" />
          </view>
        </view>
      </view>
    </view>
  </scroll-view>
  <scroll-view scroll-y="{{true}}" class="rootlists" style="float:left;" bindscrolltolower="getMoreCategoryNew">
    <view class="ul rootList {{category_template=='05'?'rootList_no':''}}" wx:if='{{list}}'>
      <view class="li {{category_template=='02'?'tem_2':''}}" catchtap="bpfun" wx:if="{{brandShow=='0'}}">
        {{language.category['推荐品牌']}}
      </view>
      <view class="li {{category_template=='02'?'tem_2':''}} {{active2?'active':''}}" catchtap="allList" wx:if="{{categoryShow=='0'}}">
        <view class="span">{{language.category['推荐分类']}}</view>
      </view>
      <view wx:key="index" wx:for="{{onelist}}" wx:if="{{item.name && category_template != '05'}}" class="li {{category_template=='02'?'tem_2':''}} {{active==index?'active':''}}" wx:for-index="index" wx:key="index" wx:for-item="item" catchtap="tabsa" data-index="{{index}}" data-item="{{item}}">
        <view class="span">{{item.name}}</view>
      </view>
      <view wx:key="index" wx:for="{{onelist}}" wx:if="{{item.name && category_template=='05'}}" wx:for-index="index" wx:key="index" class="li {{category_template=='02'?'tem_2':''}} {{active==index?'active':''}}" style="box-shadow: {{active==index?'0 0 10px 0px rgba(0,0,0,0.1)':''}};" wx:for-item="item" catchtap="tabsa" data-index="{{index}}" data-item="{{item}}">
        <view class="{{active==index?'name_no':'name_no_ae'}}">{{item.name}}</view>
        <view wx:for="{{list.recommend}}" wx:for-item="iket" wx:if="{{iket.parent_id == item.id && active != 9999 && fiveShow}}" wx:for-index="eind" wx:key="eind" class="{{iket.id == secondaryId ? 'addClass_no dt indAct' : 'removeClass_no dt'}} dodL" data-item="{{iket}}" catchtap="clickActive">
          {{iket.name}}
        </view>
      </view>
    </view>
  </scroll-view>
  <!-- 选规格 -->
  <van-popup show="{{show2}}" position="center" round bind:close='close' closeable>
    <view>
      <view class="spec_box q5">
        <view class="h3">
          {{ popTitle }}
          <!-- <icon catchtap="close" class="iconfont icon-close11"></icon> -->
        </view>
        <view style="height:80rpx;"></view>
        <view class="spec_a" wx:for="{{goodsInfo.has_many_specs}}" wx:for-item="spec" wx:key="index">
          <view class="h5">{{ spec.title }}：</view>
          <view class="option ul">
            <block wx:if="{{spec.has_many_specs_item.length>0}}">
              <view wx:for="{{spec.has_many_specs_item}}" wx:key="index" wx:for-item="item" data-item="{{item}}" data-id="{{item.id}}" catchtap="selectSpecs" class="li  {{m1.getindexof(specid,item.id)?'cur':''}}">
                {{ item.title }}
              </view>
            </block>
          </view>
        </view>
        <view style="height:110rpx;"></view>
      </view>
      <view class="add_car">
        <view class="car_btn ul">
          <view class="left li" wx:if="{{goodsInfo.point_goods}}">
            {{ popPrice }}<text class="point-text">{{integral}}</text>
          </view>
          <view class="left li" wx:else>
            <text class="good-price">
              <text class="span">{{language['money']}}</text>{{ popPrice }}
            </text>
            <view class="vip-price" wx:if="{{isMultiSpecs}}">
              <van-loading class="m-l-w6" color="#fdbc2e" size='16' wx:if="{{specsVIPPrc == 0}}" />
              <text class="m-l-w6" wx:if="{{specsVIPPrc}}">会员价: {{language['money']}}{{ specsVIPPrc }} </text>
            </view>
          </view>
          <view class="right li" catchtap="submitAction">
            <view class="span" wx:if="{{!popNum}}">{{language.category['加入购物车']}}</view>
          </view>
          <view class="Box" wx:if="{{popNum >= 1}}">
            <view data-id="{{popCard.id}}" data-num="{{popNum-1}}" data-i="-1" catchtap="changeAddCount">
              <icon class="iconfont icon-store_reduceLine"></icon>
            </view>
            <block class="show">{{ popNum }}</block>
            <view data-id="{{popCard.id}}" data-num="{{popNum+1}}" data-i="1" catchtap="changeAddCount">
              <icon class="iconfont icon-store_plus"></icon>
            </view>
          </view>
        </view>
      </view>
    </view>

  </van-popup>
  <view style="height: 90rpx;"></view>
</view>
<shopfoot></shopfoot>