<template>
	<view class="container">
		<!-- #ifdef H5 -->
		<view style="color: #fff;">
			<tn-nav-bar backgroundColor="#26B3A0" :bottomShadow="false" @rightClick="jumpScoreRed">支付状态
				<!-- 	<template slot="right">
					课程购买记录
				</template> -->
			</tn-nav-bar>
			<view :style="{ height: tobheight + 'px' }"></view>
		</view>
		<!-- #endif -->


		<view class="content">
			<view class="topIcon">
				<!-- <image src="../../../static/posImg.png" mode=""></image> -->
				<icon type="success" size="54" color="#26B3A0" />
				<view class="txt">
					支付成功
				</view>
			</view>
			<view class="btn" @click="downLoad">
				查看学习资料
			</view>
		</view>
	</view>
</template>

<script>
	import {
		courseDetail
	} from '@/api/score/index.js'
	import {
		downLoad2
	} from '@/utils/download2.js'
	export default {
		components: {},
		data() {
			return {
				detail: {},

				tobheight: 45,
			};
		},
		computed: {

		},
		watch: {

		},
		async onLoad(o) {
			let res = await courseDetail({
				course_id: o.id
			})
			if (res.code == 0) {
				this.detail = res.data
			}
			console.log('支付成功--课程详情返回值', res);
		},
		onReady() {

		},
		onShow() {

		},
		onUnload() {

		},
		methods: {
			downLoad() {
				if (!this.detail.content) {
					uni.showToast({
						title: '当前课程暂无学习资料',
						icon: 'none',
						duration: 1500
					})
					return
				}

				if (this.detail.content.endsWith('.mp4')) {
					let plat = uni.getSystemInfoSync().platform

					if (plat == 'android' || plat == 'ios') {
						window.open(
							this.detail.content
						)
					} else {
						downLoad2(this.detail.content, this.detail.name + '-学习资料', 'video/mp4')
					}
				} else {
					let plat = uni.getSystemInfoSync().platform
					if (plat == 'android' || plat == 'ios') {
						window.open(
							this.detail.content
						)
					} else {
						downLoad2(this.detail.content, this.detail.name + '-学习资料', 'application/pdf')
					}
				}
			},

			goPay() {
				uni.navigateTo({
					url: '/pages/index/scorePaySuc/index'
				})
			}
		}
	};
</script>

<style lang="scss" scoped>
	@import './index.scss';
</style>