/*
|
* @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')
|