LoginNow.vue 5.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192
  1. <template>
  2. <div>
  3. <div class="bigBox">
  4. <div class="winBox">
  5. <button class="winBtn" @click="WinMin">-</button>
  6. <button class="winBtn" @click="WinClose">×</button>
  7. </div>
  8. <!-- 信息 -->
  9. <div class="imgBox">
  10. <img src="../../assets/image/loginImg.png" alt="">
  11. <!-- <p>登录</p> -->
  12. </div>
  13. <!-- 登录信息 -->
  14. <div class="formBox">
  15. <el-form :model="loginForm" label-width="45px" style="padding-top: 24px;">
  16. <el-form-item label="账号">
  17. <el-input class="loginInp" v-model="loginForm.username" placeholder="你的账号..." maxlength="32" />
  18. </el-form-item>
  19. <el-form-item label="密码">
  20. <el-input class="loginInp" type="password" v-model="loginForm.userpass" show-password
  21. placeholder="你的密码..." maxlength="32" />
  22. </el-form-item>
  23. </el-form>
  24. <el-button class="loginBtn" type="primary" @click="sureLog" @keyup.enter="sureLog">登录</el-button>
  25. </div>
  26. </div>
  27. </div>
  28. </template>
  29. <script>
  30. import { ref, onMounted } from "vue"
  31. import { useRouter } from 'vue-router'
  32. import { ElMessage } from "element-plus"
  33. import login from "@/api/login"
  34. export default {
  35. setup() {
  36. let less = ref("")
  37. let loginForm = ref({
  38. username: "",
  39. userpass: ""
  40. })
  41. let isLogin = ref(false)
  42. let router = useRouter()
  43. function encryptPassword(password) {
  44. let val = SmCrypto.doSm3AndSm2Encrypt(password) + '0000'
  45. let ascCode = 0
  46. for (var i = 0; i < password.length; i++) {
  47. ascCode = password.charCodeAt(i).toString(16);
  48. // console.log(ascCode,'asc');
  49. if (ascCode.length == 1) {
  50. val += '00' + ascCode
  51. } else if (ascCode.length == 2) {
  52. val += '0' + ascCode
  53. } else {
  54. val += ascCode
  55. }
  56. }
  57. console.log(val, 'val');
  58. return val
  59. }
  60. function sureLog() {
  61. let kis = encryptPassword(loginForm.value.userpass)
  62. login.LoginNow({
  63. login_account: loginForm.value.username,
  64. pwd: kis
  65. }).then(res => {
  66. console.log(res, 'login');
  67. if (res.returncode === 200) {
  68. isLogin.value = true
  69. sessionStorage.setItem("loginStatus", isLogin.value)
  70. sessionStorage.setItem("userInfo", JSON.stringify(res.data))
  71. if (typeof (window.windowEx) != "undefined") {
  72. windowEx.Size(0, 0) //全屏
  73. windowEx.Position('center')
  74. }
  75. router.push('/home/mission')
  76. ElMessage({
  77. message: '登陆成功!',
  78. type: "success"
  79. })
  80. windowEx.Size(1920, 1080)
  81. // windowEx.Position('center')
  82. } else {
  83. ElMessage({
  84. message: res.msg,
  85. type: "error"
  86. })
  87. }
  88. })
  89. }
  90. function WinClose() {
  91. windowEx.Exit()
  92. }
  93. function WinMin() {
  94. windowEx.Min()
  95. }
  96. onMounted(() => {
  97. // window.onload = function () {
  98. // // 设置定时器,在 5000 毫秒(即 5 秒)后执行刷新操作
  99. // setTimeout(function () {
  100. // location.reload(); // 执行页面刷新
  101. // }, 100); // 5000 毫秒 = 5 秒
  102. // };
  103. })
  104. return {
  105. encryptPassword,
  106. less,
  107. sureLog,
  108. loginForm,
  109. isLogin,
  110. WinMin,
  111. WinClose
  112. }
  113. }
  114. }
  115. </script>
  116. <style scoped>
  117. .bigBox {
  118. width: 31.8rem;
  119. height: 35.5rem;
  120. margin: 0;
  121. background: #FFFFFF;
  122. box-shadow: 0px 1px 1.25rem 2px rgba(61, 128, 177, 0.13);
  123. position: relative;
  124. border: 1px solid #ededed;
  125. border-radius: 3px;
  126. }
  127. .formBox {
  128. width: 320px;
  129. height: 244px;
  130. text-align: center;
  131. background: #FFFFFF;
  132. box-shadow: 0px 1px 1.67rem 3px rgba(52, 123, 231, 0.12);
  133. border-radius: 4px 4px 4px 4px;
  134. opacity: 1;
  135. margin: 0 auto;
  136. }
  137. .imgBox {
  138. width: 22.67rem;
  139. height: 8.33rem;
  140. margin: 0 auto;
  141. margin-left: 90px;
  142. padding-top: 40px;
  143. }
  144. .loginInp {
  145. width: 22.5rem;
  146. height: 3.33rem;
  147. margin-top: 5px;
  148. border: 1px solid #A3ADE0;
  149. }
  150. .loginBtn {
  151. width: 22.67rem;
  152. height: 3.33rem;
  153. margin-top: 10px;
  154. background-color: #255CE7;
  155. }
  156. .winBox {
  157. width: 5.67rem;
  158. height: 5.67rem;
  159. position: absolute;
  160. top: 0px;
  161. right: 0px;
  162. color: #676767;
  163. }
  164. .winBtn {
  165. width: 2.83rem;
  166. height: 2.83rem;
  167. background-color: transparent;
  168. border: none;
  169. font-size: 2.5rem;
  170. text-align: center;
  171. line-height: 2.83rem;
  172. color: #676767;
  173. }
  174. .winBtn:nth-child(1):hover {
  175. border: 1px black solid;
  176. }
  177. .winBtn:nth-child(2):hover {
  178. background-color: red;
  179. }
  180. </style>