diff --git a/monitorMobile/api/user.js b/monitorMobile/api/user.js index f3df701..c7195af 100644 --- a/monitorMobile/api/user.js +++ b/monitorMobile/api/user.js @@ -1,85 +1,9 @@ import http from '@/http/api.js' -// 获取token -export const token = (tenantId, username, password, type) => { +// 登录 +export const login = (data) => { return http.request({ - url: '/api/blade-auth/oauth/token', + url: '/api/sys/auth/b/login', method: 'POST', - header: { - 'Tenant-Id': tenantId - }, - params: { - tenantId, - username, - password, - grant_type: "password", - scope: "all", - type - } - }) -} -export const getTenantId = (params) => { - return http.request({ - url: '/api/blade-auth/oauth/getTenantId', - method: 'get', - params: { - ...params - } - }) -} - -export const refreshToken = (refresh_token, tenantId) => { - return http.request({ - url: '/api/blade-auth/oauth/token', - method: 'post', - header: { - 'Tenant-Id': tenantId - }, - params: { - tenantId, - refresh_token, - grant_type: "refresh_token", - scope: "all", - } - }) -} - -// 获取用户信息 -export const userInfo = () => { - return http.request({ - url: '/api/blade-user/info', - method: 'GET', - }) -} - -// 获取用户信息 -export const getUser = (id) => { - return http.request({ - url: '/api/blade-user/detail', - method: 'GET', - params: { id } - }) -} -/* 修改用户信息 */ -export const updateInfo = (row) => { - return http.request({ - url: '/api/blade-user/update-info', - method: 'post', - data: row - }) -} -// 修改密码 -export const updatePassword = (data) => { - return http.request({ - url: '/api/blade-user/update-password', - method: 'post', - params: data - }) -} -// 修改密码 -export const passwordCheck = (data) => { - return http.request({ - url: '/api/blade-user/passwordCheck', - method: 'post', - params: data + data }) } diff --git a/monitorMobile/common/mixins.vue b/monitorMobile/common/mixins.vue index 6947778..1a5fbe0 100644 --- a/monitorMobile/common/mixins.vue +++ b/monitorMobile/common/mixins.vue @@ -58,6 +58,42 @@ return url + query }, + // 获取一个全局变量 + // key 为键名 + GET_GLOBAL(key) { + return this.$store.state[key] + }, + + // 设置一个全局变量 + // key 为键名 + // val 为值 + SET_GLOBAL(key, val) { + this.$store.commit(key, val) + }, + + // 清空全局变量 + CLEAR_GLOBAL() { + this.$store.commit('clear') + uni.removeStorageSync('token') + }, + // 将数据写入本地缓存 + SET_STORAGE(key, data) { + if (data === null) { + uni.removeStorageSync(key) + } else { + uni.setStorageSync(key, data) + } + }, + + // 获取之前写入本地缓存的数据 + GET_STORAGE(key) { + return uni.getStorageSync(key) + }, + + // 清空本地缓存 + CLEAR_STORAGE() { + uni.clearStorageSync() + }, // 设置页面标题 SET_TITLE(title) { uni.setNavigationBarTitle({ @@ -103,6 +139,10 @@ }); }) }, + // 展示提示框 + // title 为提示文字 + // mask 为是否禁止点击 + // icon 为显示图标,可以改为 'success' TOAST(title){ uni.showToast({ icon: "none", @@ -110,6 +150,10 @@ duration: 2000, }); }, + // 停止展示 toast 提示框 + HIDE_TOAST() { + uni.hideToast() + }, UPLOAD_FILE(filePath){ let that = this // 假设有token值需要在头部需要携带 @@ -179,18 +223,9 @@ data: item, // 要复制的路径 success: function(res) { resolve(true) - // uni.getClipboardData({ - // success: function(data) { - // resolve(true) - // }, - // fail: function(data1) { - // resolve(false) - // } - // }); } }); }) - }, }, } diff --git a/monitorMobile/common/setting.js b/monitorMobile/common/setting.js index 8db6a83..377a1e3 100644 --- a/monitorMobile/common/setting.js +++ b/monitorMobile/common/setting.js @@ -3,7 +3,6 @@ */ // #ifdef H5 let origin = window.location.origin -console.log(window.location.origin) // #endif module.exports = { // 应用名 @@ -26,8 +25,8 @@ module.exports = { // 小程序接口Url // #ifndef H5 // devUrl: 'http://192.168.10.46', - devUrl: 'https://www.bjjyp.org.cn/rider',//开发环境接口Url - prodUrl: `https://www.bjjyp.org.cn/rider`,//线上环境接口Url + devUrl: '',//开发环境接口Url + prodUrl: ``,//线上环境接口Url // prodUrl: 'http://192.168.100.236:1888', // prodUrl: 'http://114.255.136.189:1888', // #endif @@ -50,8 +49,6 @@ module.exports = { // token过期时间 tokenTime: 3000, switchMode: true, // 是否开启部门切换模式 - //本地 - previewUrl: 'http://cp.qjkjedu.com/onlinePreview', - //金隅生产 - // previewUrl: 'https://www.bjjyp.org.cn/preview/onlinePreview', + //文件预览地址 + previewUrl: '', } diff --git a/monitorMobile/http/api.js b/monitorMobile/http/api.js index 8c1a1cc..1f7f810 100644 --- a/monitorMobile/http/api.js +++ b/monitorMobile/http/api.js @@ -12,7 +12,6 @@ import { import Request from '@/utils/luch-request/index.js'; const http = new Request(options); http.interceptors.request.use((config) => { // 可使用async await 做异步操作 - // 假设有token值需要在头部需要携带 let accessToken = uni.getStorageSync('accessToken'); if (accessToken) { @@ -24,29 +23,10 @@ http.interceptors.request.use((config) => { // 可使用async await 做异步操 // #ifndef H5 let url = config.url if (process.env.NODE_ENV == 'development' && !url.startsWith("http")) { - // url = url.substring(url.indexOf('/api') + 4) config.url = url } // #endif - - // 额外参数 - // config.data = config.data || {}; - // config.data.pf = uni.getSystemInfoSync().platform; - // config.data.sys = uni.getSystemInfoSync().system; - - // 演示custom 用处 - // if (config.custom.auth) { - // config.header.token = 'token' - // } - // if (config.custom.loading) { - // uni.showLoading() - // } - /** - /* 演示 - if (!token) { // 如果token不存在,return Promise.reject(config) 会取消本次请求 - return Promise.reject(config) - } - **/ + return config }, config => { // 可使用async await 做异步操作 return Promise.reject(config) @@ -80,7 +60,7 @@ http.interceptors.response.use((response) => { const pages = getCurrentPages() const currentPage = pages[pages.length - 1] uni.redirectTo({ - url: `/pages/login/login?redirect=/${currentPage.route}` + url: `pages/login?redirect=/${currentPage.route}` }) } return Promise.reject(response) diff --git a/monitorMobile/http/config.js b/monitorMobile/http/config.js index 206323d..33be5e9 100644 --- a/monitorMobile/http/config.js +++ b/monitorMobile/http/config.js @@ -44,6 +44,6 @@ var options = { // previewUrl: 'https://www.bjjyp.org.cn/preview/onlinePreview', // previewUrl: 'http://114.255.136.189:6696/onlinePreview', // previewUrl: 'http://192.168.100.236:85/onlinePreview', - previewUrl: 'http://cp.qjkjedu.com/onlinePreview', + previewUrl: '', }; export { options }; diff --git a/monitorMobile/main.js b/monitorMobile/main.js index 587410e..6ca9977 100644 --- a/monitorMobile/main.js +++ b/monitorMobile/main.js @@ -1,12 +1,9 @@ import App from './App' import Vue from 'vue' -import store from '@/store'; import mixins from '@/common/mixins.vue' - Vue.mixin(mixins) // 引入vuex -Vue.prototype.$u = {} const vuexStore = require("@/store/$u.mixin.js"); Vue.mixin(vuexStore); @@ -34,6 +31,7 @@ export function createApp() { } // #endif +// 添加http实例 import http from '@/http/api.js' Vue.prototype.$http = http diff --git a/monitorMobile/pages/login.vue b/monitorMobile/pages/login.vue index 8f5b7ae..56e2e38 100644 --- a/monitorMobile/pages/login.vue +++ b/monitorMobile/pages/login.vue @@ -37,7 +37,9 @@