<template>
	<view class="bg">
		<view class="scale_name">职业心理年龄测试</view>
		<view class="test_time">测试时间：{{time}}</view>
		<image class="temp_type" src="https://test.jue-ming.com:8849/api/show?filePath=./webo/Career/result_title.png"
			mode="widthFix">
		</image>
		<view class="score_box">
			<view style="overflow: hidden;"></view>
			<view class="score_num" style="margin-top: 90rpx;">得分：{{scoreNum}}</view>
			<view class="score_percentage">
				<view class="score_wrap">
					<view class="process_bar" :style="{'left': percentage}">
						<image src="https://test.jue-ming.com:8849/api/show?filePath=./webo/Career/process_bar.png"
							mode="widthFix"></image>
						<view class="score_text">{{parseInt(scoreNum)}}/{{parseInt(maxScore)}}</view>
					</view>
				</view>
			</view>
			<view class="score_explain">注:得分越高，职业心理年龄越成熟</view>
			<!-- <view class="min_max"><text>0</text><text>60</text></view> -->
			<view class="score_num">结论：</view>
			<image v-if="role" class="role_name" :src="roleList[role].name" mode="widthFix"></image>
			<image v-if="role" class="role_img" :src="roleList[role].img" mode="widthFix"></image>
		</view>
		<view class="result_box">
			<view style="overflow: hidden;"></view>
			<view class="result_box_top"></view>
			<view class="result_box_bottom">
				<view style="overflow: hidden;"></view>
				<!-- <view class="sm_title">说明：</view> -->
				<view class="r_content">
					<view class="c_item" v-for="item in (segmentation(improvementSuggestions))">
						<view class="list_style_bg"></view>
						<text style="flex: 1;">{{item}}</text>
					</view>
				</view>
			</view>

		</view>
		<view class="report_desc">
			<view class="desc_title">报告阅读说明</view>
			<view class="stext">谢谢您的参与，阅读本报告时，请注意以下内容:</view>
			<view style="display: flex;">
				<view class="list_mark">·</view>
				<view class="desc_txt">本结果仅供参考，不可作为临床诊断的依据；</view>
			</view>
			<view style="display: flex;">
				<view class="list_mark">·</view>
				<view class="desc_txt">如对报告有不理解的地方，建议咨询专业人员；</view>
			</view>
			<view style="display: flex;">
				<view class="list_mark">·</view>
				<view class="desc_txt">如结果与你自己或他人的感受有出入，可回忆在测试时是否有事情影响到你，或自己回答时是否有所顾虑。</view>
			</view>
		</view>
	</view>
</template>

<script>
	import {
		getRecordById
	} from "@/api/index.js";
	import {
		photoUrl
	} from "@/common/config.js"
	const photoUrls = `${photoUrl}api/show?filePath=./webo`
	console.log(photoUrl);
	export default {
		data() {
			return {
				isChecked: true,
				isShake: false,
				scaleDetail: {},
				questionList: [],
				currentQuestion: {},
				currentAnswerList: [],
				currentIndex: 0,
				userAnswerList: [],
				resultId: '',
				isLoading: false,
				isDisbale: false,
				roleList: {
					'纯真儿童': {
						name: `${photoUrls}/Career/role/role1.png`,
						img: `${photoUrls}/Career/role/role_img1.png`,
						index: 1,
						'roleWidth': {
							'width': '375rpx'
						}
					},
					'理想青年': {
						name: `${photoUrls}/Career/role/role2.png`,
						img: `${photoUrls}/Career/role/role_img2.png`,
						index: 2,
						'roleWidth': {
							'width': '375rpx'
						}
					},
					'成熟中年': {
						name: `${photoUrls}/Career/role/role3.png`,
						img: `${photoUrls}/Career/role/role_img3.png`,
						index: 3,
						'roleWidth': {
							'width': '375rpx'
						}
					}
				},
				resultId: '',
				role: '',
				improvementSuggestions: '',
				scoreNum: 0,
				maxScore: 0,
				minScore: 0,
				keywords: '',
				time: ''
			}
		},
		onLoad(options) {
			if (options && options.resultId) {
				this.resultId = options.resultId
				this.getScaleTestResults(this.resultId);
			}
		},
		computed: {
			percentage() {
				return (((this.scoreNum / this.maxScore) * 312) - 318) + 'rpx'
			}
		},
		methods: {
			getScaleTestResults(id) {
				let _this = this;
				_this.$request
					.get({
						url: `${getRecordById}?id=${id}`,
						loadingTip: "加载中...",
						data: {},
					})
					.then(
						(res) => {
							console.log('222:', new Date().getTime());
							console.log("----测试结果--->", res);
							if (res.code == 200) {
								_this.testResult = JSON.parse(res.data?.userRecordEntity?.testResult)[0];
								_this.role = _this.testResult.newTableContext.result[0].symptom;
								_this.improvementSuggestions = _this.testResult.newTableContext.result[0]
									.improvementSuggestions;
								_this.keywords = _this.trimStart(_this.improvementSuggestions.slice(0, 5));
								_this.scoreNum = _this.testResult.newTableContext.result[0].score;
								_this.maxScore = _this.testResult.newTableContext.result[0].maxScore;
								let testDateTime = res.data.userRecordEntity.testDate;
								let yearMonthDay = testDateTime
									.replace("年", "/")
									.replace("月", "/")
									.replace("日", " ")
									.replace("时", ":")
									.replace("分", ":")
									.replace("秒", "");
								_this.time = yearMonthDay;
							} else if (res.code == 401) {} else {
								(res) => {
									console.log("世界上绝对绝对绝对绝对绝对的", res);
								}
							}
						})
			},
			trimStart(str) {
				return str.replace(/^\s+/, '');
			},
			segmentation(str) {
				return str.split('\n');
			}
		}
	}
