login.vue 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210
  1. <template>
  2. <view class="main">
  3. <view id="box">
  4. <view id="top" class="">
  5. <view class="top_le"></view>
  6. <view class="top_ri"></view>
  7. </view>
  8. <view class="title">
  9. <view style="font-size: 28px!important;">公文流转管理平台</view>
  10. </view>
  11. <view class="login-form">
  12. <u--form :model="inputForm" labelWidth="100px" labelPosition="left" :rules="rules" ref="uForm">
  13. <u-form-item label="用户名" borderBottom prop="username">
  14. <u-input v-model="inputForm.username" />
  15. </u-form-item>
  16. <u-form-item label="密码" borderBottom prop="password">
  17. <u-input password v-model="inputForm.password" />
  18. </u-form-item>
  19. </u--form>
  20. </view>
  21. <view class="but">
  22. <u-button type="primary" shape="circle" color="linear-gradient(90deg, #1989FA, #19C2FA)"
  23. @click="bindLogin" text="登录"></u-button>
  24. </view>
  25. </view>
  26. </view>
  27. </template>
  28. <script>
  29. import * as $auth from "@/common/auth.js"
  30. import loginService from "@/api/auth/loginService"
  31. import {
  32. mapActions
  33. } from 'vuex'
  34. export default {
  35. data() {
  36. return {
  37. isfocus: false,
  38. captchaImg: '',
  39. accounts: [],
  40. isrember: [],
  41. inputForm: {
  42. 'username': '',
  43. 'password': '',
  44. 'code': '',
  45. 'uuid': ''
  46. },
  47. rules: {
  48. username: [{
  49. required: true,
  50. message: '请输入用户名',
  51. trigger: ['blur', 'change']
  52. }],
  53. password: [{
  54. required: true,
  55. message: '请输入密码',
  56. trigger: ['blur', 'change']
  57. }],
  58. code: [{
  59. required: true,
  60. message: '请输入验证码',
  61. trigger: ['blur', 'change']
  62. }]
  63. }
  64. }
  65. },
  66. created() {
  67. this.getCaptcha()
  68. },
  69. methods: {
  70. ...mapActions(['refreshUserInfo']),
  71. // 登录
  72. bindLogin() {
  73. /**
  74. * 客户端对账号信息进行一些必要的校验。
  75. * 实际开发中,根据业务需要进行处理,这里仅做示例。
  76. */
  77. this.$refs.uForm.validate().then(res => {
  78. loginService.login(this.inputForm).then((data) => {
  79. this.$store.commit('SET_TOKEN', data.token);
  80. this.refreshUserInfo();
  81. uni.reLaunch({
  82. url: '../index/index',
  83. });
  84. }).catch(e => {
  85. uni.showToast({
  86. title: e.data
  87. })
  88. this.getCaptcha()
  89. console.error(e)
  90. })
  91. })
  92. },
  93. // 获取验证码
  94. getCaptcha() {
  95. loginService.getCode().then((data) => {
  96. this.captchaImg = 'data:image/gif;base64,' + data.codeImg
  97. this.inputForm.uuid = data.uuid
  98. })
  99. }
  100. }
  101. }
  102. </script>
  103. <style lang="scss" scoped>
  104. // 记住账户展示
  105. .focus_info {}
  106. #box {
  107. position: relative;
  108. // color: $u-content-color;
  109. }
  110. .title {
  111. position: absolute;
  112. top: 15vh;
  113. width: 100vw;
  114. text-align: center;
  115. font-size: 28rpx;
  116. color: #198bfa;
  117. }
  118. .title view:nth-child(1) {
  119. height: 54px;
  120. font-size: 56rpx;
  121. font-family: PingFang SC;
  122. font-weight: bold;
  123. text-shadow: 0px 2px 24px rgba(58, 199, 118, 0.4);
  124. }
  125. .title view:nth-child(2) {
  126. font-size: 32rpx;
  127. font-family: PingFang SC;
  128. font-weight: 500;
  129. color: #198BFA;
  130. margin-top: 5vw;
  131. }
  132. #top {
  133. width: 100vw;
  134. height: 40vh;
  135. position: relative;
  136. }
  137. .top_ri {
  138. width: 100vw;
  139. height: 100vw;
  140. background: linear-gradient(141deg, #19C0FA 0%, #198BFA 100%);
  141. opacity: 0.1;
  142. border-radius: 50%;
  143. position: absolute;
  144. right: -47vw;
  145. top: -37vw;
  146. }
  147. .top_le {
  148. width: 100vw;
  149. height: 100vw;
  150. background: linear-gradient(141deg, #19C0FA 0%, #198BFA 100%);
  151. opacity: 0.1;
  152. border-radius: 50%;
  153. position: absolute;
  154. left: -34vw;
  155. top: -54vw;
  156. }
  157. .inp {
  158. padding-left: 5vw;
  159. position: relative;
  160. top: -4vh;
  161. }
  162. .inp text {
  163. font-size: 36rpx;
  164. font-family: PingFang SC;
  165. font-weight: 500;
  166. color: #333333;
  167. margin-left: 5px;
  168. }
  169. .but {
  170. padding-left: 50rpx;
  171. padding-right: 50rpx;
  172. margin-top: 60rpx;
  173. }
  174. .fot {
  175. width: 100vw;
  176. height: 26px;
  177. text-align: center;
  178. font-size: 28rpx;
  179. font-family: PingFang SC;
  180. font-weight: 500;
  181. color: #8E8E8E;
  182. margin-top: 20px;
  183. }
  184. .login-form {
  185. padding-left: 100rpx;
  186. padding-right: 30rpx;
  187. }
  188. </style>