<template>
	<view>
		<view class="main-btn" @click="toPage(courseUrl)">
			<image :src="`${FILE_URL}/edu-icon/course.png`"></image>
			<text>培训课程</text>
		</view>
		<view class="main-btn" @click="toOtherApp">
			<image :src="`${FILE_URL}/edu-icon/net.png`"></image>
			<text>网络教育</text>
		</view>
		<view class="main-btn" @click="toPage(trainUrl)">
			<image :src="`${FILE_URL}/train-record.png`"></image>
			<text>培训实况</text>
		</view>
	</view>
</template>

<script>
	import configService from '@/utils/baseurl.js'
	export default {
		data() {
			return {
				FILE_URL: configService.FILE_URL,
				netAppid: "wx65323471c83da344",
				courseUrl: "/pages/goOnEdu/course/index",
				trainUrl: "/pages/goOnEdu/trainRecord/trainRecord"
			};
		},
		methods: {
			toOtherApp() {
				if (this.netAppid === "") {
					uni.showToast({
						title: "跳转其他小程序",
						icon: "none"
					})
					return;
				}
				uni.navigateToMiniProgram({
					appId: this.netAppid, // 替换为你要跳转的小程序的AppID
					path: 'pages/index/index', // 目标小程序的页面路径，留空则默认为首页
					envVersion: 'release', // 指定要打开的小程序版本: release 或 trial
					success(res) {
						console.log('成功跳转到小程序', res);
					},
					fail(err) {
						console.error('跳转失败', err);
					}
				});
			},
			toPage(url){
				uni.navigateTo({
					url:url
				})
			}
		}
	}
</script>

<style lang="scss">
	.main-btn {
		width: 85%;
		background-color: #006af4;
		border-radius: 20rpx;
		margin: 30rpx auto;
		padding: 40rpx 30rpx;
		display: flex;
		align-items: center;
		
		image {
			width: 100rpx;
			height: 100rpx;
			flex: 0 0 auto;
		}

		text {
			margin-left: 30rpx;
			color: #fff;
			font-size: 50rpx;
			font-weight: bold;
		}
	}
</style>
