login.vue 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212
  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>公文流转管理平台</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 class="fot">
  26. <text @tap="reg_ok">免费注册</text>
  27. <text style="display: inline-block;width: 10vw;"></text>
  28. <text @tap="forget_ok">忘记密码</text>
  29. </view> -->
  30. </view>
  31. </view>
  32. </template>
  33. <script>
  34. import * as $auth from "@/common/auth.js"
  35. import loginService from "@/api/auth/loginService"
  36. import {
  37. mapActions
  38. } from 'vuex'
  39. export default {
  40. data() {
  41. return {
  42. captchaImg: '',
  43. inputForm: {
  44. 'username': '',
  45. 'password': '',
  46. 'code': '',
  47. 'uuid': ''
  48. },
  49. rules: {
  50. username: [{
  51. required: true,
  52. message: '请输入用户名',
  53. trigger: ['blur', 'change']
  54. }],
  55. password: [{
  56. required: true,
  57. message: '请输入密码',
  58. trigger: ['blur', 'change']
  59. }],
  60. code: [{
  61. required: true,
  62. message: '请输入验证码',
  63. trigger: ['blur', 'change']
  64. }]
  65. }
  66. }
  67. },
  68. created() {
  69. this.getCaptcha()
  70. },
  71. methods: {
  72. ...mapActions(['refreshUserInfo']),
  73. // 登录
  74. bindLogin() {
  75. /**
  76. * 客户端对账号信息进行一些必要的校验。
  77. * 实际开发中,根据业务需要进行处理,这里仅做示例。
  78. */
  79. this.$refs.uForm.validate().then(res => {
  80. loginService.login(this.inputForm).then((data) => {
  81. this.$store.commit('SET_TOKEN', data.token);
  82. this.refreshUserInfo();
  83. uni.reLaunch({
  84. url: '../index/index',
  85. });
  86. }).catch(e => {
  87. uni.showToast({
  88. title: e.data
  89. })
  90. this.getCaptcha()
  91. console.error(e)
  92. })
  93. })
  94. },
  95. // 获取验证码
  96. getCaptcha() {
  97. loginService.getCode().then((data) => {
  98. this.captchaImg = 'data:image/gif;base64,' + data.codeImg
  99. this.inputForm.uuid = data.uuid
  100. })
  101. }
  102. }
  103. }
  104. </script>
  105. <style lang="scss" scoped>
  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>