</script>

<style scoped>
	.bg {
		width: 100%;
		min-height: 1624rpx;
		background: url(https://test.jue-ming.com:8849/api/show?filePath=./webo/Career/test_result_bg.png) no-repeat top;
		background-size: 100% 100%;
		overflow: hidden;
		position: relative;
	}

	.scale_name {
		font-family: 'Alibaba PuHuiTi 2.0';
		font-weight: bold;
		font-size: 40rpx;
		color: #ffffff;
		margin: 32rpx 0 0 29rpx;
	}

	.test_time {
		font-family: 'Alibaba PuHuiTi 2.0';
		font-weight: normal;
		font-size: 28rpx;
		color: #ffffff;
		margin-left: 29rpx;
	}

	.temp_type {
		width: 205rpx;
		position: absolute;
		top: 29rpx;
		right: 38rpx;
	}

	.score_box {
		width: 712rpx;
		height: 425rpx;
		background: url(https://test.jue-ming.com:8849/api/show?filePath=./webo/Career/score_box_bg.png) no-repeat center;
		background-size: cover;
		border-radius: 28rpx;
		margin: 37rpx auto 0;
		position: relative;
	}

	.score_num {
		font-family: 'Alibaba PuHuiTi 2.0';
		font-weight: normal;
		font-size: 32rpx;
		color: #333333;
		line-height: 31rpx;
		margin: 14rpx 0 0 22rpx;
	}

	.score_percentage {
		display: flex;
		align-items: center;
		justify-content: space-between;
		width: 319rpx;
		height: 36rpx;
		background: url(https://test.jue-ming.com:8849/api/show?filePath=./webo/Career/score_percentage_bg.png) no-repeat center;
		background-size: cover;
		margin: 14rpx 0 8rpx 20rpx;
	}

	.score_wrap {
		width: 348rpx;
		height: 48rpx;
		margin: 0 0 0 12rpx;
		position: relative;
		overflow: hidden;
		border-radius: 25rpx;
	}

	.process {
		overflow: hidden;
	}

	.process_bar {
		width: 318rpx;
		position: absolute;
		left: -100rpx;
		top: 8rpx;
	}

	.process_bar image {
		width: 100%;
	}

	.score_text {
		width: 68rpx;
		height: 42rpx;
		background: url(https://test.jue-ming.com:8849/api/show?filePath=./webo/Career/socre_text_bg.png) no-repeat;
		background-size: cover;
		position: absolute;
		top: -6rpx;
		right: 6rpx;
		z-index: 2;
		font-family: 'Alibaba PuHuiTi 2.0';
		font-weight: bold;
		font-size: 20rpx;
		color: #EE5C00;
		line-height: 42rpx;
		text-align: center;
	}

	.min_max {
		width: 300rpx;
		display: flex;
		justify-content: space-between;
		font-family: 'Alibaba PuHuiTi 2.0';
		font-weight: normal;
		font-size: 20rpx;
		color: #999999;
		margin-left: 30rpx;
	}

	.role_name {
		width: 409rpx;
		margin: 10rpx 0 0 21rpx;
		position: relative;
		z-index: 2;
	}

	.role_img {
		width: 347rpx;
		position: absolute;
		top: -20rpx;
		right: -16rpx;
	}

	.result_box {
		width: 712rpx;
		min-height: 804rpx;
		background: url(https://test.jue-ming.com:8849/api/show?filePath=./webo/Career/result_box_bg.png) no-repeat;
		background-size: 100% 100%;
		box-shadow: 0rpx 3rpx 24rpx 0rpx rgba(126, 77, 0, 0.13);
		border-radius: 26rpx;
		margin: 13rpx auto 0;
		position: relative;
		z-index: 2;
	}

	.result_box_top {
		width: 712rpx;
		height: 109rpx;
		background: url(https://test.jue-ming.com:8849/api/show?filePath=./webo/Career/result_box_top.png);
		background-size: cover;
		margin: 0 auto;
	}

	.result_box_bottom {
		width: 700rpx;
		min-height: 109rpx;
		background: url(https://test.jue-ming.com:8849/api/show?filePath=./webo/Career/result_box_top.png);
		background-size: cover;
		background: linear-gradient(0deg, #99CDFF 0%, #ECF6FF 100%);
		border-radius: 0 0 28rpx 28rpx;
		margin: 0 auto;
		overflow: hidden;
	}

	.title_img {
		width: 302rpx;
		position: relative;
		z-index: 3;
		margin: 31rpx 0 0 28rpx;
	}

	.sm_title {
		font-family: 'Alibaba PuHuiTi 2.0';
		font-weight: normal;
		font-size: 36rpx;
		color: #333333;
		line-height: 31rpx;
		margin: 10rpx 0 0 26rpx;
	}

	.r_content {
		box-sizing: border-box;
		width: 94%;
		min-height: 307rpx;
		margin: 26rpx auto 40rpx;
		padding: 30rpx 26rpx;
		border-radius: 18rpx;
		background: #ffffff;
		font-family: 'Alibaba PuHuiTi 2.0';
		font-weight: normal;
		font-size: 32rpx;
		color: #333333;
		line-height: 50rpx;
		letter-spacing: 2rpx;
	}

	.c_item {
		display: flex;
		align-items: flex-start;
		text-align: justify;
		letter-spacing: 2px;
		margin-bottom: 16rpx;
	}

	.list_style_bg {
		width: 36rpx;
		height: 36rpx;
		background: url(https://test.jue-ming.com:8849/api/show?filePath=./webo/Career/list_style_bg.png) no-repeat center;
		background-size: 100% auto;
		margin: 10rpx 8rpx 0 0;
	}

	.report_desc {
		padding: 30rpx 38rpx;
		letter-spacing: 1px;
	}

	.desc_title {
		font-family: 'Alibaba PuHuiTi 2.0';
		font-weight: normal;
		font-size: 28rpx;
		color: #ffffff;
		line-height: 46rpx;
	}

	.stext {
		font-family: 'Alibaba PuHuiTi 2.0';
		font-weight: normal;
		font-size: 20rpx;
		color: #ffffff;
		line-height: 30rpx;
	}

	.desc_txt {
		font-family: 'Alibaba PuHuiTi 2.0';
		font-weight: normal;
		font-size: 20rpx;
		color: #ffffff;
		line-height: 30rpx;
	}

	.list_mark {
		line-height: 0.7;
		font-size: 36rpx;
		color: #ffffff;
		font-weight: 600;
		margin-right: 5rpx;
	}

	.analysis_title {
		width: 362rpx;
		position: absolute;
		top: -30rpx;
		left: 50%;
		transform: translateX(-50%);
	}

	.paperclip {
		width: 55rpx;
		position: absolute;
		top: -40rpx;
		left: 38rpx;
	}

	.score_explain {
		font-family: 'Alibaba PuHuiTi 2.0';
		font-weight: normal;
		font-size: 24rpx;
		color: #999999;
		line-height: 31rpx;
		margin-left: 36rpx;
	}
</style>