<template>
	<view :class="[AppTheme]" class="all_box">
		<themes1 :thflag="thflag" :primary2="primary" ref="themes1"></themes1>
		<themes2 :thflag="thflag" :primary2="primary" ref="themes2"></themes2>
		<!-- #ifdef MP-WEIXIN -->
		<button class="btn1" open-type="contact" v-if="ischar">
			<u-icon name="server-man" :color="primary" size="60"></u-icon>
		</button>
		<!-- #endif -->
		<!-- #ifdef APP-PLUS -->
		<updatepage class='updatepage' :isUpdate="isUpdate"></updatepage>
		<!-- #endif -->
		<!-- 广告 -->
		<admyself :opshow="true"></admyself>
		<!-- 底部tabbar -->
		<tabbar :primary="primary"></tabbar>
		<!-- 分享 -->
		<sharebox ref="sbox" v-if="sharedata" :data="sharedata"></sharebox>
	</view>
</template>
<script>
	// 组件加载主体
	import themes1 from '@/components/systhemes/themes1.vue';
	import themes2 from '@/components/systhemes/themes2.vue';
	export default {
		components: {
			themes1,
			themes2
		},
		data() {
			return {
				thflag: 1,
				ischar: false,
				sharedata: null,
				primary: this.$theme.primary,
				isUpdate: true
			}
		},
		onLoad(options) {
			let that = this
			that.$bindid.getbindid(options, that.$store);
			that.$init_config(1, function(res) {
				that.ischar = res.app.ischar
				that.thflag = res.thflag
				that.sharedata = res.sharedata
				if (that.thflag == 1) {
					that.$refs.themes1.init()
				} else if (that.thflag == 2) {
					that.$refs.themes2.init()
				}
			})
		},
		onPullDownRefresh() {
			let that = this
			if (that.thflag == 1) {
				that.$refs.themes1.toBottom(1)
			} else if (that.thflag == 2) {
				that.$refs.themes2.toBottom(1)
			}
		},
		onReachBottom() {
			let that = this
			if (that.thflag == 1) {
				that.$refs.themes1.toBottom()
			} else if (that.thflag == 2) {
				that.$refs.themes2.toBottom()
			}
		},
		onShareAppMessage(res) {
			let that = this
			let uinfo = uni.getStorageSync("userInfo")
			let path = 'pages/index/index?a=1'
			if (uinfo) {
				path = path + '&pid=' + uinfo.id;
			}
			return {
				title: that.sharedata.title,
				imageUrl: that.sharedata.imageUrl,
				path: path
			}
		},
		onShareTimeline(res) {
			let that = this
			let uinfo = uni.getStorageSync("userInfo")
			let path = 'pages/index/index?a=1'
			if (uinfo) {
				path = path + '&pid=' + uinfo.id;
			}
			return {
				title: that.sharedata.title,
				imageUrl: that.sharedata.imageUrl,
				path: path
			}
		},
		onShow: function() {
			let that = this;
			let config = that.$until.myCache(that.$cache_config_info_key);
			if (!config) {
				that.$init_config(1);
			}
			if (that.thflag == 1 && that.$refs.themes1) {
				that.$refs.themes1.init()
			}
		},
		methods: {
			getcar() {
				let uid = uni.getStorageSync('userInfo') ? uni.getStorageSync('userInfo').id : ''
				if (uid) {
					homeApi.getcar().then(res => {
						if (res.status == 200) {
							this.carnum = res.sdata;
						}
					});
				}
			},
		}
	}
</script>
<style lang="scss">
	.all_box {

		background-color: #f5f5f5;
	}

	.btn1 {
		background-color: transparent;
		position: fixed;
		right: 0;
		top: 77.5%;
		z-index: 11;
		width: 200rpx;
		height: 100rpx;
		outline: none;
		border: none;
	}

	.btnImg {
		width: 100%;
		height: 100%;
	}

	.btn1::after {
		outline: none;
		border: none;
	}
</style>
