login.vue 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111
  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. }
  33. },
  34. methods: {
  35. login() {
  36. if(this.isLogin) return
  37. this.$store.dispatch({
  38. type: 'login/commActions',
  39. payload: {
  40. key: 'login',
  41. data: {
  42. username: encryption(this.username),
  43. password: encryption(this.password)
  44. }
  45. }
  46. }).then((data) => {
  47. if (data) {
  48. uni.setStorageSync('token', data.hiId);
  49. uni.setStorageSync('token', data.permissions);
  50. uni.setStorageSync('token', data.token);
  51. uni.setStorageSync('token', data.nowPermission);
  52. }
  53. });
  54. }
  55. },
  56. computed:{
  57. //判断是否输入了用户名和密码
  58. isLogin(){
  59. return !this.username || !this.password;
  60. }
  61. }
  62. }
  63. </script>
  64. <style lang="less" scoped>
  65. .pic{
  66. height: 281.25rpx;
  67. width: 430rpx;
  68. float: right;
  69. }
  70. .title-top{
  71. height: 45rpx;
  72. font-size: 45rpx;
  73. font-weight: bold;
  74. margin-top: 250rpx;
  75. margin-left: 62.5rpx;
  76. font-family: SourceHanSansCN-Bold, SourceHanSansCN;
  77. color: #2E2F33;
  78. float: left;
  79. }
  80. .title-buttom{
  81. height: 45rpx;
  82. font-size: 45rpx;
  83. font-family: SourceHanSansCN-Bold, SourceHanSansCN;
  84. font-weight: bold;
  85. color: #2E2F33;
  86. float: left;
  87. margin-left: 62.5rpx;
  88. margin-top: 40rpx;
  89. }
  90. .main-content{
  91. margin-top: 37.5rpx;
  92. float: left;
  93. }
  94. .uni-input-box{
  95. width: 625rpx;
  96. float: left;
  97. margin-left: 62.5rpx;
  98. margin-top: 62.5rpx;
  99. font-size: 30rpx;
  100. padding-bottom: 25rpx;
  101. border-bottom:1.25rpx solid #E6EAF2 ;
  102. }
  103. .login-button{
  104. float: left;
  105. margin-left: 62.5rpx;
  106. margin-top: 62.5rpx;
  107. background-color: #A3B1CC;
  108. }
  109. </style>