diff --git a/monitorMobile/App.vue b/monitorMobile/App.vue
index 981ee0f..cac54d5 100644
--- a/monitorMobile/App.vue
+++ b/monitorMobile/App.vue
@@ -2,7 +2,7 @@
export default {
onLaunch: function() {},
onShow: function() {},
- onHide: function() {}
+ onHide: function() {},
}
@@ -11,7 +11,7 @@
@import "uview-ui/index.scss";
@font-face {
- font-family: 'Alimama ShuHeiTi';//字体别名
+ font-family: 'Alimama ShuHeiTi'; //字体别名
src: url('/static/fonts/alimamashuheiti.ttf') format('truetype');
font-weight: normal;
font-style: normal;
diff --git a/monitorMobile/api/work/rollCall.js b/monitorMobile/api/work/rollCall.js
new file mode 100644
index 0000000..b68dc45
--- /dev/null
+++ b/monitorMobile/api/work/rollCall.js
@@ -0,0 +1,38 @@
+import http from '@/http/api.js'
+const url = '/api/business/classRoomCallApi'
+
+// 获取列表
+export const page = (params) => {
+ return http.request({
+ url: url + '/getPageList',
+ method: 'get',
+ params
+ })
+}
+
+// 获取不分页列表
+export const list = (params) => {
+ return http.request({
+ url: url + '/getNoPageList',
+ method: 'get',
+ params
+ })
+}
+
+// 获取点名列表某一项所有人员
+export const detail = (data) => {
+ return http.request({
+ url: '/api/business/personApi/pageQuery',
+ method: 'post',
+ data
+ })
+}
+
+// 获取点名任务列表
+export const taskPage = (params) => {
+ return http.request({
+ url: url + '/getTaskPageList',
+ method: 'get',
+ params
+ })
+}
\ No newline at end of file
diff --git a/monitorMobile/http/api.js b/monitorMobile/http/api.js
index c900b0d..2ad7776 100644
--- a/monitorMobile/http/api.js
+++ b/monitorMobile/http/api.js
@@ -3,11 +3,23 @@ import {
} from '@/http/config.js';
import Request from '@/utils/luch-request/index.js';
const http = new Request(options);
+import store from "@/store"
http.interceptors.request.use((config) => { // 可使用async await 做异步操作
// 假设有token值需要在头部需要携带
let token = uni.getStorageSync('token');
if (token) {
config.header['Authorization'] = 'Bearer ' + token;
+
+ const jwt = decryptJWT(token);
+ const exp = getJWTDate(jwt.exp);
+ // token 已经过期
+ if (new Date() <= exp) {
+ let refreshToken = store.state.refreshToken;
+ // 携带刷新 token
+ if (refreshToken) {
+ config.header["X-" + 'Authorization'] = 'Bearer ' + refreshToken;
+ }
+ }
}
// #ifndef H5
@@ -22,10 +34,7 @@ http.interceptors.request.use((config) => { // 可使用async await 做异步操
return Promise.reject(config)
})
http.interceptors.response.use((response) => {
- // 若有数据返回则通过
- if (response.data.access_token || response.data.key) {
- return response.data
- }
+ checkAndStoreAuthentication(response)
// 服务端返回的状态码不等于200,则reject()
if (response.data.code && response.data.code !== 200) {
setTimeout(() => {
@@ -49,6 +58,7 @@ http.interceptors.response.use((response) => {
if (response.statusCode == 401) {
const pages = getCurrentPages()
const currentPage = pages[pages.length - 1]
+ this.$store.dispatch('clearToken')
uni.redirectTo({
url: `/pages/login?redirect=/${currentPage.route}`
})
@@ -74,4 +84,21 @@ function decryptJWT(token) {
function getJWTDate(timestamp) {
return new Date(timestamp * 1000);
}
+/**
+ * 检查并存储授权信息
+ * @param res 响应对象
+ */
+const checkAndStoreAuthentication = (res) => {
+ // 读取响应报文头 token 信息
+ let token = res.header['access-token'];
+ let refreshToken = res.header['x-access-token'];
+ // 判断是否是无效 token
+ if (token === "invalid_token") {
+ stroe.dispatch('clearToken')
+ }
+ // 判断是否存在刷新 token,如果存在则存储在本地
+ else if (refreshToken && token && token !== "invalid_token") {
+ stroe.dispatch('setToken',{token,refreshToken})
+ }
+}
export default http;
\ No newline at end of file
diff --git a/monitorMobile/pages.json b/monitorMobile/pages.json
index 6c21822..40f9f7d 100644
--- a/monitorMobile/pages.json
+++ b/monitorMobile/pages.json
@@ -57,7 +57,8 @@
{
"path": "pages/work/returnBed/index",
"style": {
- "navigationBarTitleText": "归寝"
+ "navigationBarTitleText": "归寝",
+ "enablePullDownRefresh": true
}
},
{
@@ -71,7 +72,8 @@
{
"path": "pages/work/passengerFlow/index",
"style": {
- "navigationBarTitleText": "客流"
+ "navigationBarTitleText": "客流",
+ "enablePullDownRefresh": true
}
},
{
@@ -85,7 +87,8 @@
{
"path": "pages/work/rollCall/index",
"style": {
- "navigationBarTitleText": "点名"
+ "navigationBarTitleText": "点名",
+ "enablePullDownRefresh": true
}
},
{
diff --git a/monitorMobile/pages/login.vue b/monitorMobile/pages/login.vue
index c254dfa..6b7c961 100644
--- a/monitorMobile/pages/login.vue
+++ b/monitorMobile/pages/login.vue
@@ -89,6 +89,7 @@
let data = res.data
this.$store.dispatch('setToken',{token:data.token})
this.$store.dispatch('getUserInfo')
+ this.$store.dispatch('getAllOptions')
this.NAV_TO('/')
}).finally(() => {
this.isLoading = false
diff --git a/monitorMobile/pages/my/index.vue b/monitorMobile/pages/my/index.vue
index 669da38..67c34ff 100644
--- a/monitorMobile/pages/my/index.vue
+++ b/monitorMobile/pages/my/index.vue
@@ -125,7 +125,7 @@
},
loginOut() {
this.CONFIRM('您是否确认退出登录?').then(()=>{
- this.$store.dispatch('clearToken')
+ this.CLEAR_STORAGE()
this.JUMP_TO('/pages/login')
})
}
diff --git a/monitorMobile/pages/work/passengerFlow/index.vue b/monitorMobile/pages/work/passengerFlow/index.vue
index 8638b67..a6b0524 100644
--- a/monitorMobile/pages/work/passengerFlow/index.vue
+++ b/monitorMobile/pages/work/passengerFlow/index.vue
@@ -37,7 +37,6 @@
-