<template>
	<view class="home">
		
		<image src="/static/image/bg/1.png"
		class="page-bg"
		mode="aspectFill"></image>
		
		<!-- next1 -->
		<view class="content_now" v-if="stop == 1">
			<view class=""
			v-if="Answer[index]"
			v-html="$utils.stringFormatHtml(Answer[index].title)">
			</view>
			
			<!-- <view class="mian-btn" 
			:class="{active:isActive === '是'}" 
			@click="setActive('是')">是</view>
			
			<view class="mian-btn" 
			:class="{active:isActive === '否'}" 
			@click="setActive('否')">否</view> -->
			
			<view class="mian-btn"
			v-for="(item, index) in Answer[index] && Answer[index].answer && Answer[index].answer.split(',')"
			:class="{active:isActive === item}" 
			:key="index"
			@click="setActive(item)">{{ item }}</view>
			
		</view>
		
		
		<view class="an">
			
			<!-- <view style="display: flex;width: 600rpx;"
			v-if="stop == 1">
				<view class="next-btn"
				v-if="index > 0"
				@click="index--">
					上一题
				</view>
				
				<view class="next-btn"
				@click="next">
					下一题
				</view>
			</view> -->
			
			<view class="next-btn"
			@click="next">
				下一题
			</view>
			
			<text class="second-color">{{ configList.bg_title }}</text>
		</view>
		
	</view>
</template>

<script>
	import { mapState } from 'vuex'
	export default {
		data() {
			return {
				isActive : null,
				stop : 1,
				index : 0,
				oId : 0,
			}
		},
		computed : {
			...mapState(['reviewAnswerList', 'configList']),
			Answer(){
				
				// let ids = []
				
				// for(let i = 0;i < this.queryMyLog.length;i++){
				// 	ids.push(this.queryMyLog[i].topId)
				// }
				
				// return this.problemList.filter(n => {
				// 	return !ids.includes(n.id)
				// })
				
				return this.reviewAnswerList
			},
		},
		onLoad(args) {
			this.oId = args.oid
		},
		onShow() {
		},
		methods: {
			setActive(value){
				this.isActive = value
			},
			next(){
				this['next' + this.stop]()
			},
			next1(){
				if(this.isActive){
					this.$api('answerComment', {
						topId : this.Answer[this.index].id,
						context : this.isActive,
						answerId : this.oId,
					}, res => {
						this.isActive = null
						if(this.index == this.Answer.length - 1){
							// 评论完成，退出评论页面
							// uni.showToast({
							// 	title: '评价成功',
							// 	icon: 'none'
							// })
							
							uni.navigateTo({
								url: '/pages/index/cancelArticle?key=sucess'
							})
							
						}else{
							this.index++
						}
					})
				}else{
					uni.showToast({
						title:'请选择后进行下一题',
						icon: 'none'
					})
				}
			},
		}
	}
</script>

<style lang="scss" scoped>
	
	.region{
		display: flex;
		align-items: center;
		&>view{
			width: 140rpx;
			height: 50rpx;
			border-radius: 10rpx;
			border: 1px solid #e6bf7f;
			margin: 0 10rpx;
			line-height: 50rpx;
			text-align: center;
		}
	}
	
	.b-btn{
		width: 86%;
		display: flex;
		justify-content: center;
		padding-top: 130rpx;
		
		.pre-btn{
			border: 4rpx solid #f1e0c6;
			padding: 16rpx 90rpx;
			border-radius: 66rpx;
			color: #e6bf7f;
		}
	}
		
	.next-btn{
		// background-image: url('../../static/image/home/btn.png');
		background-size: contain;
		background-repeat: no-repeat;
		background-position: center;
		width: 280rpx;
		display: flex;
		align-items: center;
		justify-content: center;
		color: white;
		padding: 16rpx 90rpx;
	}
	
	.an{
		position: fixed;
		bottom: 300rpx;
		text-align: center;
		display: flex;
		flex-direction: column;
		align-items: center;
		justify-content: center;
		width: 100%;
	}
</style>
