<script>
import { mapMutations, mapActions, mapGetters } from 'vuex'
import { setTimeout } from 'timers'
import { getUser, wxLoginFn } from '@/utils/auth'
export default {
	// 全端，数据共享，还可以解决页面初始化模板访问不到值得问题
	// 有坑 分包里的页面访问不到
	globalData: {
	},
	onLaunch() {
		// this.getAllOptions()
		// #ifdef MP-WEIXIN
		// wxLoginFn()
		const extConfig = wx.getExtConfigSync ? wx.getExtConfigSync() : {}
		console.log('extConfig', extConfig)
		uni.setStorageSync('account', extConfig.account)
		// #endif
		// 开发
		if (process.env.NODE_ENV == 'development') {
			uni.setStorageSync('token', 'eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiIsImp0aSI6IjBfMTI1NDM3NDUifQ.eyJpc3MiOiJodHRwczpcL1wvYXBpLmIuaHVhbWwuY29tIiwiYXVkIjoiaHR0cHM6XC9cL2FwaS5iLmh1YW1sLmNvbSIsImp0aSI6IjBfMTI1NDM3NDUiLCJpYXQiOjE1ODA3MTA1NjEsIm5iZiI6MTU4MDcxMDU2MSwiZXhwIjoxNTg5MzUwNTYxLCJ1bmlxdWVJZCI6IjEyNTQzNzQ1Iiwic291cmNlSWQiOjB9.kHrIKm0MUOnX8fCDjOXwd7wQ4jOSEV8gvwR4H4hn_hQ')
			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>
