login.vue 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131
  1. <template>
  2. <view class="login-model">
  3. <view class="com-model">
  4. <view class="top-box">
  5. <image class="pic" src="/static/images/底纹.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/creatingSituations/creatingSituations'}, // targetIndexs:targetList种对应的下标
  34. {permission: 2, name: '查核组长',pagePath: 'pages/creatingSituations/creatingSituations'},
  35. {permission: 3, name: '查核组员', pagePath: 'pages/creatingSituations/creatingSituations'},
  36. {permission: 4, name: '单位负责人', pagePath: 'pages/creatingSituations/creatingSituations'},
  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. this.rolToTarget(data.nowPermission)
  60. }
  61. });
  62. },
  63. //角色和对应的跳转页面
  64. rolToTarget(nowPermission) {
  65. if(nowPermission != 0){
  66. let current = this.rolList.find(item => item.permission == nowPermission);
  67. if(current){
  68. // 页面跳转
  69. uni.navigateTo({
  70. url: `/${current.pagePath}`
  71. });
  72. }
  73. }
  74. }
  75. },
  76. computed:{
  77. //判断是否输入了用户名和密码
  78. isLogin(){
  79. return !this.username || !this.password;
  80. }
  81. }
  82. }
  83. </script>
  84. <style lang="less" scoped>
  85. .pic{
  86. height: 281.25rpx;
  87. width: 430rpx;
  88. float: right;
  89. }
  90. .title-top{
  91. height: 45rpx;
  92. font-size: 45rpx;
  93. font-weight: bold;
  94. margin-top: 250rpx;
  95. margin-left: 62.5rpx;
  96. font-family: SourceHanSansCN-Bold, SourceHanSansCN;
  97. color: #2E2F33;
  98. float: left;
  99. }
  100. .title-buttom{
  101. height: 45rpx;
  102. font-size: 45rpx;
  103. font-family: SourceHanSansCN-Bold, SourceHanSansCN;
  104. font-weight: bold;
  105. color: #2E2F33;
  106. float: left;
  107. margin-left: 62.5rpx;
  108. margin-top: 40rpx;
  109. }
  110. .main-content{
  111. margin-top: 37.5rpx;
  112. float: left;
  113. }
  114. .uni-input-box{
  115. width: 625rpx;
  116. float: left;
  117. margin-left: 62.5rpx;
  118. margin-top: 62.5rpx;
  119. font-size: 30rpx;
  120. padding-bottom: 25rpx;
  121. border-bottom:1.25rpx solid #E6EAF2 ;
  122. }
  123. .login-button{
  124. float: left;
  125. margin-left: 62.5rpx;
  126. margin-top: 62.5rpx;
  127. background-color: #A3B1CC;
  128. }
  129. </style>