123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103 |
- import Vue from 'vue'
- import App from './App'
- import cookies from 'weapp-cookie'
- import router from './router/index.js'
- import store from './store/index.js'
- import permission from './utils/permission'
- import { isEmpty } from './utils/types'
- import { guid } from './utils/lib'
- import { STATIC_URL_FN, appVersion } from './config.js'
- Vue.config.productionTip = false
- Vue.use(router)
- Vue.prototype.$isEmpty = isEmpty
- Vue.prototype.$auth = permission
- Vue.prototype.$guid = guid
- /**
- * Toast
- */
- Vue.prototype.$toast = (msg, duration = 3000) => {
- // #ifdef APP-PLUS
- const richtext = '<font color="#FFFFFF" style="font-size:14px;">' + msg + '</font>'
- plus.nativeUI.toast(richtext, {
- background: 'rgba(0,0,0,1)',
- duration: duration > 3000 ? 'long' : 'short',
- type: 'richtext',
- verticalAlign: 'top'
- })
- // #endif
- // #ifndef APP-PLUS
- uni.showToast({
- position: 'top',
- title: msg,
- icon: 'none',
- duration: duration
- })
- // #endif
- }
- /**
- * 返回并刷新上一页内容
- */
- Vue.prototype.$refreshAndToPrev = (that, toPrev = true) => {
- const pages = getCurrentPages()
- if (pages.length >= 2) {
- const prevPage = pages[pages.length - 2]
-
- if (prevPage.$vm) {
- prevPage.$vm.refreshPage = true
- } else {
- prevPage.refreshPage = true
- }
- }
- if (toPrev) {
- that.$nextTick(function() {
- that.$Router.navigateBack()
- })
- }
- }
- /**
- * 拼接静态资源路径
- * @param {Object} val
- * @return {String}
- */
- Vue.prototype.$static = STATIC_URL_FN
- Vue.filter('static', Vue.prototype.$static)
- Vue.prototype.$clearStorage = () => {
- const username = uni.getStorageSync('username') || null
- const quickConfig = uni.getStorageSync('quickConfig') || [1, 2, 3, 4]
- const appid = uni.getStorageSync('appid') || null
- uni.clearStorageSync()
- if (username) {
- uni.setStorageSync('username', username)
- }
- if (appid) {
- uni.setStorageSync('appid', appid)
- }
- uni.setStorageSync('version', appVersion)
- uni.setStorageSync('quickConfig', quickConfig)
- }
- App.mpType = 'app'
- if (process.env.NODE_ENV !== 'development') {
- console.log = () => {}
- }
- const app = new Vue({
- ...App,
- store
- })
- app.$mount()
- export default app
|