<template>
	<view v-if="role" :class="['bg', `bg${roleList[role].index}`]">
		<view class="scale_name">在婚姻里，你有安全感吗？</view>
		<view class="test_time">测试时间：{{time}}</view>
		<image class="temp_type" v-if="role" :src="roleList[role].name" mode="widthFix">
		</image>
		<view class="result_box">
			<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 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: {
					'安全感指数：10%': {
						name: `${photoUrls}/Marriage/score1.png`,
						index: 1
					},
					'安全感指数：40%': {
						name: `${photoUrls}/Marriage/score2.png`,
						index: 2
					},
					'安全感指数：60%': {
						name: `${photoUrls}/Marriage/score3.png`,
						index: 3
					},
					'安全感指数：95%': {
						name: `${photoUrls}/Marriage/score4.png`,
						index: 4
					}
				},
				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) * 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.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: linear-gradient(0deg, #FB4643 0%, #FF8B59 100%);
		overflow: hidden;
		position: relative;
	}

	.bg1 {
		background: #DEA2FD url('https://test.jue-ming.com:8849/api/show?filePath=./webo/Marriage/bg1.png') no-repeat top;
		background-size: 100% auto;
	}

	.bg2 {
		background: #FFB0E6 url('https://test.jue-ming.com:8849/api/show?filePath=./webo/Marriage/bg2.png')no-repeat top;
		background-size: 100% auto;
	}


	.bg3 {
		background: #FF709C url('https://test.jue-ming.com:8849/api/show?filePath=./webo/Marriage/bg3.png')no-repeat top;
		background-size: 100% auto;
	}

	.bg4 {
		background: #EE4A51 url('https://test.jue-ming.com:8849/api/show?filePath=./webo/Marriage/bg4.png')no-repeat top;
		background-size: 100% auto;
	}

	.bg5 {
		background: url('https://test.jue-ming.com:8849/api/show?filePath=./webo/Marriage/bg5.png')no-repeat top;
		background-size: 100% auto;
	}

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

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

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

	.role_name image {
		width: 550rpx;
	}

	.temp_type {
		width: 444rpx;
		position: absolute;
		top: 140rpx;
		left: 25rpx;
	}

	.carton {
		width: 244rpx;
		position: absolute;
		top: 56rpx;
		right: 23rpx;
		z-index: 1;
	}

	.result_box {
		width: 702rpx;
		min-height: 804rpx;
		padding-bottom: 30rpx;
		background: #DFD8FF url(https://test.jue-ming.com:8849/api/show?filePath=./webo/Marriage/result_box_bg.png) no-repeat top;
		background-size: 100% auto;
		box-shadow: 0rpx 3rpx 24rpx 0rpx rgba(126, 77, 0, 0.13);
		border-radius: 26rpx;
		margin: 323rpx auto 0;
		position: relative;
	}

	.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: #4A73F1;
		line-height: 31rpx;
		margin: 108rpx 0 0 26rpx;
	}

	.r_content {
		box-sizing: border-box;
		width: 674rpx;
		min-height: 620rpx;
		background: #FFF9FA;
		border-radius: 18rpx;
		margin: 121rpx auto 0;
		padding: 30rpx 16rpx;
		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: 29rpx;
		height: 28rpx;
		background: url(https://test.jue-ming.com:8849/api/show?filePath=./webo/Marriage/list_style_bg.png) no-repeat center;
		background-size: 100% 100%;
		margin: 5rpx 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;
	}
</style>