Skip to content

Commit 1e8eb29

Browse files
committed
uniapp-admin
1 parent bead0e1 commit 1e8eb29

File tree

485 files changed

+144278
-0
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

485 files changed

+144278
-0
lines changed

.gitignore

+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
node_modules/
2+
.project
3+
unpackage/
4+
.vscode/
5+
.idea
6+
.DS_Store
7+
*.iml

App.vue

+148
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,148 @@
1+
<script>
2+
import Vue from 'vue'
3+
import {
4+
mapGetters
5+
} from 'vuex'
6+
export default {
7+
computed: mapGetters(['user']),
8+
onLaunch: function() {
9+
// 初始化系统
10+
this.initSystem()
11+
// 自动登录检测
12+
this.autoLogin()
13+
},
14+
methods: {
15+
/**
16+
* app整包更新检测
17+
*/
18+
appUpgrade(platform) {
19+
if (platform !== 'android') {
20+
return
21+
}
22+
//#ifdef APP-PLUS
23+
plus.runtime.getProperty(plus.runtime.appid, (wgtinfo) => {
24+
let params = {
25+
appid: plus.runtime.appid,
26+
version: wgtinfo.versionCode,
27+
platform: platform
28+
}
29+
this.$minApi.findUpgradeApp(params).then(appRes => {
30+
if (appRes.appid) {
31+
uni.showModal({
32+
title: "下载更新提示",
33+
content: appRes.note,
34+
showCancel: false,
35+
confirmText: '确定',
36+
success: sucRes => {
37+
if (sucRes.confirm) {
38+
plus.runtime.openURL(appRes.url)
39+
// uni.downloadFile({
40+
// url: appRes.url,
41+
// success: res => {}
42+
// })
43+
}
44+
}
45+
})
46+
}
47+
})
48+
})
49+
//#endif
50+
},
51+
/**
52+
* 自动登录
53+
* 判断本地是否有账号信息,如果有,就自动重新登录
54+
*/
55+
autoLogin() {
56+
// 判断本地是否有账号信息,如果有,就自动重新登录
57+
if (this.user && this.user.id && this.user.name && this.user.passwd) {
58+
const params = {
59+
name: this.user.name,
60+
passwd: this.user.passwd
61+
}
62+
uni.showLoading({
63+
title: '自动登录中...'
64+
})
65+
this.$store.dispatch('login', params).then(res => {
66+
uni.hideLoading()
67+
// uni.showToast({
68+
// title: '已自动登录!',
69+
// icon: 'success'
70+
// })
71+
setTimeout(() => {
72+
uni.reLaunch({
73+
url: '/pages/index/index'
74+
})
75+
}, 1000)
76+
}).catch(() => {
77+
uni.hideLoading()
78+
uni.showToast({
79+
title: '会话过期,请重新登录!',
80+
icon: 'none'
81+
})
82+
setTimeout(() => {
83+
uni.reLaunch({
84+
url: '/pages/login/login'
85+
})
86+
}, 1000)
87+
})
88+
} else {
89+
// 如果本地没有账号信息,就提示用户必须登录
90+
uni.showModal({
91+
title: '未登录',
92+
content: '您未登录,需要登录后才能继续',
93+
showCancel: false,
94+
confirmText: '确定',
95+
success: res => {
96+
if (res.confirm) {
97+
uni.reLaunch({
98+
url: '/pages/login/login'
99+
})
100+
}
101+
}
102+
})
103+
}
104+
},
105+
/**
106+
* 初始化系统
107+
*/
108+
initSystem() {
109+
const self = this
110+
uni.getSystemInfo({
111+
success: function(e) {
112+
// app整包更新检测
113+
self.appUpgrade(e.platform)
114+
115+
// #ifndef MP
116+
Vue.prototype.StatusBar = e.statusBarHeight;
117+
if (e.platform == 'android') {
118+
Vue.prototype.CustomBar = e.statusBarHeight + 50;
119+
} else {
120+
Vue.prototype.CustomBar = e.statusBarHeight + 45;
121+
};
122+
// #endif
123+
124+
// #ifdef MP-WEIXIN
125+
Vue.prototype.StatusBar = e.statusBarHeight;
126+
let custom = wx.getMenuButtonBoundingClientRect();
127+
Vue.prototype.Custom = custom;
128+
Vue.prototype.CustomBar = custom.bottom + custom.top - e.statusBarHeight;
129+
// #endif
130+
131+
// #ifdef MP-ALIPAY
132+
Vue.prototype.StatusBar = e.statusBarHeight;
133+
Vue.prototype.CustomBar = e.statusBarHeight + e.titleBarHeight;
134+
// #endif
135+
}
136+
})
137+
}
138+
}
139+
}
140+
</script>
141+
142+
<style>
143+
@import "common/css/uni.css";
144+
@import "colorui/main.css";
145+
@import "colorui/icon.css";
146+
@import "common/css/iconfont.css";
147+
@import "common/css/common.css";
148+
</style>

api/api.js

+88
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,88 @@
1+
import Vue from 'vue'
2+
import MinRequest from '@/utils/MinRequest'
3+
import globalConfig from '@/config'
4+
5+
const minRequest = new MinRequest()
6+
7+
// 请求拦截器
8+
minRequest.interceptors.request((request) => {
9+
return request
10+
})
11+
12+
// 响应拦截器
13+
minRequest.interceptors.response((response) => {
14+
if (response.statusCode === 500 && response.data && response.data.errorMsg === '您还未登录系统,请先登录!') {
15+
const user = Vue.prototype.$store.getters.user
16+
if (user && user.id && user.name && user.passwd) {
17+
const params = {
18+
name: user.name,
19+
password: user.passwd,
20+
subSystemCode: 4
21+
}
22+
uni.showLoading({
23+
title: '会话过期,自动登录中...'
24+
})
25+
Vue.prototype.$store.dispatch('login', params).then(res => {
26+
uni.hideLoading()
27+
uni.showToast({
28+
title: '已自动登录!',
29+
icon: 'success'
30+
})
31+
setTimeout(() => {
32+
uni.reLaunch({
33+
url: '/pages/index/index'
34+
})
35+
}, 1000)
36+
}).catch(() => {
37+
uni.hideLoading()
38+
uni.showToast({
39+
title: '会话过期,请重新登录!',
40+
icon: 'none'
41+
})
42+
setTimeout(() => {
43+
uni.reLaunch({
44+
url: '/pages/login/login'
45+
})
46+
}, 1000)
47+
})
48+
}
49+
} else {
50+
if (response.statusCode !== 200) {
51+
let msg = ''
52+
if (response.data && response.data.errorMsg) {
53+
msg = response.data.errorMsg
54+
} else {
55+
msg = '请求超时,请检查网络配置,重新登录!'
56+
}
57+
uni.showToast({
58+
title: msg,
59+
icon: 'none'
60+
})
61+
setTimeout(() => {
62+
uni.reLaunch({
63+
url: '/pages/login/login'
64+
})
65+
}, 1000)
66+
}
67+
}
68+
return response.data
69+
})
70+
71+
// 设置默认配置
72+
minRequest.setConfig((config) => {
73+
config.baseURL = globalConfig.baseUrl
74+
return config
75+
})
76+
77+
export default {
78+
// 这里统一管理api请求
79+
apis: {
80+
// api请求示例
81+
// login(params) {
82+
// // get方法
83+
// // minRequest.get('/api/login', params)
84+
// // post方法
85+
// return minRequest.post('/api/login', params)
86+
// }
87+
}
88+
}

0 commit comments

Comments
 (0)