<template>
	<view>
		<!-- 胶囊 -->
		<mvBar :mysNavConfig="mysNavConfig"></mvBar>
		<view style="height: 160rpx;width: 100%; position: fixed;background-color: #FFFFFF;top: 0;z-index: 8;">
		</view>
		<view class="menu">
			<view class="menu-item" @click="toShow1()">
				<p v-bind:class="showList1?'lor':''">待传脚本</p>
			</view>
			<view class="menu-item" @click="toShow2()">
				<p v-bind:class="showList2?'lor':''">待传初稿</p>
			</view>
			<view class="menu-item" @click="toShow3()">
				<p v-bind:class="showList3?'lor':''">待发布</p>
			</view>
			<view class="menu-item" @click="toShow4()">
				<p v-bind:class="showList4?'lor':''">待传数据</p>
			</view>
		</view>

		<view class="home" v-if="showList1">
			<view class="task" v-for="item in List1">
				<view @click="toDetail(item)">
					<view class="task-head">
						<view class="task-head-account">
							<image :src="item.platform_icon_url" style="height: 50rpx;width: 50rpx;"></image>
							<p style="margin-left: 20rpx;">{{item.platform_nick_name}}</p>
						</view>
						<view class="task-head-status">
							<p>{{item.task_stage_txt}}</p>
						</view>
					</view>
					<view class="task-info">
						<image :src="item.product_img_url" style="height: 120rpx;width: 120rpx;"></image>
						<p style="margin-left: 50rpx;">{{item.project_name}}</p>
					</view>
				</view>
			</view>
		</view>

		<view class="home" v-if="showList2">
			<view class="task" v-for="item in List2">
				<view @click="toDetail(item)">
					<view class="task-head">
						<view class="task-head-account">
							<image :src="item.platform_icon_url" style="height: 50rpx;width: 50rpx;"></image>
							<p style="margin-left: 20rpx;">{{item.platform_nick_name}}</p>
						</view>
						<view class="task-head-status">
							<p>{{item.task_stage_txt}}</p>
						</view>
					</view>
					<view class="task-info">
						<image :src="item.product_img_url" style="height: 120rpx;width: 120rpx;"></image>
						<p style="margin-left: 50rpx;">{{item.project_name}}</p>
					</view>
				</view>
			</view>
		</view>

		<view class="home" v-if="showList3">
			<view class="task" v-for="item in List3">
				<view @click="toDetail(item)">
					<view class="task-head">
						<view class="task-head-account">
							<image :src="item.platform_icon_url" style="height: 50rpx;width: 50rpx;"></image>
							<p style="margin-left: 20rpx;">{{item.platform_nick_name}}</p>
						</view>
						<view class="task-head-status">
							<p>{{item.task_stage_txt}}</p>
						</view>
					</view>
					<view class="task-info">
						<image :src="item.product_img_url" style="height: 120rpx;width: 120rpx;"></image>
						<p style="margin-left: 50rpx;">{{item.project_name}}</p>
					</view>
				</view>
			</view>
		</view>

		<view class="home" v-if="showList4">
			<view class="task" v-for="item in List4">
				<view @click="toDetail(item)">
					<view class="task-head">
						<view class="task-head-account">
							<image :src="item.platform_icon_url" style="height: 50rpx;width: 50rpx;"></image>
							<p style="margin-left: 20rpx;">{{item.platform_nick_name}}</p>
						</view>
						<view class="task-head-status">
							<p>{{item.task_stage_txt}}</p>
						</view>
					</view>
					<view class="task-info">
						<image :src="item.product_img_url" style="height: 120rpx;width: 120rpx;"></image>
						<p style="margin-left: 50rpx;">{{item.project_name}}</p>
					</view>
				</view>
			</view>
		</view>
	</view>
</template>

