<template>
	<view style="width: 100%;height: 100vh;">
		<view class="fbanniu" @click="btnclick" v-if="companyStatus == 5">
			<u-icon name="plus" color="#FFF" size='30'></u-icon>
			<!-- <image src="https://viitto-1301420277.cos.ap-chengdu.myqcloud.com/Static/fabupyq.png" style="height: 26rpx;" mode="aspectFit"></image> -->
			<text style="font-size: 10px;color: #FFF;">新增</text>
		</view>
		<u-empty v-if="dataList.length == 0" text="暂无数据" mode="list" class="noBox"></u-empty>
		<view class="list-box" v-if="dataList.length > 0">
			<scroll-view :scroll-y="true" :enable-back-to-top="true" :enable-flex="true" @scrolltolower="lower"
				style="height: 100%;">
				<view v-for="(item,index) in dataList" :key="index" class="wish-item" @click="goDetail(item.Id)">
					<view class="name">
						{{item.BranchName}}
					</view>
					<view class="flex">
						<view class="addr flex">
							<image src="https://viitto-1301420277.cos.ap-chengdu.myqcloud.com/Static/floor_red.png" style="width: 13px;height: 12px;margin-right: 5px;"></image>
							{{item.CarrierName}}
						</view>
						<view class="addr flex" style="margin-left: 10px;">
							<image src="https://viitto-1301420277.cos.ap-chengdu.myqcloud.com/Static/address_red.png" style="width: 9px;height: 13px;margin-right: 5px;"></image>
							{{item.Area}}
						</view>
					</view>
					<view class="con" >
						<view v-html='item.Description'  style="width: 100%;height: 50px;overflow: hidden;"></view>
					</view>
					<view class="flex between-center" style="margin-top: 10px;">
						<view class="date">
							{{item.UpdateDate}}
						</view>
						<view class="" @click.stop="goedit(item.Id)">
							<image src="https://viitto-1301420277.cos.ap-chengdu.myqcloud.com/Static/edit_black.png" style="width: 13px;height: 13px;"></image>
							
						</view>
					</view>
				</view>
				<u-loadmore :status="status" :load-text="loadText" :font-size="24" :margin-top="20" :margin-bottom="20"
					bg-color="#FFFFFF" />
			</scroll-view>
		</view>
		<!-- 加载中 -->
		<view class="loading" v-if="loading">
			<u-loading mode="flower" size="48"></u-loading>
			<Text style="color: #f6f6f6; margin-top: 10rpx;">加载中...</Text>
		</view>
		
	</view>
</template>

<script>
	import tabbars from '@/components/tabbar/index';
	export default {
		components:{
			tabbars
		},
		data() {
			return {
				mainColor: '',
				active: 0,
				searchKey:"",
				typeList: [],
				dataList:[],
				msg:{
					 pageIndex:1,
					 pageSize:10,
					 UserId:"",
					 BranchName:"",
					 CarrierName:"",
					
				},
				loading: false,
				pageCount:0,
				status: "loadmore",
				loadText: {
					loadmore: "轻轻上拉，加载更多",
					loading: "努力加载中",
					nomore: "没有更多了",
				},
				contentHeight:0,
				companyStatus:0,
				FirstShopType:1
			};
		},
		onLoad(options) {
			if(options && options.id){
				this.msg.ProjectType = options.id
			}
			let c = this.$uiConfig.is_bang ? 78 : 50;
			this.contentHeight = this.$utils.calcContentHeight(c)+40;
			// this.getTypeList()
		},
		created() {
			this.mainColor = this.$uiConfig.mainColor;
			
		},
		mounted() {
			uni.setNavigationBarTitle({
				title: '心愿清单列表',
			});
			this.msg.UserId = uni.getStorageSync("mall_UserInfo")?uni.getStorageSync("mall_UserInfo").UserId:'0'
			this.getCarrierPageList()
			this.getComponyStatus()
		},
		methods: {
			
			// 获取载体分页列表
			getCarrierPageList(type=0){
				if(type==1 || type==2){
					this.msg.pageIndex=1;
					this.dataList = []
				}
				let parms = {
					url: "/api/AppletTrade/GetMyWishPageList",
					data:this.msg
				}
				this.request2(parms, (res) => {
					this.loading = false;
					if (res.resultCode == 1) {
						
						this.dataList = this.dataList.concat(res.data.pageData);
						this.pageCount = res.data.pageCount
						if (this.pageCount == 1) {
							this.status = "nomore";
						}
					}
				})
			},
			// 获取公司认证信息
			getComponyStatus(){
				let that = this
				let parms = {
					url: "/api/AppletTrade/GetCommpanyStatus",
				}
				this.request2(parms, (res) => {
					if (res.resultCode == 1&&res.data!=null) {
						// 获取公司名字和认证状态
						that.companyStatus=res.data.CompanyStatus
						this.FirstShopType = res.data.FirstShopType
					}
				})
			},
		
			//触底事件
			lower(e) {
				if (this.msg.pageIndex < this.pageCount) {
					this.msg.pageIndex++;
					this.status = "loading";
					// this.getCarrierPageList();
				} else {
					this.status = "nomore";
				}
			},
			goDetail(id){
				uni.navigateTo({
					 url: '/pages/kotra/wish/detail?Id='+id
				})
			},
			btnclick(){//新增心愿
				uni.navigateTo({
					 url: '/pages/kotra/wish/myWishPlan'
				})
			},
			goedit(Id){
				uni.navigateTo({
					 url: '/pages/kotra/wish/myWishPlan?Id='+Id +'&type=2'
				})
			}
		}
	};
</script>

<style lang="scss" scoped>
	.flex{
		display: flex;
	}
	.between-center{
		justify-content: space-between;
		align-items: center;
	}
	.list-box{
		height: 100vh;
		margin: 0rpx; 
		
		box-sizing: border-box;
		font-family: PingFang SC;
	}
	.wish-item{
		width: 690rpx;
		
		margin: 0 auto 34rpx;
		padding: 30rpx;
		background-color: #FFFFFF;
		box-shadow: 0rpx 10rpx 50rpx 0rpx rgba(218, 220, 230, 0.85);
		border-radius: 30rpx;
		
		.name{
			font-size: 28rpx;
			font-weight: 800;
			color: #111111;
			margin-bottom: 20rpx;
		}
		.addr{
			font-size: 24rpx;
			font-weight: 500;
			color: #999999;
			margin-bottom: 20rpx;
			align-items: center;
		}
		.con{
			font-size: 24rpx;
			color: #999999;
			overflow : hidden;
			text-overflow: ellipsis;
			display: -webkit-box;
			-webkit-line-clamp: 2;
			-webkit-box-orient: vertical;
			margin-bottom: 20rpx;
		}
		.date{
			font-size: 22rpx;
			color: #BCBCBC;
		}
		
		
	}
	.fbanniu{
		width: 42px;
		height: 42px;
		border-radius: 21px;
		position: fixed;
		right: 20rpx;
		bottom: 180rpx;
		background: #40766E;
		display: flex;
		flex-direction: column;
		align-items: center;
		justify-content: center;
		z-index: 99;
	}
</style>
