<template>
  <view class="u-page">
    <z-paging
      ref="paging"
      inside-more
      loading-more-no-more-text="咱也是有底线的！"
      :auto-show-back-to-top="true"
      v-model="dataList"
      @query="queryList"
    >
      <template #top>
        <navBar></navBar>
        <view class="detail">
          <view class="desc">检索到XX篇文章</view>
          <view class="desc">检索到X个视频</view>
          <view class="desc">检索词：陈煜</view>
        </view>
        <view class="filterbox">
          <u-dropdown class="u-dropdown">
            <up-dropdown-item
              v-model="value"
              title="温度"
              :options="options"
            ></up-dropdown-item>
          </u-dropdown>
        </view>
      </template>
      <view class="item" v-for="(item, index) in dataList" :key="index">
        <view class="title ellipsis">{{ item.title }}</view>
        <view class="tagsbox">
          <view class="tag">陈煜</view>
        </view>
        <view class="deal">
          <view class="left">
            <view class="eyebox">
              <up-icon name="eye" color="#6B7280" size="28rpx"></up-icon>
              <view class="num">1</view>
            </view>
            <view class="collect">
              <up-icon name="heart" color="#6B7280" size="28rpx"></up-icon>
              <view class="num">1</view>
            </view>
          </view>
          <view class="time">
            <up-icon name="clock" color="#6B7280" size="28rpx"></up-icon>
            <view class="num">1</view>
          </view>
        </view>
      </view>
    </z-paging>
  </view>
</template>

<script setup>
import { ref, reactive } from "vue";
import navBar from "@/components/navBar/navBar.vue";
import list from "@/uni_modules/z-paging/components/z-paging/z-paging";
import api from "@/api/api";
import { onLoad } from "@dcloudio/uni-app";
const paging = ref(null);
const dataList = ref([]);
const value = ref("");
const options = ref([
  {
    label: "去冰",
    value: 1,
  },
  {
    label: "加冰",
    value: 2,
  },
]);

onLoad(() => {});
const queryList = (pageNo, pageSize) => {
  const params = {
    pageNo: pageNo,
    pageSize: pageSize,
    type: 1,
  };
  // 此处请求仅为演示，请替换为自己项目中的请求
  api
    .queryList(params)
    .then((res) => {
      // console.log(res)
      // dataList.value=dataList.value.concat(res.data.list)
      // 将请求结果通过complete传给z-paging处理，同时也代表请求结束，这一行必须调用
      paging.value.complete(res.data.list);
    })
    .catch((res) => {
      // 如果请求失败写paging.value.complete(false);
      // 注意，每次都需要在catch中写这句话很麻烦，z-paging提供了方案可以全局统一处理
      // 在底层的网络请求抛出异常时，写uni.$emit('z-paging-error-emit');即可
      paging.value.complete(false);
    });
};
</script>

<style lang="scss" scoped>
.u-page {
  :deep(.u-flex) {
    display: flex;
    flex-direction:row;

  }
  .deal {
    margin-top: 20rpx;
    display: flex;
    color: #6b7280;
    font-size: 24rpx;
    justify-content: space-between;
    .left {
      display: flex;
      align-items: center;
    }
    .collect {
      display: flex;
      align-items: center;
    }
    .eyebox {
      width: 160rpx;
      display: flex;
      align-items: center;
    }
    .time {
      display: flex;
      align-items: center;
    }
    .num {
      margin-left: 8rpx;
    }
  }
  .item {
    border-bottom: 1rpx solid #f3f4f6;
    padding: 30rpx;
    .title {
      font-size: 30rpx;
      color: #111827;
      line-height: 46rpx;
    }
  }
  .tagsbox {
    margin-top: 20rpx;
    display: flex;
    .tag {
      padding: 0 10rpx;
      margin-right: 16rpx;
      height: 46rpx;
      line-height: 46rpx;
      text-align: center;
      background: rgba(60, 199, 192, 0.1);
      border-radius: 8rpx;
      font-weight: 400;
      font-size: 24rpx;
      color: #3cc7c0;
    }
  }
}
.detail {
  background: #f9f9f9;
  padding: 12rpx 30rpx;
  .desc {
    font-size: 26rpx;
    color: #4b5563;
    line-height: 40rpx;
  }
}
</style>