<script>
import store from '@/store'
import { mapMutations, mapActions, mapGetters } from 'vuex'
import { setTimeout } from 'timers'
import { getDictionaries } from '@/api/mini'
import util from "./utils/util"
import priceSocket from "./mixins/priceSocket";
export default {
	mixins:[priceSocket],
  // 全端，数据共享，还可以解决页面初始化模板访问不到值得
  // 有坑 分包里的页面访问不到
  globalData: {},
  onLaunch () {
			uni.removeStorageSync('suitInfoList');
			uni.removeStorageSync('productInfoList');
			uni.removeStorageSync('pxClassInfoList');
    // #ifdef H5
    // H5开发环境无法微信授权，使用固定的用户 shish 2020.4.30
    if (process.env.NODE_ENV == "development") {
      uni.setStorageSync("token","eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiIsImp0aSI6IjBfNTIifQ.eyJpc3MiOiJodHRwczpcL1wvYXBpLnNob3AuaHpnaGQuY29tIiwiYXVkIjoiaHR0cHM6XC9cL2FwaS5zaG9wLmh6Z2hkLmNvbSIsImp0aSI6IjBfNTIiLCJpYXQiOjE2MTYxNTc2NjQsIm5iZiI6MTYxNjE1NzY2NCwiZXhwIjoxNjI0Nzk3NjY0LCJ1bmlxdWVJZCI6IjUyIiwic291cmNlSWQiOjB9.VzSekbSwSczMWsfdPVdrm3gZ-v9o3p01NbMVNT4nGZ4")
      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 (extraData) {
  	if(extraData){
  		uni.setStorageSync('extraData',extraData)
			}
  },
  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(170upx / 2 - 50upx);
	bottom: 140upx;
	display: flex;
	align-items: center;
	justify-content: center;
	width: 100upx;
	height: 100upx;
	color: #FFFFFF;
	background: #4b8cf4;
	border-radius: 50%;
	font-size: 42upx;
	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>
