<template>
	<view>
		<view v-if="evaluations.length>0"
			style="display: flex;flex-direction: column;justify-content: center;width: 100%;margin-top: 10rpx;">
			<view class="content" v-for="(evaluation,index) in evaluations" :key="index" @tap="itemClick(evaluation)"
				:data-taskid="evaluation.evaluationId">
				<view class="item-li">
					<view class="item-title">{{index + 1}}.{{evaluation.evaluationName}}</view>
				</view>
			</view>
		</view>
		<view v-else>
			<emptyView></emptyView>
		</view>
		<yomol-upgrade :type="upgradeType" :url="upgradeUrl" title="发现新版本" :content="upgradeContent" ref="yomolUpgrade">
		</yomol-upgrade>
	</view>

</template>

<script>
	import common from '../../common/common.js'
	import yomolUpgrade from '@/components/yomol-upgrade/yomol-upgrade.vue'
	var _self;
	export default {
		components: {
			yomolUpgrade
		},
		data() {
			return {
				token: '',
				upgradeType: 'pkg', //pkg 整包 wgt 升级包	
				upgradeContent: '', //更新内容			
				upgradeUrl: '', //更新地址
				divider: '&nbsp;|&nbsp;',
				evaluations: [],
				more: 'more',
				uploadContentText: {
					contentdown: '点击加载更多',
					contentrefresh: '正在加载...',
					contentnomore: '没有更多数据了'
				},
				keyword: '',
			}
		},
		onShow() {
			var appToken = uni.getStorageSync('appToken');
			if (!appToken) {
				uni.reLaunch({
					url: '../login/index'
				});
			}
			_self.token = appToken
		},
		onLoad() {
			_self = this;
			var appToken = uni.getStorageSync('appToken');
			if (!appToken) {
				uni.reLaunch({
					url: '../login/index'
				});
			}
			_self.token = appToken
			// #ifdef APP-PLUS
			_self.checkAppVersion();
			// #endif
			_self.initData();
		},
		methods: {
			checkAppVersion() {
				var versionUrl = common.userCenterBaseUrl +
					'/app/appversion/getappversionnumber/240fbf7a-aa32-4cde-9674-5147a7d5eb2f'
				var downloadUrl = common.userCenterBaseUrl +
					'/app/appversion/downloadapp/240fbf7a-aa32-4cde-9674-5147a7d5eb2f'
				uni.request({
					url: versionUrl,
					header: {
						'token': _self.token
					},
					success(res) {
						plus.runtime.getProperty(plus.runtime.appid, (wgtinfo) => {
							var appId = wgtinfo.appid;
							var appVersion = wgtinfo.versionCode;
							if (res.data.data && res.data.data > appVersion) {
								_self.upgradeType = 'pkg'
								_self.upgradeContent = "新增部分更能,请更新;"
								_self.upgradeUrl = downloadUrl
								_self.$refs.yomolUpgrade.show()
							} else {}
						});
					},
					fail(error) {}
				})
			},
			initData() {
				uni.showLoading({
					title: '加载中...',
				})
				var self = this;
				// var listUrl = common.evalutaionBaseUrl + '/app/apptask/listtasktoapp';
				var listUrl = common.evalutaionBaseUrl + '/app/apptask/listevaluation';
				uni.request({
					url: listUrl,
					header: {
						'token': _self.token
					},
					success(res) {
						uni.hideLoading()
						if (res.data != undefined && res.data.length > 0) {
							_self.evaluations = res.data
						} else {
							_self.evaluations = [];
						}
					},
					fail(error) {
						uni.hideLoading()
						uni.showToast({
							title: '加载失败,请重试',
							duration: 2000
						})
						_self.evaluations = [];
					}
				})
			},
			itemClick(e) {
				uni.navigateTo({
					url: 'indexTwo?id=' + e.evaluationId,
				})

				// uni.navigateTo({
				// 	url: '../evaluation/doEvaluation?taskId=' + e.taskId
				// })
			},
			clickLoadMore(e) {
				var self = this;
				self.more = 'loading';
				setTimeout(() => {
					self.more = 'noMore';
					setTimeout(() => {
						self.more = 'more';
					}, 1000);
				}, 2000);
			}
		}
	}
</script>

<style>
	.content {
		width: 100%;
		display: flex;
		margin-top: 20rpx;
		flex-direction: column;
		align-items: center;
		justify-content: center;
	}


	.search-input {
		background-color: #F7F7F7;
		font-size: 28upx;
		border-radius: 50upx;
	}


	.voice-icon {
		width: 36upx;
		height: 36upx;
		padding: 16upx 20upx 16upx 0;
		position: absolute;
		left: 16upx;
		top: 4upx;
		z-index: 10;
	}

	.search-icon {
		width: 36upx;
		height: 36upx;
		padding: 16upx 20upx 16upx 0;
		position: absolute;
		right: 0;
		top: -2upx;
		z-index: 10;
	}

	.item-count {
		font-size: 15rpx;
		display: flex;
		flex-direction: row;
		justify-content: space-between;
		align-items: center;
	}

	.input-box {
		margin-top: 10rpx;
		width: 90%;
		min-height: 50rpx;
		display: flex;
		flex-direction: row;
		align-items: center;
		justify-content: center;
		background-color: #F5F5F5;
		border: #666666 solid #555555;
		border-radius: 20rpx;
	}

	.input-font {
		color: #000000;
		width: 90%;
		margin-left: 10rpx;
		padding-left: 10rpx;
		align-self: center;
		font-size: 30rpx;
		min-height: 50rpx;
		border: #666666 solid #555555;
		border-radius: 15rpx;
	}

	.item-li {
		display: flex;
		flex-direction: column;
		height: auto;
		align-self: center;
		justify-content: space-between;
		align-items: flex-start;
		width: 92%;
		background: #FFFFFF;
		/* background: #008B8B; */
		padding: 25rpx;
		border-radius: 10rpx;
		box-shadow: 3rpx 3rpx 5rpx #d9d9d9;
	}

	.item-title {
		font-size: 28rpx;
		font-weight: bold;
		color: #000000;
	}

	.item-content {
		font-size: 30rpx;
		color: #000000;
	}

	.item-count-tag {
		display: flex;
		font-size: 20rpx;
		color: #000000;
		background: #008B8B;
		padding: 10rpx;
		height: 35rpx;
		align-items: center;
		text-align: center;
		border-radius: 10rpx;
		box-shadow: 8rpx 8rpx 10rpx #d9d9d9;
	}

	.item-count-yet {
		color: #FFFFFF;
	}

	.item-count-not {
		color: #f9e9c3;
	}

	.item-tag-box {
		display: flex;
		flex-direction: column;
		align-items: flex-start;
	}

	.item-bottom-box {
		display: flex;
		margin-top: 15rpx;
		flex-direction: row;
		align-items: center;
		justify-content: space-between;
		width: 100%;
	}

	.item-time {
		font-size: 25rpx;
		color: #000000;
	}

	.item-tag {
		color: #888888;
		display: flex;
		justify-content: center;
		align-items: flex-start;
		text-align: left;
		font-size: 25rpx;
	}

	.input-placeholder {
		color: #808080;
		font-size: 25rpx;
	}
</style>
