guangchao.xu | 070005a | 2020-12-07 09:56:40 +0800 | [diff] [blame] | 1 | import Vue from 'vue' |
| 2 | import App from './App' |
| 3 | |
| 4 | Vue.config.productionTip = false |
| 5 | |
| 6 | App.mpType = 'app' |
| 7 | |
| 8 | |
| 9 | // 引入全局uView |
| 10 | import uView from 'uview-ui' |
| 11 | Vue.use(uView) |
| 12 | |
| 13 | // 此处为演示vuex使用,非uView的功能部分 |
| 14 | import store from '@/store' |
| 15 | |
| 16 | // 引入uView提供的对vuex的简写法文件 |
| 17 | let vuexStore = require('@/store/$u.mixin.js') |
| 18 | Vue.mixin(vuexStore) |
guangchao.xu | 070005a | 2020-12-07 09:56:40 +0800 | [diff] [blame] | 19 | // #ifndef H5 |
| 20 | var value = "" |
| 21 | uni.getScreenBrightness({ |
| 22 | success: function(res) { |
| 23 | value = res.value |
| 24 | } |
| 25 | }); |
| 26 | Vue.prototype.changeTabbar = function(e) { |
| 27 | // #ifdef APP-PLUS |
| 28 | uni.removeStorageSync("stopShowTwice") |
| 29 | // #endif |
| 30 | if (e == 2) { |
| 31 | uni.setScreenBrightness({ |
| 32 | value: 1, |
| 33 | success: function() {} |
| 34 | }); |
| 35 | } else { |
| 36 | uni.setScreenBrightness({ |
| 37 | value: value, |
| 38 | success: function() {} |
| 39 | }); |
| 40 | } |
| 41 | } |
| 42 | // #endif |
| 43 | |
| 44 | // #ifdef H5 |
| 45 | Vue.prototype.changeTabbar = function(e) { |
| 46 | // console.log(e) |
| 47 | } |
| 48 | // #endif |
| 49 | |
| 50 | //全局页面跳转 |
| 51 | Vue.prototype.toPath = function(e) { |
| 52 | let token = uni.getStorageSync("token") |
| 53 | if (!token) { |
| 54 | uni.showModal({ |
| 55 | title: "提示", |
| 56 | content: "您还未登录,无法使用app功能", |
| 57 | cancelText: "再等等", |
| 58 | confirmText: "去登陆", |
| 59 | success(res) { |
| 60 | if (res.confirm) { |
| 61 | uni.reLaunch({ |
guangchao.xu | 6cdd45e | 2021-04-16 17:44:30 +0800 | [diff] [blame] | 62 | url: '/pages/sub_basic/login' |
guangchao.xu | 070005a | 2020-12-07 09:56:40 +0800 | [diff] [blame] | 63 | }) |
| 64 | } |
| 65 | } |
| 66 | }) |
| 67 | return false |
| 68 | } |
| 69 | if (!e) { |
| 70 | uni.showToast({ |
| 71 | icon: "none", |
| 72 | title: "功能暂未开通", |
| 73 | duration: 1500, |
| 74 | }) |
| 75 | return false |
| 76 | } |
| 77 | if (e == "/pages/sub_tabbar/active" || e == "/pages/sub_tabbar/index") { |
| 78 | uni.switchTab({ |
| 79 | url: e |
| 80 | }) |
| 81 | return false |
| 82 | } |
| 83 | |
| 84 | uni.navigateTo({ |
| 85 | url: e |
| 86 | }) |
| 87 | } |
| 88 | Vue.prototype.toUrl = function(e) { |
| 89 | if (e == "/pages/sub_tabbar/active" || e == "/pages/sub_tabbar/index") { |
| 90 | uni.switchTab({ |
| 91 | url: e |
| 92 | }) |
| 93 | return false |
| 94 | } |
| 95 | |
| 96 | uni.navigateTo({ |
| 97 | url: e |
| 98 | }) |
| 99 | } |
| 100 | const app = new Vue({ |
| 101 | store, |
| 102 | ...App |
| 103 | }) |
| 104 | // http拦截器,此为需要加入的内容,如果不是写在common目录,请自行修改引入路径 |
| 105 | import httpInterceptor from '@/static/js/http.interceptor.js' |
| 106 | // 这里需要写在最后,是为了等Vue创建对象完成,引入"app"对象(也即页面的"this"实例) |
| 107 | Vue.use(httpInterceptor, app) |
| 108 | |
| 109 | //http接口API集中管理引入部分 |
| 110 | // import httpApi from '@/static/js/http.api.js' |
| 111 | // Vue.use(httpApi, app) |
| 112 | |
| 113 | app.$mount() |