<template>
	<view class="bg">
		<view class="process"></view>
		<view class="scale_name">看一下自己的“神经”是否正常？</view>
		<view class="test_time">测试时间：{{time}}</view>
		<view class="score_title">得分：{{scoreNum}}</view>
		<view class="score_percentage">
			<view class="process_bar" v-if="scoreNum > 0" :style="{'width': percentage}">
				<view class="line"></view>
				<view class="score_text">{{parseInt(scoreNum)}}/{{parseInt(maxScore)}}</view>
			</view>
		</view>
		<view class="score_explain">注:得分越高，精神状态越差</view>
		<!-- <view class="min_max"><text>0</text><text>60</text></view> -->
		<view class="score_title">结论：</view>
		<view class="role_medal">
			<image src="https://test.jue-ming.com:8849/api/show?filePath=./webo/Mental/result_title.png"
				mode="widthFix"></image>
		</view>
		<view class="role_img">
			<image v-if="roleList[role]" :src="roleList[role].title" mode="widthFix"></image>
		</view>
		<view class="result_box">
			<!-- <view class="role_name">
				<image v-if="roleList[role]" :src="roleList[role].title" mode="widthFix"></image>
			</view> -->
			<view class="result_box_wrap">
				<view class="c_item" v-for="item in (segmentation(suggestion))">
					<view class="list_style_bg"></view>
					<text style="flex: 1;">{{item}}</text>
				</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"
	import {
		getTestTime
	} from "@/utils/util.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: {
					'心态积极': {
						title: `${photoUrls}/Mental/title1.png`,
						img: `${photoUrls}/Mental/role1.png`,
					},
					'轻微不适': {
						title: `${photoUrls}/Mental/title2.png`,
						img: `${photoUrls}/Mental/role2.png`,
					},
					'轻度焦虑': {
						title: `${photoUrls}/Mental/title3.png`,
						img: `${photoUrls}/Mental/role2.png`,
					},
					'中度压力': {
						title: `${photoUrls}/Mental/title4.png`,
						img: `${photoUrls}/Mental/role2.png`,
					},
					'严重沮丧': {
						title: `${photoUrls}/Mental/title5.png`,
						img: `${photoUrls}/Mental/role2.png`,
					},
					'极度焦虑': {
						title: `${photoUrls}/Mental/title6.png`,
						img: `${photoUrls}/Mental/role2.png`,
					},
					'崩溃': {
						title: `${photoUrls}/Mental/title7.png`,
						img: `${photoUrls}/Mental/role2.png`,
					},
				},
				resultId: '',
				role: '',
				suggestion: '',
				scoreNum: 0,
				maxScore: 140,
				time: '',
			}
		},
		onLoad(options) {
			if (options && options.resultId) {
				this.resultId = options.resultId
				this.getScaleTestResults(this.resultId);
			}
		},
		computed: {
			percentage() {
				return ((this.scoreNum / this.maxScore) * 663) + '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.tableContext[1].value[0];
								_this.scoreNum = _this.testResult.tableContext[0].value[0];
								this.time = getTestTime(res.data.userRecordEntity.testDate);
								_this.suggestion = _this.testResult.tableContext[2].value[0];
							} else if (res.code == 401) {} else {
								(res) => {
									console.log("世界上绝对绝对绝对绝对绝对的", res);
								}
							}
						})
			},
			getNameUrl() {
				console.log(`${photoUrls}/Sleep/role/role_name1.png`)
				return `${photoUrls}/Sleep/role/role_name1.png`
			},
			segmentation(str) {
				return str.split('\n');
			}
		}
	}
</script>

