login.vue 4.4 KB

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