<template>
	<view class="configPopup">
		<uv-popup ref="popup" :round="30" :closeOnClickOverlay="!required">
			<view class="content">
				<scroll-view 
				id="scrollView" 
				scroll-y="true" 
				:scroll-top="scrollTop"
				style="height: 100%;">
					<uv-parse :content="configList[keys[index]]"></uv-parse>
					<view class="uni-color-btn" @click="success">
						下一步
					</view>
				</scroll-view>
			</view>
			<view class="content" v-else>
				<uv-parse :content="text || content"></uv-parse>
			</view>
		</uv-popup>
	</view>
</template>

<script>
	import {
		mapState
	} from 'vuex'
	export default {
		name: 'configPoup',
		props: {
			text: {
				default: ''
			},
			keys: {
				default: [],
			},
			required: {
				default: false,
			},
		},
		data() {
			return {
				content: '',
				index: 0,
				scrollTop : 0,
			}
		},
		onShow() {},
		methods: {

			//打开配置信息菜单
			open(key) {
				this.content = this.configList[key]
				this.$refs.popup.open('bottom');
			},
			openkeys() {
				this.index = 0
				this.$refs.popup.open('bottom');
			},
			success() {
				if (this.index == this.keys.length - 1) {
					this.$emit('success')
					this.$refs.popup.close();
					return
				}
				this.index++
				
				this.scrollTop = 100
				
				this.$nextTick(res => {
					this.scrollTop = 0
				})

			},
		},

		computed: {
			...mapState(['configList'])
		}
	}
</script>

<style lang="scss" scoped>
	.configPopup {
		.content {
			padding: 30rpx 20rpx;
			overflow: scroll;
			height: 50vh;
			box-sizing: border-box;
		}
	}
</style>