login.vue 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146
  1. <template>
  2. <view class="login-page">
  3. <view class="com-model">
  4. <view class="top-box">
  5. <image class="pic" src="/static/images/shade.png"></image>
  6. <text class="title-top">你好,</text>
  7. <text class="title-buttom">欢迎使用追踪方法学系统</text>
  8. </view>
  9. <view class="main-content">
  10. <input class="uni-input-box"
  11. placeholder="请输入账号"
  12. placeholder-style="color: #A1A7B3"
  13. v-model="username" />
  14. <input class="uni-input-box"
  15. placeholder="请输入密码"
  16. placeholder-style="color: #A1A7B3"
  17. password
  18. v-model="password" />
  19. <com-button class="login-button"
  20. :width="998" :height="120" :fontSize="48" :background="isLogin?'#A3B1CC':''" btnText="登录" @btnClick="login" />
  21. </view>
  22. </view>
  23. </view>
  24. </template>
  25. <script>
  26. import encryption from "../../utils/crypto.js";
  27. export default {
  28. data() {
  29. return {
  30. hospSign: '', // 医院标识
  31. username: '', // 用户名
  32. password: '', // 密码
  33. rolList: [
  34. {permission: 1, name: '管理员', pagePath: 'pages/situationsCenter/situationsCenter'}, // targetIndexs:targetList种对应的下标
  35. {permission: 2, name: '查核组长',pagePath: 'pages/situationsCenter/situationsCenter'},
  36. {permission: 3, name: '查核组员', pagePath: 'pages/situationsCenter/situationsCenter'},
  37. {permission: 4, name: '单位负责人', pagePath: 'pages/mission/mission'},
  38. {permission: 5, name: '改善者', pagePath: 'pages/mission/mission'}
  39. ]
  40. }
  41. },
  42. onLoad({ hospSign }){
  43. this.hospSign = hospSign;
  44. },
  45. methods: {
  46. login() {
  47. if(this.isLogin) return
  48. this.$store.dispatch({
  49. type: 'login/commActions',
  50. payload: {
  51. key: 'login',
  52. data: {
  53. username: encryption(this.username),
  54. password: encryption(this.password),
  55. hospSign: this.hospSign
  56. }
  57. }
  58. }).then((data) => {
  59. if (data) {
  60. uni.setStorageSync('hiId', data.hiId);
  61. uni.setStorageSync('permissions', data.permissions);
  62. uni.setStorageSync('token', data.token);
  63. uni.setStorageSync('nowPermission', data.nowPermission);
  64. uni.setStorageSync('id', data.id);
  65. uni.setStorageSync('name', data.name);
  66. this.rolToTarget(data.nowPermission)
  67. }
  68. });
  69. },
  70. //角色和对应的跳转页面
  71. rolToTarget(nowPermission) {
  72. if(nowPermission != 0){
  73. let current = this.rolList.find(item => item.permission == nowPermission);
  74. if(current){
  75. // 页面跳转
  76. uni.navigateTo({
  77. url: `/${current.pagePath}`
  78. });
  79. }
  80. }
  81. }
  82. },
  83. computed:{
  84. //判断是否输入了用户名和密码
  85. isLogin(){
  86. return !this.username || !this.password;
  87. }
  88. }
  89. }
  90. </script>
  91. <style lang="less" scoped>
  92. .login-page {
  93. height: 100%;
  94. background-color: #FFFFFF;
  95. .top-box {
  96. display: flex;
  97. flex-direction: column;
  98. padding-left: 62.5rpx;
  99. .pic{
  100. position: absolute;
  101. top: 0;
  102. right: 0;
  103. width: 430rpx;
  104. height: 281.25rpx;
  105. }
  106. .title-top{
  107. height: 45rpx;
  108. font-size: 45rpx;
  109. font-weight: bold;
  110. margin-top: 250rpx;
  111. font-family: SourceHanSansCN-Bold, SourceHanSansCN;
  112. color: #2E2F33;
  113. }
  114. .title-buttom{
  115. margin-top: 40rpx;
  116. height: 45rpx;
  117. font-size: 45rpx;
  118. font-family: SourceHanSansCN-Bold, SourceHanSansCN;
  119. font-weight: bold;
  120. color: #2E2F33;
  121. }
  122. }
  123. .main-content{
  124. margin-top: 37.5rpx;
  125. float: left;
  126. }
  127. .uni-input-box{
  128. width: 625rpx;
  129. float: left;
  130. margin-left: 62.5rpx;
  131. margin-top: 62.5rpx;
  132. font-size: 30rpx;
  133. padding-bottom: 25rpx;
  134. border-bottom:1.25rpx solid #E6EAF2 ;
  135. }
  136. .login-button{
  137. float: left;
  138. margin-left: 62.5rpx;
  139. margin-top: 62.5rpx;
  140. background-color: #A3B1CC;
  141. }
  142. }
  143. </style>