App.vue 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106
  1. <script>
  2. import store from '@/store'
  3. import { mapMutations, mapActions, mapGetters } from 'vuex'
  4. import { setTimeout } from 'timers'
  5. import { getUser, wxLoginFn } from '@/utils/auth'
  6. import { getDictionaries } from '@/api/mini'
  7. import util from "./utils/util";
  8. import priceSocket from "./mixins/priceSocket";
  9. export default {
  10. mixins:[priceSocket],
  11. // 全端,数据共享,还可以解决页面初始化模板访问不到值得
  12. // 有坑 分包里的页面访问不到
  13. globalData: {},
  14. onLaunch() {
  15. // #ifdef H5
  16. // H5开发环境无法微信授权,使用固定的用户 shish 2020.4.30
  17. if (process.env.NODE_ENV == "development") {
  18. uni.setStorageSync("token","eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiIsImp0aSI6IjBfMSJ9.eyJpc3MiOiJodHRwOlwvXC9hcGkuc2hvcC5oemdoZC5jb20iLCJhdWQiOiJodHRwOlwvXC9hcGkuc2hvcC5oemdoZC5jb20iLCJqdGkiOiIwXzEiLCJpYXQiOjE2MTg0MDg4NTcsIm5iZiI6MTYxODQwODg1NywiZXhwIjoxNjI3MDQ4ODU3LCJ1bmlxdWVJZCI6IjEiLCJzb3VyY2VJZCI6MH0.iDSEqewx8D1vdiyhQDkfBJBDWljF4zK19M0uqhGmLe4")
  19. uni.setStorageSync("account", "0")
  20. getDictionaries({ token: uni.getStorageSync('token') }).then(res => {
  21. if (util.isEmpty(res)) {
  22. return false
  23. }
  24. store.commit('setDictionariesInfo', {
  25. ...res.data.dict,
  26. ...res.data
  27. })
  28. store.commit('setMyShopInfo', {
  29. ...res.data.shop,
  30. ...res.data
  31. })
  32. })
  33. }
  34. // #endif
  35. // 删除缓存
  36. if (process.env.NODE_ENV == 'production') {
  37. uni.removeStorageSync('shopUser')
  38. }
  39. // #ifdef MP-WEIXIN
  40. // wxLoginFn()
  41. // uni.clearStorage()
  42. const extConfig = wx.getExtConfigSync ? wx.getExtConfigSync() : {}
  43. uni.setStorageSync('account', extConfig.account)
  44. // #endif
  45. wxLoginFn(true)
  46. .then(res => {
  47. //客户可以访问的页面
  48. var urlArr = ['admin/shopAdmin/bind', 'pagesClient/official','pagesClient/member/bind','pagesShare/pay'];
  49. var redirectPage = res.redirectPage;
  50. var needRedirect = true;
  51. urlArr.forEach((item, index, array) => {
  52. if (redirectPage.indexOf(item) != -1) {
  53. needRedirect = false;
  54. }
  55. })
  56. if (needRedirect === true) {
  57. //客户访问不能查看的页面跳转去官网
  58. if (res.data.shopAdminId == '0') {
  59. this.$util.pageTo({
  60. url: "/pagesClient/official/index",
  61. type: 2,
  62. query: {
  63. ...this.option
  64. }
  65. });
  66. }
  67. }
  68. getUser(true)
  69. //获取门店信息
  70. this.setUserShopAll()
  71. })
  72. },
  73. onLoad(){
  74. // const pages = getCurrentPages();
  75. // const currentPage = pages[pages.length - 1];
  76. // const url = `/${currentPage.route}`;
  77. // console.log(1111,url)
  78. },
  79. onShow() {
  80. },
  81. onHide() {},
  82. onError(err) {
  83. console.error(err, '错误捕获')
  84. },
  85. methods: {
  86. ...mapActions(['setUserShopAll'])
  87. }
  88. }
  89. </script>
  90. <style lang="scss">
  91. //没有scss变量方法的,主要引入 这样打包的时候就不会所有的组件都打包进去
  92. @import './static/iconfont/iconfont.css';
  93. @import './static/css/uni2.css';
  94. @import './static/css/base.scss';
  95. @import './static/css/common.scss';
  96. @import './static/css/reset.scss';
  97. page {
  98. height: 100%;
  99. }
  100. .animation{animation:imgmove 0.3s 1;animation-iteration-count:1}
  101. @-webkit-keyframes imgmove{
  102. 0%{transform: scale(0.7);}
  103. //50%{transform: scale(1);}
  104. 100%{transform: scale(1);}
  105. }
  106. </style>