<script>
import store from '@/store'
import { mapMutations, mapActions, mapGetters } from 'vuex'
import { setTimeout } from 'timers'
import { getUser, wxLoginFn } from '@/utils/auth'
import { getDictionaries } from '@/api/mini'
import util from "./utils/util";
import priceSocket from "./mixins/priceSocket";
export default {
	mixins:[priceSocket],
	// 全端，数据共享，还可以解决页面初始化模板访问不到值得
	// 有坑 分包里的页面访问不到
	globalData: {},
	onLaunch() {
		// #ifdef H5
		// H5开发环境无法微信授权，使用固定的用户 shish 2020.4.30
		if (process.env.NODE_ENV == "development") {
			uni.setStorageSync("token","eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiIsImp0aSI6IjBfMSJ9.eyJpc3MiOiJodHRwOlwvXC9hcGkuc2hvcC5oemdoZC5jb20iLCJhdWQiOiJodHRwOlwvXC9hcGkuc2hvcC5oemdoZC5jb20iLCJqdGkiOiIwXzEiLCJpYXQiOjE2MTg0MDg4NTcsIm5iZiI6MTYxODQwODg1NywiZXhwIjoxNjI3MDQ4ODU3LCJ1bmlxdWVJZCI6IjEiLCJzb3VyY2VJZCI6MH0.iDSEqewx8D1vdiyhQDkfBJBDWljF4zK19M0uqhGmLe4")
			uni.setStorageSync("account", "0")
			getDictionaries({ token: uni.getStorageSync('token') }).then(res => {
				if (util.isEmpty(res)) {
					return false
				}
				store.commit('setDictionariesInfo', {
					...res.data.dict,
					...res.data
				})
				store.commit('setMyShopInfo', {
					...res.data.shop,
					...res.data
				})
			})
		}
		// #endif
		// 删除缓存
		if (process.env.NODE_ENV == 'production') {
			uni.removeStorageSync('shopUser')
		}
		// #ifdef MP-WEIXIN
		// wxLoginFn()
		// uni.clearStorage()
		const extConfig = wx.getExtConfigSync ? wx.getExtConfigSync() : {}
		uni.setStorageSync('account', extConfig.account)
		// #endif

	},
	onLoad(){
		// const pages = getCurrentPages();
		// const currentPage = pages[pages.length - 1];
		// const url = `/${currentPage.route}`;
		// console.log(1111,url)
	},
	onShow() {
	},
	onHide() {},
	onError(err) {
		console.error(err, '错误捕获')
	},
	methods: {
		...mapActions(['setUserShopAll'])
	}
}
</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%;
	}
	/**开单-扎和支切换样式**/
	.switchover-unit{
		position: fixed;
		left: calc(170rpx / 2 - 50rpx);
		bottom: 140rpx;
		display: flex;
		align-items: center;
		justify-content: center;
		width: 100rpx;
		height: 100rpx;
		color: #FFFFFF;
		background: #4b8cf4;
		border-radius: 50%;
		font-size: 42rpx;
		font-weight: 700;
		z-index: 2;
	}
	/**开单-增加减少动画**/
	.animation{animation:imgmove 0.3s 1;animation-iteration-count:1;}
	@-webkit-keyframes imgmove{0%{transform: scale(0.7);}100%{transform: scale(1);}}
</style>
