blob: 59255e93735cb069d0f80741a73dc266223717f2 [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)
guangchao.xu070005a2020-12-07 09:56:40 +080019// #ifndef H5
20var value = ""
21uni.getScreenBrightness({
22 success: function(res) {
23 value = res.value
24 }
25});
26Vue.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
45Vue.prototype.changeTabbar = function(e) {
46 // console.log(e)
47}
48// #endif
49
50//全局页面跳转
51Vue.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.xu6cdd45e2021-04-16 17:44:30 +080062 url: '/pages/sub_basic/login'
guangchao.xu070005a2020-12-07 09:56:40 +080063 })
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}
88Vue.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}
100const app = new Vue({
101 store,
102 ...App
103})
104// http拦截器,此为需要加入的内容,如果不是写在common目录,请自行修改引入路径
105import httpInterceptor from '@/static/js/http.interceptor.js'
106// 这里需要写在最后,是为了等Vue创建对象完成,引入"app"对象(也即页面的"this"实例)
107Vue.use(httpInterceptor, app)
108
109//http接口API集中管理引入部分
110// import httpApi from '@/static/js/http.api.js'
111// Vue.use(httpApi, app)
112
113app.$mount()