<template>
	<view class="content main-bg">
		<news ref="news" v-if="type === '2'"></news>
		<news ref="news" v-if="type === '3'"></news>
		<news ref="news" v-else-if="type === '1'"></news>
		<goods ref="goods" v-else-if="type === '4'"></goods>
	</view>
</template>

<script>
import news from '@/pages/soldier/news/index'
import goods from '@/pages/manage/goods/index'
export default {
	components:{
		news,
		goods,
	},
	data() {
		return {
			type: ''
		}
	},
	onLoad() {
		let role = uni.getStorageSync('role');
		this.type = role;
		if(this.type === '4'){
			uni.setNavigationBarTitle({
				title: '商品审核'
			})
		};
		setTimeout(function () {
			console.log('start pulldown');
		}, 1000);
		uni.startPullDownRefresh();
	},
	onPullDownRefresh() {
		let role = uni.getStorageSync('role');
		this.type = role;
		if(this.type === '4'){
			this.handleShow();
		}else{
			this.handleMain();
		}
		setTimeout(function () {
			uni.stopPullDownRefresh();
		}, 1000);
	},
	onShow() {
		let role = uni.getStorageSync('role');
		this.type = role
		if(this.type === '4'){
			this.handleShow();
		}else{
			this.handleMain();
		}
	},
	methods: {
		handleShow(){
			this.$refs.goods.show("qwe")
		},
		handleMain(){
			this.$refs.news.show("qwe")
		}
	},
}
</script>

<style>
	
</style>
