管理系统PC端
25'ten fazla konu seçemezsiniz Konular bir harf veya rakamla başlamalı, kısa çizgiler ('-') içerebilir ve en fazla 35 karakter uzunluğunda olabilir.

login.vue 7.5 KiB

1 hafta önce
5 gün önce
1 hafta önce
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243
  1. <template>
  2. <div class="home_wrapper">
  3. <div class="focus_head">
  4. <div class="title">
  5. <p>Hello</p>
  6. <p>欢迎登录资源清查</p>
  7. </div>
  8. </div>
  9. <div style="position:relative;">
  10. <van-form @submit="handleLogin">
  11. <div class="login_from">
  12. <van-field
  13. v-model="formData.username"
  14. placeholder="请输入手机号/账号"
  15. left-icon="contact-o"
  16. :rules="[{ required: true, message:'' }]"
  17. />
  18. <van-field
  19. v-model="formData.password"
  20. type="password"
  21. left-icon="edit"
  22. style="margin-top: 20px"
  23. placeholder="请输入密码"
  24. :rules="[{ required: true, message:'' }]"
  25. />
  26. <div style="display: flex;width: 90%;margin: 20px auto 0;">
  27. <van-field
  28. v-model="formData.code"
  29. left-icon="shield-o"
  30. center
  31. clearable
  32. placeholder="图形验证码"
  33. />
  34. <div style="border-radius: 100vh;width: 120px;margin-left: 20px;overflow: hidden;flex-shrink: 0;">
  35. <img style="width: 120px;display: block;transform: scale(1.1);" :src="codeUrl" @click="getCode" />
  36. </div>
  37. </div>
  38. <div style="display: flex;width: 90%;margin: 20px auto 0;">
  39. <van-checkbox v-model="formData.rememberMe" shape="square">记住密码</van-checkbox>
  40. </div>
  41. </div>
  42. <div style="margin: 0px 16px 16px;border-radius: 100vh;overflow: hidden;">
  43. <van-button
  44. class="btn"
  45. color="linear-gradient(to right, #53E4A5, #24DBDB)"
  46. round
  47. block
  48. type="info"
  49. native-type="submit"
  50. :loading="loading"
  51. >登录</van-button>
  52. </div>
  53. </van-form>
  54. </div>
  55. <p class="copy">{{this.$store.getters.technicalSupport == "" ? "中农融信(北京)科技股份有限公司" : this.$store.getters.technicalSupport}}</p>
  56. </div>
  57. </template>
  58. <script>
  59. import { getCodeImg, getSmsCode } from "@/api/login";
  60. import Cookies from "js-cookie";
  61. import { encrypt, decrypt } from "../../utils/jsencrypt";
  62. //引用wx sdk
  63. // import wx from "weixin-js-sdk";
  64. export default {
  65. name: "appLogin",
  66. data() {
  67. return {
  68. formData: {
  69. username: "", //账号
  70. password: "", //密码
  71. // username:'',
  72. // password:'',
  73. code: null, //图片验证码
  74. uuid: null, //识别uuid
  75. mobile: null, //手机号
  76. smsCode: null, //短信验证码
  77. rememberMe:false
  78. },
  79. loading: false,
  80. codeUrl: "", //验证码
  81. isSmsLogin: false, //是否手机验证码
  82. computeTime: 0,
  83. height:0,
  84. show:true
  85. };
  86. },
  87. created() {
  88. this.getCode();
  89. this.height = document.body.clientHeight
  90. this.getCookie();
  91. //调用微信公众号方法
  92. // wx.config({
  93. // debug: true, // 开启调试模式,
  94. // appId: res.appId, // 必填,企业号的唯一标识,此处填写企业号corpid
  95. // timestamp: res.timestamp, // 必填,生成签名的时间戳
  96. // nonceStr: res.nonceStr, // 必填,生成签名的随机串
  97. // signature: res.signature,// 必填,签名,见附录1
  98. // jsApiList: ['scanQRCode'] // 必填,需要使用的JS接口列表,所有JS接口列表见附录2
  99. // });
  100. //分享要用encodeURIComponent()方法
  101. },
  102. methods: {
  103. showPassword(){
  104. this.show = !this.show;
  105. },
  106. getCode() {
  107. getCodeImg().then((res) => {
  108. this.formData.uuid = res.uuid;
  109. this.codeUrl = "data:image/gif;base64," + res.img;
  110. });
  111. },
  112. getCookie() {
  113. const username = Cookies.get("username");
  114. const password = Cookies.get("password");
  115. const rememberMe = Cookies.get("rememberMe");
  116. this.formData = {
  117. username: username === undefined ? this.formData.username : username,
  118. password:
  119. password === undefined ? this.formData.password : decrypt(password),
  120. rememberMe: rememberMe === undefined ? false : Boolean(rememberMe),
  121. };
  122. },
  123. getSmsCode() {
  124. if (!this.computeTime) {
  125. let myreg = /^[1][3,4,5,7,8,9][0-9]{9}$/;
  126. if (!myreg.test(this.formData.mobile)) {
  127. this.$dialog.alert({
  128. message: '手机号格式不正确',
  129. });
  130. return false;
  131. }
  132. getSmsCode(this.formData.mobile).then((res) => {
  133. if (res.code === 200) {
  134. this.$dialog.alert({
  135. message: '验证码已发送',
  136. });
  137. this.loginForm.uuid = res.uuid;
  138. this.computeTime = 60;
  139. this.timer = setInterval(() => {
  140. this.computeTime--;
  141. if (this.computeTime <= 0) {
  142. clearInterval(this.timer);
  143. }
  144. }, 1000);
  145. }
  146. });
  147. }
  148. },
  149. handleLogin(values) {
  150. if (this.formData.rememberMe) {
  151. Cookies.set("username", this.formData.username, { expires: 30 });
  152. Cookies.set("password", encrypt(this.formData.password), { expires: 30 });
  153. Cookies.set("rememberMe", this.formData.rememberMe, { expires: 30 });
  154. } else {
  155. Cookies.remove("username");
  156. Cookies.remove("password");
  157. Cookies.remove("rememberMe");
  158. }
  159. //账号密码登录
  160. if (this.formData.username == "") {
  161. this.$dialog.alert({
  162. message: '账号不能为空',
  163. });
  164. return false;
  165. } else if (this.formData.password == "") {
  166. this.$dialog.alert({
  167. message: '密码不能为空',
  168. });
  169. return false;
  170. } else if (!this.formData.code) {
  171. this.$dialog.alert({
  172. message: '图片验证码不能为空',
  173. });
  174. return false;
  175. }
  176. this.$store
  177. .dispatch("Login", this.formData)
  178. .then(() => {
  179. this.$router.push({ name: 'appIndex' || "/" }).catch(() => {});
  180. })
  181. .catch(() => {
  182. this.loading = false;
  183. this.getCode();
  184. });
  185. },
  186. },
  187. };
  188. </script>
  189. <style scoped lang="scss">
  190. ::v-deep .van-checkbox__label{
  191. color: #24DBDB;
  192. }
  193. .home_wrapper{
  194. width: 100vw;
  195. min-height: 100vh;
  196. background: #ffffff url('../../assets/images/app/login_bg.png') no-repeat center top;
  197. background-size: 100% auto;
  198. .focus_head{
  199. display: flex;
  200. align-items: center;
  201. justify-content: space-between;
  202. padding: 8vh 0 0 3vw;
  203. .title{
  204. color: #06101C;
  205. font-size: 4.5vh;
  206. p{
  207. margin-bottom: 1vh;
  208. }
  209. p:nth-child(1){
  210. font-weight: bold;
  211. }
  212. p:nth-child(2){
  213. font-size: 3vh;
  214. }
  215. }
  216. }
  217. .login_from{
  218. width: 94%;
  219. background: #ffffff;
  220. background-size: 100% 100%;
  221. margin: 30PX auto 0;
  222. padding:20px 0px 50px;
  223. border-radius: 20PX 20PX 0 0;
  224. ::v-deep.van-cell{
  225. background: #eaeef6;
  226. border-radius: 100vh;
  227. width: 90%;
  228. margin: 0 auto;
  229. }
  230. }
  231. .copy{
  232. text-align: center;
  233. color: #999999;
  234. margin-top: 20vh;
  235. }
  236. }
  237. </style>