login.vue 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139
  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. username: '', // 用户名
  31. password: '', // 密码
  32. rolList: [
  33. {permission: 1, name: '管理员', pagePath: 'pages/situationsCenter/situationsCenter'}, // targetIndexs:targetList种对应的下标
  34. {permission: 2, name: '查核组长',pagePath: 'pages/situationsCenter/situationsCenter'},
  35. {permission: 3, name: '查核组员', pagePath: 'pages/situationsCenter/situationsCenter'},
  36. {permission: 4, name: '单位负责人', pagePath: 'pages/situationsCenter/situationsCenter'},
  37. {permission: 5, name: '改善者', pagePath: 'pages/mission/mission'}
  38. ]
  39. }
  40. },
  41. methods: {
  42. login() {
  43. if(this.isLogin) return
  44. this.$store.dispatch({
  45. type: 'login/commActions',
  46. payload: {
  47. key: 'login',
  48. data: {
  49. username: encryption(this.username),
  50. password: encryption(this.password)
  51. }
  52. }
  53. }).then((data) => {
  54. if (data) {
  55. uni.setStorageSync('hiId', data.hiId);
  56. uni.setStorageSync('permissions', data.permissions);
  57. uni.setStorageSync('token', data.token);
  58. uni.setStorageSync('nowPermission', data.nowPermission);
  59. uni.setStorageSync('id', data.id);
  60. uni.setStorageSync('name', data.name);
  61. this.rolToTarget(data.nowPermission)
  62. }
  63. });
  64. },
  65. //角色和对应的跳转页面
  66. rolToTarget(nowPermission) {
  67. if(nowPermission != 0){
  68. let current = this.rolList.find(item => item.permission == nowPermission);
  69. if(current){
  70. // 页面跳转
  71. uni.navigateTo({
  72. url: `/${current.pagePath}`
  73. });
  74. }
  75. }
  76. }
  77. },
  78. computed:{
  79. //判断是否输入了用户名和密码
  80. isLogin(){
  81. return !this.username || !this.password;
  82. }
  83. }
  84. }
  85. </script>
  86. <style lang="less" scoped>
  87. .login-page {
  88. height: 100%;
  89. background-color: #FFFFFF;
  90. .pic{
  91. height: 281.25rpx;
  92. width: 430rpx;
  93. float: right;
  94. }
  95. .title-top{
  96. height: 45rpx;
  97. font-size: 45rpx;
  98. font-weight: bold;
  99. margin-top: 250rpx;
  100. margin-left: 62.5rpx;
  101. font-family: SourceHanSansCN-Bold, SourceHanSansCN;
  102. color: #2E2F33;
  103. float: left;
  104. }
  105. .title-buttom{
  106. height: 45rpx;
  107. font-size: 45rpx;
  108. font-family: SourceHanSansCN-Bold, SourceHanSansCN;
  109. font-weight: bold;
  110. color: #2E2F33;
  111. float: left;
  112. margin-left: 62.5rpx;
  113. margin-top: 40rpx;
  114. }
  115. .main-content{
  116. margin-top: 37.5rpx;
  117. float: left;
  118. }
  119. .uni-input-box{
  120. width: 625rpx;
  121. float: left;
  122. margin-left: 62.5rpx;
  123. margin-top: 62.5rpx;
  124. font-size: 30rpx;
  125. padding-bottom: 25rpx;
  126. border-bottom:1.25rpx solid #E6EAF2 ;
  127. }
  128. .login-button{
  129. float: left;
  130. margin-left: 62.5rpx;
  131. margin-top: 62.5rpx;
  132. background-color: #A3B1CC;
  133. }
  134. }
  135. </style>