1
0

login.vue 8.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352
  1. <template>
  2. <div class="login">
  3. <div class="header">
  4. <div class="inner">
  5. <div class="header-left">
  6. <div class="header-left-logo">
  7. <img src="~@/assets/images/login/icon.png" alt="" />
  8. </div>
  9. <div class="header-left-line"></div>
  10. <div class="header-left-text">
  11. <div style="font-size: 24px">CZO智能分析管理系统</div>
  12. <div style="font-size: 12px">Enterprise management integration platform</div>
  13. </div>
  14. </div>
  15. <div class="header-right">
  16. <span>合同样本</span>
  17. <span>税收政策</span>
  18. <span>政府惠企政策</span>
  19. <span>四险一金</span>
  20. </div>
  21. </div>
  22. </div>
  23. <div class="main">
  24. <div class="inner">
  25. <div class="main-info">
  26. <div class="main-info-text">企业智能信息化 高效管理 节能降耗</div>
  27. <div class="main-info-text" style="margin-top: 20px">实现 标准化、机制化、流程化、责任化、市场化、人性化</div>
  28. <div class="main-info-link">
  29. <a href="javascript:void(0);">产品视频</a>
  30. <a href="javascript:void(0);">企业诊断</a>
  31. </div>
  32. </div>
  33. <div class="main-login">
  34. <div class="main-login-title">黑龙江省华滋佐味酿造有限公司</div>
  35. <div class="main-login-form">
  36. <div class="main-login-from-user">
  37. <label>
  38. <span>账号</span>
  39. <input type="text" auto-complete="off" v-model="formData.username" @keyup.enter="handleLogin" />
  40. </label>
  41. </div>
  42. <div class="main-login-from-pass">
  43. <label>
  44. <span>密码</span>
  45. <input type="password" auto-complete="off" v-model="formData.password" @keyup.enter="handleLogin" />
  46. </label>
  47. </div>
  48. <div class="main-login-from-com">
  49. <label>
  50. <span>公司</span>
  51. <select v-model="formData.companyId" class="com-select">
  52. <option v-for="item in comList" :key="item.companyId" :value="item.companyId">{{ item.companyName }}</option>
  53. </select>
  54. </label>
  55. </div>
  56. <div class="main-login-from-pass">
  57. <label>
  58. <span>验证码</span>
  59. <input type="text" auto-complete="off" v-model="formData.code" style="width: 150px" @keyup.enter="handleLogin" />
  60. <img :src="codeUrl" @click="getCode" class="login-code-img" />
  61. </label>
  62. </div>
  63. <div class="main-login-from-btn">
  64. <button @click="handleLogin">
  65. <span v-if="!loading">立即登录</span>
  66. <span v-else>登 录 中...</span>
  67. </button>
  68. </div>
  69. </div>
  70. </div>
  71. </div>
  72. </div>
  73. <div class="footer">
  74. <div class="inner">
  75. <a href="javascript:void(0);">代理商</a>
  76. <a href="javascript:void(0);">加盟商</a>
  77. <a href="javascript:void(0);">合作商</a>
  78. </div>
  79. </div>
  80. </div>
  81. </template>
  82. <script>
  83. import { getCodeImg, getComList } from '@/api/login'
  84. import Cookies from 'js-cookie'
  85. import { encrypt, decrypt } from '@/utils/jsencrypt'
  86. export default {
  87. data() {
  88. return {
  89. codeUrl: '',
  90. loading: false,
  91. formData: {
  92. username: 'admin',
  93. password: 'admin123',
  94. code: '',
  95. uuid: '',
  96. companyId: 0
  97. },
  98. redirect: undefined,
  99. comList: []
  100. }
  101. },
  102. watch: {
  103. $route: {
  104. handler: function (route) {
  105. this.redirect = route.query && route.query.redirect
  106. },
  107. immediate: true
  108. }
  109. },
  110. created() {
  111. this.getCode()
  112. //this.getCookie();
  113. },
  114. methods: {
  115. getCode() {
  116. getCodeImg().then(res => {
  117. this.captchaOnOff = res.captchaOnOff === undefined ? true : res.captchaOnOff
  118. if (this.captchaOnOff) {
  119. this.codeUrl = 'data:image/gif;base64,' + res.img
  120. this.formData.uuid = res.uuid
  121. }
  122. })
  123. getComList().then(res => {
  124. if (res.code === 200) {
  125. this.comList = res.data
  126. res.data.length && (this.formData.companyId = res.data[0].companyId)
  127. }
  128. })
  129. },
  130. handleLogin() {
  131. if (this.formData.username.trim() == '') {
  132. this.$msg({ type: 'error', message: '账号不能为空' })
  133. return
  134. }
  135. if (this.formData.password.trim() == '') {
  136. this.$msg({ type: 'error', message: '密码不能为空' })
  137. return
  138. }
  139. if (this.formData.code.trim() == '') {
  140. this.$msg({ type: 'error', message: '未输入验证码' })
  141. return
  142. }
  143. this.loading = true
  144. this.$store
  145. .dispatch('Login', this.formData)
  146. .then(() => {
  147. this.$router.push({ path: this.redirect || '/' }).catch(() => {})
  148. })
  149. .catch(() => {
  150. this.loading = false
  151. })
  152. }
  153. }
  154. }
  155. </script>
  156. <style scoped lang="scss">
  157. .login {
  158. width: 100%;
  159. height: 100vh;
  160. .login-code-img {
  161. width: 80px;
  162. height: 30px;
  163. }
  164. .header,
  165. .footer {
  166. width: 100%;
  167. height: 80px;
  168. background: url('~@/assets/images/login/line.jpg') 0 0 no-repeat;
  169. }
  170. .main {
  171. width: 100%;
  172. height: calc(100vh - 160px);
  173. background: url('~@/assets/images/login/main.jpg') 0 0 no-repeat;
  174. }
  175. .inner {
  176. width: 80%;
  177. margin: 0 auto;
  178. display: flex;
  179. }
  180. .header {
  181. .inner {
  182. height: 80px;
  183. justify-content: space-between;
  184. align-items: center;
  185. .header-left {
  186. display: flex;
  187. color: #fff;
  188. .header-left-logo,
  189. .header-left-line,
  190. .header-left-text {
  191. height: 60px;
  192. display: flex;
  193. align-items: center;
  194. }
  195. .header-left-line {
  196. width: 2px;
  197. background: url('~@/assets/images/login/1.png') 0 0 no-repeat;
  198. margin: 0 5px;
  199. }
  200. .header-left-text {
  201. height: 50px;
  202. align-items: flex-start;
  203. flex-direction: column;
  204. justify-content: space-around;
  205. }
  206. }
  207. .header-right {
  208. height: 60px;
  209. display: flex;
  210. align-items: flex-end;
  211. span {
  212. background-color: #3cc3cc;
  213. display: inline-block;
  214. border-radius: 5px;
  215. padding: 3px 5px;
  216. margin-left: 8px;
  217. }
  218. }
  219. }
  220. }
  221. .footer {
  222. .inner {
  223. height: 80px;
  224. align-items: center;
  225. a {
  226. display: inline-block;
  227. background-color: #3cc3cc;
  228. border-radius: 5px;
  229. -webkit-box-shadow: 0 0 11px 3px #4fcaca inset;
  230. box-shadow: inset 0 0 11px 3px #4fcaca;
  231. width: 175px;
  232. height: 50px;
  233. border: 1px solid #000;
  234. font-size: 18px;
  235. margin-right: 8px;
  236. color: #fff;
  237. text-align: center;
  238. line-height: 50px;
  239. }
  240. }
  241. }
  242. .main {
  243. .inner {
  244. height: 100%;
  245. align-items: center;
  246. justify-content: space-between;
  247. .main-info {
  248. .main-info-text {
  249. color: #fff;
  250. font-size: 28px;
  251. font-weight: bolder;
  252. }
  253. .main-info-link {
  254. margin-top: 100px;
  255. a {
  256. display: inline-block;
  257. width: 175px;
  258. height: 50px;
  259. color: #fff;
  260. border-radius: 5px;
  261. text-align: center;
  262. line-height: 50px;
  263. font-size: 18px;
  264. border: 1px solid #000;
  265. &:first-child {
  266. background: rgba(7, 34, 83, 0.89);
  267. -webkit-box-shadow: 0 0 11px 3px rgba(8, 49, 157, 0.8) inset;
  268. box-shadow: inset 0 0 11px 3px rgba(8, 49, 157, 0.8);
  269. }
  270. &:last-child {
  271. background: rgba(51, 204, 204, 0.7);
  272. -webkit-box-shadow: 0 0 11px 3px #4fcaca inset;
  273. box-shadow: inset 0 0 11px 3px #4fcaca;
  274. margin-left: 8px;
  275. }
  276. }
  277. }
  278. }
  279. .main-login {
  280. width: 360px;
  281. .main-login-title {
  282. width: 100%;
  283. height: 45px;
  284. line-height: 45px;
  285. font-size: 18px;
  286. background: #07276a;
  287. border-radius: 5px 5px 0 0;
  288. color: #fff;
  289. text-align: center;
  290. }
  291. .main-login-form {
  292. width: 100%;
  293. background: #a4a4af;
  294. border-radius: 0 0 5px 5px;
  295. padding: 40px 30px;
  296. box-sizing: border-box;
  297. .main-login-from-user,
  298. .main-login-from-pass,
  299. .main-login-from-com {
  300. width: 300px;
  301. border: 1px solid #000;
  302. height: 30px;
  303. border-radius: 5px;
  304. margin-bottom: 10px;
  305. overflow: hidden;
  306. label {
  307. display: flex;
  308. span {
  309. display: inline-block;
  310. width: 70px;
  311. height: 50px;
  312. background-color: #a6a6a6;
  313. text-align: center;
  314. line-height: 30px;
  315. }
  316. input {
  317. display: block;
  318. width: 230px;
  319. height: 30px;
  320. padding: 0;
  321. margin: 0;
  322. border: none;
  323. background-color: #fff;
  324. outline: none;
  325. line-height: 30px;
  326. padding-left: 5px;
  327. }
  328. }
  329. .com-select {
  330. width: 235px;
  331. height: 30px;
  332. outline: none;
  333. }
  334. }
  335. .main-login-from-btn {
  336. button {
  337. width: 100%;
  338. color: #fff;
  339. background-color: #07276a;
  340. height: 50px;
  341. border-radius: 5px;
  342. outline: none;
  343. }
  344. }
  345. }
  346. }
  347. }
  348. }
  349. }
  350. </style>