login.vue 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141
  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/mission/mission'},
  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. .top-box {
  91. display: flex;
  92. flex-direction: column;
  93. padding-left: 62.5rpx;
  94. .pic{
  95. position: absolute;
  96. top: 0;
  97. right: 0;
  98. width: 430rpx;
  99. height: 281.25rpx;
  100. }
  101. .title-top{
  102. height: 45rpx;
  103. font-size: 45rpx;
  104. font-weight: bold;
  105. margin-top: 250rpx;
  106. font-family: SourceHanSansCN-Bold, SourceHanSansCN;
  107. color: #2E2F33;
  108. }
  109. .title-buttom{
  110. margin-top: 40rpx;
  111. height: 45rpx;
  112. font-size: 45rpx;
  113. font-family: SourceHanSansCN-Bold, SourceHanSansCN;
  114. font-weight: bold;
  115. color: #2E2F33;
  116. }
  117. }
  118. .main-content{
  119. margin-top: 37.5rpx;
  120. float: left;
  121. }
  122. .uni-input-box{
  123. width: 625rpx;
  124. float: left;
  125. margin-left: 62.5rpx;
  126. margin-top: 62.5rpx;
  127. font-size: 30rpx;
  128. padding-bottom: 25rpx;
  129. border-bottom:1.25rpx solid #E6EAF2 ;
  130. }
  131. .login-button{
  132. float: left;
  133. margin-left: 62.5rpx;
  134. margin-top: 62.5rpx;
  135. background-color: #A3B1CC;
  136. }
  137. }
  138. </style>