<script>
	import { mapMutations, mapActions, mapGetters } from 'vuex'
	import { setTimeout } from 'timers'
	import { getUser, wxLoginFn } from '@/utils/auth'
	export default {
		// 全端，数据共享，还可以解决页面初始化模板访问不到值得问题
		// 有坑 分包里的页面访问不到
		globalData: {},
		onLaunch() {
			// this.getAllOptions()
			// 删除缓存
			if (process.env.NODE_ENV == 'production') {
				uni.removeStorageSync('shopUser')
			}
			// #ifdef MP-WEIXIN
			// wxLoginFn()
			// uni.clearStorage()
			const extConfig = wx.getExtConfigSync ? wx.getExtConfigSync() : {}
			console.log('extConfig', extConfig)
			uni.setStorageSync('account', extConfig.account)
			// #endif
			// 开发
			if (process.env.NODE_ENV == 'development') {
				if (this.$constant.source == 'business') {
					uni.setStorageSync('token', 'eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiIsImp0aSI6IjBfNyJ9.eyJpc3MiOiJodHRwczpcL1wvYXBpLmIuaHVhbWwuY29tIiwiYXVkIjoiaHR0cHM6XC9cL2FwaS5iLmh1YW1sLmNvbSIsImp0aSI6IjBfNyIsImlhdCI6MTU4MjAyOTY2MywibmJmIjoxNTgyMDI5NjYzLCJleHAiOjE1OTA2Njk2NjMsInVuaXF1ZUlkIjoiNyIsInNvdXJjZUlkIjowfQ.v04WwuiNYArwrCzERY--uB3mWx4r2Za2R0chdjdTZF4')
					uni.setStorageSync('account', '12362')
				} else {
					uni.setStorageSync('token', 'eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiIsImp0aSI6IjBfMTI1NDM3NDUifQ.eyJpc3MiOiJodHRwOlwvXC9hcGkubS5odWFtbC5jb20iLCJhdWQiOiJodHRwOlwvXC9hcGkubS5odWFtbC5jb20iLCJqdGkiOiIwXzEyNTQzNzQ1IiwiaWF0IjoxNTgyNDY5NDIzLCJuYmYiOjE1ODI0Njk0MjMsImV4cCI6MTU5MTEwOTQyMywidW5pcXVlSWQiOiIxMjU0Mzc0NSIsInNvdXJjZUlkIjowfQ.ebTPvzLj4aI8F4iLHy_UdsVlAI-KyzErGQbJhPL1YRY')
					uni.setStorageSync('account', '12362')
				}
			}
		},
		onShow() {
			// this.isLogin()
		},
		onHide() {},
		onError(err) {
			console.error(err, '错误捕获')
		},
		methods: {
			isLogin() {
				let token = uni.getStorageSync('token')
				if (!token) {
					uni.reLaunch({
						url: '/pages/page/login/index'
					})
				}
			}
			// ...mapMutations(['setLoginInfo'])
			// #ifdef MP-WEIXIN
			// wxLogin() {
			// 	uni.login({
			// 		provider: 'weixin',
			// 		success: res => {
			// 			uni.setStorageSync('code', res.code)
			// 			console.log(res.code, 'res.code')
			// 			postWxCode({ code: res.code }).then(subRes => {
			// 				const { openid, session_key, unionid } = subRes.data
			// 				this.setLoginInfo({
			// 					openid,
			// 					session_key,
			// 					unionid
			// 				})
			// 			})
			// 		}
			// 	})
			// }
			// #endif
		}
	}
</script>

<style lang="scss">
	//没有scss变量方法的，主要引入 这样打包的时候就不会所以的组件都打包进去
	@import './static/iconfont/iconfont.css';
	@import './static/css/uni2.css';
	@import './static/css/base.scss';
	@import './static/css/common.scss';
	@import './static/css/reset.scss';
	page {
		height: 100%;
	}
</style>
