“yst 4 rokov pred
rodič
commit
baa10fb5f0

+ 9 - 0
pages.json

@@ -53,6 +53,15 @@
             }
             
         }
+        ,{
+            "path" : "pages/role-switching/role-switching",
+            "style" :                                                                                    
+            {
+                "navigationBarTitleText": "角色切换",
+                "enablePullDownRefresh": false
+            }
+            
+        }
     ],
 	"globalStyle": {
 		"navigationStyle": "custom",

+ 292 - 116
pages/home/home.vue

@@ -2,35 +2,55 @@
 	<view class="home-page">
 		<view class="content-info">
 			<view class="top-box">
-				<image class="bgpic" src="/static/images/个人中心背景.png"></image>
+				<image class="bgpic" src="/static/images/pcbg.png"></image>
+				<text class="hosname">{{hospName}}</text>
 			</view>
 			<view class="avatar-box">
-				<image class="avatar" src="/static/images/小哥哥.png"></image>
+				<image class="avatar" src="/static/images/boy-avatar.png"></image>
 			</view>
 			<view class="info-box">
-				<text class="">
-					毛之易
-				</text>
+				<view class="head">
+					<text class="name">
+						{{name}}
+					</text>
+					<!-- <image class="gender" src="/static/images/boy.png"></image> -->
+					<text class="username">{{code}}</text>
+				</view>
+				<!-- <view class="row">
+					<text class="text">心血管内科</text>
+				</view> -->
+				<view class="row">
+					<view class="col">
+						<text class="text">主管:{{depManager}}</text>
+					</view>
+					<view class="col">
+						<text class="text">|</text>
+					</view>
+					<view class="col">
+						<text class="text">所属查核组:{{dep}}</text>
+					</view>
+				</view>
+
 			</view>
 			<view class="function-box">
-				<view class="role-switch">
+				<view class="role-switch" @click="switchRole">
 					<text class="func-text">角色切换</text>
-					<image class="msgbubble" src="/static/images/消息气泡.png"></image>
-					<image class="icon-more" src="/static/images/icon更多.png"></image>
-					<text class="role">管理员</text>
-				</view>			
-				<view class="sys-setting">
-					<text class="func-text">系统设置</text>
-					<image class="icon-more" src="/static/images/icon更多.png"></image>
-				</view>
-			</view>
-			<view class="bg-box">
-				<view class="logout-box">
-					<text class=""></text>
+					<view class="msg-box" v-show="isMsgShow">
+						<text class="msg-text">{{this.totalTodo}}</text>
+					</view>
+					<image class="icon-more" src="/static/images/icon-more.png"></image>
+					<text class="role">{{nowPermissionName}}</text>
 				</view>
+				<!-- 				<view class="sys-setting">
+					<text class="func-text">系统设置</text>
+					<image class="icon-more" src="/static/images/icon-more.png"></image>
+				</view> -->
 			</view>
 		</view>
-		<tm-tabbar :permission="1" />
+		<view class="logout-box" @click="logOut">
+			<text class="logout-text">退出登录</text>
+		</view>
+		<tm-tabbar :permission="nowPermission" />
 	</view>
 </template>
 
@@ -38,110 +58,266 @@
 	export default {
 		data() {
 			return {
-				nowPermission:'',//用户当前第一权限
+				nowPermission: '', //用户当前第一权限
+				nowPermissionName:'',//当前权限名
+				code:'',//用户名
+				name:'',//名字
+				dep:'',//所属查核组
+				depManager:'',//查核组组长
+				hospName:'',//医院名
+				totalTodo:0,//总待办数
+				pemissionList:[
+					{permission: 1, name: '管理员'}, 
+					{permission: 2, name: '查核组长'},
+					{permission: 3, name: '查核组员'},
+					{permission: 4, name: '单位负责人'},
+					{permission: 5, name: '改善者'}
+				]
 			}
 		},
+		created: function() {
+			this.$store.dispatch({
+				type: 'home/commActions',
+				payload: {
+					key: 'getuser',
+				}
+			}).then((data) => {
+				if (data) {
+					uni.setStorageSync('permissions', data.permissions);
+					uni.setStorageSync('nowPermission', data.nowPermission);
+					this.code=data.code;
+					this.name=data.name;
+					this.nowPermission=data.nowPermission;
+					this.dep=data.dep;
+					this.depManager=data.depManager;
+					this.hospName=data.hospName;
+					let current=this.pemissionList.find(item => item.permission == data.nowPermission);
+					this.nowPermissionName=current.name;
+					this.totalTodo=data.permissions.reduce(function(total,currentValue){
+						return total+currentValue.todoNum;
+					},0);
+				}
+			});
+		},
 		methods: {
-			
+			logOut() {
+				this.$store.dispatch({
+					type: 'home/commActions',
+					payload: {
+						key: 'logout',
+					}
+				}).then((data)=>{
+					if(data!==null){
+						uni.navigateTo({
+							url: '/pages/login/login'
+						});
+					}
+				});
+			},
+			switchRole() {
+				uni.navigateTo({
+					url: '/pages/role-switching/role-switching'
+				});
+			}
+		},
+		computed:{
+			isMsgShow(){
+				return this.totalTodo<=0?false:true;
+			}
 		}
 	}
 </script>
 
 <style lang="less">
-	.top-box{
-		position: relative;
-		height: 350rpx;
-	}
-	.bgpic{
-		width: 750rpx;
-		height: 350rpx;
-	}
-	.info-box{
-		width: 700rpx;
-		height: 250rpx;
-		border-radius: 15rpx;
-		background-color: #FFFFFF;
-		position: absolute;
-		left: 25rpx;
-		right: 25rpx;
-		top: 226.25rpx;
-		box-shadow: 0px 10px 30px 0px rgba(0, 13, 51, 0.1);
-	}
-	.avatar-box{
-		width: 125rpx;
-		height: 125rpx;
-		position: absolute;
-		right: 75rpx;
-		top: 187.5rpx;
-		background: #FFFFFF;
-		z-index: 2;
-		border-radius:50%
-	}
-	.avatar{
-		width: 112.5rpx;
-		height: 112.5rpx;
-		margin-left: 6.25rpx;
-		margin-top: 6.25rpx;
-		border-radius:50%
-	}
-	.function-box{
-		position: absolute;
-		top: 496.25rpx;
-		width: 750rpx;
-	}
-	.role-switch{
-		height: 100rpx;
-		width: 725rpx;
-		margin-left: 25rpx;
-		background: #FFFFFF;
-		border-bottom: 0.62rpx solid #DADEE6;
-	}
-	.sys-setting{
-		height: 100rpx;
-		width: 725rpx;
-		margin-left: 25rpx;
-		background: #FFFFFF;
-	}
-	.func-text{
-		font-size: 22.5rpx;
-		font-family: SourceHanSansCN-Medium, SourceHanSansCN;
-		font-weight: 500;
-		color: #292C33;
-		line-height: 100rpx;
-		float: left;
-	}
-	.icon-more{
-		width: 12.37rpx;
-		height: 21.21rpx;
-		line-height: 100rpx;
-		float: right;
-		margin-top: 39.37rpx;
-		margin-right: 25rpx;
-	}
-	.msgbubble{
-		width: 50rpx;
-		height: 30rpx;
-		background: #FF4060;
-		border-radius: 24px;
-		float: left;
-		margin-top: 35rpx;
-		margin-left: 15rpx;
-	}
-	.bg-box{
-		width: 750rpx;
-		height: 416.25rpx;
-		position: absolute;
-		bottom: 87.5rpx;
-		background-color: #F5F6FA;
-		z-index: -1;
-	}
-	.role{
-		font-size: 22.5rpx;
-		font-family: SourceHanSansCN-Normal, SourceHanSansCN;
-		font-weight: 400;
-		color: #7A8599;
-		line-height: 100rpx;
-		float: right;
-		margin-right: 25rpx;
+	.home-page {
+		height: 100%;
+
+		.content-info {
+			height: 596.25rpx;
+			background-color: #FFFFFF;
+
+			.top-box {
+				position: relative;
+				height: 350rpx;
+
+				.bgpic {
+					width: 750rpx;
+					height: 350rpx;
+				}
+
+				.hosname {
+					font-size: 45rpx;
+					font-family: SourceHanSansCN-Normal, SourceHanSansCN;
+					font-weight: 400;
+					color: #FFFFFF;
+					position: absolute;
+					left: 50rpx;
+					top: 92.5rpx;
+				}
+			}
+
+			.info-box {
+				width: 700rpx;
+				height: 250rpx;
+				border-radius: 15rpx;
+				background-color: #FFFFFF;
+				position: absolute;
+				left: 25rpx;
+				right: 25rpx;
+				top: 226.25rpx;
+				box-shadow: 0px 10px 30px 0px rgba(0, 13, 51, 0.1);
+
+				.head {
+					margin-left: 37.5rpx;
+					margin-top: 68.75rpx;
+
+					.name {
+						font-size: 35rpx;
+						font-family: SourceHanSansCN-Normal, SourceHanSansCN;
+						font-weight: 400;
+						color: #17181A;
+					}
+
+					.gender {
+						width: 25rpx;
+						height: 25rpx;
+						background: linear-gradient(135deg, #4DA6FF 0%, #4D88FF 100%);
+						border-radius: 6.25rpx;
+						margin-left: 15rpx;
+					}
+
+					.username {
+						font-size: 25rpx;
+						font-family: SourceHanSansCN-Normal, SourceHanSansCN;
+						font-weight: 400;
+						color: #17181A;
+						margin-left: 55rpx;
+					}
+				}
+
+				.row {
+					margin-left: 37.5rpx;
+					margin-top: 62.5rpx;
+
+					.col {
+						display: inline-block;
+						margin-right: 25rpx;
+					}
+				}
+
+				.text {
+					font-size: 22.5rpx;
+					font-family: SourceHanSansCN-Normal, SourceHanSansCN;
+					font-weight: 400;
+					color: #666E80;
+				}
+
+			}
+
+			.avatar-box {
+				width: 125rpx;
+				height: 125rpx;
+				position: absolute;
+				right: 75rpx;
+				top: 187.5rpx;
+				background: #FFFFFF;
+				z-index: 2;
+				border-radius: 50%
+			}
+
+			.avatar {
+				width: 112.5rpx;
+				height: 112.5rpx;
+				margin-left: 6.25rpx;
+				margin-top: 6.25rpx;
+				border-radius: 50%
+			}
+
+			.function-box {
+				position: absolute;
+				top: 496.25rpx;
+				width: 750rpx;
+
+				.role-switch {
+					height: 100rpx;
+					width: 725rpx;
+					margin-left: 25rpx;
+					background: #FFFFFF;
+					border-bottom: 0.62rpx solid #DADEE6;
+
+					.msg-box {
+						width: 50rpx;
+						height: 30rpx;
+						float: left;
+						margin-top: 35rpx;
+						margin-left: 15rpx;
+						position: relative;
+						background: #FF4060;
+						border-radius: 24px;
+						text-align: center;
+
+						.msg-text {
+							font-size: 17.5rpx;
+							font-family: SourceHanSansCN-Normal, SourceHanSansCN;
+							font-weight: 400;
+							color: #FFFFFF;
+							line-height: 30rpx;
+						}
+					}
+
+					.role {
+						font-size: 22.5rpx;
+						font-family: SourceHanSansCN-Normal, SourceHanSansCN;
+						font-weight: 400;
+						color: #7A8599;
+						line-height: 100rpx;
+						float: right;
+						margin-right: 25rpx;
+					}
+				}
+
+				// .sys-setting{
+				// 	height: 100rpx;
+				// 	width: 725rpx;
+				// 	margin-left: 25rpx;
+				// 	background: #FFFFFF;
+				// }
+				.func-text {
+					font-size: 22.5rpx;
+					font-family: SourceHanSansCN-Medium, SourceHanSansCN;
+					font-weight: 500;
+					color: #292C33;
+					line-height: 100rpx;
+					float: left;
+				}
+
+				.icon-more {
+					width: 12.37rpx;
+					height: 21.21rpx;
+					line-height: 100rpx;
+					float: right;
+					margin-top: 39.37rpx;
+					margin-right: 25rpx;
+				}
+			}
+
+
+		}
+
+		.logout-box {
+			width: 750rpx;
+			height: 100rpx;
+			background-color: #FFFFFF;
+			margin-top: 15rpx;
+
+			.logout-text {
+				font-size: 22.5rpx;
+				font-family: SourceHanSansCN-Medium, SourceHanSansCN;
+				font-weight: 500;
+				color: #292C33;
+				line-height: 100rpx;
+				margin-left: 330rpx;
+			}
+		}
 	}
 </style>

+ 14 - 0
pages/home/model.js

@@ -0,0 +1,14 @@
+import { commServer } from './server.js';
+
+export default {
+  namespaced: true,
+  state: {
+  },
+  mutations: {},
+  actions: {
+		commActions({ commit, state }, { payload }) {
+			// payload = {key,data} // data是请求数据,key是请求接口id
+      return commServer(payload);
+		},
+  }
+}

+ 18 - 0
pages/home/server.js

@@ -0,0 +1,18 @@
+import { creatRequest } from '../../utils/request.js';
+
+const requestList = {
+  //退出登录
+  logout: {
+    method: 'POST',
+    url: 'login/out'
+  },
+	//获取用户信息
+	getuser:{
+		method: 'GET',
+		url: 'user'
+	}
+};
+export const commServer = ({ key, data }) => {
+  let obj = requestList[key];
+  return creatRequest(obj, data);
+}

+ 1 - 1
pages/login/server.js

@@ -4,7 +4,7 @@ const requestList = {
   //登录
   login: {
     method: 'POST',
-    url: 'imed/pfm/login/in'
+    url: 'login/in'
   },
 };
 export const commServer = ({ key, data }) => {

+ 4 - 0
pages/model.js

@@ -1,6 +1,10 @@
 import login from './login/model.js';
+import home from './home/model.js';
+import roleSwitching from './role-switching/model.js';
 import configure from './configure/model.js';
 export default module = {
   login,
   configure,
+	home,
+	roleSwitching,
 }

+ 14 - 0
pages/role-switching/model.js

@@ -0,0 +1,14 @@
+import { commServer } from './server.js';
+
+export default {
+  namespaced: true,
+  state: {
+  },
+  mutations: {},
+  actions: {
+		commActions({ commit, state }, { payload }) {
+			// payload = {key,data} // data是请求数据,key是请求接口id
+      return commServer(payload);
+		},
+  }
+}

+ 150 - 0
pages/role-switching/role-switching.vue

@@ -0,0 +1,150 @@
+<template>
+	<view class="role-page">
+		<view class="row-box">
+			<view class="role-list" v-for="(item,index) in permissionList">
+				<text class="role-name">{{item.label}}</text>
+				<view class="radio-item" @click="toggleSelect(item,index)">
+					<image class="icon" :src="`/static/${item.isChecked ? 'check-radio' : 'check-no'}.png`"></image>
+				</view>
+				<text class="nowrole" v-show="item.isNowRole" >当前角色</text>
+				<text class="task-msg">{{item.todoNum}}</text>
+			</view>
+		</view>
+		<view class="btn-confirm" @click="saveChange">
+			<text class="btn-text">确定</text>
+		</view>
+	</view>
+</template>
+
+<script>
+	export default {
+		data() {
+			return {
+				permissionList:[],//权限列表
+				nowPermission:'',//当前权限
+				selectedPermission:'',//当前选中的权限
+				roleList:[
+					{permission: 1, name: '管理员'}, 
+					{permission: 2, name: '查核组长'},
+					{permission: 3, name: '查核组员'},
+					{permission: 4, name: '单位负责人'},
+					{permission: 5, name: '改善者'}
+				]
+			}
+		},
+		created() {
+			let permissions=uni.getStorageSync('permissions');
+			this.nowPermission=uni.getStorageSync('nowPermission');
+			this.permissionList=permissions.map((item,index)=>{
+				let match=this.roleList.find(i => i.permission == item.permission);
+				return {
+					value:match.permission,
+					label:match.name,
+					todoNum:item.todoNum>0?item.todoNum+'个任务待处理':'暂无待处理',
+					isNowRole:this.nowPermission==match.permission?true:false,
+					isChecked:this.nowPermission==match.permission?true:false,
+				}
+			});
+		},
+		methods: {
+			toggleSelect(item,index) {
+				this.permissionList.map((item,index)=>{
+					item.isChecked=false;
+				});
+				this.permissionList[item.value-1].isChecked=true;
+				this.selectedPermission=item.value;
+			},
+			saveChange(){
+				this.$store.dispatch({
+					type: 'roleSwitching/commActions',
+					payload: {
+						key: 'updatePermission',
+						data: {
+							permission: this.selectedPermission,
+						}
+					}
+				}).then((data)=>{
+					if(data!==null){
+						uni.navigateTo({
+							url: '/pages/home/home'
+						});
+					}
+				});
+			}
+		},
+	}
+</script>
+
+<style lang="less">
+	.role-page {
+		height: 100%;
+
+		.row-box {
+			.role-list {
+				height: 107.5rpx;
+				width: 750rpx;
+				background: #FFFFFF;
+				border-bottom: 0.62rpx solid #DADEE6;
+				position: relative;
+				.role-name {
+					font-size: 22.5rpx;
+					font-family: SourceHanSansCN-Bold, SourceHanSansCN;
+					font-weight: bold;
+					color: #292C33;
+					float: left;
+					margin-left: 25rpx;
+					margin-top: 25rpx;
+				}
+				
+				.nowrole {
+					float: right;
+					font-size: 22.5rpx;
+					font-family: SourceHanSansCN-Normal, SourceHanSansCN;
+					font-weight: 400;
+					color: #7A8599;
+					margin-top: 42.5rpx;
+					margin-right: 25rpx;
+				}
+				
+				.radio-item {
+					float: right;
+					margin-right: 25rpx;
+					margin-top: 41.25rpx;
+				
+					.icon {
+						width: 25rpx;
+						height: 25rpx;
+					}
+				}
+				
+				.task-msg {
+					font-size: 20rpx;
+					font-family: SourceHanSansCN-Normal, SourceHanSansCN;
+					font-weight: 400;
+					color: #7A8599;
+					position: absolute;
+					top: 62.5rpx;
+					left: 25rpx;
+				}
+					
+			}
+		}
+
+		.btn-confirm {
+			width: 750rpx;
+			height: 75rpx;
+			background: #3377FF;
+			position: absolute;
+			bottom: 0rpx;
+
+			.btn-text {
+				font-size: 22.5rpx;
+				font-family: SourceHanSansCN-Normal, SourceHanSansCN;
+				font-weight: 400;
+				color: #FFFFFF;
+				line-height: 75rpx;
+				margin-left: 352.5rpx;
+			}
+		}
+	}
+</style>

+ 13 - 0
pages/role-switching/server.js

@@ -0,0 +1,13 @@
+import { creatRequest } from '../../utils/request.js';
+
+const requestList = {
+  //角色设置
+  updatePermission: {
+    method: 'GET',
+    url: 'login/updatePermission'
+  },
+};
+export const commServer = ({ key, data }) => {
+  let obj = requestList[key];
+  return creatRequest(obj, data);
+}

+ 0 - 0
static/images/小哥哥.png → static/images/boy-avatar.png


+ 0 - 0
static/images/男生.png → static/images/boy.png


+ 0 - 0
static/images/小姐姐.png → static/images/girl-avatar.png


+ 0 - 0
static/images/女生标识.png → static/images/girl.png


+ 0 - 0
static/images/icon更多.png → static/images/icon-more.png


+ 0 - 0
static/images/消息气泡.png → static/images/messagebubble.png


+ 0 - 0
static/images/个人中心背景.png → static/images/pcbg.png


+ 0 - 0
static/images/底纹.png → static/images/shade.png


+ 1 - 1
utils/request.js

@@ -8,7 +8,7 @@
 import { URL } from "./requestUrl";
 import { stringify } from 'qs';
 
-const BASE_URL = `${URL}/`;
+const BASE_URL = `${URL}/imed/pfm/`;
 let AllRequestNum = 0; // 存放请求数,以保证有请求未返回就持续loading
 
 /**