<template>
	<view class="page">

		<view v-for="(item,index) in dataList" class="newslist">

			<view class="item" @click="navToDetailPage(item.sid)">


				<view class="item-lift">

					<text class="tetx1">{{item.entryName}}</text>
					<text class="tetx2">{{item.enterpriseName}}</text>

				</view>

				<image src="../../static/baseIcon/zy.png" mode="aspectFill" style="width: 15px;height: 15px;"></image>

			</view>

		</view>

	</view>

</template>

<script>
	export default {
		data() {
			return {
				dataList: [
					// {
					// 	sid: "1",
					// 	name: "瀚川商贸化工动产质押项目",
					// 	custerName: "石家庄鸿彩字业制作有限公司",
					// },
					// {
					// 	sid: "2",
					// 	name: "富荣食品快消品动产质押项目",
					// 	custerName: "石家庄富荣食品有限公司",
					// }
				],
			}
		},
		created() {
			this.$bus.$on('wholeSpin', msg => {
				//这里获取到http工具js文件中传过来的wholeSpin值
				console.log(">>>>>", this.isShow)
		
				var userSid = getApp().globalData.sid
				console.log(">>>>>", userSid)
				this.loadData();
			});
		},
		
		
		onLoad() {
		
		},
		onShow() {
			
			wx.hideHomeButton()
					
					
			console.log('onShow', getApp().globalData.isLogin)
			
			let token = uni.getStorageSync("Global-Auth-Token")
			if (token != null && token.length != 0) {
				getApp().globalData.token = token
			}
			let isLogin =uni.getStorageSync("isLogin")
			if (isLogin != null && isLogin == 1) {
				getApp().globalData.isLogin = isLogin
			}
			let sid = uni.getStorageSync("sid")
			if (sid != null && sid.length != 0) {
				getApp().globalData.sid = sid
			}
			
			console.log('用户Sid', getApp().globalData.sid)
			console.log('token', getApp().globalData.token)
			console.log('是否登陆', getApp().globalData.isLogin)
			
			// setTimeout(() => {
			if (getApp().globalData.isLogin) {
				var userSid = getApp().globalData.sid
				console.log(">>>>>", userSid)
					this.loadData();
				// uni.setTabBarBadge({ //显示数字
				// 	index: 0, //tabbar下标
				// 	text: '100' //数字
				// })
			} else {
			
				/*  #ifdef  MP-WEIXIN */
				this.WxSilentLogin()
				/* #endif */
			
				/*  #ifdef APP-PLUS */
				uni.redirectTo({
					url: '../login/login'
				})
				/* #endif */
			}
		},
		methods: {

			loadData() {
				this.$api.getProjectByUserSid(getApp().globalData.sid).then((resp) => {
					// if (resp.success) {
					console.log('1111', resp)
					this.dataList = resp

				}).catch(e => {
					console.log('eeeee', e)
				})
			},
			//详情
			navToDetailPage(sid) {
				console.log("sid>>>>", sid)
				uni.navigateTo({
					url: 'ProjectDetail?sid=' + sid
				});
				// uni.navigateTo({
				// 	url: 'WarehouseDetaile?sid='+sid,
				// 	// // 版本2.8.9+ 支持
				// 	// success: (res) => {
				// 	// 	// 和上面其实没差什么,但是这种方式是可以的 这里不是$emit
				// 	// 	res.eventChannel.emit('sendTestValue', {
				// 	// 		info: item
				// 	// 	})
				// 	// }
				// });
			},

			editData() {

			},
		}
	}
</script>

<style lang="scss">
	.page {
		width: 100%;
		padding-bottom: 20px;
		.newslist {
			
			margin-top: 15px;
			margin-left: 15px;
			margin-right: 15px;
			display: flex;
			flex-direction: row;
			align-items: center;
			background: #fff;
			border-radius: 10px;
			padding: 15px 20px;

			.item {
				width: 100%;
				display: flex;
				flex-direction: row;
				align-items: center;

				.item-lift {
					flex: 1;
					display: flex;
					flex-direction: column;

					.tetx1 {
						color: #101010;
						font-size: 16px;
						overflow: hidden;
						text-overflow: ellipsis;
						display: -webkit-box;
						-webkit-line-clamp: 1;
						-webkit-box-orient: vertical;
					}

					.tetx2 {
						margin-top: 10px;
						color: #999;
						font-size: 14px;
					}
				}
			}

		}
	}
</style>