<template>
	<view class="pageBgImg">
		<topNavbar title=" "></topNavbar>
		<view class="pad">
			<view class="h3">请选择您要学习的类型</view>
			<view class="radioBox">
				<view class="radioItem" v-for="(item,index) in radioArr" :key="index" @click="changeNav(item)">
					<view class="text">{{ item.text }}</view>
					<view class="icon">
						<image src="@/static/images/index/radio_cli.png" mode="" v-if="currentId==item.id"></image>
						<image src="@/static/images/index/radio_nor.png" mode="" v-else></image>
					</view>
				</view>
			</view>
			<view class="btn" @click="goPage">去练习</view>
		</view>
	</view>
</template>

<script>
	import { website } from '@/config/site.config.js'
	export default {
		data() {
			return {
				radioArr: [
					{text: '自学练习', id: 1},
					{text: '记录理论学时', id: 2},
					{text: '安全警示教育在线视频学习', id: 3},
				],
				currentId: 2,
			}
		},
		onLoad(options) {
			if(options.type) this.currentId = options.type
		},
		methods: {
			changeNav(item) {
				this.currentId = item.id
			},
			goPage() {
				if(this.currentId==1) {
					// let url = 'https://www.hzsjspx.com/theory/scienceStudy?token=amlhcGVpMTY5NTc3NzUzODg5ODA5NjU1&lat=30.343055&lng=120.183711&isUni=1'
					let questionUrl = website+':93/question/'
					let phone = this.vuex_userInfo.phone
					let obj = {
						phone,
						cityCode: '3311',
					}
					// #ifdef MP-WEIXIN
					obj.isWx = 1
					// #endif
					let uniItem = encodeURIComponent(JSON.stringify(obj))
					let url = `${questionUrl}?uniItem=${uniItem}`
					console.log(url)
					this.$store.commit('updateWebVeiwUrl', url)
					this.$goPage('/pages/indexEntry/webView/webView')
				}else if(this.currentId==2) {
					 let theory = website+':91/theory/'
					 let token = this.$store.state.user.vuex_loginInfo.accessToken
					 let lat = this.vuex_cityInfo.lat|| 30.27419537786047
					 let lng = this.vuex_cityInfo.lng|| 120.20633397715788
					 let url = `${theory}?token=${token}&lat=${lat}&lng=${lng}&isWx=1`
					this.$store.commit('updateWebVeiwUrl', url)
					this.$goPage('/pages/indexEntry/webView/webView')
				}
			}
		}
	}
</script>

<style lang="scss" scoped>
	.radioBox {
		width: 100%;
	}
	.h3 {
		font-size: 28rpx;
		color: #fff;
		padding: 20rpx 10rpx;
	}
	.radioItem {
		width: 100%;
		height: 120rpx;
		background: #FFFFFF;
		border-radius: 16rpx;
		margin-bottom: 20rpx;
		display: flex;
		justify-content: space-between;
		align-items: center;
		padding: 0 32rpx;
		.text {
			font-size: 28rpx;
		}
		.icon {
			width: 32rpx;
			height: 32rpx;
		}
	}
	.btn {
		width: 396rpx;
		height: 72rpx;
		background: #1989FA;
		border-radius: 8rpx;
		font-size: 28rpx;
		color: #fff;
		text-align: center;
		line-height: 72rpx;
		margin: 140rpx auto 0 auto;
	}
</style>