App.vue 3.3 KB

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