dzflogin.vue 5.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232
  1. <template>
  2. <view class="zai-box">
  3. <view class="zai-title2">
  4. <form class="zai-form">
  5. <view class="title1">企业大走访</view>
  6. <view class="formg">
  7. <image class="formimg" src="@/static/img/zhanghao-.png"></image>
  8. <input class="formgin" placeholder="请输入账号" v-model="account" name="input"></input>
  9. </view>
  10. <view class="formg">
  11. <image class="formimg" src="@/static/img/mima.png"></image>
  12. <input class="formgin" placeholder="请输入密码" type="password" displayable v-model="password" name="input"></input>
  13. </view>
  14. <view class="formg">
  15. <image class="formimg" src="@/static/img/yanzhengma.png"></image>
  16. <input class="formgin" placeholder="请输入验证码" v-model="code" name="input"></input>
  17. <image @click="getCaptcha" style="height: 50rpx;width: 160rpx;" :src="captchaImg" mode="aspectFill"></image>
  18. </view>
  19. <view >
  20. <view class="button " @click="bindLogin">登录</view>
  21. </view>
  22. </form>
  23. <!-- <view class="zai-label" @click="gotoNewPass">忘记密码?</view> -->
  24. </view>
  25. </view>
  26. </template>
  27. <script>
  28. import * as $auth from "@/common/auth.js"
  29. import loginService from "@/api/auth/loginService"
  30. import {mapActions} from 'vuex'
  31. export default {
  32. data() {
  33. return {
  34. captchaImg: '',
  35. account: '',
  36. password: '',
  37. code: '',
  38. uuid: ''
  39. }
  40. },
  41. created() {
  42. this.getCaptcha()
  43. },
  44. methods: {
  45. ...mapActions(['refreshUserInfo']),
  46. gotoNewPass() {
  47. uni.navigateTo({
  48. url: '/pages/newPass/newPass'
  49. })
  50. },
  51. // 登录
  52. bindLogin() {
  53. /**
  54. * 客户端对账号信息进行一些必要的校验。
  55. * 实际开发中,根据业务需要进行处理,这里仅做示例。
  56. */
  57. if (this.account.length < 1) {
  58. uni.showToast({
  59. icon: 'none',
  60. title: '账号不能为空'
  61. });
  62. return;
  63. }
  64. if (this.password.length < 1) {
  65. uni.showToast({
  66. icon: 'none',
  67. title: '密码不能为空'
  68. });
  69. return;
  70. }
  71. const inputForm ={
  72. 'username': this.account,
  73. 'password': this.password,
  74. 'code': this.code,
  75. 'uuid': this.uuid
  76. }
  77. loginService.login(inputForm).then(({data}) => {
  78. this.$store.commit('SET_TOKEN',data.token);
  79. this.refreshUserInfo();
  80. setTimeout(function() {
  81. uni.reLaunch({
  82. url: '../index/Tabindex',
  83. });
  84. },1000)
  85. }).catch(e => {
  86. this.getCaptcha()
  87. console.error(e)
  88. })
  89. },
  90. // 获取验证码
  91. getCaptcha () {
  92. loginService.getCode().then(({data}) => {
  93. this.captchaImg = 'data:image/gif;base64,' + data.codeImg
  94. this.uuid = data.uuid
  95. })
  96. }
  97. }
  98. }
  99. </script>
  100. <style>
  101. .zai-box{
  102. background-size: cover;
  103. background-position: center;
  104. background-repeat: no-repeat;
  105. height: 100vh; /* 设置高度,确保背景图片显示完整 */
  106. display: flex;
  107. justify-content: center;
  108. background-image: url('~@/static/login.png');
  109. background-size: cover; /* 调整图片大小以覆盖整个屏幕 */
  110. background-position: center; /* 图片居中 */
  111. background-repeat: no-repeat; /* 防止图片重复 */
  112. }
  113. .zai-title2{
  114. display: flex;
  115. flex-direction: column;
  116. align-items: center; /* 水平居中 */
  117. }
  118. .zai-title{
  119. margin-top: 260upx;
  120. color: #fff;
  121. width: 100%; /* 可选:确保图片适应容器宽度 */
  122. max-width: 610rpx;
  123. height: 100rpx;
  124. }
  125. /* .title1{
  126. font-size: 32upx;
  127. font-weight: 600;
  128. color: #000;
  129. } */
  130. .title1 {
  131. font-size: 48rpx;
  132. font-weight: bold;
  133. line-height: 48rpx;
  134. text-shadow: -1px 2px 1px rgba(0, 0, 0, 0.1);
  135. background: -webkit-linear-gradient(45deg, #15EDFF, #23C1D7);
  136. /* Chrome, Safari */
  137. background: linear-gradient(45deg, #15EDFF, #23C1D7);
  138. /* 标准语法 */
  139. -webkit-background-clip: text;
  140. /* Chrome, Safari */
  141. background-clip: text;
  142. -webkit-text-fill-color: transparent;
  143. /* Chrome, Safari */
  144. color: transparent;
  145. /* 在不支持 -webkit-text-fill-color 的浏览器中,字体颜色设置为透明 */
  146. }
  147. .zai-form{
  148. margin-top: 200px;
  149. border-radius: 16px;
  150. height: 650upx;
  151. background: rgba(255, 255, 255, 0.8);
  152. padding: 45upx;
  153. margin-left: 50upx;
  154. margin-right: 50upx;
  155. }
  156. .formg{
  157. display: flex;
  158. padding-bottom: 43upx;
  159. padding-top: 43upx;
  160. border-bottom: 1px solid #dcdcdc;
  161. }
  162. .formimg{
  163. width: 42upx;
  164. height: 42upx;
  165. }
  166. .formgin{
  167. margin-left: 32upx;
  168. width: 250upx;
  169. }
  170. .zai-input{
  171. background: #e2f5fc;
  172. margin-top: 30upx;
  173. border-radius: 100upx;
  174. padding: 20upx 40upx;
  175. font-size: 36upx;
  176. }
  177. .input-placeholder, .zai-input{
  178. color: #94afce;
  179. }
  180. .zai-label{
  181. padding: 60upx 0;
  182. text-align: center;
  183. font-size: 30upx;
  184. color: #a7b6d0;
  185. }
  186. .zai-btn{
  187. background: #ff65a3;
  188. color: #fff;
  189. border: 0;
  190. border-radius: 100upx;
  191. font-size: 36upx;
  192. }
  193. .zai-btn:after{
  194. border: 0;
  195. }
  196. /*按钮点击效果*/
  197. .zai-btn.button-hover{
  198. transform: translate(1upx, 1upx);
  199. }
  200. .cu-form-group .title {
  201. min-width: calc(4em + 15px);
  202. }
  203. .button {
  204. width: 100%;
  205. height: 40px;
  206. margin-top: 30upx;
  207. border-radius: 16px;
  208. text-align: center;
  209. line-height: 40px;
  210. letter-spacing: 4px;
  211. color: #fff;
  212. cursor: pointer;
  213. background-color: #22c8db !important;
  214. color: #fff !important;
  215. }
  216. </style>