<template>
	<view class="container">
		<home-deco :deco_info="deco_data" :width='width' :height='height' :home_page_img='home_page_img' :is_show_top="false" type="information"></home-deco>
	</view>
</template>

<script>
	import HomeDeco from '@/components/home_deco.vue'
	export default {
		data() {
			return {
				deco_data:[],
				home_page_img:[],
				width:'',
				height:'',
				client:'' //客户端类型
			};
		},
		components: {
			HomeDeco
		},
		onLoad(option) {
			this.loadData(this.topic_id);
		},
		onBackPress(e){
		
		  uni.navigateTo({
		    url:"/pages/details/details?type=2"
		  })
		  // 此处一定姚要return为true，否则页面不会返回到指定路径
		  return true;
		},
		methods: {
			/**
			 * 请求静态数据只是为了代码不那么乱
			 * 分次请求未作整合
			 */
			async loadData(id) {
				uni.showLoading({
					title:this.$L('加载中...'),
				})
				// #ifdef H5
				this.client = 'h5'
				// #endif
				
				// #ifdef APP-PLUS
				switch(uni.getSystemInfoSync().platform){
					case 'android':
					   this.client = 'android'
					   break;
					case 'ios':
					   this.client = 'ios'
					   break;
					default:
					   break;
				}
				// #endif
				
				// #ifdef MP
				this.client = 'weixinXcx'
				// #endif
				let param = {}
				param.url = 'v3/system/front/deco/information?os='+this.client
				param.method = 'GET'
				this.$request(param).then(res => {
					if (res.state == 200) {
						if(res.data&&res.data.data){
							this.deco_data = JSON.parse(res.data.data)
						}
						uni.hideLoading()
						if(res.data.showTip != null){
							this.home_page_img = JSON.parse(res.data.showTip)
							const {windowWidth,windowHeight} = uni.getSystemInfoSync();
							this.width = this.home_page_img[0].width || windowWidth*0.75 * 1.8;
							this.height = this.home_page_img[0].height || windowHeight*0.56 * 1.8;
						}else{
							this.home_page_img = []
						}
					}
				})
			}
		}
	}
</script>

<style lang="scss">

</style>
