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