@@ -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 | |||
}) | |||
} |
@@ -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) | |||
// } | |||
// }); | |||
} | |||
}); | |||
}) | |||
}, | |||
}, | |||
} |
@@ -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: '', | |||
} |
@@ -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) | |||
@@ -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 }; |
@@ -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 | |||
@@ -37,7 +37,9 @@ | |||
</template> | |||
<script> | |||
import {token} from '@/api/user.js' | |||
import { | |||
login | |||
} from '@/api/user.js' | |||
export default { | |||
data() { | |||
return { | |||
@@ -47,13 +49,14 @@ | |||
}, | |||
passType: 'password', | |||
isLoading: false, | |||
redirect:'', | |||
rules: { | |||
account: [{ | |||
required: true, | |||
message: '请输入账号', | |||
trigger: ['blur', 'change'] | |||
}], | |||
pass: [{ | |||
password: [{ | |||
required: true, | |||
message: '请输入密码', | |||
trigger: ['blur', 'change'] | |||
@@ -69,12 +72,22 @@ | |||
} | |||
} | |||
}, | |||
onLoad(e) { | |||
if (e.redirect) this.redirect = redirect | |||
// this.username = '' | |||
// this.password = '' | |||
}, | |||
methods: { | |||
login() { | |||
token() | |||
this.$refs.uForm.validate(valid => { | |||
if (!valid) return | |||
this.$refs.uForm.validate().then(() => { | |||
this.isLoading = true | |||
login(this.form).then(res => { | |||
this.isLoading = false | |||
console.log(res) | |||
}).catch(()=>{ | |||
this.isLoading = false | |||
}) | |||
}) | |||
} | |||
}, | |||
@@ -99,7 +112,7 @@ | |||
} | |||
input[type="password"]::-ms-reveal { | |||
display: none!important; | |||
display: none !important; | |||
} | |||
.logoBox { | |||
@@ -138,8 +151,8 @@ | |||
margin-bottom: 30rpx; | |||
// font-weight: 700; | |||
} | |||
/deep/.u-form-item__body{ | |||
/deep/.u-form-item__body { | |||
padding: 15rpx 0; | |||
} | |||
} |
@@ -15,7 +15,6 @@ module.exports = { | |||
mounted() { | |||
// 将vuex方法挂在到$u中 | |||
// 使用方法为:如果要修改vuex的state中的user.name变量为"史诗" => this.$u.vuex('user.name', '史诗') | |||
// 如果要修改vuex的state的version变量为1.0.1 => this.$u.vue x('version', '1.0.1') | |||
this.$u.vuex = (name, value) => { | |||
this.$store.commit('$uStore', { | |||
name, | |||
@@ -38,13 +38,13 @@ const store = new Vuex.Store({ | |||
// 下面这些值仅为示例,使用过程中请删除 | |||
state: { | |||
// 如果上面从本地获取的lifeData对象下有对应的属性,就赋值给state中对应的变量 | |||
userInfo: lifeData.userInfo ? lifeData.userInfo : { | |||
avatar: '', | |||
nick_name: '游客', | |||
tenant_id: '暂无' | |||
}, | |||
accessToken: lifeData.accessToken ? lifeData.accessToken : '', | |||
isLogin: lifeData.isLogin ? lifeData.isLogin : false, | |||
// userInfo: lifeData.userInfo ? lifeData.userInfo : { | |||
// avatar: '', | |||
// nick_name: '游客', | |||
// tenant_id: '暂无' | |||
// }, | |||
// accessToken: lifeData.accessToken ? lifeData.accessToken : '', | |||
// isLogin: lifeData.isLogin ? lifeData.isLogin : false, | |||
}, | |||
mutations: { | |||
$uStore(state, payload) { | |||
@@ -69,5 +69,5 @@ const store = new Vuex.Store({ | |||
} | |||
} | |||
}) | |||
Vue.prototype.$store = store | |||
export default store |