You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

488 lines
18 KiB

2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
  1. <template>
  2. <div :class="['tw-h-full tw-p-[30px] tw-bg-white md:tw-bg-primary-pale']">
  3. <div
  4. class="xl:tw-grid xl:tw-grid-cols-[auto_414px] xl:tw-gap-[96px] xl:tw-max-w-[1246px] xl:tw-mx-auto xl:tw-px-[60px]">
  5. <div class="tw-hidden xl:tw-block xl:tw-mt-[30px]">
  6. <p class="welcome tw-text-primary-light">{{ $t("Welcome to ShowEasy") }}</p>
  7. <p class="sub tw-text-neutral-400">
  8. {{
  9. $t(
  10. "Your best guide from trip to show and from show to the world."
  11. )
  12. }}
  13. </p>
  14. <img class="mt-11 ml-15" :src="require('@/assets/img/UserLoginMain.png')" />
  15. </div>
  16. <div class="md:tw-w-[414px] md:tw-mx-auto">
  17. <div class="tw-bg-white tw-mt-[30px] md:tw-rounded-[24px] md:tw-pt-[60px] md:tw-pb-[150px] md:tw-px-[30px]">
  18. <h1 class="tw-text-[40px] tw-font-bold tw-mb-[20px] md:tw-text-[24px]">{{ $t('Login') }}</h1>
  19. <p class="tw-body-3 tw-text-neutral-400 tw-mb-[16px] md:tw-mb-[12px]">
  20. {{ $t('Welcome back! Please enter your details') }}
  21. </p>
  22. <p class="tw-body-3 tw-mb-[24px] md:tw-mb-[32px]">{{ $t('Not a member?') }} <nuxt-link
  23. :to="localePath('/user/signup')" class="primary--text text-decoration-none">{{ $t('Sign up') }}</nuxt-link>
  24. </p>
  25. <!-- <div class="tw-grid tw-grid-cols-1 tw-gap-[10px] tw-mb-[30px] md:tw-gap-[12px] md:tw-mb-[12px]">
  26. <button @click="googleLogin"
  27. class="tw-block tw-w-full tw-py-[8px] tw-rounded-[16px] tw-border tw-border-solid tw-text-black tw-border-neutrals-200"><img
  28. width="20px" height="20px" src="~/assets/img/g-normal.png" class="mr-5" />{{ $t('Login with Google')
  29. }}</button>
  30. <button @click="facebookLogin"
  31. class="tw-block tw-w-full tw-py-[8px] tw-rounded-[16px] tw-border tw-border-solid tw-text-black tw-border-neutrals-200"><img
  32. width="20px" height="20px" src="~/assets/img/f_logo_RGB-Blue_72.png" class="mr-5" />
  33. {{ $t("Login with Facebook")
  34. }}</button>
  35. </div>
  36. <div class="tw-grid tw-grid-cols-[auto_16px_auto] tw-gap-[28px] tw-mb-[6px]">
  37. <div class="tw-flex tw-justify-center tw-items-center">
  38. <div class="tw-w-full tw-h-[1px] tw-bg-neutral-200"></div>
  39. </div>
  40. <div class="tw-text-neutral-400 tw-body-3 tw-font-normal">{{ $t("or") }}</div>
  41. <div class="tw-flex tw-justify-center tw-items-center">
  42. <div class="tw-w-full tw-h-[1px] tw-bg-neutral-200"></div>
  43. </div>
  44. </div> -->
  45. <div v-if="wrongMessageActive" class="warning--text text-size-14 ps-1 mb-3">
  46. {{ $t('The username or password entered is incorrect') }}
  47. </div>
  48. <v-form ref="loginFormRef" lazy-validation>
  49. <!-- <div v-if="$auth.$storage.getUniversal('userAccount') && $auth.$storage.getUniversal('userPassword')"></div>
  50. <div v-else></div> -->
  51. <v-text-field
  52. v-model="userData.Account" background-color="neutrals darken-1" :label="this.$t('Email')"
  53. :placeholder="this.$t('Email')" height="40px" filled rounded dense single-line persistent-placeholder
  54. :rules="[rules.email,rules.require]" v-on:input="updateValid"
  55. />
  56. <v-text-field
  57. v-model="userData.Password" background-color="neutrals darken-1" :label="this.$t('Password')"
  58. :type=" showPass ? 'text' : 'password'" :placeholder="this.$t('Password')" filled rounded dense single-line
  59. persistent-placeholder :append-icon=" showPass ? 'mdi-eye' : 'mdi-eye-off'" @click:append="showPass = !showPass"
  60. :rules="[rules.checkPassword,rules.require]" v-on:input="updateValid" @keyup.enter="userLogin"
  61. />
  62. </v-form>
  63. <div class="tw-flex tw-justify-between tw-items-center tw-mb-[28px] md:tw-mb-[32px]">
  64. <div class="tw-flex tw-items-center">
  65. <div class="tw-flex tw-items-center">
  66. <div class="tw-flex tw-flex-col">
  67. <label class="tw-body-4 container-checkbox" for="remember">
  68. {{ $t('Remember me')
  69. }}
  70. <input id="remember" type="checkbox" value="remember" v-model="remember" />
  71. <span class="checkmark"></span>
  72. </label>
  73. </div>
  74. </div>
  75. </div>
  76. <div class="tw-flex tw-items-center">
  77. <nuxt-link class="complementary--text text-decoration-none text-size-14" :to="localePath('/user/forgot')">{{
  78. $t('Forgot Password?') }}</nuxt-link>
  79. </div>
  80. </div>
  81. <div class="md:tw-flex md:tw-justify-center md:tw-items-center"> <button @click="userLogin" :disabled="!valid"
  82. :class="['tw-block tw-w-full tw-py-[10px] tw-rounded-[16px] tw-border tw-border-solid tw-body-3 tw-font-normal tw-transition-all tw-duration-200 tw-ease-in-out',valid?'tw-text-white tw-bg-primary-default tw-border-primary-default':'tw-text-base-disable tw-bg-neutral-100 tw-border-neutral-100']">{{
  83. $t("Login")
  84. }}</button></div>
  85. <v-dialog v-model="dialog" :width="$vuetify.breakpoint.smAndUp ? 423 : 294"
  86. @click:outside="colseDialog()">
  87. <v-card class="tw-p-[30px]" :height="$vuetify.breakpoint.smAndUp ? 289 : 290">
  88. <v-spacer class="d-flex align-center tw-justify-between tw-mb-[30px]">
  89. <div class="tw-text-[20px] tw-font-bold tw-text-black">
  90. {{ $t("Verify your email") }}
  91. </div>
  92. <v-btn @click="colseDialog()" icon>
  93. <v-icon> mdi-close </v-icon>
  94. </v-btn>
  95. </v-spacer>
  96. <v-spacer class="tw-mb-[40px]">
  97. <div class="tw-text-[16px] tw-text-neutrals-800">
  98. {{ $t("Oops! Seems like you haven't verified your email,please click the button below to resend a verification email.")}}
  99. </div>
  100. </v-spacer>
  101. <button @click="resendVerifyEmail()" :class="['tw-text-white tw-bg-primary-1 hover:tw-bg-primary-light tw-text-[18px] tw-rounded-[16px] tw-px-[77px] tw-py-[13px]']">
  102. {{ $t("Resend verification email") }}
  103. </button>
  104. <!-- <v-btn @click="resendVerifyEmail" class="tw-bg-primary-1 hover:tw-bg-primary-light tw-text-white tw-text-[18px] tw-rounded-[16px] tw-px-[77px] tw-py-[13px]"
  105. :disabled="countdown > 0">
  106. {{ $t("Resend verification email") }}
  107. <span v-if="countdown > 0">
  108. {{ `(${this.countdown})` }}
  109. </span>
  110. </v-btn> -->
  111. </v-card>
  112. </v-dialog>
  113. <v-dialog v-model="deleteDialog" :width="$vuetify.breakpoint.smAndUp ? 423 : 294"
  114. @click:outside="colseDialog()">
  115. <v-card class="tw-p-[30px]" :height="$vuetify.breakpoint.smAndUp ? 289 : 290">
  116. <v-spacer class="d-flex tw-justify-between align-center tw-mb-[30px]">
  117. <div class="tw-text-[20px] tw-text-black tw-font-bold">
  118. {{ $t("Reactivate your account") }}
  119. </div>
  120. <v-btn @click="colseDialog()" icon>
  121. <v-icon> mdi-close </v-icon>
  122. </v-btn>
  123. </v-spacer>
  124. <v-spacer class="tw-mb-[40px]">
  125. <div class="tw-text-[16px] tw-text-neutrals-800 tw-font-bold">
  126. {{ $t("Welcome back!")}}
  127. </div>
  128. <div class="tw-text-[16px] tw-text-neutrals-800">
  129. {{ $t("Looks like your account has been deactivated.")}}
  130. <br />
  131. {{ $t("Would you like to reactivate this account?")}}
  132. </div>
  133. </v-spacer>
  134. <button @click="ReactivateAccount()" class="tw-bg-primary-1 tw-text-white hover:tw-bg-primary-light tw-text-[18px] tw-rounded-[16px] tw-px-[86px] tw-py-[13px]">
  135. {{ $t("Reactivate my account") }}
  136. </button>
  137. <!-- <v-btn class="primary tw-w-auto" rounded
  138. :disabled="countdown > 0">
  139. <span v-if="countdown > 0">
  140. {{ `(${this.countdown})` }}
  141. </span>
  142. </v-btn> -->
  143. </v-card>
  144. </v-dialog>
  145. </div>
  146. </div>
  147. </div>
  148. </div>
  149. </template>
  150. <script>
  151. import { getCurrentTime } from "~/utils/assist";
  152. export default {
  153. name: "login",
  154. layout: "login",
  155. auth: false,
  156. data() {
  157. return {
  158. timer: null,
  159. showPass: false,
  160. resendDialog: false,
  161. wrongMessageActive: false,
  162. verifyEmailSent: false,
  163. valid: false,
  164. remember: false,
  165. countdown: 60,
  166. userData: {
  167. Account: '',
  168. Password: '',
  169. },
  170. rules: {
  171. require: value => !!value || this.$t('Required.'),
  172. email: v => /^([a-zA-Z0-9_\-\.]+)@([a-zA-Z0-9_\-\.]+)\.([a-zA-Z]{2,5})$/.test(v) || this.$t('Invalid email'),
  173. // checkPassword: v => (/(?=.*[0-9])(?=.*[a-z])(?=.*[A-Z])/.test(v) && v.length >= 8 && v.length <= 20) || '請輸入密碼',
  174. checkPassword: v => v.length >= 1 || '請輸入密碼',
  175. },
  176. deleteDialog: false,
  177. dialog: false,
  178. expireTime: new Date(),
  179. }
  180. },
  181. watch: {
  182. remember: {
  183. handler: function () {
  184. if (this.remember == true) {
  185. this.$auth.$storage.setUniversal("userPassword", this.userData.Password);
  186. this.$auth.$storage.setUniversal("userAccount", this.userData.Account);
  187. }else{
  188. this.$auth.$storage.removeUniversal("userPassword");
  189. this.$auth.$storage.removeUniversal("userAccount", this.userData.Account);
  190. }
  191. },
  192. },
  193. },
  194. created(){
  195. if(this.$auth.$storage.getUniversal('userAccount') && this.$auth.$storage.getUniversal('userPassword')){
  196. this.checkExpireTime();
  197. }
  198. },
  199. mounted(){
  200. if(this.$auth.$storage.getUniversal('userAccount') && this.$auth.$storage.getUniversal('userPassword')){
  201. this.remember = true;
  202. }else{
  203. this.remember = false;
  204. }
  205. var userAccount = this.$auth.$storage.getUniversal('userAccount');
  206. var userPassword = this.$auth.$storage.getUniversal('userPassword');
  207. this.userData.Account = userAccount ? userAccount : '';
  208. this.userData.Password = userPassword ? userPassword : '';
  209. if(this.userData.Account !=='' && this.userData.Password !==''){
  210. this.valid = true;
  211. }else{
  212. this.valid = false;
  213. }
  214. },
  215. methods: {
  216. colseDialog(){
  217. this.dialog = false;
  218. this.deleteDialog = false;
  219. },
  220. async userLogin() {
  221. let that = this;
  222. if (!that.$refs.loginFormRef.validate()) return;
  223. try {
  224. const response =await that.$auth.loginWith('local', { data: that.userData });
  225. if(response.data.STATUSCODE==200){
  226. let data = response.data.DATA;
  227. console.log(JSON.stringify(data.authtoken));
  228. if(data.authtoken){
  229. const authtoken = data.authtoken;
  230. that.$auth.$storage.removeUniversal('authtoken');
  231. that.$auth.$storage.setUniversal('authtoken', authtoken);
  232. that.$auth.loggedIn ? that.$router.push({path: that.$auth.$storage.getUniversal('userBeforePath')}) : that.$auth.redirect('login');
  233. }
  234. }else if(response.data.STATUSCODE==200 && this.remember == true){
  235. }else if(response.data.STATUSCODE==500){
  236. that.$auth.redirect('login');
  237. }else if(response.data.STATUSCODE==401){
  238. if(response.data.MSG == "0"){
  239. this.dialog = true;
  240. }else if(response.data.MSG == "2"){
  241. this.deleteDialog = true;
  242. }else if(response.data.MSG == "帳號或密碼不正確"){
  243. this.wrongMessageActive = true;
  244. }
  245. }else{
  246. // that.resendDialog = !that.resendDialog;
  247. that.wrongMessageActive = true;
  248. }
  249. } catch(err) {
  250. console.log(err);
  251. // if(err && err.response && err.response.status){
  252. // err.response.status === 403 ? that.resendDialog = !that.resendDialog : err.response.status === 401 ? that.wrongMessageActive = true : that.resendDialog;
  253. // }
  254. }
  255. },
  256. resendVerifyEmail() {
  257. this.$axios
  258. .post(
  259. `/trending/api/Signup/ReSendVerifyMail?Email=${this.userData.Account}`
  260. )
  261. .then((response) => {
  262. //console.log(JSON.stringify(response))
  263. if(response && response.data){
  264. this.dialog = false;
  265. }
  266. })
  267. .catch((error) => {
  268. console.log(error);
  269. });
  270. },
  271. ReactivateAccount(){
  272. this.$axios
  273. .post(
  274. `/trending/api/Members/ReactivateAccountByAcc?Account=${this.userData.Account}`
  275. )
  276. .then((response) => {
  277. //console.log(JSON.stringify(response))
  278. if(response && response.data && response.data.DATA && response.data.DATA.rel){
  279. let data = response.data.DATA.rel
  280. if(data){
  281. this.deleteDialog = false;
  282. }
  283. }
  284. })
  285. .catch((error) => {
  286. console.log(error);
  287. });
  288. },
  289. updateValid(){
  290. if(this.userData.Account !=='' && this.userData.Password !==''){
  291. this.valid = true;
  292. }else{
  293. this.valid = false;
  294. }
  295. },
  296. checkExpireTime(){
  297. console.log("給我時間");
  298. console.log("帳號:" + this.$auth.$storage.getUniversal('userAccount'));
  299. this.$axios
  300. .get(`/trending/api/System/RememberMe?Account=${this.$auth.$storage.getUniversal('userAccount')}`)
  301. .then((response) => {
  302. //console.log(response);
  303. const data = response.data.DATA.authtoken;
  304. this.expireTime = new Date(data.ExpireTime);
  305. const now = new Date(Date.now());
  306. const saveTime = this.expireTime - now;
  307. if(saveTime >= 0){
  308. const hour = saveTime / (60 * 60 * 1000);
  309. if(hour == 0){
  310. this.$auth.$storage.removeUniversal('userPassword');
  311. this.$auth.$storage.removeUniversal('userAccount');
  312. }
  313. }else{
  314. this.$auth.$storage.removeUniversal('userPassword');
  315. this.$auth.$storage.removeUniversal('userAccount');
  316. }
  317. })
  318. .catch((error) => {
  319. console.log(error);
  320. });
  321. }
  322. },
  323. beforeUnmount() {
  324. if(this.timer!=null){
  325. clearInterval(this.timer);
  326. }
  327. },
  328. beforeRouteEnter(to, from, next) {
  329. next(vm => {
  330. if (from.name) {
  331. if (!from.path.includes('user')) {
  332. vm.$auth.$storage.setUniversal("userBeforePath", from.fullPath, true)
  333. }
  334. }
  335. if (vm.$auth.loggedIn) {
  336. vm.$router.push({path: vm.$auth.$storage.getUniversal('userBeforePath') || '/'})
  337. }
  338. else {
  339. next()
  340. }
  341. })
  342. },
  343. }
  344. </script>
  345. <style lang="scss" scoped>
  346. $border-style: 1px solid #E5E5E5;
  347. #app {
  348. overflow-y: hidden;
  349. }
  350. .welcome {
  351. color: #f5cda8;
  352. font-family: Damion;
  353. font-size: 48px;
  354. margin-bottom: 0px;
  355. font-weight: 400;
  356. line-height: 66px;
  357. letter-spacing: 0.02em;
  358. }
  359. .sub {
  360. color: #9c9c9c;
  361. font-style: italic;
  362. font-weight: 400;
  363. font-size: 22px;
  364. line-height: 29px;
  365. letter-spacing: 0.02em;
  366. }
  367. .title {
  368. font-weight: 700;
  369. font-size: 26px;
  370. line-height: 34px;
  371. letter-spacing: 0.02em;
  372. color: #232323;
  373. }
  374. .btn-border {
  375. border: $border-style;
  376. }
  377. .seperator {
  378. border-bottom: $border-style;
  379. text-align: center;
  380. height: 12px;
  381. margin: 20px 0 30px;
  382. }
  383. :deep(.v-text-field.v-text-field--enclosed .v-text-field__details) {
  384. margin-bottom: 0;
  385. padding: 0;
  386. .v-messages {
  387. display: none;
  388. }
  389. .v-messages.error--text {
  390. display: block;
  391. margin-top: 4px;
  392. margin-bottom: 16px;
  393. }
  394. }
  395. /* The container */
  396. .container-checkbox {
  397. display: block;
  398. position: relative;
  399. padding-left: 28px;
  400. cursor: pointer;
  401. -webkit-user-select: none;
  402. -moz-user-select: none;
  403. -ms-user-select: none;
  404. user-select: none;
  405. }
  406. /* Hide the browser's default checkbox */
  407. .container-checkbox input {
  408. position: absolute;
  409. opacity: 0;
  410. cursor: pointer;
  411. }
  412. /* Create a custom checkbox */
  413. .container-checkbox .checkmark {
  414. position: absolute;
  415. top: 0;
  416. left: 0;
  417. height: 18px;
  418. width: 18px;
  419. background-color: transparent;
  420. border: 1px solid #f48800;
  421. border-radius: 4px;
  422. }
  423. /* On mouse-over, add a grey background color */
  424. .container-checkbox:hover input~.checkmark {
  425. border-color: #f48800;
  426. }
  427. /* When the checkbox is checked, add a blue background */
  428. .container-checkbox input:checked~.checkmark {
  429. background-color: #f48800;
  430. border-color: #f48800;
  431. }
  432. /* Create the checkmark/indicator (hidden when not checked) */
  433. .container-checkbox .checkmark:after {
  434. content: "";
  435. position: absolute;
  436. display: none;
  437. }
  438. /* Show the checkmark when checked */
  439. .container-checkbox input:checked~.checkmark:after {
  440. display: block;
  441. }
  442. /* Style the checkmark/indicator */
  443. .container-checkbox .checkmark:after {
  444. left: 5px;
  445. top: 2px;
  446. width: 5px;
  447. height: 10px;
  448. border: solid #ffffff;
  449. border-width: 0 2px 2px 0;
  450. -webkit-transform: rotate(45deg);
  451. -ms-transform: rotate(45deg);
  452. transform: rotate(45deg);
  453. }
  454. </style>