<style scoped>
	.bg {
		width: 100%;
		min-height: 100vh;
		background: #000000;
		background-size: 100% auto;
	}

	.role_name {
		width: 454rpx;
		position: absolute;
		top: -50rpx;
		left: 50%;
		transform: translateX(-50%);
	}

	.role_name image {
		width: 100%;
	}

	.role_img {
		width: 687rpx;
		margin: 20rpx auto 0;
		padding-bottom: 40rpx;
	}

	.role_img image {
		width: 100%;
	}

	.result_box {
		width: 690rpx;
		min-height: 416rpx;
		background: #FCFBFF;
		padding-bottom: 12rpx;
		border: 2rpx solid #333333;
		margin: 0 0 0 38rpx;
	}

	.result_box_wrap {
		box-sizing: border-box;
		width: 690rpx;
		min-height: 591rpx;
		padding: 115rpx 30rpx 60rpx 30rpx;
		margin: -20rpx 0 0 -12rpx;
		border: 2rpx solid #333333;
		background: #FCFBFF url(https://test.jue-ming.com:8849/api/show?filePath=./webo/Mental/result_bg_top.png) no-repeat top;
		background-size: 100% auto;
		font-family: 'Alibaba PuHuiTi 2.0';
		font-weight: normal;
		font-size: 32rpx;
		color: #333333;
		line-height: 60rpx;
		letter-spacing: 4rpx;
		text-align: justify;
	}

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

	.role_medal {
		position: absolute;
		right: 27rpx;
		top: 18rpx;
	}

	.role_medal image {
		width: 211rpx;
	}

	.result_box_r {
		box-sizing: border-box;
		width: 100%;
		min-height: 283rpx;
		padding: 0 26rpx;
		background: #FFFFFF;
		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: normal;
		font-size: 36rpx;
		color: #FFFFFF;
		margin: 26rpx 0 0 38rpx;
	}

	.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: 663rpx;
		height: 32rpx;
		background: #5085C9;
		border-radius: 20rpx;
		border: 2px solid #333333;
		margin: 14rpx 0 8rpx 38rpx;
	}

	.process {
		overflow: hidden;
	}

	.process_bar {
		width: 100rpx;
		height: 39rpx;
		background: #FFC832;
		border-radius: 20rpx;
		border: 2px solid #333333;
		position: relative;
	}

	.process_bar .line {
		width: 88%;
		height: 5rpx;
		background: #FFFFFF;
		border-radius: 4rpx;
		border: 1px solid #333333;
		margin: 4rpx auto;
	}

	.score_text {
		padding: 0 4rpx;
		width: 95rpx;
		height: 39rpx;
		background: #FF7976;
		border-radius: 24rpx;
		border: 2px solid #333333;
		position: absolute;
		top: -6rpx;
		right: -20rpx;
		z-index: 2;
		font-family: 'Alibaba PuHuiTi 2.0';
		font-weight: bold;
		font-weight: normal;
		font-size: 24rpx;
		color: #000000;
		line-height: 39rpx;
		text-align: center;
	}

	.sm_box {
		box-sizing: border-box;
		width: 100%;
		padding: 30rpx 24rpx;
		background: #FDE8CA;
		border-radius: 20rpx;
		border: 1px solid #F8C983;
	}

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

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

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

	.stext {
		color: #ffffff;
	}

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

	.scale_name {
		font-family: 'Alibaba PuHuiTi 2.0';
		font-weight: bold;
		font-size: 36rpx;
		color: #FFFFFF;
		margin: 48rpx 0 0 39rpx;
	}

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

	.dimension_item {
		width: 624rpx;
		height: 90rpx;
		background: url(https://test.jue-ming.com:8849/api/show?filePath=./webo/Mental/suggest_item_bg.png) no-repeat;
		background-size: 100% 100%;
		margin: 19rpx auto;
		display: flex;
		justify-content: space-between;
	}

	.dimension_name {
		font-family: 'Alibaba PuHuiTi 2.0';
		font-weight: normal;
		font-size: 41rpx;
		color: #333333;
		margin: 8rpx 0 0 27rpx;
	}

	.dimension_value {
		font-family: 'Alibaba PuHuiTi 2.0';
		font-weight: bold;
		font-size: 41rpx;
		color: #F35855;
		margin: 8rpx 58rpx 0 0;
	}

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