<template>
	<view class="activity">
		<!-- <image @click.stop="navToDetailPage" src="https://img.caimei365.com/group1/M00/03/9A/Cmis216Zf8GAb_UqABE6NiwUUZs004.jpg" mode="widthFix"></image> -->
	   <web-view :webview-styles="webviewStyles" :src="activityPath"></web-view>
	</view>
</template>

<script>
	export default {
	    data() {
	        return {
	            webviewStyles: {
	                progress: {
	                    color: '#FF3333'
	                }
	            },
				productID:'',
				activityPath:'',
	        }
	    },
		onLoad(option) {
            // 普通传参
            if(option.link) {
                this.activityPath = option.link
                return
            }
            this.initPath(option)
		},
		methods:{
			navToDetailPage() {//跳转商品详情页
				this.$api.navigateTo(`/pages/goods/product?id=${this.productID}`)
			},
            initPath(option){
                if(!option.key || !option.type) return
                const link = uni.getStorageSync(option.key)
                const type = parseInt(option.type)
                uni.removeStorageSync(option.key) // 清除链接缓存
                //是word 或 ppt链接
                if(type === 1){
                    this.activityPath = link
                    return
                }
                //是pdf链接
                let URL_CONFIG = ''
                if(process.env.NODE_ENV === 'development'){
                    URL_CONFIG = 'http://zzjtest.gz.aeert.com'
                }else{
                    URL_CONFIG = 'https://www.caimei365.com/'
                }
                this.activityPath = `${URL_CONFIG}/document/pdfdetails.html?type=1&src=${link}`
            }
		}
	}
</script>
	
<style lang="scss">
	.activity{
		width: 100%;
		height: auto;
		image{
			width: 100%;
			height: auto;
		}
	}
</style>
