<template>
|
<view class="container">
|
|
<view class="row bgc-ff mt-20 flex f-d-c a-i-c j-c-c">
|
|
|
<!-- <u-row customStyle="margin-bottom: 10px">
|
<u-col span="6">
|
<view class="demo-layout bg-purple-light">
|
离线/在线:
|
</view>
|
</u-col>
|
<u-col span="6">
|
<u-switch v-model="onLine" asyncChange @change="asyncChange"></u-switch>
|
</u-col>
|
</u-row> -->
|
|
<view class="f-32 mb-20">
|
当前状态 {{onLine?"在线 ":"离线"}}
|
</view>
|
<view class="round" :class="onLine?'bgc-main':' bgc-gray '" @click="asyncChange(!onLine)">
|
{{onLine?"在线 ":"离线"}}
|
</view>
|
|
|
</view>
|
<!-- <view> -->
|
<!-- <role-list :roleData="roleData" :current-id="selectRole.id" @select="select"></role-list> -->
|
<!-- <u-switch v-model="value13" asyncChange @change="asyncChange"></u-switch> -->
|
<!-- </view> -->
|
|
<!-- <footer-btn v-if="roleData.length" text="确定" @click="submit" /> -->
|
|
<u-loading-page :loading="loading"></u-loading-page>
|
</view>
|
</template>
|
|
<script>
|
import {
|
getUser,
|
updateUserInfo
|
} from "@/api/user.js"
|
// import roleList from "@/subPackage/user/components/roleList.vue"
|
// import {
|
// dynamicMenu,
|
// getRoleListByIds,
|
// } from "@/api/system/role.js"
|
export default {
|
components: {
|
// roleList
|
},
|
|
data() {
|
return {
|
onLine: false,
|
userInfo: {},
|
loading: false,
|
}
|
},
|
created() {
|
// this.selectRole = uni.getStorageSync("activeRole")
|
|
},
|
onShow() {
|
this.getUserInfo()
|
},
|
|
methods: {
|
|
asyncChange(e) {
|
uni.showModal({
|
content: e ? '确定是否上线?' : '确定是否下线?',
|
success: (res) => {
|
if (res.confirm) {
|
this.onLine = e
|
if (e) {
|
this.userInfo.status = 2
|
} else {
|
this.userInfo.status = 1
|
}
|
updateUserInfo(this.userInfo).then(res => {
|
console.log("**********userInfo*************", res)
|
let userInfo = uni.getStorageSync("userInfo")
|
userInfo.status = this.userInfo.status
|
uni.setStorageSync("userInfo", userInfo)
|
})
|
}
|
}
|
})
|
},
|
//获取当前角色的所有权限列表
|
getUserInfo() {
|
this.loading = !this.loading
|
getUser(
|
uni.getStorageSync("userInfo").user_id
|
).then(res => {
|
this.userInfo = res.data
|
if (res.data.status && res.data.status == 2) {
|
this.onLine = true
|
} else {
|
this.onLine = false
|
}
|
});
|
this.loading = !this.loading
|
},
|
|
select(item) {
|
this.selectRole = item
|
console.log("当前选中角色", this.selectRole)
|
},
|
|
async submit() {
|
//保存当前激活的角色
|
this.$store.commit("setActiveRole", this.selectRole)
|
// const res = await dynamicMenu(this.selectRole.id)
|
// let data = res.data
|
// const appMenu = data.filter(e => e.name == 'app')[0].children
|
// console.log("菜单:", appMenu)
|
// store.commit("SET_MENU", appMenu)
|
this.$store.dispatch("getMenuList").then(res => {
|
uni.showToast({
|
title: "切换身份成功",
|
icon: "success",
|
duration: 1500,
|
success: () => {
|
uni.$emit("refresh")
|
setTimeout(() => {
|
this.$u.func.globalNavigator(
|
"/pages/home/index",
|
"switchTab")
|
}, 500)
|
}
|
})
|
});
|
|
}
|
}
|
}
|
</script>
|
|
<style lang="scss">
|
page {
|
backgrond-color: #f5f5f5;
|
}
|
|
.row {
|
// padding: 20rpx;
|
// margin: 0 20rpx;
|
// border-radius: 4rpx;
|
padding-top: 200rpx;
|
}
|
|
.container {
|
position: relative;
|
width: 100%;
|
height: 100%;
|
display: flex;
|
flex-direction: column;
|
// background-color: #fff;
|
// background: #F9F9FA;
|
|
|
}
|
|
.cur-btn {
|
width: 100%;
|
padding: 20rpx;
|
position: fixed;
|
bottom: 0;
|
left: 0;
|
box-sizing: border-box;
|
z-index: 10;
|
|
}
|
|
.round {
|
width: 200rpx;
|
height: 200rpx;
|
line-height: 200rpx;
|
border-radius: 50%;
|
|
text-align: center;
|
color: #fff;
|
font-weight: bold;
|
|
}
|
|
.bgc-gray {
|
background: #949494;
|
}
|
</style>
|