<template>
<view class="liveStyle" :style="{ height: contentHeight }">
    <u-empty v-if="g.length == 0" text="暂无相关直播列表" mode="coupon"></u-empty>

    <template
      v-if="g.length > 0"
      style="
        height: calc(100vh -50px);
        width: calc(100vw -20px);
        overflow: hidden;
		margin-left: 10px;
		padding-top: 10px;
      "
    >
      <scroll-view
        :scroll-y="true"
        :enable-back-to-top="true"
        :enable-flex="true"
        @scrolltolower="lower"
        :style="{ height: '100%' ,}"
      >
        <view class="u-good-list" >
          <u-row gutter="20">
            <u-col span="6" v-for="(cx, ci) in g" :key="ci">
              <view class="good" @click="clickHandler(cx)">
                <view class="good-img">
                  <image
                    mode="aspectFit"
                    :src="cx.cover_img"
                    style="width: 100%; height: 100%;"
                  />
                </view>
                <view class="good-name">{{ cx.name }}</view>
                <view class="good-info">
                  <u-avatar :src="cx.anchor_img" size="80" ></u-avatar>
				  <Text style="font-size: 12px;">{{cx.anchor_name}}</Text>		
                </view>
              </view>
            </u-col>
          </u-row>
        </view>
		 <u-loadmore
		   :status="status"
		   :load-text="loadText"
		   :font-size="24"
		   :margin-top="20"
		   :margin-bottom="20"
		   bg-color="#f3f4f6"
		 />
      </scroll-view>
	 
    </template>
	<tabbars></tabbars>
  </view>
</template>

<script>
	import tabbars from '@/components/tabbar/index';
export default {
	components: {
		tabbars
	},
  data() {
    return {
      mc: "",
      secondary: "",
      pageTitle: "直播列表",
	  contentHeight: 0,
	  g:[],
      msg:{
      		pageIndex: 1,
      		pageSize:10,
      },
      page_count: 1,
      status: "loadmore",
      loadText: {
        loadmore: "轻轻上拉，加载更多",
        loading: "努力加载中",
        nomore: "没有更多了",
      },
    };
  },
  onLoad(option) {
    this.mc = this.$uiConfig.mainColor;
    this.secondary = this.$uiConfig.secondary;
	let c = this.$uiConfig.is_bang ? 80 : 52;
	this.contentHeight = this.$utils.calcContentHeight(c-40) + "px";
    this.initPage();
	uni.showNavigationBarLoading();
	this.init();
    
  },
  methods: {
    initPage() {
      let currentPages = getCurrentPages();
      let u = "/" + currentPages[currentPages.length - 1].route;
      let pages = uni.getStorageSync("basedata")
        ? uni.getStorageSync("basedata").bar_title
        : [];
      pages.forEach((x) => {
        if (x.value == u) {
          this.pageTitle = x.new_name ? x.new_name : x.name;
        }
      });
      uni.setNavigationBarTitle({
        title: this.pageTitle,
      });
    },
    init() {
		uni.showLoading({
		    title: '加载中'
		});
		this.request2(
			{
				url: '/api/AppletUser/GetLiveHouseList',
				data: this.msg
			},
			res => {
				uni.hideLoading();
				uni.hideNavigationBarLoading();
				if(res.resultCode==1){
					this.g = this.g.concat(res.data.pageData);
						 this.page_count = res.data.pageCount;
						 if (this.page_count == 1) {
						   this.status = "nomore";
						 }
				}
			}
		);
    },
	lower(e) {
		
		 if (this.msg.pageIndex < this.page_count) {
			this.msg.pageIndex++;
			this.status = "loading";
			this.init();
		 } else {
			this.status = "nomore";
		 }
	},
  },
};
</script>

<style>
	.liveStyle{
		background: #f3f4f6;
	}
	.liveStyle .u-good-list .good {
	  background: #fff;
	  border-radius: 10px;
	  overflow: hidden;
	  margin-bottom: 10px;
	}
	.liveStyle .u-good-list .good .good-img {
	  width: calc(50vw);
	  height: calc(50vw);
	  display: block;
	}
	.liveStyle .u-good-list .good .good-name {
	  overflow: hidden;
	  text-overflow: ellipsis;
	  display: -webkit-box;
	  -webkit-line-clamp: 2;
	  -webkit-box-orient: vertical;
	  margin-bottom: 3px;
	  font-size: 13px;
	  margin: 7px 10px;
	  height: 36px;
	}
	.liveStyle .u-good-list .good .good-info {
	  display: flex;
	  margin: 7px 10px;
	  margin-top: 0;
	  align-items: flex-end;
	  padding-bottom: 5px;
	}
	
</style>
