<template>
	<view class="bg">
		<view style="overflow: hidden;"></view>
		<view class="role_img">
			<view class="xdzs">
				<view class="xdzs_title">
					<image src="https://test.jue-ming.com:8849/api/show?filePath=./webo/Charm/xdzs.png" mode="widthFix">
					</image>
				</view>
				<view class="cardiac_index">
					<text> {{ parseInt(scoreNum) }}%</text>
				</view>
			</view>
			<image class="carton" v-if="roleList[role]" :src="roleList[role].img" mode="widthFix"></image>
		</view>
		<view class="result_box">
			<view style="overflow: hidden;"></view>
			<image class="paperclip" src="https://test.jue-ming.com:8849/api/show?filePath=./webo/Charm/paperclip.png"
				mode="widthFix"></image>
			<image class="analysis_title"
				src="https://test.jue-ming.com:8849/api/show?filePath=./webo/Charm/analysis_title.png" mode="widthFix">
			</image>
			<view class="role_medal">
				<image v-if="roleList[role]" :src="roleList[role].name" 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/Charm/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="cardiac">
					<!-- <view style="text-align: left;">
						<image class="cardiac_title"
							src="https://test.jue-ming.com:8849/api/show?filePath=./webo/Charm/cardiac_title_img.png"
							mode="widthFix"></image>
					</view> -->
					<!-- <image v-if="role" class="cardiac_index" :src="roleList[role].score" mode="widthFix"></image> -->
				</view>
				<!-- 	<view class="sm_title">
					<image src="https://test.jue-ming.com:8849/api/show?filePath=./webo/Charm/sm_title.png"
						mode="widthFix"></image>
				</view> -->
				<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 class="report_desc">
				<view class="desc_title">报告阅读说明</view>
				<view class="desc_txt" style="color: #FFAEBF;">谢谢您的参与，阅读本报告时，请注意以下内容:</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>
	</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: {
					'30%': {
						name: `${photoUrls}/Charm/result_type/comment30.png`,
						img: `${photoUrls}/Charm/result_type/people_img30.png`,
						score: `${photoUrls}/Charm/result_type/score30.png`,
						'魅不可挡': `${photoUrls}/Charm/result_type/mbkd88.png`,
						'魅力撩人': `${photoUrls}/Charm/result_type/mllr88.png`,
						'魅力迷人': `${photoUrls}/Charm/result_type/mlmr88.png`,
						'魅力无穷': `${photoUrls}/Charm/result_type/mlwq88.png`,
						'气质成谜': `${photoUrls}/Charm/result_type/qzcm88.png`,
					},
					'60%': {
						name: `${photoUrls}/Charm/result_type/comment60.png`,
						img: `${photoUrls}/Charm/result_type/people_img60.png`,
						score: `${photoUrls}/Charm/result_type/score60.png`,
						'热情奔放': `${photoUrls}/Charm/result_type/rqbf99.png`,
						'热情豪爽': `${photoUrls}/Charm/result_type/rqhs99.png`,
						'热情澎湃': `${photoUrls}/Charm/result_type/rqpp99.png`,
						'热情如火': `${photoUrls}/Charm/result_type/rqrh99.png`,
						'热情洋溢': `${photoUrls}/Charm/result_type/rqyy99.png`,
					},
					'80%': {
						name: `${photoUrls}/Charm/result_type/comment80.png`,
						img: `${photoUrls}/Charm/result_type/people_img80.png`,
						score: `${photoUrls}/Charm/result_type/score80.png`,
						'怦然心动': `${photoUrls}/Charm/result_type/prxd160.png`,
						'神魂颠倒': `${photoUrls}/Charm/result_type/shdd160.png`,
						'神韵动人': `${photoUrls}/Charm/result_type/sydr160.png`,
						'心动不已': `${photoUrls}/Charm/result_type/xdby160.png`,
						'心花怒放': `${photoUrls}/Charm/result_type/xhnf160.png`,
					},
					'100%': {
						name: `${photoUrls}/Charm/result_type/comment100.png`,
						img: `${photoUrls}/Charm/result_type/people_img100.png`,
						score: `${photoUrls}/Charm/result_type/score100.png`,
						'瞬间倾心': `${photoUrls}/Charm/result_type/sjqx300.png`,
						'一见倾心': `${photoUrls}/Charm/result_type/yjqx300.png`,
						'爱情闪现': `${photoUrls}/Charm/result_type/aqsx300.png`,
						'一见心动': `${photoUrls}/Charm/result_type/yjxd300.png`,
						'一见钟情': `${photoUrls}/Charm/result_type/yjzq300.png`,
					}
				},
				resultId: '',
				role: '',
				improvementSuggestions: '',
				scoreNum: 0,
				maxScore: 0,
				minScore: 0,
				keywords: ''
			}
		},
		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) => {
							uni.hideLoading();
							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.tableContext[5].value[0];
								_this.maxScore = _this.testResult.newTableContext.result[0].maxScore;
							} else if (res.code == 401) {} else {
								(res) => {
									console.log("世界上绝对绝对绝对绝对绝对的", res);
								}
							}
						})
			},
			getNameUrl() {
				console.log(`${photoUrls}/Charm/result_type/role_name1.png`)
				return `${photoUrls}/Charm/result_type/role_name1.png`
			},
			trimStart(str) {
				return str.replace(/^\s+/, '');
			},
			segmentation(str) {
				return str.split('\n');
			}
		}
	}
