<template>
	<view class="bg">
		<view class="process"></view>
		<view class="role_name">
			<image v-if="roleList[role]" :src="roleList[role].name" mode="widthFix"></image>
		</view>
		<view class="role_img">
			<image v-if="roleList[role]" :src="roleList[role].img" mode="widthFix"></image>
		</view>
		<view class="result_box">
			<view class="role_medal">
				<image v-if="roleList[role]" :src="roleList[role].medal" mode="widthFix"></image>
			</view>
			<view class="score_bar">
				<view class="score_title">得分：</view>
				<view class="score_num">{{scoreNum}}</view>
				<view class="score_percentage">
					<view class="score_wrap">
						<image class="process_bar" :style="{'left': percentage}"
							src="https://test.jue-ming.com:8849/api/show?filePath=./webo/EQtest/process_bar.png"
							mode="widthFix"></image>
					</view>
					<view class="score_text">{{parseInt(scoreNum)}}/{{parseInt(maxScore)}}</view>
				</view>
			</view>
			<view class="result_box_r">
				<view class="sm_title">说明：</view>
				{{improvementSuggestions}}
			</view>
		</view>
		<view class="report_desc">
			<view class="desc_title">报告阅读说明</view>
			<view class="desc_txt">谢谢您的参与，阅读本报告时，请注意以下内容:</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}/EQtest/role/role_name1.png`,
						img: `${photoUrls}/EQtest/role/role_img1.png`,
						medal: `${photoUrls}/EQtest/role/role_medal1.png`
					},
					'学徒': {
						name: `${photoUrls}/EQtest/role/role_name2.png`,
						img: `${photoUrls}/EQtest/role/role_img2.png`,
						medal: `${photoUrls}/EQtest/role/role_medal1.png`
					},
					'学徒+': {
						name: `${photoUrls}/EQtest/role/role_name3.png`,
						img: `${photoUrls}/EQtest/role/role_img2.png`,
						medal: `${photoUrls}/EQtest/role/role_medal2.png`
					},
					'探索者': {
						name: `${photoUrls}/EQtest/role/role_name4.png`,
						img: `${photoUrls}/EQtest/role/role_img3.png`,
						medal: `${photoUrls}/EQtest/role/role_medal3.png`
					},
					'探索者+': {
						name: `${photoUrls}/EQtest/role/role_name5.png`,
						img: `${photoUrls}/EQtest/role/role_img3.png`,
						medal: `${photoUrls}/EQtest/role/role_medal3.png`
					},
					'达人': {
						name: `${photoUrls}/EQtest/role/role_name6.png`,
						img: `${photoUrls}/EQtest/role/role_img4.png`,
						medal: `${photoUrls}/EQtest/role/role_medal4.png`
					},
					'达人+': {
						name: `${photoUrls}/EQtest/role/role_name7.png`,
						img: `${photoUrls}/EQtest/role/role_img4.png`,
						medal: `${photoUrls}/EQtest/role/role_medal4.png`
					},
					'大师': {
						name: `${photoUrls}/EQtest/role/role_name8.png`,
						img: `${photoUrls}/EQtest/role/role_img5.png`,
						medal: `${photoUrls}/EQtest/role/role_medal5.png`
					},
					'大师+': {
						name: `${photoUrls}/EQtest/role/role_name9.png`,
						img: `${photoUrls}/EQtest/role/role_img5.png`,
						medal: `${photoUrls}/EQtest/role/role_medal5.png`
					},
					'导师': {
						name: `${photoUrls}/EQtest/role/role_name10.png`,
						img: `${photoUrls}/EQtest/role/role_img6.png`,
						medal: `${photoUrls}/EQtest/role/role_medal6.png`
					},
					'智者': {
						name: `${photoUrls}/EQtest/role/role_name11.png`,
						img: `${photoUrls}/EQtest/role/role_img7.png`,
						medal: `${photoUrls}/EQtest/role/role_medal7.png`
					},
					'巨匠': {
						name: `${photoUrls}/EQtest/role/role_name12.png`,
						img: `${photoUrls}/EQtest/role/role_img8.png`,
						medal: `${photoUrls}/EQtest/role/role_medal8.png`
					},
					'大帝': {
						name: `${photoUrls}/EQtest/role/role_name13.png`,
						img: `${photoUrls}/EQtest/role/role_img9.png`,
						medal: `${photoUrls}/EQtest/role/role_medal9.png`
					},
					'至尊': {
						name: `${photoUrls}/EQtest/role/role_name14.png`,
						img: `${photoUrls}/EQtest/role/role_img10.png`,
						medal: `${photoUrls}/EQtest/role/role_medal10.png`
					}
				},
				resultId: '',
				role: '',
				improvementSuggestions: '',
				scoreNum: 0,
				maxScore: 0,
				minScore: 0,
			}
		},
		onLoad(options) {
			if (options && options.resultId) {
				this.resultId = options.resultId
				this.getScaleTestResults(this.resultId);
			}
		},
		computed: {
			percentage() {
				return (((this.scoreNum / this.maxScore) * 318) - 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.scoreNum = _this.testResult.newTableContext.result[0].score;
								_this.maxScore = _this.testResult.newTableContext.result[0].maxScore;
							} else if (res.code == 401) {} else {
								(res) => {
									console.log("世界上绝对绝对绝对绝对绝对的", res);
								}
							}
						})
			},
			getNameUrl() {
				console.log(`${photoUrls}/EQtest/role/role_name1.png`)
				return `${photoUrls}/EQtest/role/role_name1.png`
			}
		}
	}
</script>

<style scoped>
	.bg {
		width: 100%;
		height: 1900rpx;
		background: url(../../static/images/EQtest/test_result_bg.png) no-repeat center;
		background-size: 100% auto;
	}

	.role_name {
		text-align: center;
		margin: 202rpx 0 0 0;
	}

	.role_name image {
		width: 308rpx;
	}

	.role_img {
		text-align: center;
		margin-top: -30rpx;
	}

	.role_img image {
		width: 660rpx;
	}

	.result_box {
		width: 706rpx;
		min-height: 548rpx;
		padding-bottom: 28rpx;
		background: url(https://test.jue-ming.com:8849/api/show?filePath=./webo/EQtest/result_bg_w.png) no-repeat top;
		background-size: 100% auto;
		overflow: hidden;
		margin: -180rpx auto 0;
		border-radius: 33rpx;
		position: relative;
	}

	.role_medal {
		position: absolute;
		right: 50rpx;
		top: 0;
	}

	.role_medal image {
		width: 155rpx;
	}

	.result_box_r {
		box-sizing: border-box;
		width: 660rpx;
		min-height: 283rpx;
		padding: 26rpx;
		margin: 0 auto 0;
		background: #FFFFFF url(https://test.jue-ming.com:8849/api/show?filePath=./webo/EQtest/result_bg_r.png) no-repeat top;
		background-size: 100% auto;
		border-radius: 33rpx;
		font-family: 'Alibaba PuHuiTi 2.0';
		font-weight: normal;
		font-size: 32rpx;
		color: #333333;
		line-height: 46rpx;
	}

	.score_title {
		font-family: 'Alibaba PuHuiTi 2.0';
		font-weight: bold;
		font-size: 36rpx;
		color: #333333;
		line-height: 31rpx;
		margin: 104rpx 0 0 42rpx;
	}

	.score_num {
		font-family: 'Alibaba PuHuiTi 2.0';
		font-weight: bold;
		font-size: 81rpx;
		color: #FF9C00;
		line-height: 51rpx;
		/* text-stroke: 4px #FFFFFF;
		background: linear-gradient(269deg, #FF443D 0%, #FF9C00 100%);
		-webkit-text-stroke: 4px #FFFFFF;
		-webkit-background-clip: text;
		-webkit-text-fill-color: transparent; */
		margin: 12rpx 0 7rpx 156rpx;
	}

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

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

	.process {
		overflow: hidden;
	}

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

	.score_text {
		font-family: Alibaba PuHuiTi 2.0;
		font-weight: normal;
		font-size: 18rpx;
		color: #FFFFFF;
		line-height: 16rpx;
		margin-right: 16rpx;
	}

	.sm_title {
		font-family: 'Alibaba PuHuiTi 2.0';
		font-weight: bold;
		font-size: 36rpx;
		color: #333333;
		line-height: 31rpx;
		margin-bottom: 22rpx;
	}

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

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

	.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;
	}
</style>