fuliqi
2024-01-24 29c1e7eb5ac16e90d8991a86c1c071bc312ec8d9
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
/*
 * @Descripttion:
 * @version: 1.0.0
 * @Author: Bridge
 * @Date: 2021-09-08 16:55:07
 */
import Vue from 'vue'
import App from './App.vue'
import router from './router'
import './router/permission'
import store from './store'
import './assets/styles/index.styl'
import alert from './components/alert/main'
 
// import Mui from 'vue-awesome-mui'
import 'swiper/dist/css/swiper.css'
import VueAwesomeSwiper from 'vue-awesome-swiper'
import uni from 'uni'
import Vant, {
  Lazyload,
  ImagePreview,
  Toast
} from 'vant'
 
import 'vant/lib/index.css'
 
import scrollView from './components/scroll-view/index.vue'
import navBar from './components/nav-bar/index.vue'
import VueLazyload from 'vue-lazyload'
import Vconsole from 'vconsole'
// 开发、sit环境 打开vconsole
if (process.env.VUE_APP_CURRENTMODE === 'development' || process.env.VUE_APP_CURRENTMODE === 'sit' || process.env.VUE_APP_CURRENTMODE === 'uat') {
  new Vconsole()
}
// 全局注册
Vue.use(VueAwesomeSwiper)
Vue.use(Vant)
Vue.use(Lazyload, {
  lazyComponent: true
})
// Vue.use(Mui)
Vue.use(alert)
Vue.use(Toast)
Vue.use(VueLazyload)
Vue.component('nav-bar', navBar)
Vue.component('scroll-view', scrollView)
Vue.config.productionTip = false
Vue.directive('link', {
  bind: function (el, binding) {
    el.addEventListener('click', function () {
      const {
        value
      } = binding
      // uni.navigateTo({
      //   url: value
      // })
      uni.postMessage({
        data: {
          url: value,
          type: 'jumpLink'
        }
      })
    })
  }
})
Vue.prototype.$setVw = function (size) {
  var num = (size / 375) * 100
  var length = num.toString().split('.')[1] ? num.toString().split('.')[1].length : 0
  if (length && length > 2) {
    return num.toFixed(2) + 'vw'
  } else {
    return num + 'vw'
  }
}
Vue.prototype.$isMp4 = function (url) {
  const arr = url.split('.')
  return arr[arr.length - 1].toLowerCase() === 'mp4'
}
Vue.filter('ossProcess', function (val) {
  return `${val}?x-oss-process=image/resize,w_750/format,jpg/quality,q_90/interlace,1`
})
Vue.prototype.$ImagePreview = ImagePreview
// 全局过滤器
Vue.filter('fillerToFixed', function (val) {
  return val ? Number(val).toFixed(2) : '0.00'
})
new Vue({
  router,
  store,
  data () {
    return {
      isIos: false
    }
  },
  render: h => h(App),
  created () {
    console.log('v2.0最新包---------1.27')
    this.getIsIos()
  },
  methods: {
    getIsIos () {
      // Browser environment sniffing
      var inBrowser = typeof window !== 'undefined'
      // Weex 是使用流行的 Web 开发体验来开发高性能原生应用的框架
      var inWeex = typeof WXEnvironment !== 'undefined' && !!WXEnvironment.platform
      // 两个不等号的含义有值取值,没值就是false 类似于  var  a = 'b' || false
      var weexPlatform = inWeex && WXEnvironment.platform.toLowerCase()
      // 浏览器的用户代理报头:window.navigator.userAgent
      var UA = inBrowser && window.navigator.userAgent.toLowerCase()
      var isIOS = (UA && /iphone|ipad|ipod|ios/.test(UA)) || (weexPlatform === 'ios')
      if (isIOS) {
        this.isIos = isIOS
      }
      this.setToken()
    },
    setToken () {
      if (this.isIos) {
        window.getIosToken = function (str) {
          console.log('ios获取到的token', str)
          window.localStorage.setItem('access_token', str)
        }
        window.delIosToken = function () {
          console.log('退出登录清除token')
          window.localStorage.removeItem('access_token')
        }
      } else {
        if (window.wlyxls) {
          const _token = window.wlyxls.getToken('') || ''
          window.localStorage.setItem('access_token', _token)
        }
      }
      // window.localStorage.setItem('access_token', 'b9cdbd680bca21ec6a848a05f5d691a8')
    }
  }
}).$mount('#app')