App.vue 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120
  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 == '2') {
  56. // this.$util.pageTo({
  57. // url: "/admin/home/workbench",
  58. // type: 4
  59. // });
  60. //花店员工
  61. } else if(res.data.admin.identity == '1'){
  62. if(redirectPage !== 'admin/billing/customerPlace') {
  63. this.$util.pageTo({
  64. url: "/pagesClient/official/latest-shop",
  65. type: 2,
  66. query:{
  67. ...this.option
  68. }
  69. });
  70. }
  71. //未知身份
  72. }else{
  73. if(this.option.style != 1){
  74. this.$util.pageTo({
  75. url: "/pagesClient/official/index",
  76. type: 2,
  77. query: {
  78. ...this.option
  79. }
  80. });
  81. }
  82. }
  83. }
  84. getUser(true)
  85. //获取门店信息
  86. this.setUserShopAll()
  87. })
  88. },
  89. onLoad(){
  90. // const pages = getCurrentPages();
  91. // const currentPage = pages[pages.length - 1];
  92. // const url = `/${currentPage.route}`;
  93. // console.log(1111,url)
  94. },
  95. onShow() {
  96. },
  97. onHide() {},
  98. onError(err) {
  99. console.error(err, '错误捕获')
  100. },
  101. methods: {
  102. ...mapActions(['setUserShopAll'])
  103. }
  104. }
  105. </script>
  106. <style lang="scss">
  107. //没有scss变量方法的,主要引入 这样打包的时候就不会所有的组件都打包进去
  108. @import './static/iconfont/iconfont.css';
  109. @import './static/css/uni2.css';
  110. @import './static/css/base.scss';
  111. @import './static/css/common.scss';
  112. @import './static/css/reset.scss';
  113. page {
  114. height: 100%;
  115. }
  116. </style>