index.js 3.12 KB
import api from '@/api/api';
import {
	httpGet,
	httpPost
} from '@/api/fetch-api.js';
import {
	mapGetters,
	mapActions,
	mapState
} from "vuex";
var UA = require("ua-device");

import { gotoVHIS } from '@/utils/biz.js';

export default {
	data() {
		return {
			key: 'value',
			// swiper
			swiperOption: {
				// navigation: {
				// 	nextEl: '.swiper-button-next',
				// 	prevEl: '.swiper-button-prev'
				// },
				pagination: {
					el: '.swiper-pagination',
					clickable: true,
				},
				autoplay: {
					delay: 5000,
					stopOnLastSlide: false,
					disableOnInteraction: false
				},
				speed: 1000,

			},
			// 视频
			playerOptions: {},

		}
	},
	components: {},
	computed: {
		...mapState({
			isSmallScreen: state => state.isSmallScreen
		}),
		locale() {
			return this.$i18n.locale || 'tc';
		},
		i18n() {
			return this.$i18n.messages && this.$i18n.locale ? this.$i18n.messages[this.$i18n.locale] : {};
		},
		player() {
			return this.$refs.videoPlayer.player
		},

	},
	methods: {
		toVhis(){
			gotoVHIS(this.locale);
		},
		/**
		 * 推荐产品
		 */
		onRecommendHandler(val) {
			if (val == 1) {
				this.$router.push({
					path: "/product"
				})
			}
			if (val == 2) {
				this.$router.push({
					path: "/custom/service?q=m6"
				})
			}
			if (val == 3) {
				this.$router.push({
					path: "/custom/product"
				})
			}
			if(val == 4){
				this.$router.push({
					path: "/news/list"
				})
			}

		},

		/**
		 * 推荐产品
		 */
		onMoreNewsHandler() {
			this.$router.push({
				path: "/news/list"
			})
		},

		/**
		 * 去新闻详情页面
		 * 需要带id
		 */
		toNewsDetail() {
			this.$router.push({
				path: '/news/detail'
			})
		},
		toProfile() {
			this.$router.push({
				path: '/profile'
			})
		},
		refreshVideoPlayer() {

			let playerOptions = {
				width: 800,
				height: 450,
				// aspectRatio: '16:9', // 将播放器置于流畅模式,并在计算播放器的动态大小时使用该值。值应该代表一个比例 - 用冒号分隔的两个数字(例如"16:9"或"4:3")
				autoplay: false, //如果true,浏览器准备好时开始回放。
				muted: true, // 默认情况下将会消除任何音频。
				language: 'en',
				// playbackRates: [0.7, 1.0, 1.5, 2.0],//播放速度
				sources: [{
					type: "video/mp4",
					// mp4
					src: process.env.VUE_APP_INDEX_VIDEO,
					// webm
					// src: "https://cdn.theguardian.tv/webM/2015/07/20/150716YesMen_synd_768k_vp8.webm"
				}],
				poster: 'images/video-poster.png',
				controlBar: {
					timeDivider: true,
					durationDisplay: true,
					remainingTimeDisplay: false,
					fullscreenToggle: true //全屏按钮
				}
			}
			let output = new UA(navigator.userAgent);
			let deviceType = output.device.type;
			let isMobile = deviceType == "mobile";
			// if (this.isSmallScreen) {
			if (isMobile) {
				playerOptions.aspectRatio = "16:9";
			}
			this.playerOptions = playerOptions;
		},
		initData() {}
	},
	beforeDestroy() {
		window.removeEventListener('resize', this.refreshVideoPlayer(), false);
	},
	mounted() {
		this.refreshVideoPlayer();
		window.addEventListener('resize', () => this.refreshVideoPlayer(), false);
	},
	created() {

	}

}