<template>
  <view class="myrecruitstick" :style="{ height: contentHeight }">
   
    <u-empty v-if="g.length == 0" text="暂无数据" mode="list"></u-empty>
		
    <view
      v-if="g.length > 0"
      style="
        height: calc(100vh);
        width: calc(100vw);
        overflow: hidden;
      "
    >
      <scroll-view
        :scroll-y="true"
        :enable-back-to-top="true"
        :enable-flex="true"
        @scrolltolower="lower"
        :style="{ height: '100%' }"
      >
        <view class="details">
		  <view class="item" v-for="(x, i) in g" :key="i" @click="godetails(x)">
			  <view class="item-l">
				  <view style="font-size: 13px;color: #111;">{{x.CreateDate.split(' ')[0].split('-')[2]}}</view>
				  <view style="font-size: 12px;color: #444;">{{x.CreateDate.split(' ')[0].split('-')[1]}}月</view>
			  </view>
			  <view style="width: calc(100vw - 30px - 40px);">
				  <view style="display: flex;align-items: center;justify-content: space-between;width: 100%;">
					  <view style="font-size: 10px;color: #B2B2B2;">{{x.ForumName}}</view>
					  <u-icon name="delete" :size="35" color="111" @click.native.stop='cancel(x,i)'></u-icon>
				  </view>
				  <view style="font-size: 14px;color: #111111;line-height: 18px;margin-top: 5px;">
					  {{x.ActivityTitle}}
				  </view>
				  <view style="display: flex;align-items: center;margin-top: 10px;" >
					  <view v-for="(item, index) in x.ImageList" v-if="index<3" :key="index" @click.native.stop="previewImage(index,x.ImageList)" style="width: calc((100vw - 30px - 40px - 10px) /3 );height: calc((100vw - 30px - 40px - 10px) /3 );margin-right: 5px;position: relative;">
						  <image :src="item" mode="aspectFill" style="width: 100%;height: 100%;"></image>
						  <view v-if="index==2 &&x.ImageList.length>3" style="width: 100%;height: 100%;position: absolute;left: 0;top: 0;background: rgba(1, 1, 1, 0.2);"></view>
						  <view v-if="index==2 &&x.ImageList.length>3" style="font-size: 11px;color: #FFF;position: absolute;bottom: 5px;right: 5px;">
							  +{{x.ImageList.length-3}}
						  </view>
					  </view>
				  </view>
			  </view>
		  </view>
        </view>
     
		<u-loadmore
		  :status="status"
		  :load-text="loadText"
		  :font-size="24"
		  :margin-top="20"
		  :margin-bottom="20"
		  bg-color="#FFF"
		/>
      </scroll-view>
    </view>

    <!-- 加载中 -->
    <view class="loading" v-if="loading">
      <u-loading mode="flower" size="48">></u-loading>
      <Text style="color: #fff; margin-top: 10rpx;">加载中...</Text>
    </view>
   
   <auth v-if="showAuth" @changeuserinfo="reloadUserinfo" @gbAuth= 'gbAuth'></auth>
   <u-modal v-model="show" content="是否删除此贴？" :show-cancel-button='true' @confirm='queren'></u-modal>
  </view>
</template>

<script>
import auth from "@/components/auth/index.vue";
export default {
  components: {
    auth
  },
  data() {
    return {
      pageTitle: "我的招募贴",
      showAuth:false,
	  u:{},
	  show:false,
	  current:0,
      list: [
        { name: "不限" },
        { name: "正常" },
        { name: "取消" },
      ],
      mainColor: "",
      contentHeight: 0,
      
	  msg:{
		  pageIndex: 1,
		  pageSize:10,
		  ForumId:0,
		  UserId:0,
	  },
      page_count: 1,
      g: [],
      loading: false,
	  status: "loadmore",
	  loadText: {
	    loadmore: "轻轻上拉，加载更多",
	    loading: "努力加载中",
	    nomore: "没有更多了",
	  },
	  bmobj:{}
    };
  },
  created() {
    this.contentHeight = this.$utils.calcContentHeight(-40) + "px";
    this.mainColor = this.$uiConfig.mainColor;
  },
  mounted() {
    let currentPages = getCurrentPages();
    let u = "/" + currentPages[currentPages.length - 1].route;
    let pages = wx.getStorageSync("basedata")
      ? wx.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,
    });
  },
  onLoad: function (option) {    
    this.u = uni.getStorageSync("mall_UserInfo");
    if (!this.u) {
      this.u = {
    	nickName: "未登录",
    	avatarUrl: ""
      };
      this.showAuth = true;
    }	else{
		this.msg.UserId = this.u.UserId
    	this.init();
    }
  },
  methods: {

    init() {
      
	  this.request2(
	  	{
	  		url: '/api/AppletMiai/GetActivityPageList',
	  		data: this.msg
	  	},
	  	res => {
	  		if(res.resultCode==1){
	  				this.loading = false;
	  				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";
      }
    },
	reloadUserinfo() {
	  this.u = uni.getStorageSync("mall_UserInfo");
	  // this.showAuth=false;
	  this.init();
	},
	//关闭登录窗口
	gbAuth(){
		uni.navigateBack()
	},
	cancel(x,i){
		this.bmobj={
			EnrollId:x.Id,
			index:i
		}
		
		this.show=true
	},
	//图片预览
	previewImage(index, images) {
		uni.previewImage({
			urls: images,
			current: index,
		});
	},
	queren(){
		this.request2(
			{
				url: '/api/AppletMiai/DelActivityInfo',
				data: {ActivityId:this.bmobj.EnrollId}
			},
			res => {
				if(res.resultCode==1){
					uni.showToast({
						title: '删除成功',
						icon: 'success',
					})
					this.g.splice(this.bmobj.index,1)
					
				}
			}
		);
	},
	godetails(x){
		uni.navigateTo({
			url: '/pages/blindDate/postDetails?Id='+x.Id 
		})
	}
	
  },
};
</script>
<style>
.myrecruitstick {
  width: 100%;
  height: 100%;
  background: #FFF;
  position: relative;
}

.myrecruitstick .loading {
  width: 180rpx;
  height: 180rpx;
  background: #000000;
  opacity: 0.7;
  border-radius: 10rpx;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  position: fixed;
  left: 50%;
  top: 30%;
  margin-left: -100rpx;
  z-index: 999;
}
.myrecruitstick .details{
	
	display: flex;
	flex-direction: column;
	
}
.myrecruitstick .item{
	padding: 15px;
	display: flex;
	align-items: flex-start;
}
.myrecruitstick .item-l{
	width: 40px;
	display: flex;
	flex-direction: column;
	align-items: center;
	margin-top: 4px;
}









</style>
