<template>
	<view>
		<view class="se-pb-200">
			<view v-if="list.length>0">
				<view class="se-my-20 se-mx-20 se-px-20  se-py-20 se-br-20 se-bgc-white se-flex se-flex-v"  v-for="(item,index) in list" :key="index">
					<view @click="onDetail(item)" class="  se-flex">
						<view class="se-pos se-w-260 se-h-180">
							<image v-if="item.iconImage" class="se-a-80 se-pos-lt" :src="item.iconImage" mode=""></image>
							<image class="se-w-260 se-h-180 se-br-10" :src="item.images[0]" mode=""></image>
						</view>
						<view class="se-pl-10 se-w-p-100">
							<view class="se-c-black se-fs-28">
								{{item.title}}
							</view>
							<view class="se-flex se-flex-h-sb se-flex-ai-c se-fs-24 se-mt-10 se-c-66">
								<text>{{item.homeType}}</text>
								<text>{{item.timeGo}}年</text>
							</view>
							<view class="se-flex se-flex-h-sb se-flex-ai-c se-mt-10">
								<template v-if="item.iconTitles.length>0">
									<view class="se-flex">
										<view class="se-display-ib se-c-white se-bgc-orange se-fs-22 se-br-8 se-px-10 se-py-5 se-mr-10" v-for="(items,indexs) in item.iconTitles" :key="indexs">
											{{items}}
										</view>
									</view>
								</template>
								<template v-else><view></view></template>
								<view class="se-c-66 se-flex se-flex-ai-c">
									<uv-icon name="eye"></uv-icon>
									<text class="se-ml-5 se-fs-18">{{item.num}}</text>
								</view>
							</view>
							<view class="se-flex  se-flex-h-sb se-flex-ai-c se-mt-10">
								<text class="se-c-red se-fs-24 se-fw-6 se-toe-1">￥{{item.price}}元/{{item.unit}}</text>
								<text class="se-c-66 se-fs-22 se-toe-1">{{item.address}}</text>
							</view>
						</view>
					</view>
					<view class="se-flex se-fs-24">
						<view class="se-flex-1 se-py-20">
							<text class="se-c-99 se-mr-20">编辑</text>
						</view>
						<view class="se-flex-1 se-py-20 se-flex se-flex-h-fe">
							<text class="se-c-red se-mr-20" @click="onDelete(item)">删除</text>
						</view>
					</view>
				</view>
			</view>
			<view v-else>
				<uv-empty mode="list" ></uv-empty>
			</view>
		</view>
	</view>

</template>

<script>
	import { MyHousePageList,deleteHouse } from "@/common/api.js"
	export default {
		data(){
			return{
				pageNo:1,
				pageSize:10,
				list:[]
			}
		},
		onLoad(options) {
			this.onMyHousePageList()
		},
		onPullDownRefresh() {
			let that = this
			that.pageNo =  1
			that.list = []
			that.onMyHousePageList()
		},
		onReachBottom() {
			let that = this
			that.pageNo = that.pageNo + 1
			that.onMyHousePageList()
		},
		methods:{
			onMyHousePageList(){
				let that = this
				let params={
					pageNo:that.pageNo,
					pageSize:that.pageSize
				}
				MyHousePageList(params).then((response) => {
					console.info("responseindexsindexsindexs",response.result.records)
					response.result.records.forEach((items,indexs)=>{
						if(items.image){
							items.images = items.image.split(',')
						}else{
							items.images = []
						}
						if(items.homeImage){
							items.homeImages = items.homeImage.split(',')
						}else{
							items.homeImages = []
						}
						if(items.iconTitle){
							items.iconTitles = items.iconTitle.split(',')
						}else{
							items.iconTitles = []
						}
						
					})
					console.info('response.resultindexsindexsindexs',response.result.records)
					that.list = that.list.concat(response.result.records) 
				}).catch((error) =>{
					
				})
			},
			onDetail(event){
				uni.navigateTo({
					url:"/pages_subpack/detail/index?id="+event.id
				})
			},
			onDelete(event){
				let that = this;
				uni.showModal({
					title: '温馨提示',
					content: '确定是否删除该数据？',
					success: function (res) {
						if (res.confirm) {
							console.log('用户点击确定');
							console.info('event',event)
							deleteHouse({houseId:event.id}).then(response=>{
								uni.showToast({
									icon:"none",
									title:"删除成功"
								})
								that.onMyHousePageList()
							}).catch(error=>{
								
							})
						} else if (res.cancel) {
							console.log('用户点击取消');
						}
					}
				});
			}
		}
	}
</script>

<style>
</style>