<template>
  <view class="content">
    <up-navbar placeholder style="z-index: 10080;">
      <!-- #ifdef MP-WEIXIN -->
      <template #left>
        <view style="width: 540rpx;"><up-search placeholder="请输入商品" v-model="keyword" :showAction="false"></up-search>
        </view>
      </template>
      <!-- #endif -->
      <!-- #ifndef MP-WEIXIN -->
      <template #left>
        <view></view>
      </template>
      <template #center>
        <view style="width: 700rpx;"><up-search placeholder="请输入商品" v-model="keyword" :showAction="false"></up-search>
        </view>
      </template>
      <!-- #endif -->
    </up-navbar>
    <view style="position: relative;overflow: hidden;">
      <scroll-view class="head-view" scroll-x>
        <view class="list">
          <view class="item" :class="{'item-active': topActive==index}" v-for="(item, index) in 10" :key="index">
            <image class="c-img" src="https://cdn.uviewui.com/uview/album/1.jpg"></image>
            <view class="c-text u-line-1">惠农生活{{item}}</view>
          </view>
          <view class="item" style="width: 80rpx;height: 20rpx;">
          </view>
        </view>
      </scroll-view>
      <view class="r-btn" @click="show=1">
        <view>全</view>
        <view>部</view>
        <up-icon name="list"></up-icon>
      </view>
    </view>
    <viewPopup nav v-if="show===1" @close="show=0">
      <view class="cateOne">
        <view class="head-title">全部分类</view>
        <scroll-view scroll-y style="height: 60vh;">
          <view class="list">
            <view class="item" :class="{'item-active': topActive==index}" v-for="(item, index) in 55" :key="index">
              <image class="c-img" src="https://cdn.uviewui.com/uview/album/1.jpg"></image>
              <view class="c-text u-line-1">惠农生活{{item}}</view>
            </view>
          </view>
        </scroll-view>
      </view>
    </viewPopup>
    <view class="scroll-box">
      <scroll-view class="left" scroll-y>
        <view class="item u-line-1" :class="{'item-active': leftActive==index}" v-for="(item, index) in 20"
          :key="index">惠农生活{{item}}</view>
        <view style="width: 100%;height: 200rpx;"></view>
      </scroll-view>
      <view class="right">
        <view class="classify">
          <scroll-view style="height: 90rpx;" scroll-x>
            <view class="classify-list">
              <view class="classify-list-item u-line-1" :class="{'item-active': rightActive==index}"
                v-for="(item, index) in 6" :key="index">
                牛肉
              </view>
              <view style="width: 70rpx;flex-shrink: 0;"></view>
            </view>
          </scroll-view>
          <view class="done" @click="show=2">
            <up-icon name="arrow-down"></up-icon>
          </view>
          <view class="order-by">
            <view class="item">综合</view>
            <view class="item">价格</view>
            <view class="item">销量</view>
          </view>
        </view>
        <viewPopup v-if="show===2" @close="show=0">
          <view class="cateOne">
            <scroll-view scroll-y style="height: 230rpx;">
              <view class="classify-list">
                <view class="classify-list-item u-line-1" :class="{'item-active': rightActive==index}"
                  v-for="(item, index) in 6" :key="index">
                  牛肉
                </view>
              </view>
            </scroll-view>
          </view>
        </viewPopup>
        <scroll-view class="list" scroll-y>
          <view class="shop-item" v-for="(item, index) in 20" :key="index">
            <image class="shop-img" src="https://cdn.uviewui.com/uview/album/1.jpg"></image>
            <view class="shop-content">
              <view class="title">
                <view class="name u-line-2">好吃的瓜果{{item}}</view>
                <view class="tip u-line-1">香味辛辣|葱香味浓|调味增香香味辛辣|葱香味浓|调味增香</view>
              </view>
              <view class="price-btn">
                <view class="price">￥12.00</view>
                <view class="btn">
                  <u--icon name="minus-circle-fill" size="20" color="#20b128"></u--icon>
                  <view class="num">{{1}}</view>
                  <u--icon name="plus-circle-fill" size="20" color="#20b128"></u--icon>
                </view>
              </view>
            </view>
          </view>
          <view style="width: 100%;height: 200rpx;"></view>
        </scroll-view>
      </view>
    </view>
  </view>
</template>

<script setup>
  import { ref } from "vue"
  import viewPopup from "@/components/viewPopup/index.vue"

  const topActive = ref(0);
  const leftActive = ref(2);
  const rightActive = ref(1);
  const show = ref(0);
  const keyword = ref('')
</script>

