login.vue 4.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265
  1. <template>
  2. <view>
  3. <!-- <view class="head"></view>
  4. -->
  5. <view class="img">
  6. <image src="../../static/登录/bg@2x.png" class="image"></image>
  7. <view class="white">
  8. <view class="title">
  9. <text class="title1">中央空调管理系统</text>
  10. <text class="title2">MANAGEMENT SYSTEM</text>
  11. </view>
  12. <view class="form">
  13. <form @submit="formSubmit">
  14. <view class="uni-form-item">
  15. <view class="titleA">用户名</view>
  16. <view class="input">
  17. <input placeholder="请输入用户名" v-model="formData.account" style="margin-left: 30rpx;" />
  18. </view>
  19. </view>
  20. <view class="uni-form-item">
  21. <view class="titleA">密码</view>
  22. <view class="input">
  23. <input type="password" placeholder="请输入密码" v-model="formData.password"
  24. style="margin-left: 30rpx;" />
  25. <!-- <input placeholder="请输入密码" v-model="formData.password" style="margin-left: 30rpx;" />
  26. <view class="icon">
  27. <uni-icons type="eye" size="26" @click="isC" v-show="block"></uni-icons>
  28. <uni-icons type="eye-slash" size="26" @click="isC" v-show="toggle"></uni-icons>
  29. </view> -->
  30. </view>
  31. </view>
  32. <view class="uni-form-item">
  33. <view class="titleA">验证码</view>
  34. <view class="AAA">
  35. <view class="input1">
  36. <input placeholder="请输入验证码" v-model="formData.verifyCode"
  37. style="margin-left: 30rpx;" />
  38. </view>
  39. <view class="code" @tap="handleRefreshVerifyCode">
  40. <img class="verify-img" :src="verifyCodeUrl" style="cursor: pointer">
  41. </view>
  42. </view>
  43. </view>
  44. <view class="login">
  45. <button class="loginBut" form-type="submit">登录</button>
  46. </view>
  47. <view class="forget">忘记密码</view>
  48. </form>
  49. </view>
  50. </view>
  51. </view>
  52. </view>
  53. </template>
  54. <script>
  55. export default {
  56. data() {
  57. return {
  58. verifyCodeUrl: 'http://127.0.0.1:9999/auth/verifyCode',
  59. isCollapse: false,
  60. toggle: false, //第二个图标默认隐藏
  61. block: true, //默认显示第一个图标
  62. formData: {
  63. account: '',
  64. password: '',
  65. verifyCode: '',
  66. }
  67. }
  68. },
  69. onLoad() {
  70. },
  71. methods: {
  72. handleRefreshVerifyCode() {
  73. this.verifyCodeUrl = 'http://127.0.0.1:9999/auth/verifyCode' + "?t=" + new Date()
  74. .getTime();
  75. },
  76. isC() {
  77. this.isCollapse = !this.isCollapse;
  78. this.toggle = !this.toggle;
  79. this.block = !this.block;
  80. },
  81. async formSubmit(e) {
  82. let vm = this;
  83. let url = uni.$api.auth.login;
  84. let data = {
  85. account: this.formData.account,
  86. password: this.formData.password,
  87. verifyCode: this.formData.verifyCode
  88. };
  89. let res = await uni.$http.get(url, data);
  90. console.log('form发生了submit事件')
  91. console.log(res);
  92. if (res.data.status == 200) {
  93. uni.showToast({
  94. title: res.data.desc,
  95. icon: "none"
  96. })
  97. uni.switchTab({
  98. url: '/pages/operator/operator'
  99. })
  100. }
  101. if (res.data.status == 400) {
  102. uni.showToast({
  103. title: res.data.data.errorFields[0].message,
  104. icon: "none"
  105. })
  106. }
  107. if (res.data.status == 500) {
  108. uni.showToast({
  109. title: res.data.desc,
  110. icon: "none"
  111. })
  112. }
  113. }
  114. },
  115. }
  116. </script>
  117. <style>
  118. .AAA {
  119. display: flex;
  120. flex-direction: row;
  121. }
  122. .icon {
  123. margin-left: 200rpx;
  124. }
  125. .form {
  126. margin-top: 80rpx;
  127. }
  128. .titleA {
  129. font-size: 30rpx;
  130. margin-bottom: 20rpx;
  131. margin-left: 32rpx;
  132. margin-top: 24rpx;
  133. }
  134. .input {
  135. background-color: white;
  136. width: 654rpx;
  137. margin-left: 24rpx;
  138. height: 98rpx;
  139. border-radius: 10rpx;
  140. border: 4rpx solid #F7F8F9;
  141. display: flex;
  142. align-items: center;
  143. }
  144. .verify-img {
  145. margin-left: 20rpx;
  146. width: 320rpx;
  147. height: 100rpx;
  148. border-radius: 10rpx;
  149. }
  150. .input1 {
  151. background-color: white;
  152. width: 320rpx;
  153. margin-left: 24rpx;
  154. height: 98rpx;
  155. border-radius: 10rpx;
  156. border: 4rpx solid #F7F8F9;
  157. display: flex;
  158. align-items: center;
  159. }
  160. .title1 {
  161. font-size: 44rpx;
  162. font-weight: 550;
  163. }
  164. .title2 {
  165. font-size: 26rpx;
  166. color: #AAAAAA;
  167. margin-top: 10rpx;
  168. }
  169. .title {
  170. margin-top: 60rpx;
  171. margin-left: 30rpx;
  172. display: flex;
  173. flex-direction: column;
  174. }
  175. .img {
  176. width: 750rpx;
  177. height: 1520rpx;
  178. z-index: 9;
  179. }
  180. .white {
  181. position: absolute;
  182. bottom: 40rpx;
  183. z-index: 10;
  184. width: 702rpx;
  185. height: 1060rpx;
  186. margin-left: 24rpx;
  187. background-color: #FFFFFF;
  188. opacity: 0.8;
  189. }
  190. .image {
  191. width: 750rpx;
  192. height: 1500rpx;
  193. }
  194. /* .head {
  195. height: 80rpx;
  196. background-color: white;
  197. } */
  198. .loginBut {
  199. margin-top: 60rpx;
  200. background-color: #007AFF;
  201. color: white;
  202. display: flex;
  203. align-items: center;
  204. justify-content: center;
  205. width: 654rpx;
  206. height: 98rpx;
  207. }
  208. .forget {
  209. font-size: 30rpx;
  210. color: #007AFF;
  211. display: flex;
  212. align-items: center;
  213. justify-content: center;
  214. margin-top: 30rpx;
  215. }
  216. </style>