鉴权相关配置
This commit is contained in:
parent
8cfd9d5df6
commit
d3a0651fb7
7
App.vue
7
App.vue
@ -1,6 +1,7 @@
|
||||
<script>
|
||||
import config from '@/config'
|
||||
import request from '@/utils/request';
|
||||
import store from '@/store'
|
||||
export default {
|
||||
onLaunch: function() {
|
||||
console.log('app lunch');
|
||||
@ -81,6 +82,12 @@
|
||||
|
||||
}
|
||||
})
|
||||
// 判断本地是否有 token,有的话就去获取权限
|
||||
if (store.state.user.token) {
|
||||
store.dispatch('GetInfo').catch(err => {
|
||||
console.error('获取用户信息失败', err)
|
||||
})
|
||||
}
|
||||
},
|
||||
onShow: function() {
|
||||
console.log('App Show')
|
||||
|
@ -23,13 +23,17 @@ export function wechatLogin(data) {
|
||||
return request({
|
||||
'url': '/weChat/wechatLogin',
|
||||
'method': 'post',
|
||||
'data':data
|
||||
'data': data
|
||||
})
|
||||
}
|
||||
// 获取用户详细信息
|
||||
export function getInfo() {
|
||||
// return request({
|
||||
// 'url': '/rescue/getInfo',
|
||||
// 'method': 'get'
|
||||
// })
|
||||
return request({
|
||||
'url': '/rescue/getInfo',
|
||||
'url': '/admin-api/system/auth/get-permission-info',
|
||||
'method': 'get'
|
||||
})
|
||||
}
|
||||
|
10
main.js
10
main.js
@ -17,9 +17,9 @@ import {
|
||||
} from '@/utils/auth'
|
||||
let msgTimer;
|
||||
let msgSocket;
|
||||
export function startMsgSocket(tenantId,userId) {
|
||||
export function startMsgSocket(tenantId, userId) {
|
||||
msgSocket = null
|
||||
msgSocket = tabBarconnect(tenantId,userId);
|
||||
msgSocket = tabBarconnect(tenantId, userId);
|
||||
if (!msgTimer && getStrData('userId')) {
|
||||
msgTimer = setInterval(() => {
|
||||
sendMsg(msgSocket)
|
||||
@ -40,6 +40,7 @@ export function getclearInterval() {
|
||||
Vue.prototype.$getclearInterval = getclearInterval;
|
||||
// #ifndef VUE3
|
||||
import Vue from 'vue'
|
||||
import store from './store'
|
||||
import './uni.promisify.adaptor'
|
||||
import {
|
||||
request
|
||||
@ -48,13 +49,16 @@ Vue.prototype.$request = request
|
||||
Vue.config.productionTip = false
|
||||
App.mpType = 'app'
|
||||
const app = new Vue({
|
||||
store,
|
||||
...App
|
||||
})
|
||||
app.$mount()
|
||||
// #endif
|
||||
|
||||
// #ifdef VUE3
|
||||
import { createSSRApp } from 'vue'
|
||||
import {
|
||||
createSSRApp
|
||||
} from 'vue'
|
||||
export function createApp() {
|
||||
const app = createSSRApp(App)
|
||||
return {
|
||||
|
@ -23,6 +23,11 @@
|
||||
getJSONData,
|
||||
} from '@/utils/auth'
|
||||
import tabBarVue from "@/components/tabBar/tabBar.vue";
|
||||
import {
|
||||
checkPermi,
|
||||
checkRole
|
||||
} from "@/utils/permission"; // 权限判断函数
|
||||
|
||||
|
||||
export default {
|
||||
components: {
|
||||
@ -65,11 +70,14 @@
|
||||
});
|
||||
return;
|
||||
}
|
||||
if (this.checkRole(['tenant_admin'])) {
|
||||
console.log('哈哈哈哈哈');
|
||||
}
|
||||
if (this.checkPermi(['system:user:add', 'system:user:edit'])) {
|
||||
console.log('哈哈哈哈哈');
|
||||
}
|
||||
|
||||
this.customInfo = getUserInfo();
|
||||
console.log('customInfo', this.customInfo);
|
||||
|
||||
if (this.customInfo.roleCodes.includes('weixiu') || this.customInfo.roleCodes.includes('tenant_admin')) {
|
||||
if (this.checkRole(['tenant_admin', 'weixiu'])) {
|
||||
this.filteredList = this.menuList;
|
||||
|
||||
} else {
|
||||
@ -77,6 +85,8 @@
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
checkPermi,
|
||||
checkRole,
|
||||
goManage(id) {
|
||||
const routes = {
|
||||
1: '/pages-internal/staffManagement/NewstaffManagement',
|
||||
|
@ -24,8 +24,8 @@
|
||||
<text style="color: red;">*</text>
|
||||
汇报内容
|
||||
</view>
|
||||
<u--textarea v-if="type != 'look'" v-model="report.reportContent" placeholder="请输入内容"></u--textarea>
|
||||
<textarea v-else v-model="report.reportContent" placeholder="请输入内容" disabled></textarea>
|
||||
<!-- <u--textarea v-if="type != 'look'" v-model="report.reportContent" placeholder="请输入内容"></u--textarea> -->
|
||||
<textarea auto-height v-model="report.reportContent" placeholder="请输入内容" disabled></textarea>
|
||||
<view class="x_"></view>
|
||||
<view class="d_b" @click="handleUpload" v-if="type != 'look'">
|
||||
<view class="">附件</view>
|
||||
|
@ -22,9 +22,9 @@
|
||||
<view class="inputs" v-if="activeid == 0 || activeid == 2 ">
|
||||
<input type="password" v-model="wrod" placeholder="请输入密码">
|
||||
</view>
|
||||
<!-- <view class="wjworb" v-if="activeid == 0 || activeid == 2" @click="goforgot()">-->
|
||||
<!-- <view class="">忘记密码</view>-->
|
||||
<!-- </view>-->
|
||||
<!-- <view class="wjworb" v-if="activeid == 0 || activeid == 2" @click="goforgot()">-->
|
||||
<!-- <view class="">忘记密码</view>-->
|
||||
<!-- </view>-->
|
||||
</view>
|
||||
<view class="dl" @click="getlogin()">
|
||||
<text>登 录</text>
|
||||
@ -62,14 +62,14 @@
|
||||
getInfo,
|
||||
getTenantIdByPhone
|
||||
} from '@/api/login'
|
||||
let innerAudioContext ='';
|
||||
let innerAudioContext = '';
|
||||
export default {
|
||||
data() {
|
||||
return {
|
||||
// 是否正在播放
|
||||
ifPlay:false,
|
||||
ifPlay: false,
|
||||
//系统标识
|
||||
sysCode:"weixiu",
|
||||
sysCode: "weixiu",
|
||||
phoneNumber: "",
|
||||
baseUrl: this.$baseUrl,
|
||||
isButtonDisabled: false,
|
||||
@ -98,7 +98,7 @@
|
||||
},
|
||||
},
|
||||
mounted() {},
|
||||
onShow(){
|
||||
onShow() {
|
||||
if (getToken()) {
|
||||
//判断是否是仓管,仓管需要跳单独的首页
|
||||
let userInfo = getUserInfo()
|
||||
@ -154,8 +154,8 @@
|
||||
phone: this.tel,
|
||||
code: this.yzm,
|
||||
type: 1,
|
||||
sysCode:this.sysCode,
|
||||
tenantId:getTenantId()
|
||||
sysCode: this.sysCode,
|
||||
tenantId: getTenantId()
|
||||
}
|
||||
} else {
|
||||
//密码登录
|
||||
@ -163,8 +163,8 @@
|
||||
username: this.tel,
|
||||
password: this.wrod,
|
||||
type: 0,
|
||||
sysCode:this.sysCode,
|
||||
tenantId:getTenantId()
|
||||
sysCode: this.sysCode,
|
||||
tenantId: getTenantId()
|
||||
}
|
||||
}
|
||||
request({
|
||||
@ -180,16 +180,17 @@
|
||||
})
|
||||
setToken(res.data.loginResult.accessToken)
|
||||
setUserInfo(res.data.userinfo)
|
||||
setStrData("userId",res.data.userinfo.id)
|
||||
setStrData("userId", res.data.userinfo.id)
|
||||
//查租户下维修企业信息
|
||||
this.getCompanyInfo()
|
||||
this.getNoReadNum()
|
||||
if(res.data.userinfo.roleCodes.includes("repair_staff")){
|
||||
this.loginSuccess()
|
||||
if (res.data.userinfo.roleCodes.includes("repair_staff")) {
|
||||
//维修工角色,需要再查一下是否是班组长
|
||||
this.getIdLeader()
|
||||
}
|
||||
this.getStaffInfo(res.data.userinfo.id)
|
||||
if (res.data.userinfo.roleCodes.includes("repair_warehouse")){
|
||||
if (res.data.userinfo.roleCodes.includes("repair_warehouse")) {
|
||||
//跳转首页
|
||||
uni.navigateTo({
|
||||
url: '/pages-warehouse/home/home'
|
||||
@ -201,7 +202,7 @@
|
||||
})
|
||||
}
|
||||
|
||||
}else{
|
||||
} else {
|
||||
uni.showToast({
|
||||
title: res.msg,
|
||||
icon: 'none'
|
||||
@ -230,32 +231,41 @@
|
||||
}
|
||||
})
|
||||
},
|
||||
// 登录成功后,处理函数
|
||||
loginSuccess(result) {
|
||||
// 设置用户信息
|
||||
this.$store.dispatch('GetInfo').then(res => {
|
||||
|
||||
})
|
||||
},
|
||||
/**
|
||||
* 查员工个人信息
|
||||
*/
|
||||
getStaffInfo(userId){
|
||||
getStaffInfo(userId) {
|
||||
request({
|
||||
url: '/admin-api/company/staff/getById',
|
||||
method: 'get',
|
||||
params: {id:userId}
|
||||
params: {
|
||||
id: userId
|
||||
}
|
||||
}).then((res) => {
|
||||
console.log(res)
|
||||
if (res.code == 200) {
|
||||
setJSONData("staffInfo",res.data)
|
||||
setJSONData("staffInfo", res.data)
|
||||
}
|
||||
})
|
||||
},
|
||||
/**
|
||||
* 查是否班组长
|
||||
*/
|
||||
getIdLeader(){
|
||||
getIdLeader() {
|
||||
request({
|
||||
url: '/admin-api/repair/worker/getIfLeader',
|
||||
method: 'get'
|
||||
}).then((res) => {
|
||||
console.log(res)
|
||||
if (res.code == 200) {
|
||||
setStrData("ifLeader",res.data)
|
||||
setStrData("ifLeader", res.data)
|
||||
}
|
||||
})
|
||||
},
|
||||
@ -288,7 +298,7 @@
|
||||
}
|
||||
const data = {
|
||||
phone: this.tel,
|
||||
sysCode:this.sysCode,
|
||||
sysCode: this.sysCode,
|
||||
}
|
||||
request({
|
||||
url: '/app-api/company/staff/loginSmsCode',
|
||||
@ -330,43 +340,46 @@
|
||||
* 获取未读消息数量
|
||||
* @returns {Promise<void>}
|
||||
*/
|
||||
async getNoReadNum(){
|
||||
async getNoReadNum() {
|
||||
await request({
|
||||
url: "/admin-api/system/notify-message/get-unread-count?systemCode=weixiu",
|
||||
method: "GET"
|
||||
}).then((res) => {
|
||||
if(res.code==200 && res.data>0){
|
||||
if (res.code == 200 && res.data > 0) {
|
||||
this.dianyidain()
|
||||
}
|
||||
})
|
||||
},
|
||||
async getCompanyInfo(){
|
||||
async getCompanyInfo() {
|
||||
await request({
|
||||
url: "/admin-api/base/company/getCompanyByTenantId",
|
||||
method: "GET",
|
||||
params:{tenantId:getTenantId(),systemCode:"weixiu"}
|
||||
params: {
|
||||
tenantId: getTenantId(),
|
||||
systemCode: "weixiu"
|
||||
}
|
||||
}).then((res) => {
|
||||
if(res.code==200){
|
||||
setJSONData("companyInfo",res.data)
|
||||
console.log(res.data,"企业信息")
|
||||
if (res.code == 200) {
|
||||
setJSONData("companyInfo", res.data)
|
||||
console.log(res.data, "企业信息")
|
||||
}
|
||||
})
|
||||
},
|
||||
dianyidain() {
|
||||
if(!this.ifPlay){
|
||||
if (!this.ifPlay) {
|
||||
console.log('执行了,dianyidain');
|
||||
if(innerAudioContext!=""){
|
||||
if (innerAudioContext != "") {
|
||||
try {
|
||||
console.log('调用前先销毁');
|
||||
innerAudioContext.stop();
|
||||
innerAudioContext.destroy();
|
||||
innerAudioContext="";
|
||||
}catch (e){
|
||||
innerAudioContext = "";
|
||||
} catch (e) {
|
||||
console.log('销毁出错');
|
||||
}
|
||||
}
|
||||
innerAudioContext = uni.createInnerAudioContext();
|
||||
this.ifPlay=true
|
||||
this.ifPlay = true
|
||||
// #ifdef APP-PLUS
|
||||
innerAudioContext.src = '../../static/msgV.mp3';
|
||||
// #endif
|
||||
@ -380,13 +393,13 @@
|
||||
innerAudioContext.play();
|
||||
// 震动
|
||||
uni.vibrateLong({
|
||||
success: function () {
|
||||
success: function() {
|
||||
console.log('success');
|
||||
}
|
||||
});
|
||||
innerAudioContext.onError((err) => {
|
||||
console.error('播放错误', err);
|
||||
this.ifPlay=false
|
||||
this.ifPlay = false
|
||||
innerAudioContext.stop();
|
||||
innerAudioContext.destroy(); // 播放错误后释放实例
|
||||
});
|
||||
@ -400,20 +413,20 @@
|
||||
innerAudioContext.play();
|
||||
// 震动
|
||||
uni.vibrateLong({
|
||||
success: function () {
|
||||
success: function() {
|
||||
console.log('success');
|
||||
}
|
||||
});
|
||||
} else {
|
||||
// 播放完成,可以在这里添加额外的逻辑
|
||||
console.log('播放完成');
|
||||
this.ifPlay=false
|
||||
this.ifPlay = false
|
||||
//及时释放资源
|
||||
innerAudioContext.stop();
|
||||
innerAudioContext.destroy();
|
||||
}
|
||||
});
|
||||
}else{
|
||||
} else {
|
||||
console.log('正在播放音频,拒绝播放请求');
|
||||
}
|
||||
},
|
||||
@ -501,7 +514,8 @@
|
||||
border-bottom: 2px solid #E8E8E8;
|
||||
margin-top: 20px;
|
||||
}
|
||||
.inputs input{
|
||||
|
||||
.inputs input {
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
|
@ -1,8 +1,16 @@
|
||||
import config from '@/config'
|
||||
import storage from '@/utils/storage'
|
||||
import constant from '@/utils/constant'
|
||||
import { login, logout, getInfo } from '@/api/login'
|
||||
import { getToken, setToken, removeToken } from '@/utils/auth'
|
||||
import {
|
||||
login,
|
||||
logout,
|
||||
getInfo
|
||||
} from '@/api/login'
|
||||
import {
|
||||
getToken,
|
||||
setToken,
|
||||
removeToken
|
||||
} from '@/utils/auth'
|
||||
|
||||
const baseUrl = config.baseUrl
|
||||
|
||||
@ -39,7 +47,9 @@ const user = {
|
||||
|
||||
actions: {
|
||||
// 登录
|
||||
Login({ commit }, userInfo) {
|
||||
Login({
|
||||
commit
|
||||
}, userInfo) {
|
||||
const username = userInfo.username.trim()
|
||||
const password = userInfo.password
|
||||
const code = userInfo.code
|
||||
@ -56,15 +66,22 @@ const user = {
|
||||
},
|
||||
|
||||
// 获取用户信息
|
||||
GetInfo({ commit, state }) {
|
||||
GetInfo({
|
||||
commit,
|
||||
state
|
||||
}) {
|
||||
return new Promise((resolve, reject) => {
|
||||
commit('SET_ROLES', [])
|
||||
commit('SET_PERMISSIONS', [])
|
||||
getInfo().then(res => {
|
||||
const user = res.user
|
||||
const avatar = (user == null || user.avatar == "" || user.avatar == null) ? require("@/static/images/profile.jpg") : baseUrl + user.avatar
|
||||
const username = (user == null || user.userName == "" || user.userName == null) ? "" : user.userName
|
||||
if (res.roles && res.roles.length > 0) {
|
||||
commit('SET_ROLES', res.roles)
|
||||
commit('SET_PERMISSIONS', res.permissions)
|
||||
const user = res.data.user
|
||||
const avatar = (user == null || user.avatar == "" || user.avatar == null) ?
|
||||
require("@/static/images/yh.png") : baseUrl + user.avatar
|
||||
const username = (user == null || user.userName == "" || user.userName ==
|
||||
null) ? "" : user.userName
|
||||
if (res.data.roles && res.data.roles.length > 0) {
|
||||
commit('SET_ROLES', res.data.roles)
|
||||
commit('SET_PERMISSIONS', res.data.permissions)
|
||||
} else {
|
||||
commit('SET_ROLES', ['ROLE_DEFAULT'])
|
||||
}
|
||||
@ -78,7 +95,10 @@ const user = {
|
||||
},
|
||||
|
||||
// 退出系统
|
||||
LogOut({ commit, state }) {
|
||||
LogOut({
|
||||
commit,
|
||||
state
|
||||
}) {
|
||||
return new Promise((resolve, reject) => {
|
||||
logout(state.token).then(() => {
|
||||
commit('SET_TOKEN', '')
|
||||
|
@ -34,6 +34,7 @@ export function checkPermi(value) {
|
||||
export function checkRole(value) {
|
||||
if (value && value instanceof Array && value.length > 0) {
|
||||
const roles = store.getters && store.getters.roles
|
||||
console.log('拥有角色:', roles);
|
||||
const permissionRoles = value
|
||||
const super_admin = "admin"
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user