login.vue 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160
  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. console.log({hospSign});
  44. if(hospSign){
  45. this.hospSign = hospSign;
  46. }else {
  47. const value = uni.getStorageSync('hospSign');
  48. console.log('hospSign',value);
  49. if(hospSign){
  50. this.hospSign = value;
  51. }
  52. }
  53. },
  54. methods: {
  55. login() {
  56. if(this.isLogin) return
  57. this.$store.dispatch({
  58. type: 'login/commActions',
  59. payload: {
  60. key: 'login',
  61. data: {
  62. username: encryption(this.username),
  63. password: encryption(this.password),
  64. hospSign: this.hospSign
  65. // hospSign:'vdQpm2OvmLVTPnXL'
  66. }
  67. }
  68. }).then((data) => {
  69. if (data) {
  70. uni.setStorageSync('hiId', data.hiId);
  71. uni.setStorageSync('permissions', data.permissions);
  72. uni.setStorageSync('token', data.token);
  73. uni.setStorageSync('nowPermission', data.nowPermission);
  74. uni.setStorageSync('id', data.id);
  75. uni.setStorageSync('name', data.name);
  76. uni.setStorageSync('hospSign', this.hospSign);
  77. this.rolToTarget(data.nowPermission)
  78. }
  79. });
  80. },
  81. //角色和对应的跳转页面
  82. rolToTarget(nowPermission) {
  83. if(nowPermission != 0){
  84. let current = this.rolList.find(item => item.permission == nowPermission);
  85. if(current){
  86. // 页面跳转
  87. uni.redirectTo({
  88. url: `/${current.pagePath}`
  89. });
  90. }
  91. }
  92. }
  93. },
  94. computed:{
  95. //判断是否输入了用户名和密码
  96. isLogin(){
  97. return !this.username || !this.password;
  98. }
  99. }
  100. }
  101. </script>
  102. <style lang="less" scoped>
  103. .login-page {
  104. height: 100%;
  105. background-color: #FFFFFF;
  106. .top-box {
  107. display: flex;
  108. flex-direction: column;
  109. padding-left: 62.5rpx;
  110. .pic{
  111. position: absolute;
  112. top: 0;
  113. right: 0;
  114. width: 430rpx;
  115. height: 281.25rpx;
  116. }
  117. .title-top{
  118. height: 45rpx;
  119. font-size: 45rpx;
  120. font-weight: bold;
  121. margin-top: 250rpx;
  122. font-family: SourceHanSansCN-Bold, SourceHanSansCN;
  123. color: #2E2F33;
  124. }
  125. .title-buttom{
  126. margin-top: 40rpx;
  127. height: 45rpx;
  128. font-size: 45rpx;
  129. font-family: SourceHanSansCN-Bold, SourceHanSansCN;
  130. font-weight: bold;
  131. color: #2E2F33;
  132. }
  133. }
  134. .main-content{
  135. margin-top: 37.5rpx;
  136. float: left;
  137. }
  138. .uni-input-box{
  139. width: 625rpx;
  140. float: left;
  141. margin-left: 62.5rpx;
  142. margin-top: 62.5rpx;
  143. font-size: 30rpx;
  144. padding-bottom: 25rpx;
  145. border-bottom:1.25rpx solid #E6EAF2 ;
  146. }
  147. .login-button{
  148. float: left;
  149. margin-left: 62.5rpx;
  150. margin-top: 62.5rpx;
  151. background-color: #A3B1CC;
  152. }
  153. }
  154. </style>