<template>
	<view class="ayuu">
		<view class="cpfapryu">
			<view class="indhuyr">
				<view class="indjbrr"></view>
				<text>测评结果</text>
			</view>
			<view class="">
				
			</view>
			<!-- <text  v-if="state==1">支付后查看测评结果</text> -->
			<!-- <view class="cpjgtxt">
				<view class="mytitles">
					<text>项目</text>
					<text>值</text>
					<text>范围</text>
				</view>
				<view class="myc">
					<view class="mycv" v-for="(item,index) in list" :key="index">
						<text>{{item.name}}</text>
						<text>{{item.key}}</text>
						<text>{{item.value}}</text>
					</view>
				</view>
			</view> -->
		</view>
		
		
		<view class="">
			<!-- url="../user/cp-fk" -->
			<!-- <view class="cpjgkan"  hover-class="none" @click="pay(1)">
				<text>解决方案 普通/{{price}}¥</text>
			</view>
			
			<view class="cpjgkanb" hover-class="none" @click="pay(2)">
				<text>解决方案 会员/{{vip_price}}¥</text>
			</view> -->
		</view>
		 

		 
		
		 
	</view>
</template>
<style>
	page {
		background: #FAFAFA;
	}
</style>
<script>
	export default {
		data() {
			return {
				id:0,
				state:1,      // 1 待支付 2 已支付
				price:0,			// 普通价格
				vip_price:0,    // vip价格
				result:[],
				pay_res:'',
				list:[],
				deviceType:'wxapp',
				resultText: '',
			}
		},
		onLoad(e) {
			// #ifdef APP-PLUS
				this.deviceType = 'wxh5'
			// #endif
			// #ifdef MP-WEIXIN
				this.deviceType = 'wxapp'
			// #endif
			this.id = e.id
			this.state = e.state || 1
			this.list = JSON.parse(decodeURIComponent(e.list)) || []
			// this.getExaminationInfo()
		},
		methods:{
			
			
			getResult(){
				let that = this;
				that.$request.getResult({
					log_id: that.id
				}).then( res =>{
					console.log(res)
					if(res.code == 0){
						this.resultText = res.data;
					}else{
						uni.showToast({
							title: res.message,
							icon: "none",
						})
					}
				}).catch( e =>{
					console.log(e)
				})
			},
			// 获取报告内容 获取价格
			getExaminationInfo(){
				this.$post({
					data:{
						do:'ExaminationInfo'
					}
				}).then(res=>{
					console.log(res,'bbbbbbbbb')
					this.price = res.data.price
					this.vip_price = res.data.vip_price
				})
			},
			pay(pay_type){
				if(pay_type==2 && uni.getStorageSync('is_vip')==0){
					uni.showToast({
						title:'您还不是会员',
						icon:'none'
					})
					return
				}
				this.$post({
					data:{
						do:'GetExamination',
						data:{
							id:this.id,
							pay_type           // 支付类型1=普通用户,2=会员用户
						},
						deviceType:this.deviceType
					}
				}).then(res=>{
					console.log(res,'kkkkkkkk')
					// this.state = res.data.state
					// this.result = res.data.data
					// this.pay_res = res.data.pay_res
					// #ifdef APP-PLUS
					uni.requestPayment({
						provider: 'wxpay',
						orderInfo:res.data.pay_res.orderinfo,
						success:()=> {
							// uni.showToast({
							// 	title: '支付成功'
							// })
							// setTimeout(()=>{
							// 	this.state = res.data.state
							// 	this.result = res.data.data
							// },1500)
							uni.navigateTo({
								url:'/pages/user/fkcg?id='+this.id
							})
						},
						fail:(err)=> {
							console.log(err)
							uni.showToast({
								title: '支付失败',
								icon: 'error'
							})
						}
					})
					// #endif
					// #ifdef MP-WEIXIN
					uni.requestPayment({
						provider: 'wxpay',
						...res.data.pay_res,
						success:()=> {
							// uni.showToast({
							// 	title: '支付成功'
							// })
							// setTimeout(()=>{
							// 	this.state = res.data.state
							// 	this.result = res.data.data
							// },1500)
							uni.navigateTo({
								url:'/pages/user/fkcg?id='+this.id
							})
						},
						fail:(err)=> {
							console.log(err)
							uni.showToast({
								title: '支付失败',
								icon: 'error'
							})
						}
					})
					// #endif
					
					
					
				})
			}
		}


	}
</script>

<style>
	.mytitles{
		display: flex;
		align-items: center;
		border: 1rpx solid #ebebeb;
	}
	.mytitles>text{
		width: 33.33%;
		text-align: center;
		padding: 10rpx 0;
	}
	.myc{
		
	}
	.mycv{
		display: flex;
		align-items: center;
		border: 1rpx solid #ebebeb;
	}
	.mycv>text{
		width: 33.33%;
		text-align: center;
		padding: 10rpx 0;
	}
</style>
<style lang="scss" scoped>
	 
 
	 
	 
</style>
