<template>
	<view class="content">
		<view class="self-title-box">
			<!-- <image src="/static/rect-icon.png" mode="aspectFill"></image> -->
				<view class="history-font" @tap="linkToChart()">历史面试记录</view>
		</view>
		<view class="list-box">
			<view v-for="(item, index) in postList" :key="index" class="flex-between" @click="goDetail(item)">
				<view>
					<image src="/static/require-icon.png" mode="aspectFill"></image>
					<text style="font-size: 28rpx;">{{item.postType}}</text>
				</view>
				<text>{{item.time}}</text>
			</view>
		</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {

				industryArray: [{
					name: "软件开发",
					value: 1
				}, {
					name: "广告",
					value: 2
				}, {
					name: "金融",
					value: 3
				}], //三个测试岗位  1-技术，2-测试，3-设计师
				positionArray: [{
					name: "技术",
					value: 1
				}, {
					name: "测试",
					value: 2
				}, {
					name: "设计师",
					value: 3
				}], //三个测试岗位  1-技术，2-测试，3-设计师
				postList: [
				]
			};
		},
		mounted() {
			let that = this;
			uni.request({
				url: getApp().globalData.services.getInterviewHistory, //需要设置为全局
				method: 'POST',
				header: {
					'content-type': 'application/x-www-form-urlencoded'
				},
				data: {
					accesstoken: that.$store.state._token,
					jwtcode: that.$store.state._jwtcode,
				},
				success: ({
					data: {
						errmsg,
						data
					}
				}) => {
					if (errmsg === "OK") {
						that.postList = data.map(item => ({
							interviewid:item.id,
							postType: `${that.positionArray[item.position].name} ---- ${that.industryArray[item.industry].name}`,
							time: that.createrTime(item.addtime)
						}))

					}
				}
			});
		},
		onLoad() {},
		onShow() {},
		methods: {
			goDetail(item) {
				uni.navigateTo({
					url: `../historyDetail/index?interviewid=${item.interviewid}`
				})
			},
			createrTime(timestamp) {
				if (!timestamp) return "";
				// 时间戳 
				// 此处时间戳以毫秒为单位
				let date = new Date(parseInt(timestamp) * 1000);
				let Year = date.getFullYear();
				let Moth = (date.getMonth() + 1 < 10 ? '0' + (date.getMonth() + 1) : date.getMonth() + 1);
				let Day = (date.getDate() < 10 ? '0' + date.getDate() : date.getDate());
				let Hour = (date.getHours() < 10 ? '0' + date.getHours() : date.getHours());
				let Minute = (date.getMinutes() < 10 ? '0' + date.getMinutes() : date.getMinutes());
				let Sechond = (date.getSeconds() < 10 ? '0' + date.getSeconds() : date.getSeconds());
				let GMT = Year + '-' + Moth + '-' + Day + ' ' + Hour + ':' + Minute + ':' + Sechond;
				return GMT;
			},
			linkToChart(){
				uni.navigateBack()
			}
		}
	};
</script>

<style lang="scss" scoped>
	.content {
		overflow: hidden;

		.self-title-box {
			margin: 10% 0 5% 3%;

			image {
				width: 6rpx;
				height: 32rpx;
				margin-right: 2%;
			}
		}

		.flex-between {
			display: flex;
			align-items: center;
			justify-content: space-between;
			border-bottom: 1px solid #d3d3d3;
			padding: 5% 3% 5% 3%;

			image {
				width: 15rpx;
				height: 15rpx;
				margin-right: 2%;
			}

			;

			view {
				width: 60%;
			}

			;

			text {
				font-size: 26rpx;
				color: #555;
			}
		}
	}
</style>