login.vue 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202
  1. <template>
  2. <view class="login">
  3. <view class="login-header">
  4. <image src="../../static/logo.png" mode=""></image>
  5. <h2>ByteSailing管理系统</h2>
  6. </view>
  7. <view class="login-form">
  8. <uni-easyinput type="text" v-model="loginForm.tenantId" placeholder="请输入租户ID" />
  9. <uni-easyinput type="text" v-model="loginForm.username" placeholder="请输入账号" />
  10. <uni-easyinput type="password" v-model="loginForm.password" placeholder="请输入密码" />
  11. <uni-easyinput type="text" v-model="loginForm.code" placeholder="验证码" />
  12. <image :src="image" @click="getCodeImg" style="width:200rpx;height:100rpx" mode=""></image>
  13. </view>
  14. <view class="login-btn">
  15. <view class="check-warp">
  16. <view class="check-icon-warp">
  17. <i class="iconfont" style="margin-right:16rpx">&#xe6cb;</i>
  18. </view>
  19. 已阅读并同意:Bytesailing <span>服务条款</span> 和 <span>隐私协议</span>
  20. </view>
  21. <button type="default" @click="lodingFn">登录</button>
  22. </view>
  23. </view>
  24. </template>
  25. <script>
  26. import Vue from 'vue'
  27. import {
  28. getParams
  29. } from '@/util/uitl.js'
  30. export default {
  31. data() {
  32. return {
  33. loginForm: {
  34. //租户ID
  35. tenantId: '000000',
  36. //部门ID
  37. deptId: '',
  38. //角色ID
  39. roleId: '',
  40. //用户名
  41. username: 'admin',
  42. //密码
  43. password: '21232f297a57a5a743894a0e4a801fc3',
  44. //账号类型
  45. type: 'account',
  46. //验证码的值
  47. code: '',
  48. //验证码的索引
  49. key: '',
  50. grant_type: 'captcha',
  51. scope: 'all'
  52. //预加载白色背景
  53. },
  54. image: 'data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7',
  55. formData: {}
  56. }
  57. },
  58. onLoad() {
  59. const v = this
  60. v.getCodeImg()
  61. },
  62. methods: {
  63. init() {
  64. const v = this
  65. },
  66. lodingFn() {
  67. const v = this
  68. uni.switchTab({
  69. url: '/pages/equipment/equipment'
  70. })
  71. return
  72. uni.request({
  73. url:v.$baseUrl + '/api/blade-auth/oauth/token?' + getParams(v.loginForm),
  74. method: 'POST',
  75. header: {
  76. 'Captcha-Key': this.loginForm.key,
  77. 'Captcha-Code': this.loginForm.code,
  78. 'Tenant-Id': this.loginForm.tenantId,
  79. 'Content-Type': 'application/json;charset=UTF-8',
  80. 'Authorization': 'Basic c2FiZXI6c2FiZXJfc2VjcmV0'
  81. },
  82. success: (res) => {
  83. console.log(res)
  84. uni.switchTab({
  85. url: '/pages/equipment/equipment'
  86. })
  87. },
  88. fail: (err) => {
  89. console.log(err)
  90. }
  91. });
  92. },
  93. getCodeImg() {
  94. this.$get('/blade-auth/oauth/captcha').then((res) => {
  95. console.log(res)
  96. const data = res
  97. this.loginForm.key = data.key
  98. this.image = data.image
  99. })
  100. },
  101. },
  102. }
  103. </script>
  104. <style>
  105. </style>
  106. <style lang="less">
  107. /deep/ .uni-easyinput {
  108. margin-bottom: 24rpx;
  109. background-color: #F1F1F1;
  110. border-radius: 10rpx !important;
  111. }
  112. /deep/ .uni-easyinput__content {
  113. border-radius: 20rpx !important;
  114. border: none !important;
  115. }
  116. /deep/ .uni-easyinput__content-input {
  117. height: 110rpx;
  118. font-size: 32rpx;
  119. background-color: #F1F1F1;
  120. color: #999999;
  121. }
  122. .login {
  123. height: 100vh;
  124. width: 100vw;
  125. background-size: 100% 100%;
  126. .login-btn {
  127. button {
  128. background-color: #3370FF;
  129. color: #fff;
  130. font-size: 32rpx;
  131. border-radius: 45rpx;
  132. height: 90rpx;
  133. }
  134. .check-warp {
  135. margin-bottom: 32rpx;
  136. margin-top: 8rpx;
  137. font-size: 24rpx;
  138. display: flex;
  139. .check-icon-warp {
  140. height: 30rpx;
  141. width: 30rpx;
  142. border-radius: 50%;
  143. border: 2rpx solid #dddddd;
  144. margin-right: 10rpx;
  145. }
  146. .iconfont {
  147. color: #39C55A;
  148. }
  149. }
  150. padding: 0 40rpx;
  151. }
  152. .login-header {
  153. padding: 128rpx 40rpx 0;
  154. background: url(../../static/images/login-header.png);
  155. background-size: 100% 100%;
  156. h2 {
  157. font-size: 48rpx;
  158. color: #333333;
  159. font-weight: 800;
  160. margin-top: 80rpx;
  161. }
  162. image {
  163. width: 280rpx;
  164. height: 90rpx;
  165. display: block;
  166. }
  167. }
  168. .login-form {
  169. margin-top: 64rpx;
  170. background: #fff;
  171. border-radius: 10rpx;
  172. padding: 0 40rpx;
  173. }
  174. }
  175. </style>