mobile-login.vue 5.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179
  1. <template>
  2. <div class="page-body">
  3. <van-row>
  4. <van-col span="20" offset="2">
  5. <div style="height: 25vh; font-size: 2rem; font-weight: 600">
  6. <div style="line-height: 15vh">旺庄统计平台</div>
  7. <div class="client">(企业客户端)</div>
  8. </div>
  9. </van-col>
  10. </van-row>
  11. <van-row>
  12. <van-col span="22" offset="1">
  13. <van-cell-group style="padding: 10px 20px; border-radius: 10px">
  14. <br />
  15. <van-field
  16. v-model="loginForm.username"
  17. input-align="left"
  18. center
  19. label="用户名:"
  20. placeholder="输入用户名"
  21. clearable
  22. >
  23. </van-field>
  24. <van-field
  25. v-model="loginForm.password"
  26. input-align="left"
  27. center
  28. label=" 密 码 :"
  29. type="password"
  30. placeholder="输入密码"
  31. clearable
  32. >
  33. </van-field>
  34. <van-field
  35. v-model="loginForm.validateCode"
  36. input-align="left"
  37. clearable
  38. placeholder="输入验证码"
  39. >
  40. <template #label>
  41. <span style="line-height: 32px">验证码:</span>
  42. </template>
  43. <template #button>
  44. <img
  45. id="codeImg"
  46. alt="点击更换"
  47. title="点击更换"
  48. :src="loginForm.captchaImage"
  49. @click="captchaImageRefresh(loginForm)"
  50. />
  51. </template>
  52. </van-field>
  53. <van-cell class="mmm">
  54. <template #right-icon>
  55. <van-checkbox
  56. checked-color="#1989fa"
  57. v-model="loginForm.checked"
  58. icon-size="16px"
  59. >
  60. 记住密码
  61. </van-checkbox>
  62. </template>
  63. </van-cell>
  64. <br />
  65. <br />
  66. <van-button
  67. :loading="loading"
  68. style="width: 40%; margin: 0 auto"
  69. round
  70. type="info"
  71. block
  72. @click="loginClick"
  73. >
  74. 登录
  75. </van-button>
  76. <br />
  77. <br />
  78. </van-cell-group>
  79. </van-col>
  80. </van-row>
  81. <div class="tips">2022@copyrigth 旺庄街道统计管理平台 tech. supported by idea-sf.com</div>
  82. </div>
  83. </template>
  84. <script>
  85. import { Toast } from 'vant'
  86. export default {
  87. data() {
  88. return {
  89. loginForm: {
  90. username: '',
  91. password: '',
  92. validateCode: '',
  93. captchaId: '',
  94. captchaImage: '',
  95. url: 'login_by_company',
  96. checked: true
  97. },
  98. loading: false
  99. }
  100. },
  101. created() {
  102. this.loginForm.checked = localStorage.getItem('remember') === '1'
  103. //if (this.loginForm.checked) {
  104. this.loginForm.username = localStorage.getItem('username')
  105. this.loginForm.password = localStorage.getItem('password')
  106. //}
  107. },
  108. mounted() {
  109. this.$store.dispatch('user/cleanCache')
  110. this.captchaImageRefresh(this.loginForm)
  111. },
  112. methods: {
  113. loginClick: function () {
  114. this.loading = true
  115. localStorage.setItem('remember', this.loginForm.checked ? '1' : '0')
  116. localStorage.setItem('username', this.loginForm.username)
  117. localStorage.setItem('password', this.loginForm.password)
  118. this.$store
  119. .dispatch('user/login1', this.loginForm)
  120. .then(res => {
  121. if (res.result) {
  122. this.$router.push('/mobile-home')
  123. this.loading = false
  124. Toast('登录成功')
  125. } else {
  126. Toast(res.msg)
  127. this.loading = false
  128. }
  129. })
  130. .catch(err => {
  131. console.log(err)
  132. Toast(err)
  133. this.loading = false
  134. })
  135. },
  136. captchaImageRefresh: function (_form) {
  137. _form.captchaId = this.$common.uuid(8)
  138. _form.captchaImage =
  139. this.$constant.BASE_URI +
  140. '/captcha/captchaImage?type=math&captchaId=' +
  141. _form.captchaId +
  142. '&s=' +
  143. Math.random()
  144. }
  145. }
  146. }
  147. </script>
  148. <style scoped>
  149. .page-body {
  150. height: 100vh;
  151. width: 100vw;
  152. background-image: url(../../assets/mobile-Page-Image/bg01.png);
  153. background-size: 100%;
  154. background-position: top;
  155. background-repeat: no-repeat;
  156. }
  157. .client {
  158. font-size: 1rem;
  159. font-weight: 400;
  160. }
  161. .tips {
  162. width: 60vw;
  163. margin: 2vh auto;
  164. padding: 0 20vw;
  165. color: #cccccc;
  166. font-size: 2vw;
  167. position: absolute;
  168. bottom: 0px;
  169. }
  170. .mmm:after {
  171. border-bottom: none;
  172. }
  173. </style>