<script>
	import mvBar from "@/components/mys_navBar/mysNavBar";
	export default {
		components: {
			mvBar,
		},
		data() {
			return {
				showList1: true,
				showList2: false,
				showList3: false,
				showList4: false,
				List1: [],
				List2: [],
				List3: [],
				List4: [],
				taskStageList: [],
				mysNavConfig: {
					/* 开启单页显示首页图标 */
					isHome: true,
					/* 固定导航  */
					navFixed: true,
					/* 标题 （屏幕中心居中 两边图标中心居中使用slot center1） */
					navTitle: {
						text: "工作台",
						color: "",
						fontSize: "32rpx", // px upx rpx
						fontWeight: "normal", // 100 - 700
					},
				},
				list: [{
					account: {
						platform: "https://horastar.obs.cn-east-3.myhuaweicloud.com/talent/lQLPDhrXwll1_MsjI7CSK_6e62AG2AGOvh1HgAcA_35_35.png",
						nickname: "丸子在成都",
					},
					status: "待确认",
					mainphoto: "https://static1.paizi.com/uploadfile/2018/1013/20181013013207465.png",
					taskname: "醉码头火锅太古里店",
				}, {
					account: {
						platform: "https://horastar.obs.cn-east-3.myhuaweicloud.com/talent/pingtai2.png",
						nickname: "成都的一颗丸子",
					},
					status: "待确认",
					mainphoto: "https://tse1-mm.cn.bing.net/th/id/R-C.978cb3a3b27875a0cc9d78a254b30b8f?rik=yrP2kNCtfQYEgQ&riu=http%3a%2f%2fnews.southcn.com%2fgd%2fcontent%2fimages%2fattachement%2fpng%2fsite4%2f20190917%2feca86b61fd551eeb23c507.png&ehk=xuWbgLrNmyhNJaByMZPJrX81PrzXrLHqHM%2fdYatFhrs%3d&risl=&pid=ImgRaw&r=0&sres=1&sresct=1",
					taskname: "奥运吉祥物冰墩墩盲盒",
				}],
			}
		},
		onShow() {
			this.isLogin()
		},
		methods: {
			// 判断登陆是否过期
			isLogin() {
				if (this.token == '') {
					this.token = uni.getStorageSync('token')
				}
				this.$https.get('/youngee/c/t/g/is-login')
					.then(res => {
						console.log(res)
						if (res.data.code == 403) {
							this.token = ""
							uni.clearStorage();
							uni.showModal({
								content: '请先登录',
								success: function(res) {
									uni.navigateTo({
										url: '../login/login'
									});
								}
							});
						} else {
							uni.showLoading({
								title: '加载中'
							});
							this.getInfoTable();
						}
					})
			},
			getInfoTable() {
				this.$https.get('/youngee/c/g/get-info-tables')
					.then(res => {
						console.log(res)
						this.taskStageList = res.data.data.TaskStage
						this.getList()
					})
			},
			getList() {
				console.log("run func getList")
				this.$https.get('/youngee/c/t/g/get-task-exe-list').then(res => {
					console.log(res)
					this.List1 = res.data.data.list1
					this.List2 = res.data.data.list2
					this.List3 = res.data.data.list3
					this.List4 = res.data.data.list4
					if (this.List1 != null) {
						for (let i = 0; i < this.List1.length; ++i) {
							for (let j = 0; j < this.taskStageList.length; ++j) {
								if (this.List1[i].task_stage == this.taskStageList[j].task_stage_id)
									this.List1[i].task_stage_txt = this.taskStageList[j].task_stage
							}
						}
					}
					if (this.List2 != null) {
						for (let i = 0; i < this.List2.length; ++i) {
							for (let j = 0; j < this.taskStageList.length; ++j) {
								if (this.List2[i].task_stage == this.taskStageList[j].task_stage_id)
									this.List2[i].task_stage_txt = this.taskStageList[j].task_stage
							}
						}
					}
					if (this.List3 != null) {
						for (let i = 0; i < this.List3.length; ++i) {
							for (let j = 0; j < this.taskStageList.length; ++j) {
								if (this.List3[i].task_stage == this.taskStageList[j].task_stage_id)
									this.List3[i].task_stage_txt = this.taskStageList[j].task_stage
							}
						}
					}
					if (this.List4 != null) {
						for (let i = 0; i < this.List4.length; ++i) {
							for (let j = 0; j < this.taskStageList.length; ++j) {
								if (this.List4[i].task_stage == this.taskStageList[j].task_stage_id)
									this.List4[i].task_stage_txt = this.taskStageList[j].task_stage
							}
						}
					}
					uni.hideLoading();
				})
			},
			toShow1() {
				this.showList2 = false;
				this.showList3 = false;
				this.showList4 = false;
				this.showList1 = true;
			},
			toShow2() {
				this.showList1 = false;
				this.showList3 = false;
				this.showList4 = false;
				this.showList2 = true;
			},
			toShow3() {
				this.showList2 = false;
				this.showList1 = false;
				this.showList4 = false;
				this.showList3 = true;
			},
			toShow4() {
				this.showList2 = false;
				this.showList1 = false;
				this.showList3 = false;
				this.showList4 = true;
			},
			toDetail(item) {
				uni.navigateTo({
					url: '/pages/workspace/taskdetail?taskId=' + item.task_id,
					success(res) {
						console.log(res);
					},
					fail(err) {
						console.log(err);
					}
				});
			},
		}
	}
</script>

<style lang="scss" scoped>
	view {
		font-size: 14px;
		line-height: inherit;
	}

	.menu {
		position: fixed;
		top: 160rpx;
		border-bottom: #FCCF41;
		background-color: #FFFFFF;
		justify-content: space-around;
		height: 5%;
		width: 100%;
		display: flex;
		z-index: 10;
	}

	.menu-item p {
		font-weight: 600;

		&.lor {
			border-bottom: 5rpx solid #F0D232;
			color: #F0D232;
			padding-bottom: 15rpx;
		}
	}

	.home {
		margin-top: 100rpx;
	}

	.task {
		margin-bottom: 20rpx;
		border-bottom: 1rpx #d7d7d7 solid;

		.task-head {
			display: flex;
			justify-content: space-between;
			align-items: center;
			padding: 10rpx 20rpx;

			.task-head-account {
				display: flex;
			}

			.task-head-status {
				color: red;
			}
		}

		.task-info {
			display: flex;
			align-items: center;
			padding: 10rpx 20rpx;

		}
	}

	.line {
		border-bottom: 1rpx #AAAAAA solid;
	}
</style>
