<style>
	.details{
		display: flex;
		flex-direction: column;
		padding: 0 15px;
	}
	.item{
		width: 100%;
		display: flex;
		align-items: flex-start;
		margin-top: 20px;
		
	}
	.item-left{
		width: 80rpx;
		height: 80rpx;
		position: relative;
	}
	.item-right{
		width: calc(100vw - 30px - 80rpx - 15px);
		margin-left: 15px;
		font-size: 11px;
		color: #666666;
		
	}
	.item-r-text{
		font-size: 15px;
		color: #000000;
		font-weight: 400;
	}
	.r-flex{
		width: 100%;
		display: flex;
		align-items: flex-start;
		margin-top: 8px;
	}
	.r-Remark{
		width: 100%;
		padding: 13px 12px;
		background: #EDEDED;
		color: #777777;
		border-radius: 6px;
		margin-top: 10px;
	}
	
	
</style>
<template>
  <view class="mydate" :style="{ height: contentHeight }">
    <u-tabs
      :list="list"
      :is-scroll="false"
      :current="current"
      @change="change"
      :active-color="mainColor"
    ></u-tabs>
    <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" >
			  <view class="item-left">
				  <u-avatar :src="x.WoManPhoto" v-if="UserId==x.ManId"  size="80"></u-avatar>
				  <u-avatar :src="x.ManPhoto" v-else  size="80"></u-avatar>
			  </view>
			  <view class="item-right">
				  <view v-if="UserId==x.ManId" class="item-r-text">{{x.WoManName}}</view>
				  <view v-else  class="item-r-text">{{x.ManName}}</view>
				  <view class="r-flex">
					  <u-icon name="clock-o"  size="24" ></u-icon>
					  <text style="margin-left: 5px;">{{x.Time}}</text>
				  </view>
				  <view class="r-flex">
					<u-icon name="location" :color="mainColor" size="24" ></u-icon>
					<text style="margin-left: 5px;">{{x.Address}}</text>
				  </view>
				  <view class="r-Remark" >
					  {{x.Remark!=null && x.Remark !=''?x.Remark:'无'}}
				  </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>
  </view>
</template>

<script>
import auth from "@/components/auth/index.vue";
export default {
  components: {
    auth
  },
  data() {
    return {
      pageTitle: "我的约会",
      showAuth:false,
	  u:{},
	  show:false,
	  current:0,
    
      mainColor: "",
      contentHeight: 0,
      
	  msg:{
		  pageIndex: 1,
		  pageSize:10,
		  
	  },
      page_count: 1,
      g: [],
      loading: false,
	  status: "loadmore",
	  loadText: {
	    loadmore: "轻轻上拉，加载更多",
	    loading: "努力加载中",
	    nomore: "没有更多了",
	  },
	  UserId:0,
	  
    };
  },
  created() {
    this.contentHeight = this.$utils.calcContentHeight(-40) + "px";
    this.mainColor = this.$uiConfig.mainColor;
	let UserId = uni.getStorageSync('mall_UserInfo')?uni.getStorageSync('mall_UserInfo').UserId : 0;
	this.UserId = UserId
  },
  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.init();
    }
  },
  methods: {
   
    init() {
      
	  this.request2(
	  	{
	  		url: '/api/AppletMiai/GetMiaiMyDatingPageList',
	  		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()
	},


	
  },
};
</script>
<style>
.mydate {
  width: 100%;
  height: 100%;
  background: #FFF;
  position: relative;
}







</style>