</script>

<style scoped>
	.bg {
		width: 100%;
		min-height: 1900rpx;
		padding-bottom: 100rpx;
		background: url(https://test.jue-ming.com:8849/api/show?filePath=./webo/Charm/test_result_bg.png) no-repeat top;
		background-size: 100% auto;
	}

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

	.role_name image {
		width: 550rpx;
	}

	.role_img {
		display: flex;
		justify-content: space-between;
		margin-top: 223rpx;
	}

	.role_img .temp_type {
		width: 224rpx;
		margin-left: 88rpx;
	}

	.role_img .carton {
		width: 437rpx;
		margin-left: -60rpx;
	}

	.xdzs {
		text-align: center;
	}

	.xdzs_title image {
		width: 234rpx;
		margin: 150rpx 0 20rpx 30rpx;
	}

	.result_box {
		width: 702rpx;
		min-height: 875rpx;
		background: linear-gradient(0deg, #EA1750 0%, #FF8189 100%);
		border-radius: 26rpx;
		margin: 10rpx auto 0;
		position: relative;
		padding-bottom: 30rpx;
	}

	.role_medal {
		margin-top: 55rpx;
		text-align: center;
	}

	.role_medal image {
		width: 550rpx;
	}

	.result_box_r {
		box-sizing: border-box;
		width: 674rpx;
		min-height: 553rpx;
		padding: 26rpx;
		margin: 0 auto 0;
		background: #FFFFFF url(https://test.jue-ming.com:8849/api/show?filePath=./webo/Charm/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: #555555;
		line-height: 60rpx;
		letter-spacing: 2rpx;
		text-align: justify;
	}

	.sm_title image {
		width: 67rpx;
	}

	.cardiac {
		text-align: center;
	}

	.cardiac_title {
		width: 213rpx;
	}

	.cardiac_index {
		width: 349rpx;
		background: url(https://test.jue-ming.com:8849/api/show?filePath=./webo/Charm/result_type/score.png) no-repeat center;
		background-size: cover;
		margin-left: 30rpx;
		text-align: center;
	}

	.cardiac_index text {
		line-height: 198rpx;
		font-family: 'Alibaba PuHuiTi 2.0';
		font-weight: bold;
		font-size: 48rpx;
		color: #F23D64;
		text-shadow: 1rpx 1rpx 6rpx rgba(142, 0, 19, 0.5);
		-webkit-text-stroke: 8rpx transparent;
		text-stroke: 8rpx transparent;
		-webkit-background-clip: text;
		background-clip: text;
		background-color: #ffffff;
		margin-right: 40rpx;
	}

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

	.list_style_bg {
		width: 16rpx;
		height: 16rpx;
		background: #fd7884;
		background-size: 100% auto;
		border-radius: 50%;
		margin: 17rpx 10rpx 0 0;
	}

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

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

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