鉴权相关配置
This commit is contained in:
parent
8cfd9d5df6
commit
d3a0651fb7
7
App.vue
7
App.vue
@ -1,6 +1,7 @@
|
|||||||
<script>
|
<script>
|
||||||
import config from '@/config'
|
import config from '@/config'
|
||||||
import request from '@/utils/request';
|
import request from '@/utils/request';
|
||||||
|
import store from '@/store'
|
||||||
export default {
|
export default {
|
||||||
onLaunch: function() {
|
onLaunch: function() {
|
||||||
console.log('app lunch');
|
console.log('app lunch');
|
||||||
@ -81,6 +82,12 @@
|
|||||||
|
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
// 判断本地是否有 token,有的话就去获取权限
|
||||||
|
if (store.state.user.token) {
|
||||||
|
store.dispatch('GetInfo').catch(err => {
|
||||||
|
console.error('获取用户信息失败', err)
|
||||||
|
})
|
||||||
|
}
|
||||||
},
|
},
|
||||||
onShow: function() {
|
onShow: function() {
|
||||||
console.log('App Show')
|
console.log('App Show')
|
||||||
|
126
api/login.js
126
api/login.js
@ -2,90 +2,94 @@ import request from '@/utils/request'
|
|||||||
|
|
||||||
// 登录方法
|
// 登录方法
|
||||||
export function login(username, password, code, uuid) {
|
export function login(username, password, code, uuid) {
|
||||||
const data = {
|
const data = {
|
||||||
username,
|
username,
|
||||||
password,
|
password,
|
||||||
code,
|
code,
|
||||||
uuid
|
uuid
|
||||||
}
|
}
|
||||||
return request({
|
return request({
|
||||||
'url': '/rescue/login',
|
'url': '/rescue/login',
|
||||||
headers: {
|
headers: {
|
||||||
isToken: false
|
isToken: false
|
||||||
},
|
},
|
||||||
'method': 'post',
|
'method': 'post',
|
||||||
'data': data
|
'data': data
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
// 微信登录
|
// 微信登录
|
||||||
export function wechatLogin(data) {
|
export function wechatLogin(data) {
|
||||||
return request({
|
return request({
|
||||||
'url': '/weChat/wechatLogin',
|
'url': '/weChat/wechatLogin',
|
||||||
'method': 'post',
|
'method': 'post',
|
||||||
'data':data
|
'data': data
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
// 获取用户详细信息
|
// 获取用户详细信息
|
||||||
export function getInfo() {
|
export function getInfo() {
|
||||||
return request({
|
// return request({
|
||||||
'url': '/rescue/getInfo',
|
// 'url': '/rescue/getInfo',
|
||||||
'method': 'get'
|
// 'method': 'get'
|
||||||
})
|
// })
|
||||||
|
return request({
|
||||||
|
'url': '/admin-api/system/auth/get-permission-info',
|
||||||
|
'method': 'get'
|
||||||
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
// 退出方法
|
// 退出方法
|
||||||
export function logout() {
|
export function logout() {
|
||||||
return request({
|
return request({
|
||||||
'url': '/rescue/logout',
|
'url': '/rescue/logout',
|
||||||
'method': 'post'
|
'method': 'post'
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
// 获取验证码
|
// 获取验证码
|
||||||
export function getCodeImg() {
|
export function getCodeImg() {
|
||||||
return request({
|
return request({
|
||||||
'url': '/rescue/captchaImage',
|
'url': '/rescue/captchaImage',
|
||||||
headers: {
|
headers: {
|
||||||
isToken: false,
|
isToken: false,
|
||||||
},
|
},
|
||||||
method: 'get',
|
method: 'get',
|
||||||
timeout: 20000
|
timeout: 20000
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// 获取验证码
|
// 获取验证码
|
||||||
export function loginApp(data) {
|
export function loginApp(data) {
|
||||||
return request({
|
return request({
|
||||||
'url': '/rescue/loginQx',
|
'url': '/rescue/loginQx',
|
||||||
headers: {
|
headers: {
|
||||||
isToken: false
|
isToken: false
|
||||||
},
|
},
|
||||||
method: 'post',
|
method: 'post',
|
||||||
timeout: 20000,
|
timeout: 20000,
|
||||||
data
|
data
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
export function loginAppuserName(data) {
|
export function loginAppuserName(data) {
|
||||||
return request({
|
return request({
|
||||||
'url': '/userClient/weChat/login',
|
'url': '/userClient/weChat/login',
|
||||||
headers: {
|
headers: {
|
||||||
isToken: false
|
isToken: false
|
||||||
},
|
},
|
||||||
method: 'post',
|
method: 'post',
|
||||||
timeout: 20000,
|
timeout: 20000,
|
||||||
data
|
data
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
// 使用手机号查询所在的租户获得租户编号
|
// 使用手机号查询所在的租户获得租户编号
|
||||||
export function getTenantIdByPhone(phone) {
|
export function getTenantIdByPhone(phone) {
|
||||||
return request({
|
return request({
|
||||||
url: '/app-api/system/user/getListByPhone',
|
url: '/app-api/system/user/getListByPhone',
|
||||||
method: 'get',
|
method: 'get',
|
||||||
params: {
|
params: {
|
||||||
phone
|
phone
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
}
|
}
|
54
main.js
54
main.js
@ -8,57 +8,61 @@ Vue.prototype.$baseImageUrl = baseImageUrl;
|
|||||||
Vue.use(uView);
|
Vue.use(uView);
|
||||||
// 如此配置即可
|
// 如此配置即可
|
||||||
import {
|
import {
|
||||||
tabBarconnect,
|
tabBarconnect,
|
||||||
closeMsgSocket,
|
closeMsgSocket,
|
||||||
sendMsg
|
sendMsg
|
||||||
} from '@/utils/tebBarSocket'
|
} from '@/utils/tebBarSocket'
|
||||||
import {
|
import {
|
||||||
getStrData
|
getStrData
|
||||||
} from '@/utils/auth'
|
} from '@/utils/auth'
|
||||||
let msgTimer;
|
let msgTimer;
|
||||||
let msgSocket;
|
let msgSocket;
|
||||||
export function startMsgSocket(tenantId,userId) {
|
export function startMsgSocket(tenantId, userId) {
|
||||||
msgSocket = null
|
msgSocket = null
|
||||||
msgSocket = tabBarconnect(tenantId,userId);
|
msgSocket = tabBarconnect(tenantId, userId);
|
||||||
if (!msgTimer && getStrData('userId')) {
|
if (!msgTimer && getStrData('userId')) {
|
||||||
msgTimer = setInterval(() => {
|
msgTimer = setInterval(() => {
|
||||||
sendMsg(msgSocket)
|
sendMsg(msgSocket)
|
||||||
}, 10000);
|
}, 10000);
|
||||||
}
|
}
|
||||||
Vue.prototype.$msgSocket = msgSocket
|
Vue.prototype.$msgSocket = msgSocket
|
||||||
}
|
}
|
||||||
Vue.prototype.$startMsgSocket = startMsgSocket; //userid
|
Vue.prototype.$startMsgSocket = startMsgSocket; //userid
|
||||||
export function tabBarcloseSocket() {
|
export function tabBarcloseSocket() {
|
||||||
closeMsgSocket;
|
closeMsgSocket;
|
||||||
}
|
}
|
||||||
export function getclearInterval() {
|
export function getclearInterval() {
|
||||||
console.log('执行关闭请求');
|
console.log('执行关闭请求');
|
||||||
clearInterval(msgTimer);
|
clearInterval(msgTimer);
|
||||||
msgTimer = undefined;
|
msgTimer = undefined;
|
||||||
|
|
||||||
}
|
}
|
||||||
Vue.prototype.$getclearInterval = getclearInterval;
|
Vue.prototype.$getclearInterval = getclearInterval;
|
||||||
// #ifndef VUE3
|
// #ifndef VUE3
|
||||||
import Vue from 'vue'
|
import Vue from 'vue'
|
||||||
|
import store from './store'
|
||||||
import './uni.promisify.adaptor'
|
import './uni.promisify.adaptor'
|
||||||
import {
|
import {
|
||||||
request
|
request
|
||||||
} from "@/utils/request.js"
|
} from "@/utils/request.js"
|
||||||
Vue.prototype.$request = request
|
Vue.prototype.$request = request
|
||||||
Vue.config.productionTip = false
|
Vue.config.productionTip = false
|
||||||
App.mpType = 'app'
|
App.mpType = 'app'
|
||||||
const app = new Vue({
|
const app = new Vue({
|
||||||
...App
|
store,
|
||||||
|
...App
|
||||||
})
|
})
|
||||||
app.$mount()
|
app.$mount()
|
||||||
// #endif
|
// #endif
|
||||||
|
|
||||||
// #ifdef VUE3
|
// #ifdef VUE3
|
||||||
import { createSSRApp } from 'vue'
|
import {
|
||||||
|
createSSRApp
|
||||||
|
} from 'vue'
|
||||||
export function createApp() {
|
export function createApp() {
|
||||||
const app = createSSRApp(App)
|
const app = createSSRApp(App)
|
||||||
return {
|
return {
|
||||||
app
|
app
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// #endif
|
// #endif
|
@ -23,6 +23,11 @@
|
|||||||
getJSONData,
|
getJSONData,
|
||||||
} from '@/utils/auth'
|
} from '@/utils/auth'
|
||||||
import tabBarVue from "@/components/tabBar/tabBar.vue";
|
import tabBarVue from "@/components/tabBar/tabBar.vue";
|
||||||
|
import {
|
||||||
|
checkPermi,
|
||||||
|
checkRole
|
||||||
|
} from "@/utils/permission"; // 权限判断函数
|
||||||
|
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
components: {
|
components: {
|
||||||
@ -65,11 +70,14 @@
|
|||||||
});
|
});
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
if (this.checkRole(['tenant_admin'])) {
|
||||||
|
console.log('哈哈哈哈哈');
|
||||||
|
}
|
||||||
|
if (this.checkPermi(['system:user:add', 'system:user:edit'])) {
|
||||||
|
console.log('哈哈哈哈哈');
|
||||||
|
}
|
||||||
|
|
||||||
this.customInfo = getUserInfo();
|
if (this.checkRole(['tenant_admin', 'weixiu'])) {
|
||||||
console.log('customInfo', this.customInfo);
|
|
||||||
|
|
||||||
if (this.customInfo.roleCodes.includes('weixiu') || this.customInfo.roleCodes.includes('tenant_admin')) {
|
|
||||||
this.filteredList = this.menuList;
|
this.filteredList = this.menuList;
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
@ -77,6 +85,8 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
|
checkPermi,
|
||||||
|
checkRole,
|
||||||
goManage(id) {
|
goManage(id) {
|
||||||
const routes = {
|
const routes = {
|
||||||
1: '/pages-internal/staffManagement/NewstaffManagement',
|
1: '/pages-internal/staffManagement/NewstaffManagement',
|
||||||
|
@ -24,8 +24,8 @@
|
|||||||
<text style="color: red;">*</text>
|
<text style="color: red;">*</text>
|
||||||
汇报内容
|
汇报内容
|
||||||
</view>
|
</view>
|
||||||
<u--textarea v-if="type != 'look'" v-model="report.reportContent" placeholder="请输入内容"></u--textarea>
|
<!-- <u--textarea v-if="type != 'look'" v-model="report.reportContent" placeholder="请输入内容"></u--textarea> -->
|
||||||
<textarea v-else v-model="report.reportContent" placeholder="请输入内容" disabled></textarea>
|
<textarea auto-height v-model="report.reportContent" placeholder="请输入内容" disabled></textarea>
|
||||||
<view class="x_"></view>
|
<view class="x_"></view>
|
||||||
<view class="d_b" @click="handleUpload" v-if="type != 'look'">
|
<view class="d_b" @click="handleUpload" v-if="type != 'look'">
|
||||||
<view class="">附件</view>
|
<view class="">附件</view>
|
||||||
|
@ -22,9 +22,9 @@
|
|||||||
<view class="inputs" v-if="activeid == 0 || activeid == 2 ">
|
<view class="inputs" v-if="activeid == 0 || activeid == 2 ">
|
||||||
<input type="password" v-model="wrod" placeholder="请输入密码">
|
<input type="password" v-model="wrod" placeholder="请输入密码">
|
||||||
</view>
|
</view>
|
||||||
<!-- <view class="wjworb" v-if="activeid == 0 || activeid == 2" @click="goforgot()">-->
|
<!-- <view class="wjworb" v-if="activeid == 0 || activeid == 2" @click="goforgot()">-->
|
||||||
<!-- <view class="">忘记密码</view>-->
|
<!-- <view class="">忘记密码</view>-->
|
||||||
<!-- </view>-->
|
<!-- </view>-->
|
||||||
</view>
|
</view>
|
||||||
<view class="dl" @click="getlogin()">
|
<view class="dl" @click="getlogin()">
|
||||||
<text>登 录</text>
|
<text>登 录</text>
|
||||||
@ -48,28 +48,28 @@
|
|||||||
loginApp
|
loginApp
|
||||||
} from '@/api/login';
|
} from '@/api/login';
|
||||||
import {
|
import {
|
||||||
getToken,
|
getToken,
|
||||||
getUserInfo,
|
getUserInfo,
|
||||||
setToken,
|
setToken,
|
||||||
setTenantId,
|
setTenantId,
|
||||||
getTenantId,
|
getTenantId,
|
||||||
setUserInfo,
|
setUserInfo,
|
||||||
setJSONData,
|
setJSONData,
|
||||||
setStrData
|
setStrData
|
||||||
} from '@/utils/auth'
|
} from '@/utils/auth'
|
||||||
import {
|
import {
|
||||||
login,
|
login,
|
||||||
getInfo,
|
getInfo,
|
||||||
getTenantIdByPhone
|
getTenantIdByPhone
|
||||||
} from '@/api/login'
|
} from '@/api/login'
|
||||||
let innerAudioContext ='';
|
let innerAudioContext = '';
|
||||||
export default {
|
export default {
|
||||||
data() {
|
data() {
|
||||||
return {
|
return {
|
||||||
// 是否正在播放
|
// 是否正在播放
|
||||||
ifPlay:false,
|
ifPlay: false,
|
||||||
//系统标识
|
//系统标识
|
||||||
sysCode:"weixiu",
|
sysCode: "weixiu",
|
||||||
phoneNumber: "",
|
phoneNumber: "",
|
||||||
baseUrl: this.$baseUrl,
|
baseUrl: this.$baseUrl,
|
||||||
isButtonDisabled: false,
|
isButtonDisabled: false,
|
||||||
@ -98,22 +98,22 @@
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
mounted() {},
|
mounted() {},
|
||||||
onShow(){
|
onShow() {
|
||||||
if (getToken()) {
|
if (getToken()) {
|
||||||
//判断是否是仓管,仓管需要跳单独的首页
|
//判断是否是仓管,仓管需要跳单独的首页
|
||||||
let userInfo = getUserInfo()
|
let userInfo = getUserInfo()
|
||||||
if (userInfo.roleCodes.includes('repair_warehouse')) {
|
if (userInfo.roleCodes.includes('repair_warehouse')) {
|
||||||
//仓管
|
//仓管
|
||||||
uni.navigateTo({
|
uni.navigateTo({
|
||||||
url: '/pages-warehouse/home/home'
|
url: '/pages-warehouse/home/home'
|
||||||
})
|
})
|
||||||
} else {
|
} else {
|
||||||
uni.navigateTo({
|
uni.navigateTo({
|
||||||
url: '/pages-home/home/home'
|
url: '/pages-home/home/home'
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
wxlogin() {
|
wxlogin() {
|
||||||
uni.login({
|
uni.login({
|
||||||
@ -146,70 +146,71 @@
|
|||||||
})
|
})
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
const loginFun = () => {
|
const loginFun = () => {
|
||||||
let data;
|
let data;
|
||||||
if (this.activeid == 1) {
|
if (this.activeid == 1) {
|
||||||
//验证码
|
//验证码
|
||||||
data = {
|
data = {
|
||||||
phone: this.tel,
|
phone: this.tel,
|
||||||
code: this.yzm,
|
code: this.yzm,
|
||||||
type: 1,
|
type: 1,
|
||||||
sysCode:this.sysCode,
|
sysCode: this.sysCode,
|
||||||
tenantId:getTenantId()
|
tenantId: getTenantId()
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
//密码登录
|
//密码登录
|
||||||
data = {
|
data = {
|
||||||
username: this.tel,
|
username: this.tel,
|
||||||
password: this.wrod,
|
password: this.wrod,
|
||||||
type: 0,
|
type: 0,
|
||||||
sysCode:this.sysCode,
|
sysCode: this.sysCode,
|
||||||
tenantId:getTenantId()
|
tenantId: getTenantId()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
request({
|
request({
|
||||||
url: '/admin-api/company/staff/loginApp',
|
url: '/admin-api/company/staff/loginApp',
|
||||||
method: 'post',
|
method: 'post',
|
||||||
data: data
|
data: data
|
||||||
}).then((res) => {
|
}).then((res) => {
|
||||||
console.log(res)
|
console.log(res)
|
||||||
if (res.code == 200) {
|
if (res.code == 200) {
|
||||||
uni.showToast({
|
uni.showToast({
|
||||||
title: '登录成功',
|
title: '登录成功',
|
||||||
icon: 'none'
|
icon: 'none'
|
||||||
})
|
})
|
||||||
setToken(res.data.loginResult.accessToken)
|
setToken(res.data.loginResult.accessToken)
|
||||||
setUserInfo(res.data.userinfo)
|
setUserInfo(res.data.userinfo)
|
||||||
setStrData("userId",res.data.userinfo.id)
|
setStrData("userId", res.data.userinfo.id)
|
||||||
//查租户下维修企业信息
|
//查租户下维修企业信息
|
||||||
this.getCompanyInfo()
|
this.getCompanyInfo()
|
||||||
this.getNoReadNum()
|
this.getNoReadNum()
|
||||||
if(res.data.userinfo.roleCodes.includes("repair_staff")){
|
this.loginSuccess()
|
||||||
//维修工角色,需要再查一下是否是班组长
|
if (res.data.userinfo.roleCodes.includes("repair_staff")) {
|
||||||
this.getIdLeader()
|
//维修工角色,需要再查一下是否是班组长
|
||||||
}
|
this.getIdLeader()
|
||||||
this.getStaffInfo(res.data.userinfo.id)
|
}
|
||||||
if (res.data.userinfo.roleCodes.includes("repair_warehouse")){
|
this.getStaffInfo(res.data.userinfo.id)
|
||||||
//跳转首页
|
if (res.data.userinfo.roleCodes.includes("repair_warehouse")) {
|
||||||
uni.navigateTo({
|
//跳转首页
|
||||||
url: '/pages-warehouse/home/home'
|
uni.navigateTo({
|
||||||
})
|
url: '/pages-warehouse/home/home'
|
||||||
} else {
|
})
|
||||||
//跳转首页
|
} else {
|
||||||
uni.navigateTo({
|
//跳转首页
|
||||||
url: '/pages-home/home/home'
|
uni.navigateTo({
|
||||||
})
|
url: '/pages-home/home/home'
|
||||||
}
|
})
|
||||||
|
}
|
||||||
|
|
||||||
}else{
|
} else {
|
||||||
uni.showToast({
|
uni.showToast({
|
||||||
title: res.msg,
|
title: res.msg,
|
||||||
icon: 'none'
|
icon: 'none'
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
//查所有可选租户
|
//查所有可选租户
|
||||||
getTenantIdByPhone(this.tel).then(res => {
|
getTenantIdByPhone(this.tel).then(res => {
|
||||||
if (res.code === 200 && res.data && res.data.length > 0) {
|
if (res.code === 200 && res.data && res.data.length > 0) {
|
||||||
uni.showActionSheet({
|
uni.showActionSheet({
|
||||||
@ -223,42 +224,51 @@
|
|||||||
})
|
})
|
||||||
} else {
|
} else {
|
||||||
//没有可选租户
|
//没有可选租户
|
||||||
uni.showToast({
|
uni.showToast({
|
||||||
title: '抱歉,您没有权限登录!',
|
title: '抱歉,您没有权限登录!',
|
||||||
icon: 'none'
|
icon: 'none'
|
||||||
})
|
})
|
||||||
|
}
|
||||||
|
})
|
||||||
|
},
|
||||||
|
// 登录成功后,处理函数
|
||||||
|
loginSuccess(result) {
|
||||||
|
// 设置用户信息
|
||||||
|
this.$store.dispatch('GetInfo').then(res => {
|
||||||
|
|
||||||
|
})
|
||||||
|
},
|
||||||
|
/**
|
||||||
|
* 查员工个人信息
|
||||||
|
*/
|
||||||
|
getStaffInfo(userId) {
|
||||||
|
request({
|
||||||
|
url: '/admin-api/company/staff/getById',
|
||||||
|
method: 'get',
|
||||||
|
params: {
|
||||||
|
id: userId
|
||||||
|
}
|
||||||
|
}).then((res) => {
|
||||||
|
console.log(res)
|
||||||
|
if (res.code == 200) {
|
||||||
|
setJSONData("staffInfo", res.data)
|
||||||
|
}
|
||||||
|
})
|
||||||
|
},
|
||||||
|
/**
|
||||||
|
* 查是否班组长
|
||||||
|
*/
|
||||||
|
getIdLeader() {
|
||||||
|
request({
|
||||||
|
url: '/admin-api/repair/worker/getIfLeader',
|
||||||
|
method: 'get'
|
||||||
|
}).then((res) => {
|
||||||
|
console.log(res)
|
||||||
|
if (res.code == 200) {
|
||||||
|
setStrData("ifLeader", res.data)
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
/**
|
|
||||||
* 查员工个人信息
|
|
||||||
*/
|
|
||||||
getStaffInfo(userId){
|
|
||||||
request({
|
|
||||||
url: '/admin-api/company/staff/getById',
|
|
||||||
method: 'get',
|
|
||||||
params: {id:userId}
|
|
||||||
}).then((res) => {
|
|
||||||
console.log(res)
|
|
||||||
if (res.code == 200) {
|
|
||||||
setJSONData("staffInfo",res.data)
|
|
||||||
}
|
|
||||||
})
|
|
||||||
},
|
|
||||||
/**
|
|
||||||
* 查是否班组长
|
|
||||||
*/
|
|
||||||
getIdLeader(){
|
|
||||||
request({
|
|
||||||
url: '/admin-api/repair/worker/getIfLeader',
|
|
||||||
method: 'get'
|
|
||||||
}).then((res) => {
|
|
||||||
console.log(res)
|
|
||||||
if (res.code == 200) {
|
|
||||||
setStrData("ifLeader",res.data)
|
|
||||||
}
|
|
||||||
})
|
|
||||||
},
|
|
||||||
getxz(index) {
|
getxz(index) {
|
||||||
this.activeid = index
|
this.activeid = index
|
||||||
},
|
},
|
||||||
@ -288,7 +298,7 @@
|
|||||||
}
|
}
|
||||||
const data = {
|
const data = {
|
||||||
phone: this.tel,
|
phone: this.tel,
|
||||||
sysCode:this.sysCode,
|
sysCode: this.sysCode,
|
||||||
}
|
}
|
||||||
request({
|
request({
|
||||||
url: '/app-api/company/staff/loginSmsCode',
|
url: '/app-api/company/staff/loginSmsCode',
|
||||||
@ -297,8 +307,8 @@
|
|||||||
}).then((res) => {
|
}).then((res) => {
|
||||||
console.log('验证码', res);
|
console.log('验证码', res);
|
||||||
if (res.code == 200) {
|
if (res.code == 200) {
|
||||||
this.disableButton(); // 禁用按钮
|
this.disableButton(); // 禁用按钮
|
||||||
this.startCountdown(); // 启动倒计时
|
this.startCountdown(); // 启动倒计时
|
||||||
uni.showToast({
|
uni.showToast({
|
||||||
title: '验证码已发送 请注意查收',
|
title: '验证码已发送 请注意查收',
|
||||||
icon: 'none'
|
icon: 'none'
|
||||||
@ -326,97 +336,100 @@
|
|||||||
}
|
}
|
||||||
}, 1000);
|
}, 1000);
|
||||||
},
|
},
|
||||||
/**
|
/**
|
||||||
* 获取未读消息数量
|
* 获取未读消息数量
|
||||||
* @returns {Promise<void>}
|
* @returns {Promise<void>}
|
||||||
*/
|
*/
|
||||||
async getNoReadNum(){
|
async getNoReadNum() {
|
||||||
await request({
|
await request({
|
||||||
url: "/admin-api/system/notify-message/get-unread-count?systemCode=weixiu",
|
url: "/admin-api/system/notify-message/get-unread-count?systemCode=weixiu",
|
||||||
method: "GET"
|
method: "GET"
|
||||||
}).then((res) => {
|
}).then((res) => {
|
||||||
if(res.code==200 && res.data>0){
|
if (res.code == 200 && res.data > 0) {
|
||||||
this.dianyidain()
|
this.dianyidain()
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
async getCompanyInfo(){
|
async getCompanyInfo() {
|
||||||
await request({
|
await request({
|
||||||
url: "/admin-api/base/company/getCompanyByTenantId",
|
url: "/admin-api/base/company/getCompanyByTenantId",
|
||||||
method: "GET",
|
method: "GET",
|
||||||
params:{tenantId:getTenantId(),systemCode:"weixiu"}
|
params: {
|
||||||
}).then((res) => {
|
tenantId: getTenantId(),
|
||||||
if(res.code==200){
|
systemCode: "weixiu"
|
||||||
setJSONData("companyInfo",res.data)
|
}
|
||||||
console.log(res.data,"企业信息")
|
}).then((res) => {
|
||||||
}
|
if (res.code == 200) {
|
||||||
})
|
setJSONData("companyInfo", res.data)
|
||||||
},
|
console.log(res.data, "企业信息")
|
||||||
dianyidain() {
|
}
|
||||||
if(!this.ifPlay){
|
})
|
||||||
console.log('执行了,dianyidain');
|
},
|
||||||
if(innerAudioContext!=""){
|
dianyidain() {
|
||||||
try {
|
if (!this.ifPlay) {
|
||||||
console.log('调用前先销毁');
|
console.log('执行了,dianyidain');
|
||||||
innerAudioContext.stop();
|
if (innerAudioContext != "") {
|
||||||
innerAudioContext.destroy();
|
try {
|
||||||
innerAudioContext="";
|
console.log('调用前先销毁');
|
||||||
}catch (e){
|
innerAudioContext.stop();
|
||||||
console.log('销毁出错');
|
innerAudioContext.destroy();
|
||||||
}
|
innerAudioContext = "";
|
||||||
}
|
} catch (e) {
|
||||||
innerAudioContext = uni.createInnerAudioContext();
|
console.log('销毁出错');
|
||||||
this.ifPlay=true
|
}
|
||||||
// #ifdef APP-PLUS
|
}
|
||||||
innerAudioContext.src = '../../static/msgV.mp3';
|
innerAudioContext = uni.createInnerAudioContext();
|
||||||
// #endif
|
this.ifPlay = true
|
||||||
// #ifndef APP-PLUS
|
// #ifdef APP-PLUS
|
||||||
innerAudioContext.src = 'https://www.nuoyunr.com/lananRsc/rescue/msgV.mp3';
|
innerAudioContext.src = '../../static/msgV.mp3';
|
||||||
// #endif
|
// #endif
|
||||||
// 设置播放次数和计数器
|
// #ifndef APP-PLUS
|
||||||
const playCount = 4;
|
innerAudioContext.src = 'https://www.nuoyunr.com/lananRsc/rescue/msgV.mp3';
|
||||||
let currentCount = 0;
|
// #endif
|
||||||
// 初次播放
|
// 设置播放次数和计数器
|
||||||
innerAudioContext.play();
|
const playCount = 4;
|
||||||
// 震动
|
let currentCount = 0;
|
||||||
uni.vibrateLong({
|
// 初次播放
|
||||||
success: function () {
|
innerAudioContext.play();
|
||||||
console.log('success');
|
// 震动
|
||||||
}
|
uni.vibrateLong({
|
||||||
});
|
success: function() {
|
||||||
innerAudioContext.onError((err) => {
|
console.log('success');
|
||||||
console.error('播放错误', err);
|
}
|
||||||
this.ifPlay=false
|
});
|
||||||
innerAudioContext.stop();
|
innerAudioContext.onError((err) => {
|
||||||
innerAudioContext.destroy(); // 播放错误后释放实例
|
console.error('播放错误', err);
|
||||||
});
|
this.ifPlay = false
|
||||||
// 监听音频播放结束事件
|
innerAudioContext.stop();
|
||||||
innerAudioContext.onEnded(() => {
|
innerAudioContext.destroy(); // 播放错误后释放实例
|
||||||
// 播放计数加一
|
});
|
||||||
currentCount++;
|
// 监听音频播放结束事件
|
||||||
// 判断是否达到播放次数上限
|
innerAudioContext.onEnded(() => {
|
||||||
if (currentCount < playCount) {
|
// 播放计数加一
|
||||||
// 继续播放
|
currentCount++;
|
||||||
innerAudioContext.play();
|
// 判断是否达到播放次数上限
|
||||||
// 震动
|
if (currentCount < playCount) {
|
||||||
uni.vibrateLong({
|
// 继续播放
|
||||||
success: function () {
|
innerAudioContext.play();
|
||||||
console.log('success');
|
// 震动
|
||||||
}
|
uni.vibrateLong({
|
||||||
});
|
success: function() {
|
||||||
} else {
|
console.log('success');
|
||||||
// 播放完成,可以在这里添加额外的逻辑
|
}
|
||||||
console.log('播放完成');
|
});
|
||||||
this.ifPlay=false
|
} else {
|
||||||
//及时释放资源
|
// 播放完成,可以在这里添加额外的逻辑
|
||||||
innerAudioContext.stop();
|
console.log('播放完成');
|
||||||
innerAudioContext.destroy();
|
this.ifPlay = false
|
||||||
}
|
//及时释放资源
|
||||||
});
|
innerAudioContext.stop();
|
||||||
}else{
|
innerAudioContext.destroy();
|
||||||
console.log('正在播放音频,拒绝播放请求');
|
}
|
||||||
}
|
});
|
||||||
},
|
} else {
|
||||||
|
console.log('正在播放音频,拒绝播放请求');
|
||||||
|
}
|
||||||
|
},
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
@ -501,11 +514,12 @@
|
|||||||
border-bottom: 2px solid #E8E8E8;
|
border-bottom: 2px solid #E8E8E8;
|
||||||
margin-top: 20px;
|
margin-top: 20px;
|
||||||
}
|
}
|
||||||
.inputs input{
|
|
||||||
width: 100%;
|
|
||||||
}
|
|
||||||
|
|
||||||
.wjworb {
|
.inputs input {
|
||||||
|
width: 100%;
|
||||||
|
}
|
||||||
|
|
||||||
|
.wjworb {
|
||||||
margin-top: 5px;
|
margin-top: 5px;
|
||||||
width: 100%;
|
width: 100%;
|
||||||
display: flex;
|
display: flex;
|
||||||
@ -639,4 +653,4 @@
|
|||||||
border: 1px solid #0078FF;
|
border: 1px solid #0078FF;
|
||||||
color: white;
|
color: white;
|
||||||
}
|
}
|
||||||
</style>
|
</style>
|
@ -1,98 +1,118 @@
|
|||||||
import config from '@/config'
|
import config from '@/config'
|
||||||
import storage from '@/utils/storage'
|
import storage from '@/utils/storage'
|
||||||
import constant from '@/utils/constant'
|
import constant from '@/utils/constant'
|
||||||
import { login, logout, getInfo } from '@/api/login'
|
import {
|
||||||
import { getToken, setToken, removeToken } from '@/utils/auth'
|
login,
|
||||||
|
logout,
|
||||||
|
getInfo
|
||||||
|
} from '@/api/login'
|
||||||
|
import {
|
||||||
|
getToken,
|
||||||
|
setToken,
|
||||||
|
removeToken
|
||||||
|
} from '@/utils/auth'
|
||||||
|
|
||||||
const baseUrl = config.baseUrl
|
const baseUrl = config.baseUrl
|
||||||
|
|
||||||
const user = {
|
const user = {
|
||||||
state: {
|
state: {
|
||||||
token: getToken(),
|
token: getToken(),
|
||||||
name: storage.get(constant.name),
|
name: storage.get(constant.name),
|
||||||
avatar: storage.get(constant.avatar),
|
avatar: storage.get(constant.avatar),
|
||||||
roles: storage.get(constant.roles),
|
roles: storage.get(constant.roles),
|
||||||
permissions: storage.get(constant.permissions)
|
permissions: storage.get(constant.permissions)
|
||||||
},
|
},
|
||||||
|
|
||||||
mutations: {
|
mutations: {
|
||||||
SET_TOKEN: (state, token) => {
|
SET_TOKEN: (state, token) => {
|
||||||
state.token = token
|
state.token = token
|
||||||
},
|
},
|
||||||
SET_NAME: (state, name) => {
|
SET_NAME: (state, name) => {
|
||||||
state.name = name
|
state.name = name
|
||||||
storage.set(constant.name, name)
|
storage.set(constant.name, name)
|
||||||
},
|
},
|
||||||
SET_AVATAR: (state, avatar) => {
|
SET_AVATAR: (state, avatar) => {
|
||||||
state.avatar = avatar
|
state.avatar = avatar
|
||||||
storage.set(constant.avatar, avatar)
|
storage.set(constant.avatar, avatar)
|
||||||
},
|
},
|
||||||
SET_ROLES: (state, roles) => {
|
SET_ROLES: (state, roles) => {
|
||||||
state.roles = roles
|
state.roles = roles
|
||||||
storage.set(constant.roles, roles)
|
storage.set(constant.roles, roles)
|
||||||
},
|
},
|
||||||
SET_PERMISSIONS: (state, permissions) => {
|
SET_PERMISSIONS: (state, permissions) => {
|
||||||
state.permissions = permissions
|
state.permissions = permissions
|
||||||
storage.set(constant.permissions, permissions)
|
storage.set(constant.permissions, permissions)
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
actions: {
|
actions: {
|
||||||
// 登录
|
// 登录
|
||||||
Login({ commit }, userInfo) {
|
Login({
|
||||||
const username = userInfo.username.trim()
|
commit
|
||||||
const password = userInfo.password
|
}, userInfo) {
|
||||||
const code = userInfo.code
|
const username = userInfo.username.trim()
|
||||||
const uuid = userInfo.uuid
|
const password = userInfo.password
|
||||||
return new Promise((resolve, reject) => {
|
const code = userInfo.code
|
||||||
login(username, password, code, uuid).then(res => {
|
const uuid = userInfo.uuid
|
||||||
setToken(res.token)
|
return new Promise((resolve, reject) => {
|
||||||
commit('SET_TOKEN', res.token)
|
login(username, password, code, uuid).then(res => {
|
||||||
resolve()
|
setToken(res.token)
|
||||||
}).catch(error => {
|
commit('SET_TOKEN', res.token)
|
||||||
reject(error)
|
resolve()
|
||||||
})
|
}).catch(error => {
|
||||||
})
|
reject(error)
|
||||||
},
|
})
|
||||||
|
})
|
||||||
|
},
|
||||||
|
|
||||||
// 获取用户信息
|
// 获取用户信息
|
||||||
GetInfo({ commit, state }) {
|
GetInfo({
|
||||||
return new Promise((resolve, reject) => {
|
commit,
|
||||||
getInfo().then(res => {
|
state
|
||||||
const user = res.user
|
}) {
|
||||||
const avatar = (user == null || user.avatar == "" || user.avatar == null) ? require("@/static/images/profile.jpg") : baseUrl + user.avatar
|
return new Promise((resolve, reject) => {
|
||||||
const username = (user == null || user.userName == "" || user.userName == null) ? "" : user.userName
|
commit('SET_ROLES', [])
|
||||||
if (res.roles && res.roles.length > 0) {
|
commit('SET_PERMISSIONS', [])
|
||||||
commit('SET_ROLES', res.roles)
|
getInfo().then(res => {
|
||||||
commit('SET_PERMISSIONS', res.permissions)
|
const user = res.data.user
|
||||||
} else {
|
const avatar = (user == null || user.avatar == "" || user.avatar == null) ?
|
||||||
commit('SET_ROLES', ['ROLE_DEFAULT'])
|
require("@/static/images/yh.png") : baseUrl + user.avatar
|
||||||
}
|
const username = (user == null || user.userName == "" || user.userName ==
|
||||||
commit('SET_NAME', username)
|
null) ? "" : user.userName
|
||||||
commit('SET_AVATAR', avatar)
|
if (res.data.roles && res.data.roles.length > 0) {
|
||||||
resolve(res)
|
commit('SET_ROLES', res.data.roles)
|
||||||
}).catch(error => {
|
commit('SET_PERMISSIONS', res.data.permissions)
|
||||||
reject(error)
|
} else {
|
||||||
})
|
commit('SET_ROLES', ['ROLE_DEFAULT'])
|
||||||
})
|
}
|
||||||
},
|
commit('SET_NAME', username)
|
||||||
|
commit('SET_AVATAR', avatar)
|
||||||
|
resolve(res)
|
||||||
|
}).catch(error => {
|
||||||
|
reject(error)
|
||||||
|
})
|
||||||
|
})
|
||||||
|
},
|
||||||
|
|
||||||
// 退出系统
|
// 退出系统
|
||||||
LogOut({ commit, state }) {
|
LogOut({
|
||||||
return new Promise((resolve, reject) => {
|
commit,
|
||||||
logout(state.token).then(() => {
|
state
|
||||||
commit('SET_TOKEN', '')
|
}) {
|
||||||
commit('SET_ROLES', [])
|
return new Promise((resolve, reject) => {
|
||||||
commit('SET_PERMISSIONS', [])
|
logout(state.token).then(() => {
|
||||||
removeToken()
|
commit('SET_TOKEN', '')
|
||||||
storage.clean()
|
commit('SET_ROLES', [])
|
||||||
resolve()
|
commit('SET_PERMISSIONS', [])
|
||||||
}).catch(error => {
|
removeToken()
|
||||||
reject(error)
|
storage.clean()
|
||||||
})
|
resolve()
|
||||||
})
|
}).catch(error => {
|
||||||
}
|
reject(error)
|
||||||
}
|
})
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export default user
|
export default user
|
@ -34,6 +34,7 @@ export function checkPermi(value) {
|
|||||||
export function checkRole(value) {
|
export function checkRole(value) {
|
||||||
if (value && value instanceof Array && value.length > 0) {
|
if (value && value instanceof Array && value.length > 0) {
|
||||||
const roles = store.getters && store.getters.roles
|
const roles = store.getters && store.getters.roles
|
||||||
|
console.log('拥有角色:', roles);
|
||||||
const permissionRoles = value
|
const permissionRoles = value
|
||||||
const super_admin = "admin"
|
const super_admin = "admin"
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user