<template>
	<view class="indexpage">
		<navbar class="navbarSticky" bg="#F6F6F6">
			<view class="index-header-box">
				<view class="index-header-img">
					<van-image width="100%" height="100%" fit="cover" class="img"
					src="https://viitto-1301420277.cos.ap-chengdu.myqcloud.com/Test/Upload/Goods/1653464014000_713.png" />
				</view>
				<view class="index-header-tetx">
					<view class="index-header-title">
						welcome 
					</view>
					<view class="index-header-name">{{userData.AccountName}}</view>
				</view>
			</view>
		</navbar>
		<view style="margin: 40rpx 0 10rpx 0;">
			<view style="padding:0 50rpx;font-weight: 800;color: #282828;">
				<view style="font-size: 36rpx;">Hello,{{userData.AccountName}}</view>
				<view style="font-size: 50rpx;">您的学情反馈已准备好</view>
			</view>
		</view>
		<course-card :stuCourseList="stuCourseList"></course-card>
		<view class="index-student-title flex">
			<text>考情详情</text>
			<view>(共53条)</view>
		</view>
		<view class="index-student-information">
			<JobComponents></JobComponents>
			<examComponents></examComponents>
			<commentsComponents></commentsComponents>
		</view>
	</view>
</template>

<script>
	import courseCard from '../../components/index/course-card'
	import JobComponents from '@/components/index/JobComponents'
	import examComponents from '@/components/index/examComponents'
	import commentsComponents from '@/components/index/commentsComponents'
	import vue, {
		ref,
		reactive,
		toRefs,
		toRef,
		getCurrentInstance,
		watch,
		computed,
		onMounted,
		provide,
		nextTick,
	} from "vue";

	 import {
		 getSweepCode
	 } from '../../api/index.js'
	import {
		getImageColor
	} from '../../utils/index.js'
	import indexassembly from './components/indexassembly.vue'
	import navbar from '../../components/navbar.vue'
	import bottom from '../../components/bottom.vue'
	export default {
		components: {
			indexassembly,
			navbar,
			bottom,
			courseCard,
			JobComponents,
			examComponents,
			commentsComponents
		},
		setup(props) {
			let {
				proxy
			} = getCurrentInstance();
			let data = reactive({
				stuCourseList: [],//学员课程列表
				userData: {},//用户信息
			});

			let methods = {
				jumpPage(url) {
					uni.navigateTo({
						url: url,
					});
				},
				jumpTimetable() {
					uni.switchTab({
						url: '/pages/timetable/timeTable',
					})
				},
		
				base64_decode(data) {
					var b64 = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=";
					var o1,
						o2,
						o3,
						h1,
						h2,
						h3,
						h4,
						bits,
						i = 0,
						ac = 0,
						dec = "",
						tmp_arr = [];
					if (!data) {
						return data;
					}
					data += "";
					do {
						h1 = b64.indexOf(data.charAt(i++));
						h2 = b64.indexOf(data.charAt(i++));
						h3 = b64.indexOf(data.charAt(i++));
						h4 = b64.indexOf(data.charAt(i++));
						bits = (h1 << 18) | (h2 << 12) | (h3 << 6) | h4;
						o1 = (bits >> 16) & 0xff;
						o2 = (bits >> 8) & 0xff;
						o3 = bits & 0xff;
						if (h3 == 64) {
							tmp_arr[ac++] = String.fromCharCode(o1);
						} else if (h4 == 64) {
							tmp_arr[ac++] = String.fromCharCode(o1, o2);
						} else {
							tmp_arr[ac++] = String.fromCharCode(o1, o2, o3);
						}
					} while (i < data.length);
					dec = tmp_arr.join("");

					return dec;
				},
                //获取学员课程列表
				getStuCourse() {
					proxy.$request("/Stu/GetStuCourse", {}).then(res => {
						data.stuCourseList = res.Data;
						//console.log("data.stuCourseList",this.stuCourseList)
					})
				},
				async getColor(src, index, y) {
					let res = await getImageColor('myCanvas', 'img' + index, src)
					let obj = {}
					obj.formatres = `rgba(${res.r},${res.g},${res.b},0.01)`
					obj.formatres1 = `rgba(${res.r},${res.g},${res.b},0.6)`
					obj.formatres2 = `rgba(${res.r},${res.g},${res.b},1)`
					obj.index = index
					obj.y = y
					return obj
				},
			};

			onMounted(() => {

			});
			return {
				...toRefs(data),
				...methods,
			};
		},
		onShow() {
			this.getStuCourse();
			this.userData = uni.getStorageSync('userInfo');
		},
		onShareAppMessage() {
			return {
				title: "甲小鹤",
				query: "/pages/index/index",
				imageUrl: "",
			};
		},
		onShareTimeline() {
			return {
				title: "甲小鹤",
				query: "/pages/index/index",
				imageUrl: "",
			};
		},
	};
</script>

<style scoped>
	.index-student-title view{
		font-size: 25rpx;
		color: #ABABAB;
		margin-left: 20rpx;
		padding: 13rpx 0 0 0;
	}
	.index-student-title text{
		font-size: 36rpx;
		font-weight: 800;
		color: #282828;
	}
	.index-student-title{
		padding: 0 50rpx 45rpx;
	}
	.index-student-information{
		min-height: 500rpx;
		background: rgba(255,255,255,.7);
		border-radius: 50rpx 50rpx 0 0;
		padding: 71rpx 0 0 0;
	}
	.index-header-name{
		font-size: 30rpx;
		color: #474747;
	}
	.index-header-tetx{
		color: #D0D0D0;
		font-size: 24rpx;
	}
	.index-header-img .img{
		display: block;
		border: 2rpx solid rgba(164, 164, 164, 0.32);
		border-radius: 50%;
		overflow: hidden;
		width: 60rpx;
		height: 60rpx;
		box-sizing: border-box;
		margin: 4rpx;
	}
	.index-header-img{
		width: 68rpx;
		height: 68rpx;
		border-radius: 50%;
		overflow: hidden;
		text-align: center;
		margin-right: 20rpx;
		background: #FFFFFF;
	}
	.indexpage {
		min-height: 100vh;
		background-color: #f6f6f6;
		box-sizing: border-box;
		background-image: url('https://viitto-1301420277.cos.ap-chengdu.myqcloud.com/Test/Upload/Goods/1653464014000_398.png');
		background-position: 0 200rpx;
		background-repeat: no-repeat;
		background-size: 100% auto;
	}
	.index-header-box{
		display: flex;
		flex-direction: row;
		align-items: center;
		padding:0rpx 42rpx ;
	}
	.index-header-box .index-header-title{
		font-size: 24rpx;
		font-weight: 400;
		color: #B8B8B8;
	}
	.index-header-box .index-header-name{
		font-size: 30rpx;
		font-weight: 800;
		color: #282828;
	}
	.navbarSticky {
		display: sticky;
		top: 0;
		z-index: 9;
	}
	
</style>
