<!-- 推荐的动态路由 -->
<template>
  <view class="recommend">
    <view class="multiple">
      <view
        class="item-food"
        v-for="(item, index) in itemFood"
        :key="item.id"
        @click="footStyle(index, item)"
        :class="{ itemstyle: footIndex == index }"
      >
        <text class="alarm">#</text> {{ item.title }}
      </view>
    </view>
    <view class="waterfall"> </view>
    <waterfall
      v-if="flowList.length > 0"
      ref="wfp"
      :colunmNumber="colunmNumber"
      :flowList="flowList"
      :columnGap="10"
      :status="status"
    ></waterfall>
    <loadMore v-if="flowList.length > 0" :status="status"></loadMore>
    <nodata v-else :config="{ top: 15, content: '暂无数据~' }"></nodata>

    <view class="release" @click="gotorelease()">
      <image src="../../../static/pen.png" mode=""></image>

      <view class="item"> 发布 </view>
    </view>
  </view>
</template>

<script>
import waterfall from "../../../components/waterfall/waterfall";
import nodata from "../../noData/nodata";
import loadMore from "../../uni-load-more/uni-load-more";
export default {
  data() {
    return {
      footIndex: 0, //点击切换food的样式，默认是第一个
      recommendIndex: 0, //点击切换头部样式，默认是第一个
      itemFood: [],

      colunmNumber: 2,
      index: 19,
      flowList: [],
      page: 1,
      limit: 10,
      themeId: null, //主题id
      status: "more",
    };
  },
  props: {},
  comments: {
    waterfall,
    nodata,
    loadMore,
  },
  watch: {},
  mounted() {
    this.getTheme();
  },
  methods: {
    isload() {
      this.page = 1;
      (this.flowList = []), this.getList(this.themeId);
    },
    loaderMore() {
      if (this.status == "more") {
        this.page++;

        this.getList(this.themeId);
      }
    },
    getTheme() {
      this.$http.get("/opus/theme/list", this.params).then((res) => {
        if (res && res.code == 200) {
          this.itemFood = res.list;
          if (res.list.length > 0) {
            this.themeId = this.itemFood[0].id;
            this.getList(this.itemFood[0].id);
          }
        }
      });
    },
    gotorelease() {
      //跳转到发布页面
      uni.navigateTo({
        url: "./release",
      });
    },
    getList(id) {
      this.$http
        .get("/opus/all-list", {
          themeId: id,
          page: this.page,
          limit: this.limit,
        })
        .then((res) => {
          if (res && res.code == 200) {
            this.flowList = this.flowList.concat(res.page.list);

            if (res.page.totalPage <= res.page.currPage) {
              this.status = "noMore";
            } else {
              this.status = "more";
            }
            console.log(this.status);
          }
        });
    },
    footStyle(index, item) {
      this.flowList=[]
      this.footIndex = index;
      this.themeId = item.id;
      this.page = 1;
      this.getList(this.themeId);
    },
  },
};
</script>

<style lang="scss" scoped>
.release {
  background-color: #00321e;
  width: 101rpx;
  height: 101rpx;
  border-radius: 999rpx;
  position: fixed;
  bottom: 259rpx;
  right: 30rpx;
  display: flex;
  align-items: center;
  flex-direction: column;
  image {
    width: 37rpx;
    height: 30rpx;
    margin-top: 15rpx;
    margin-bottom: 6rpx;
  }
  .item {
    color: #ffffff;
    font-weight: 400;
    font-size: 25rpx;
  }
}

.water-flow-box {
  background-color: #f5f5f5;
  border-radius: 40rpx;
}
.waterfall {
  background-color: #f5f5f5;
  border-radius: 40px;
}
.multiple {
  margin-top: 88rpx;
  font-size: 32rpx;
  font-weight: 700;
  color: #999999;
  background: #ffffff;
  display: flex;
  align-items: center;
  white-space: nowrap;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  .item-food {
    padding-bottom: 30rpx;
    padding-top: 32rpx;
    margin-left: 30rpx;
    box-sizing: border-box;
    height: 105rpx;
    display: flex;
    .alarm {
      margin-right: 5rpx;
      display: block;
    }
  }
  .itemstyle {
    border-bottom: 1rpx solid #00321e;
    color: #00321e;
    border-radius: 1rpx;
  }
}
.top {
  z-index: 1;
  width: 100%;
  height: 88rpx;
  position: fixed;
  background-color: #00321e;
  display: flex;
  justify-content: center;
  align-items: center;
  color: rgba(255, 255, 255, 1);
  .recommend {
    padding-bottom: 24rpx;
    padding-top: 14rpx;
    font-size: 36rpx;
    font-weight: 500;
    margin-right: 104rpx;
    box-sizing: border-box;
    height: 86rpx;
  }
  .recommendtwo {
    border-bottom: 4rpx #ffffff solid;
    border-radius: 1rpx;
  }
}
.recommend {
  overflow: hidden;
}
</style>

