login.vue 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147
  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. uni.setStorageSync('hospSign', this.hospSign);
  67. this.rolToTarget(data.nowPermission)
  68. }
  69. });
  70. },
  71. //角色和对应的跳转页面
  72. rolToTarget(nowPermission) {
  73. if(nowPermission != 0){
  74. let current = this.rolList.find(item => item.permission == nowPermission);
  75. if(current){
  76. // 页面跳转
  77. uni.redirectTo({
  78. url: `/${current.pagePath}`
  79. });
  80. }
  81. }
  82. }
  83. },
  84. computed:{
  85. //判断是否输入了用户名和密码
  86. isLogin(){
  87. return !this.username || !this.password;
  88. }
  89. }
  90. }
  91. </script>
  92. <style lang="less" scoped>
  93. .login-page {
  94. height: 100%;
  95. background-color: #FFFFFF;
  96. .top-box {
  97. display: flex;
  98. flex-direction: column;
  99. padding-left: 62.5rpx;
  100. .pic{
  101. position: absolute;
  102. top: 0;
  103. right: 0;
  104. width: 430rpx;
  105. height: 281.25rpx;
  106. }
  107. .title-top{
  108. height: 45rpx;
  109. font-size: 45rpx;
  110. font-weight: bold;
  111. margin-top: 250rpx;
  112. font-family: SourceHanSansCN-Bold, SourceHanSansCN;
  113. color: #2E2F33;
  114. }
  115. .title-buttom{
  116. margin-top: 40rpx;
  117. height: 45rpx;
  118. font-size: 45rpx;
  119. font-family: SourceHanSansCN-Bold, SourceHanSansCN;
  120. font-weight: bold;
  121. color: #2E2F33;
  122. }
  123. }
  124. .main-content{
  125. margin-top: 37.5rpx;
  126. float: left;
  127. }
  128. .uni-input-box{
  129. width: 625rpx;
  130. float: left;
  131. margin-left: 62.5rpx;
  132. margin-top: 62.5rpx;
  133. font-size: 30rpx;
  134. padding-bottom: 25rpx;
  135. border-bottom:1.25rpx solid #E6EAF2 ;
  136. }
  137. .login-button{
  138. float: left;
  139. margin-left: 62.5rpx;
  140. margin-top: 62.5rpx;
  141. background-color: #A3B1CC;
  142. }
  143. }
  144. </style>