index.vue 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610
  1. <template>
  2. <div
  3. class="login-box"
  4. :style="{
  5. height: this.windowHeight + 'px',
  6. }"
  7. >
  8. <el-row>
  9. <el-col :span="12">
  10. <div
  11. class="flex-container login login-box"
  12. :style="{
  13. height: this.windowHeight + 'px',
  14. backgroundColor: isSun ? '#f9f9f9' : '#202020',
  15. }"
  16. >
  17. <span :class="isSun ? 'logo-box-sun' : 'logo-box-moon'"></span>
  18. <img
  19. src="@/assets/images/background-left.png"
  20. alt=""
  21. class="bg-img"
  22. />
  23. <div
  24. class="desc-chn"
  25. :style="{
  26. color: !isSun ? '#FEEAEA' : '#212121',
  27. }"
  28. >
  29. # Verifiable reviews & ratings for everything in web3
  30. </div>
  31. <div
  32. class="desc-en"
  33. :style="{
  34. color: !isSun ? '#FEEAEA' : '#212121',
  35. }"
  36. >
  37. <span
  38. class="dot"
  39. :style="{
  40. backgroundColor: !isSun ? '#FEEAEA' : '#212121',
  41. }"
  42. ></span
  43. ><span class="ml-2" style="margin-top: 20px"
  44. >The world’s first verifiable review platform for NFTs, Coins,<br />
  45. DAOs, Dapps, and everything in web3</span
  46. >
  47. </div>
  48. </div>
  49. </el-col>
  50. <el-col :span="12">
  51. <div
  52. class="flex-container login-box"
  53. :style="{
  54. height: this.windowHeight + 'px',
  55. backgroundColor: isSun ? '#ffffff' : '#2e2e2e',
  56. }"
  57. >
  58. <div class="lang-box" v-show="false">
  59. <el-dropdown trigger="click">
  60. <div class="lang mt-11">
  61. Simple Chinese
  62. <svg-icon icon-class="arrow-down" />
  63. </div>
  64. <el-dropdown-menu slot="dropdown">
  65. <el-dropdown-item>中文</el-dropdown-item>
  66. <el-dropdown-item>英文</el-dropdown-item>
  67. </el-dropdown-menu>
  68. </el-dropdown>
  69. </div>
  70. <span v-show="false" @click="clickSun" style="height: 24px"
  71. ><sun-fog
  72. class="sun ml-12 mt-10"
  73. :color="isSun ? '#2980FF' : '#ababab'"
  74. /></span>
  75. <span v-show="false" @click="clickMoon" style="height: 24px">
  76. <moon
  77. class="sun ml-5 mt-10"
  78. :color="isSun ? '#292D32' : '#2980FF'"
  79. />
  80. </span>
  81. <div class="verifi">
  82. <img class="verifi-icon" src="@/assets/images/Shield.png" alt="" />
  83. <span class="verifi-url ml-2">URL verification: {{ url }}</span>
  84. </div>
  85. <div
  86. class="login-title"
  87. :style="{
  88. color: !isSun ? '#ffffff' : '#212121',
  89. }"
  90. >
  91. 管理员账户登录
  92. </div>
  93. <div class="regist"></div>
  94. <el-form
  95. ref="loginForm"
  96. :model="loginForm"
  97. :rules="loginRules"
  98. class="login-form"
  99. auto-complete="on"
  100. label-position="left"
  101. >
  102. <el-form-item prop="email">
  103. <el-input
  104. ref="email"
  105. v-model="loginForm.email"
  106. placeholder="请输入您的账号"
  107. name="email"
  108. type="text"
  109. tabindex="2"
  110. auto-complete="on"
  111. :style="{
  112. backgroundColor: isSun ? '#ffffff' : '#383838',
  113. }"
  114. />
  115. </el-form-item>
  116. <el-form-item prop="password">
  117. <el-input
  118. :key="passwordType"
  119. ref="password"
  120. v-model="loginForm.password"
  121. :type="passwordType"
  122. placeholder="请输入密码"
  123. name="password"
  124. tabindex="2"
  125. auto-complete="on"
  126. @keyup.enter.native="handleLogin"
  127. :class="isSun ? 'sun-input' : 'moon-input'"
  128. :style="{
  129. backgroundColor: isSun ? '#ffffff' : '#383838',
  130. opacity: isSun ? '#ffffff' : '#383838',
  131. }"
  132. />
  133. <span class="show-pwd" @click="showPwd">
  134. <svg-icon
  135. style="width: 20px; height: 20px"
  136. :icon-class="passwordType === 'password' ? 'eye' : 'eye-open'"
  137. />
  138. </span>
  139. </el-form-item>
  140. <div class="forget" v-show="false">忘记密码?</div>
  141. <el-button
  142. :loading="loading"
  143. type="primary"
  144. style="margin-bottom: 20px; display: block"
  145. class="btn-text mt-10"
  146. @click.native.prevent="handleLogin"
  147. >
  148. <span v-if="!loading">立即登录</span>
  149. <span v-else>登 录 中...</span>
  150. </el-button>
  151. <div v-show="false">
  152. <el-divider
  153. class="divider"
  154. :style="{
  155. backgroundColor: isSun ? '#ffffff' : '#2e2e2e',
  156. }"
  157. >
  158. </el-divider>
  159. <span
  160. class="other-account"
  161. :style="{
  162. backgroundColor: isSun ? '#ffffff' : '#2e2e2e',
  163. }"
  164. >第三方账号</span
  165. >
  166. <el-divider
  167. class="divider-right"
  168. :style="{
  169. backgroundColor: isSun ? '#ffffff' : '#2e2e2e',
  170. }"
  171. >
  172. </el-divider>
  173. </div>
  174. <div v-show="false">
  175. <el-button
  176. type="primary"
  177. class="btn-wechat mt-5"
  178. :style="{
  179. border: isSun ? '' : '1px solid #454545',
  180. backgroundColor: isSun ? '#ffffff' : '#383838',
  181. }"
  182. >
  183. <span>
  184. <Wechat
  185. :color="'#6FCF97'"
  186. style="
  187. width: 25px;
  188. height: 25px;
  189. position: relative;
  190. top: 3.5px;
  191. "
  192. />
  193. </span>
  194. <span class="wechat-text">微信登录</span>
  195. </el-button>
  196. <el-button
  197. type="primary"
  198. class="btn-qq"
  199. :style="{
  200. border: isSun ? '' : '1px solid #454545',
  201. backgroundColor: isSun ? '#ffffff' : '#383838',
  202. }"
  203. >
  204. <span>
  205. <qq
  206. :color="'#2980FF'"
  207. style="
  208. width: 25px;
  209. height: 25px;
  210. position: relative;
  211. top: 3.5px;
  212. "
  213. />
  214. </span>
  215. <span class="qq-text">QQ登录</span>
  216. </el-button>
  217. </div>
  218. </el-form>
  219. </div>
  220. </el-col>
  221. </el-row>
  222. </div>
  223. </template>
  224. <style>
  225. .el-form .el-form-item .el-input {
  226. width: 400px;
  227. height: 72px !important;
  228. border: 1px solid #f0f0f0;
  229. border-radius: 12px;
  230. box-shadow: 0px 1px 20px 0px #f5fbff inset;
  231. }
  232. .el-form .el-divider__text {
  233. padding: 0;
  234. }
  235. .el-form .el-input__inner {
  236. height: 72px !important;
  237. border-radius: 12px;
  238. backdrop-filter: blur(20px);
  239. font-size: 17px;
  240. font-family: "hm-medium";
  241. font-weight: 500;
  242. text-align: LEFT;
  243. color: #212121;
  244. line-height: 17px;
  245. }
  246. </style>
  247. <script>
  248. import CryptoJS from "crypto-js";
  249. import Cookies from "js-cookie";
  250. import { login } from "@/api/getData";
  251. import { getUserInfoByEmail, currentUser } from "@/api/user";
  252. import { getParam } from "@/api/param";
  253. import sunFog from "@/icons/icon/sun-fog.vue";
  254. import Moon from "@/icons/icon/moon.vue";
  255. import Wechat from "@/icons/icon/wechat.vue";
  256. import { getRoleIds } from "@/api/role";
  257. import Qq from "@/icons/icon/qq.vue";
  258. export default {
  259. components: { sunFog, Moon, Wechat, Qq },
  260. data() {
  261. const validatePassword = (rule, value, callback) => {
  262. if (value.length < 6) {
  263. callback(new Error("密码不能小于6位"));
  264. } else {
  265. callback();
  266. }
  267. };
  268. return {
  269. url: undefined,
  270. windowHeight: document.documentElement.clientHeight,
  271. isSun: true,
  272. loginForm: {
  273. email: undefined,
  274. username: undefined,
  275. password: undefined,
  276. systemId: undefined,
  277. nonce: undefined,
  278. },
  279. loginRules: {
  280. email: [{ required: true, trigger: "blur", message: "请输入您的邮箱" }],
  281. password: [
  282. { required: true, trigger: "blur", validator: validatePassword },
  283. ],
  284. },
  285. loading: false,
  286. passwordType: "password",
  287. redirect: undefined,
  288. };
  289. },
  290. methods: {
  291. getRoleIds() {
  292. getRoleIds().then((resp) => {
  293. Cookies.set("roles", JSON.stringify(resp), { expires: 15 });
  294. });
  295. },
  296. getUrl() {
  297. getParam("str_ams_adm_host").then((res) => {
  298. this.url = res;
  299. });
  300. },
  301. clickSun() {
  302. this.isSun = true;
  303. },
  304. clickMoon() {
  305. this.isSun = false;
  306. },
  307. showPwd() {
  308. if (this.passwordType === "password") {
  309. this.passwordType = "";
  310. } else {
  311. this.passwordType = "password";
  312. }
  313. this.$nextTick(() => {
  314. this.$refs.password.focus();
  315. });
  316. },
  317. getUserInfo() {
  318. currentUser().then((resp) => {
  319. Cookies.set("avatar", resp.avatar, { expires: 15 });
  320. Cookies.set("username", resp.username, { expires: 15 });
  321. Cookies.set("nickname", resp.username, { expires: 15 });
  322. console.log("useruseruser>>>", resp);
  323. Cookies.set("address", resp.address, { expires: 15 });
  324. Cookies.set("userId", resp.userId, { expires: 15 });
  325. });
  326. },
  327. handleLogin() {
  328. this.$refs.loginForm.validate((valid) => {
  329. if (valid) {
  330. const data = Object.assign({}, this.loginForm);
  331. const random = Math.random().toString(36).substring(2);
  332. data.password = CryptoJS.SHA256(
  333. `${CryptoJS.SHA256(data.password)}:${data.email}:${random}`
  334. ).toString();
  335. data.nonce = random;
  336. this.loading = true;
  337. login(data, random)
  338. .then((res) => {
  339. Cookies.set("email", this.loginForm.email, { expires: 15 });
  340. Cookies.set("X-UC-AuthToken", res, { expires: 15 });
  341. this.$router.push({ path: this.redirect || "/" });
  342. this.loading = false;
  343. this.getRoleIds();
  344. this.getUserInfo();
  345. setInterval(() => {
  346. if (Cookies.get("avatar")) {
  347. this.$nextTick(() => {
  348. location.reload();
  349. });
  350. }
  351. }, 300);
  352. })
  353. .catch(() => {
  354. this.loading = false;
  355. });
  356. } else {
  357. console.log("error submit!!");
  358. return false;
  359. }
  360. });
  361. },
  362. },
  363. created() {
  364. this.getUrl();
  365. },
  366. };
  367. </script>
  368. <style scoped>
  369. .login {
  370. background: #f9f9f9;
  371. }
  372. .flex-container {
  373. display: flex;
  374. justify-content: center;
  375. }
  376. .flex-container-logo {
  377. display: flex;
  378. justify-content: flex-end;
  379. }
  380. .bg-img {
  381. width: 400px;
  382. height: 400px;
  383. position: absolute;
  384. top: 22.2%;
  385. left: 20.7%;
  386. }
  387. .logo-box-sun {
  388. top: 40px;
  389. width: 210px;
  390. height: 50px;
  391. background-image: url("../../assets/images/logo.png");
  392. background-repeat: no-repeat;
  393. position: absolute;
  394. }
  395. .logo-box-moon {
  396. top: 40px;
  397. display: flex;
  398. width: 164px;
  399. height: 40px;
  400. /* background-image: url("../../images/NextSign-Moon.png"); */
  401. position: relative;
  402. background-repeat: no-repeat;
  403. left: 13.8%;
  404. }
  405. .desc-chn {
  406. top: 703px;
  407. display: flex;
  408. position: absolute;
  409. left: 20.7%;
  410. font-size: 29px;
  411. font-family: "hm-black";
  412. font-weight: 900;
  413. text-align: LEFT;
  414. color: #212121;
  415. line-height: 29px;
  416. text-shadow: 4px 4px 20px 0px rgba(15, 15, 15, 0.16);
  417. width: 422px;
  418. height: 80px;
  419. }
  420. .dot {
  421. opacity: 0.5;
  422. background-color: #212121;
  423. height: 5px;
  424. width: 5px;
  425. border-radius: 50%;
  426. position: relative;
  427. top: 24px;
  428. }
  429. .desc-en {
  430. top: 775px;
  431. display: flex;
  432. position: absolute;
  433. left: 20.7%;
  434. opacity: 0.5;
  435. font-size: 15px;
  436. font-family: "hm-medium";
  437. font-weight: 500;
  438. text-align: LEFT;
  439. color: #212121;
  440. line-height: 15px;
  441. text-shadow: 4px 4px 20px 0px rgba(15, 15, 15, 0.16);
  442. }
  443. .lang-box {
  444. height: 45px;
  445. position: relative;
  446. cursor: pointer;
  447. }
  448. .lang {
  449. font-size: 13px;
  450. font-family: "hm-medium";
  451. font-weight: 500;
  452. text-align: LEFT;
  453. color: #2980ff;
  454. line-height: 13px;
  455. }
  456. .sun {
  457. cursor: pointer;
  458. }
  459. .verifi {
  460. position: absolute;
  461. top: 25.4%;
  462. left: 61%;
  463. }
  464. .verifi-icon {
  465. position: relative;
  466. top: 3px;
  467. }
  468. .verifi-url {
  469. font-size: 12px;
  470. font-family: "hm-regular";
  471. font-weight: 400;
  472. text-align: LEFT;
  473. color: #6fcf97;
  474. line-height: 12px;
  475. }
  476. .login-title {
  477. font-size: 24px;
  478. font-family: "hm-bold";
  479. font-weight: 700;
  480. text-align: LEFT;
  481. color: #212121;
  482. line-height: 24px;
  483. position: absolute;
  484. top: 28.5%;
  485. left: 61%;
  486. }
  487. .regist {
  488. position: absolute;
  489. top: 32%;
  490. left: 61%;
  491. }
  492. .regist-desc {
  493. font-size: 14px;
  494. font-family: "hm-regular";
  495. font-weight: 400;
  496. text-align: LEFT;
  497. color: #888888;
  498. }
  499. .regist-link {
  500. font-size: 14px;
  501. font-family: "hm-regular";
  502. font-weight: 400;
  503. text-align: LEFT;
  504. color: #2980ff;
  505. cursor: pointer;
  506. }
  507. .login-form {
  508. position: absolute;
  509. top: 36.7%;
  510. left: 61%;
  511. }
  512. .show-pwd {
  513. position: absolute;
  514. right: 10px;
  515. top: 18px;
  516. color: #889aa4;
  517. cursor: pointer;
  518. user-select: none;
  519. }
  520. .btn-text {
  521. width: 400px;
  522. height: 60px;
  523. background-color: #ffffff;
  524. border-radius: 12px;
  525. color: #2980ff;
  526. font-size: 17px;
  527. font-family: "hm-medium";
  528. font-weight: 500;
  529. text-align: center;
  530. line-height: 17px;
  531. border: 1px solid #f4f4f8;
  532. }
  533. .btn-text:hover {
  534. box-shadow: 0px 1px 20px 0px rgba(0, 0, 0, 0.06);
  535. color: #ffffff !important;
  536. background: #2980ff;
  537. }
  538. .other-account {
  539. font-size: 12px;
  540. font-family: "hm-medium";
  541. font-weight: 500;
  542. text-align: LEFT;
  543. color: #888888;
  544. line-height: 12px;
  545. padding: 0 20px;
  546. position: relative;
  547. top: -20px;
  548. }
  549. .btn-wechat {
  550. width: 188px;
  551. height: 60px;
  552. background: #ffffff;
  553. border: 1px solid #e0e0e0;
  554. border-radius: 12px;
  555. }
  556. .btn-qq {
  557. width: 188px;
  558. height: 60px;
  559. background: #ffffff;
  560. border: 1px solid #e0e0e0;
  561. border-radius: 12px;
  562. margin-left: 23px !important;
  563. }
  564. .wechat-text {
  565. font-size: 15px;
  566. font-family: "hm-medium";
  567. font-weight: 500;
  568. text-align: center;
  569. color: #6fcf97;
  570. line-height: 15px;
  571. position: relative;
  572. top: -3px;
  573. left: 10px;
  574. }
  575. .qq-text {
  576. font-size: 15px;
  577. font-family: "hm-medium";
  578. font-weight: 500;
  579. text-align: LEFT;
  580. color: #2980ff;
  581. line-height: 15px;
  582. position: relative;
  583. top: -3px;
  584. left: 10px;
  585. }
  586. .divider {
  587. display: inline-block;
  588. width: 148px;
  589. }
  590. .divider-right {
  591. display: inline-block;
  592. width: 152px;
  593. }
  594. .forget {
  595. font-size: 15px;
  596. font-family: "hm-medium";
  597. font-weight: 500;
  598. text-align: right;
  599. color: #ff6b6b;
  600. line-height: 15px;
  601. cursor: pointer;
  602. }
  603. </style>