LoginNow.vue 5.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190
  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. import { useDataStore } from '@/store/modules/golbal-data';
  35. const userStoreCode = useDataStore();
  36. export default {
  37. setup() {
  38. let less = ref("")
  39. let loginForm = ref({
  40. username: "",
  41. userpass: ""
  42. })
  43. let isLogin = ref(false)
  44. let router = useRouter()
  45. function encryptPassword(password) {
  46. let val = SmCrypto.doSm3AndSm2Encrypt(password) + '0000'
  47. let ascCode = 0
  48. for (var i = 0; i < password.length; i++) {
  49. ascCode = password.charCodeAt(i).toString(16);
  50. // console.log(ascCode,'asc');
  51. if (ascCode.length == 1) {
  52. val += '00' + ascCode
  53. } else if (ascCode.length == 2) {
  54. val += '0' + ascCode
  55. } else {
  56. val += ascCode
  57. }
  58. }
  59. console.log(val, 'val');
  60. return val
  61. }
  62. function sureLog() {
  63. let kis = encryptPassword(loginForm.value.userpass)
  64. login.LoginNow({
  65. login_account: loginForm.value.username,
  66. pwd: kis
  67. }).then(res => {
  68. console.log(res, 'login');
  69. if (res.returncode === 200) {
  70. isLogin.value = true
  71. sessionStorage.setItem("loginStatus", isLogin.value)
  72. sessionStorage.setItem("userInfo", JSON.stringify(res.data))
  73. if (typeof (window.windowEx) != "undefined") {
  74. windowEx.Size(0, 0) //全屏
  75. windowEx.Position('center')
  76. }
  77. router.push('/home/mission')
  78. userStoreCode.GlobalCodes();
  79. ElMessage({
  80. message: '登陆成功!',
  81. type: "success"
  82. })
  83. windowEx.Size(1920, 1080)
  84. // windowEx.Position('center')
  85. } else {
  86. ElMessage({
  87. message: res.msg,
  88. type: "error"
  89. })
  90. }
  91. })
  92. }
  93. function WinClose() {
  94. windowEx.Exit()
  95. }
  96. function WinMin() {
  97. windowEx.Min()
  98. }
  99. onMounted(() => {
  100. })
  101. return {
  102. encryptPassword,
  103. less,
  104. sureLog,
  105. loginForm,
  106. isLogin,
  107. WinMin,
  108. WinClose
  109. }
  110. }
  111. }
  112. </script>
  113. <style scoped>
  114. .bigBox {
  115. width: 31.8rem;
  116. height: 35.5rem;
  117. margin: 0;
  118. background: #FFFFFF;
  119. box-shadow: 0px 1px 1.25rem 2px rgba(61, 128, 177, 0.13);
  120. position: relative;
  121. border: 1px solid #ededed;
  122. border-radius: 3px;
  123. }
  124. .formBox {
  125. width: 320px;
  126. height: 244px;
  127. text-align: center;
  128. background: #FFFFFF;
  129. box-shadow: 0px 1px 1.67rem 3px rgba(52, 123, 231, 0.12);
  130. border-radius: 4px 4px 4px 4px;
  131. opacity: 1;
  132. margin: 0 auto;
  133. }
  134. .imgBox {
  135. width: 22.67rem;
  136. height: 8.33rem;
  137. margin: 0 auto;
  138. margin-left: 90px;
  139. padding-top: 40px;
  140. }
  141. .loginInp {
  142. width: 22.5rem;
  143. height: 3.33rem;
  144. margin-top: 5px;
  145. border: 1px solid #A3ADE0;
  146. }
  147. .loginBtn {
  148. width: 22.67rem;
  149. height: 3.33rem;
  150. margin-top: 10px;
  151. background-color: #255CE7;
  152. }
  153. .winBox {
  154. width: 5.67rem;
  155. height: 5.67rem;
  156. position: absolute;
  157. top: 0px;
  158. right: 0px;
  159. color: #676767;
  160. }
  161. .winBtn {
  162. width: 2.83rem;
  163. height: 2.83rem;
  164. background-color: transparent;
  165. border: none;
  166. font-size: 2.5rem;
  167. text-align: center;
  168. line-height: 2.83rem;
  169. color: #676767;
  170. }
  171. .winBtn:nth-child(1):hover {
  172. border: 1px black solid;
  173. }
  174. .winBtn:nth-child(2):hover {
  175. background-color: red;
  176. }
  177. </style>