<style lang="scss">
  .content {
    background-color: #fff;
  }

  .head-view {
    background-color: #fff;
    height: 180rpx;
    width: 750rpx;

    .list {
      height: 100%;
      display: flex;
      align-items: center;
      padding: 0 20rpx;
      font-size: 22rpx;

      .item {
        width: 120rpx;
        flex-shrink: 0;
        margin-right: 20rpx;
        display: flex;
        flex-direction: column;
        align-items: center;

        .c-img {
          height: 100rpx;
          width: 100rpx;
          flex-shrink: 0;
          border-radius: 50%;
          border: 2px solid transparent;
        }

        .c-text {
          width: 100%;
          text-align: center;
          box-sizing: border-box;
          padding: 2rpx 4rpx 3rpx 4rpx;
          border-radius: 50rpx;
          margin-top: 5rpx;
        }
      }

      .item-active {
        .c-img {
          border: 2px solid #20b128;
        }

        .c-text {
          background-color: #20b128;
          color: #fff;
        }
      }
    }
  }

  .r-btn {
    position: absolute;
    right: 0;
    top: 0;
    height: 100%;
    width: 60rpx;
    font-size: 24rpx;
    background-color: #fff;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    box-shadow: -10rpx 0 60rpx 1rpx rgba(0, 0, 0, 0.3);
  }

  .cateOne {
    background-color: #fff;

    .head-title {
      color: #666666;
      font-size: 30rpx;
      height: 80rpx;
      line-height: 80rpx;
      padding-left: 30rpx;
    }

    .list {
      padding: 20rpx 0;
      font-size: 22rpx;
      display: grid;
      grid-template-columns: auto auto auto auto auto;
      justify-content: center;
      grid-gap: 20rpx;

      .item {
        width: 120rpx;
        display: flex;
        flex-direction: column;
        align-items: center;

        .c-img {
          height: 100rpx;
          width: 100rpx;
          flex-shrink: 0;
          border-radius: 50%;
          border: 2px solid transparent;
        }

        .c-text {
          width: 100%;
          text-align: center;
          box-sizing: border-box;
          padding: 2rpx 4rpx 3rpx 4rpx;
          border-radius: 50rpx;
          margin-top: 5rpx;
        }
      }

      .item-active {
        .c-img {
          border: 2px solid #20b128;
        }

        .c-text {
          background-color: #20b128;
          color: #fff;
        }
      }
    }

    .classify-list {
      padding: 20rpx 0;
      font-size: 22rpx;
      display: grid;
      grid-template-columns: auto auto auto;
      justify-content: center;
      grid-gap: 20rpx;

      .classify-list-item {
        flex-shrink: 0;
        text-align: center;
        width: 150rpx;
        height: 42rpx;
        line-height: 42rpx;
        background: #F6F6F6;
        border-radius: 22rpx 22rpx 22rpx 22rpx;
        border: 1rpx solid transparent;
      }

      .item-active {
        border: 1rpx solid #20b128;
        color: #20b128;
        background-color: rgba(#20b128, 0.1);
      }
    }
  }

  .scroll-box {
    // background-color: red;
    display: flex;

    .left {
      height: calc(100vh - var(--window-top) - var(--window-bottom) - 180rpx);
      /* #ifdef H5 */
      height: calc(100vh - 96px - 180rpx);
      /* #endif */
      width: 170rpx;
      box-sizing: border-box;
      background-color: #eee;
      font-size: 24rpx;

      .item {
        height: 96rpx;
        line-height: 96rpx;
        text-align: center;
      }

      .item-active {
        background-color: #fff;
        position: relative;
        color: #20b128;

        &::before {
          content: '';
          background-color: #20b128;
          width: 6rpx;
          height: 48rpx;
          border-radius: 10rpx;
          position: absolute;
          left: 0;
          top: 50%;
          transform: translate(0, -50%);
        }
      }
    }

    .right {
      height: calc(100vh - var(--window-top) - var(--window-bottom) - 180rpx);
      /* #ifdef H5 */
      height: calc(100vh - 96px - 180rpx);
      /* #endif */
      width: 580rpx;
      box-sizing: border-box;
      position: relative;
      overflow: hidden;

      .classify {
        height: 150rpx;
        background-color: #fff;
        border-bottom: 1rpx solid #eee;
        position: relative;
        font-size: 24rpx;

        .classify-list {
          display: flex;
          padding: 20rpx;

          .classify-list-item {
            flex-shrink: 0;
            text-align: center;
            width: 108rpx;
            height: 42rpx;
            line-height: 42rpx;
            background: #F6F6F6;
            border-radius: 22rpx 22rpx 22rpx 22rpx;
            margin-right: 20rpx;
            border: 1rpx solid transparent;
          }

          .item-active {
            border: 1rpx solid #20b128;
            color: #20b128;
            background-color: rgba(#20b128, 0.1);
          }
        }

        .done {
          height: 90rpx;
          width: 60rpx;
          position: absolute;
          top: 0;
          right: 0;
          display: flex;
          justify-content: center;
          align-items: center;
          background-color: #fff;
        }

        .order-by {
          display: flex;
          justify-content: flex-end;
          align-items: center;

          .item {
            padding-right: 20rpx;
          }
        }
      }

      .list {
        height: calc(100vh - var(--window-top) - var(--window-bottom) - 180rpx - 150rpx);
        /* #ifdef H5 */
        height: calc(100vh - 96px - 180rpx);
        /* #endif */
        .shop-item {
          padding: 20rpx;
          border-bottom: 1rpx solid #eee;
          background-color: #fff;
          display: flex;

          .shop-img {
            height: 160rpx;
            width: 160rpx;
            margin-right: 20rpx;
            border-radius: 14rpx;
          }

          .shop-content {
            width: 380rpx;
            display: flex;
            flex-direction: column;
            justify-content: space-between;

            .title {
              .name {
                font-size: 28rpx;
              }

              .tip {
                color: #999;
                font-size: 24rpx;
                margin: 12rpx 0;
              }
            }

            .price {
              font-size: 30rpx;
              font-weight: bold;
              color: #F55726;
            }

            .price-btn {
              display: flex;
              justify-content: space-between;

              .btn {
                display: flex;
                align-items: center;

                .num {
                  width: 60rpx;
                  text-align: center;
                }
              }
            }
          }
        }
      }
    }
  }
</style>