index.vue 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519
  1. <template>
  2. <div class="w-box index">
  3. <div class="login_box">
  4. <h2>
  5. 晋江人资团队协作平台
  6. </h2>
  7. <Form ref="login" :model="formLogin" :rules="ruleLogin" @submit.native.prevent>
  8. <FormItem prop="username">
  9. <Input type="text" v-model="formLogin.username" :placeholder="$L('用户名')" @on-enter="onLogin" @on-blur="onBlur">
  10. <Icon type="ios-person-outline" slot="prepend"></Icon>
  11. </Input>
  12. </FormItem>
  13. <FormItem prop="userpass">
  14. <Input type="password" v-model="formLogin.userpass" :placeholder="$L('密码')" @on-enter="onLogin">
  15. <Icon type="ios-lock-outline" slot="prepend"></Icon>
  16. </Input>
  17. </FormItem>
  18. <FormItem v-if="loginType=='login'&&codeNeed" prop="code">
  19. <Input type="text" v-model="formLogin.code" :placeholder="$L('验证码')" @on-enter="onLogin">
  20. <Icon type="ios-checkmark-circle-outline" slot="prepend"></Icon>
  21. <div slot="append" class="login-code" @click="refreshCode"><img :src="codeUrl"/></div>
  22. </Input>
  23. </FormItem>
  24. <Form-item style="text-align:center">
  25. <Button type="primary" :loading="loadIng > 0" @click="onLogin">登录</Button>
  26. </Form-item>
  27. </Form>
  28. </div>
  29. </div>
  30. </template>
  31. <style lang="scss" scoped>
  32. h2{
  33. line-height:100px;
  34. font-size:30px;
  35. text-align:center;
  36. }
  37. .login_box{
  38. width:70%;
  39. margin: 300px auto;
  40. }
  41. .index {
  42. position: absolute;
  43. color: #000000;
  44. top: 0;
  45. left: 0;
  46. min-width: 100%;
  47. min-height: 100%;
  48. padding: 0;
  49. margin: 0;
  50. .header {
  51. position: relative;
  52. z-index: 3;
  53. height: 50px;
  54. padding-top: 12px;
  55. max-width: 1280px;
  56. margin: 0 auto;
  57. .z-row {
  58. color: #fff;
  59. height: 50px;
  60. position: relative;
  61. z-index: 2;
  62. max-width: 1680px;
  63. margin: 0 auto;
  64. .header-col-sub {
  65. width: 500px;
  66. h2 {
  67. position: relative;
  68. padding: 1rem 0 0 1rem;
  69. display: flex;
  70. align-items: flex-end;
  71. img {
  72. width: 150px;
  73. margin-right: 6px;
  74. }
  75. span {
  76. font-size: 12px;
  77. font-weight: normal;
  78. color: rgba(255, 255, 255, 0.85);
  79. line-height: 14px;
  80. }
  81. }
  82. }
  83. .z-1 {
  84. dl {
  85. position: absolute;
  86. right: 20px;
  87. top: 0;
  88. font-size: 14px;
  89. dd {
  90. line-height: 50px;
  91. color: #fff;
  92. cursor: pointer;
  93. margin-right: 1px;
  94. .right-enterprise {
  95. padding: 1px 10px;
  96. font-size: 12px;
  97. color: #f6ca9d;
  98. background: #1d1e23;
  99. background: linear-gradient(90deg, #1d1e23, #3f4045);
  100. border: none;
  101. }
  102. .right-info {
  103. display: inline-block;
  104. cursor: pointer;
  105. margin-left: 12px;
  106. color: #ffffff;
  107. .right-icon {
  108. font-size: 26px;
  109. vertical-align: middle;
  110. }
  111. .right-img {
  112. vertical-align: middle;
  113. }
  114. }
  115. }
  116. }
  117. }
  118. }
  119. }
  120. .welbg {
  121. position: absolute;
  122. z-index: 1;
  123. top: 0;
  124. left: 0;
  125. right: 0;
  126. height: 762px;
  127. overflow: hidden;
  128. padding-top: 480px;
  129. margin-top: -480px;
  130. background: #2d8cf0;
  131. transform: skewY(-2deg);
  132. box-shadow: 0 2px 244px 0 rgba(56, 132, 255, 0.4);
  133. .second {
  134. position: relative;
  135. margin-top: 582px;
  136. height: 220px;
  137. .bg {
  138. transform: skewY(-2.5deg);
  139. display: block;
  140. position: absolute;
  141. top: 0;
  142. left: 0;
  143. right: 0;
  144. bottom: 0;
  145. background: #1F65D6;
  146. }
  147. }
  148. }
  149. .welcome {
  150. position: relative;
  151. z-index: 2;
  152. height: 700px;
  153. display: block;
  154. overflow: hidden;
  155. color: #FFFFFF;
  156. padding-top: 480px;
  157. margin-top: -480px;
  158. .unslider-arrow {
  159. display: none;
  160. }
  161. .banner {
  162. padding-top: 60px;
  163. height: 460px;
  164. max-width: 1200px;
  165. margin: 0 auto;
  166. .banner-carousel {
  167. max-width: 685px;
  168. border-radius: 5px;
  169. overflow: hidden;
  170. }
  171. img {
  172. height: 400px;
  173. border: 5px solid #fff;
  174. display: table;
  175. }
  176. }
  177. .z-8 {
  178. text-align: center;
  179. }
  180. h3 {
  181. color: rgba(255, 255, 255, 0.8);
  182. font-size: 40px;
  183. font-weight: normal;
  184. text-align: center;
  185. margin: 30px auto;
  186. width: 380px;
  187. }
  188. .start {
  189. display: inline-block;
  190. width: 160px;
  191. height: 50px;
  192. line-height: 50px;
  193. text-align: center;
  194. font-weight: normal;
  195. cursor: pointer;
  196. font-size: 20px;
  197. background: #fff;
  198. color: #0396f2;
  199. border-radius: 4px;
  200. border: 0;
  201. &:hover, &:focus {
  202. background: #f6f6f6;
  203. color: #0396f2;
  204. }
  205. }
  206. .second {
  207. position: relative;
  208. height: 220px;
  209. text-align: center;
  210. .bg {
  211. display: block;
  212. position: absolute;
  213. top: 0;
  214. left: 0;
  215. right: 0;
  216. bottom: 0;
  217. }
  218. .z-row {
  219. z-index: 2;
  220. position: relative;
  221. font-size: 22px;
  222. max-width: 1400px;
  223. margin: 0 auto;
  224. line-height: 220px;
  225. }
  226. i {
  227. color: rgba(255, 255, 255, 0.85);
  228. margin-right: 6px;
  229. }
  230. a {
  231. color: #fff;
  232. &:hover, &:visited {
  233. color: #fff;
  234. }
  235. }
  236. }
  237. }
  238. .block {
  239. max-width: 1200px;
  240. margin: 30px auto;
  241. padding-top: 50px;
  242. border: 1px solid transparent;
  243. .wrap-left, .wrap-right {
  244. line-height: 36px;
  245. color: #666;
  246. font-size: 16px;
  247. }
  248. .wrap-left {
  249. margin: 20px 30px 0 0;
  250. }
  251. .wrap-right {
  252. margin: 20px 0 0 30px;
  253. }
  254. i {
  255. color: rgba(248, 14, 21, 0.7);
  256. margin-right: 6px;
  257. }
  258. img {
  259. border: 5px solid #fff;
  260. border-radius: 10px;
  261. width: 100%;
  262. }
  263. }
  264. .p-footer {
  265. margin: 20px 0;
  266. text-align: center;
  267. color: #333;
  268. a, span {
  269. color: #333;
  270. margin-left: 10px;
  271. }
  272. }
  273. @media (max-width: 768px) {
  274. .header {
  275. .z-row {
  276. .header-col-sub {
  277. h2 {
  278. padding: 12px 0 0 12px;
  279. span {
  280. display: none;
  281. }
  282. }
  283. }
  284. }
  285. }
  286. .welbg {
  287. display: none;
  288. }
  289. .welcome {
  290. height: auto;
  291. background: #2d8cf0;
  292. transform: skewY(-2deg);
  293. box-shadow: 0 2px 244px 0 rgba(56, 132, 255, 0.4);
  294. .banner {
  295. height: auto;
  296. transform: skewY(2deg);
  297. .z-row {
  298. flex-direction: column;
  299. padding-bottom: 52px;
  300. > div {
  301. width: 90%;
  302. margin: 0 auto;
  303. }
  304. }
  305. h3 {
  306. font-size: 24px;
  307. width: auto;
  308. }
  309. img {
  310. max-width: 100%;
  311. height: auto;
  312. }
  313. }
  314. .second {
  315. height: 120px;
  316. display: flex;
  317. align-items: center;
  318. transform: skewY(2deg);
  319. .bg {
  320. transform: skewY(-4.5deg);
  321. background: #1F65D6;
  322. }
  323. .z-row {
  324. height: auto;
  325. line-height: 36px;
  326. font-size: 16px;
  327. display: block;
  328. .z-6 {
  329. width: 30%;
  330. margin: 0 5%;
  331. white-space: nowrap;
  332. }
  333. }
  334. }
  335. }
  336. .block {
  337. flex-direction: column;
  338. margin: 24px auto;
  339. padding-top: 24px;
  340. max-width: 90%;
  341. border: 0;
  342. > div {
  343. width: 96%;
  344. margin: 0 auto;
  345. }
  346. .wrap-left,
  347. .wrap-right {
  348. margin: 6px 0;
  349. line-height: 28px;
  350. }
  351. }
  352. }
  353. }
  354. </style>
  355. <script>
  356. export default {
  357. data() {
  358. return {
  359. loadIng: 0,
  360. loginShow: false,
  361. loginType: 'login',
  362. codeNeed: false,
  363. codeUrl: $A.apiUrl('users/login/codeimg'),
  364. formLogin: {
  365. username: '',
  366. userpass: '',
  367. userpass2: '',
  368. code: '',
  369. },
  370. ruleLogin: {},
  371. systemConfig: $A.jsonParse($A.storage("systemSetting")),
  372. fromUrl: '',
  373. formCustom: {
  374. passwd: '',
  375. passwdCheck: '',
  376. age: ''
  377. }
  378. }
  379. },
  380. mounted() {
  381. //
  382. },
  383. activated() {
  384. this.getSetting();
  385. this.fromUrl = decodeURIComponent($A.getObject(this.$route.query, 'from'));
  386. if (this.fromUrl) {
  387. this.loginChack();
  388. }
  389. },
  390. methods: {
  391. initLanguage() {
  392. this.ruleLogin = {
  393. username: [
  394. {required: true, message: this.$L('请填写用户名!'), trigger: 'change'},
  395. {type: 'string', min: 2, message: this.$L('用户名长度至少2位!'), trigger: 'change'}
  396. ],
  397. userpass: [
  398. {required: true, message: this.$L('请填写登录密码!'), trigger: 'change'},
  399. {type: 'string', min: 6, message: this.$L('密码错长度至少6位!'), trigger: 'change'}
  400. ]
  401. };
  402. },
  403. getSetting() {
  404. $A.apiAjax({
  405. url: 'system/setting',
  406. error: () => {
  407. $A.storage("systemSetting", {});
  408. },
  409. success: (res) => {
  410. if (res.ret === 1) {
  411. this.systemConfig = res.data;
  412. $A.storage("systemSetting", this.systemConfig);
  413. } else {
  414. $A.storage("systemSetting", {});
  415. }
  416. if (this.systemConfig.loginWin == 'direct') {
  417. this.loginChack();
  418. }
  419. }
  420. });
  421. },
  422. loginChack() {
  423. if ($A.getToken() !== false) {
  424. this.goForward({path: '/todo'}, true);
  425. } else {
  426. this.loginShow = true;
  427. }
  428. },
  429. refreshCode() {
  430. this.codeUrl = $A.apiUrl('users/login/codeimg?_=' + Math.random())
  431. },
  432. enterpriseOpen() {
  433. this.goForward({path: '/plans'});
  434. },
  435. onBlur() {
  436. if (this.loginType != 'login') {
  437. this.codeNeed = false;
  438. return;
  439. }
  440. this.loadIng++;
  441. $A.ajax({
  442. url: $A.apiUrl('users/login/needcode'),
  443. data: {
  444. username: this.formLogin.username,
  445. },
  446. complete: () => {
  447. this.loadIng--;
  448. },
  449. success: (res) => {
  450. this.codeNeed = res.ret === 1;
  451. }
  452. })
  453. },
  454. onLogin() {
  455. this.$refs.login.validate((valid) => {
  456. if (valid) {
  457. this.loadIng++;
  458. $A.ajax({
  459. url: $A.apiUrl('users/login?type=' + this.loginType),
  460. data: this.formLogin,
  461. complete: () => {
  462. this.loadIng--;
  463. },
  464. success: (res) => {
  465. if (res.ret === 1) {
  466. $A.storage("userInfo", res.data);
  467. $A.setToken(res.data.token);
  468. $A.triggerUserInfoListener(res.data);
  469. //
  470. this.loadIng--;
  471. this.loginShow = false;
  472. this.$refs.login.resetFields();
  473. this.$Message.success(this.$L('登录成功'));
  474. if (this.fromUrl) {
  475. window.location.replace(this.fromUrl);
  476. } else {
  477. this.goForward({path: '/todo'}, true);
  478. }
  479. } else {
  480. this.$Modal.error({
  481. title: this.$L("温馨提示"),
  482. content: res.msg
  483. });
  484. if (res.data.code === 'need') {
  485. this.codeNeed = true;
  486. this.refreshCode();
  487. }
  488. }
  489. }
  490. })
  491. }
  492. })
  493. }
  494. },
  495. }
  496. </script>