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.

452 lines
17 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. }
  179. },
  180. watch: {
  181. remember: {
  182. handler: function () {
  183. if (this.remember == true) {
  184. this.$auth.$storage.setUniversal("userPassword", this.userData.Password);
  185. this.$auth.$storage.setUniversal("userAccount", this.userData.Account);
  186. }else{
  187. this.$auth.$storage.removeUniversal("userPassword");
  188. this.$auth.$storage.removeUniversal("userAccount", this.userData.Account);
  189. }
  190. },
  191. },
  192. },
  193. created(){
  194. },
  195. mounted(){
  196. if(this.$auth.$storage.getUniversal('userAccount') && this.$auth.$storage.getUniversal('userPassword')){
  197. this.remember = true;
  198. }else{
  199. this.remember = false;
  200. }
  201. var userAccount = this.$auth.$storage.getUniversal('userAccount');
  202. var userPassword = this.$auth.$storage.getUniversal('userPassword');
  203. this.userData.Account = userAccount ? userAccount : '';
  204. this.userData.Password = userPassword ? userPassword : '';
  205. if(this.userData.Account !=='' && this.userData.Password !==''){
  206. this.valid = true;
  207. }else{
  208. this.valid = false;
  209. }
  210. },
  211. methods: {
  212. colseDialog(){
  213. this.dialog = false;
  214. this.deleteDialog = false;
  215. },
  216. async userLogin() {
  217. let that = this;
  218. if (!that.$refs.loginFormRef.validate()) return;
  219. try {
  220. const response =await that.$auth.loginWith('local', { data: that.userData });
  221. if(response.data.STATUSCODE==200){
  222. let data = response.data.DATA;
  223. console.log(JSON.stringify(data.authtoken));
  224. if(data.authtoken){
  225. const authtoken = data.authtoken;
  226. that.$auth.$storage.removeUniversal('authtoken');
  227. that.$auth.$storage.setUniversal('authtoken', authtoken);
  228. that.$auth.loggedIn ? that.$router.push({path: that.$auth.$storage.getUniversal('userBeforePath')}) : that.$auth.redirect('login');
  229. }
  230. }else if(response.data.STATUSCODE==500){
  231. that.$auth.redirect('login');
  232. }else if(response.data.STATUSCODE==401){
  233. if(response.data.MSG == "0"){
  234. this.dialog = true;
  235. }else if(response.data.MSG == "2"){
  236. this.deleteDialog = true;
  237. }else if(response.data.MSG == "帳號或密碼不正確"){
  238. this.wrongMessageActive = true;
  239. }
  240. }else{
  241. // that.resendDialog = !that.resendDialog;
  242. that.wrongMessageActive = true;
  243. }
  244. } catch(err) {
  245. console.log(err);
  246. // if(err && err.response && err.response.status){
  247. // err.response.status === 403 ? that.resendDialog = !that.resendDialog : err.response.status === 401 ? that.wrongMessageActive = true : that.resendDialog;
  248. // }
  249. }
  250. },
  251. resendVerifyEmail() {
  252. this.$axios
  253. .post(
  254. `/trending/api/Signup/ReSendVerifyMail?Email=${this.userData.Account}`
  255. )
  256. .then((response) => {
  257. //console.log(JSON.stringify(response))
  258. if(response && response.data){
  259. this.dialog = false;
  260. }
  261. })
  262. .catch((error) => {
  263. console.log(error);
  264. });
  265. },
  266. ReactivateAccount(){
  267. this.$axios
  268. .post(
  269. `/trending/api/Members/ReactivateAccountByAcc?Account=${this.userData.Account}`
  270. )
  271. .then((response) => {
  272. //console.log(JSON.stringify(response))
  273. if(response && response.data && response.data.DATA && response.data.DATA.rel){
  274. let data = response.data.DATA.rel
  275. if(data){
  276. this.deleteDialog = false;
  277. }
  278. }
  279. })
  280. .catch((error) => {
  281. console.log(error);
  282. });
  283. },
  284. updateValid(){
  285. if(this.userData.Account !=='' && this.userData.Password !==''){
  286. this.valid = true;
  287. }else{
  288. this.valid = false;
  289. }
  290. },
  291. },
  292. beforeUnmount() {
  293. if(this.timer!=null){
  294. clearInterval(this.timer);
  295. }
  296. },
  297. beforeRouteEnter(to, from, next) {
  298. next(vm => {
  299. if (from.name) {
  300. if (!from.path.includes('user')) {
  301. vm.$auth.$storage.setUniversal("userBeforePath", from.fullPath, true)
  302. }
  303. }
  304. if (vm.$auth.loggedIn) {
  305. vm.$router.push({path: vm.$auth.$storage.getUniversal('userBeforePath') || '/'})
  306. }
  307. else {
  308. next()
  309. }
  310. })
  311. },
  312. }
  313. </script>
  314. <style lang="scss" scoped>
  315. $border-style: 1px solid #E5E5E5;
  316. #app {
  317. overflow-y: hidden;
  318. }
  319. .welcome {
  320. color: #f5cda8;
  321. font-family: Damion;
  322. font-size: 48px;
  323. margin-bottom: 0px;
  324. font-weight: 400;
  325. line-height: 66px;
  326. letter-spacing: 0.02em;
  327. }
  328. .sub {
  329. color: #9c9c9c;
  330. font-style: italic;
  331. font-weight: 400;
  332. font-size: 22px;
  333. line-height: 29px;
  334. letter-spacing: 0.02em;
  335. }
  336. .title {
  337. font-weight: 700;
  338. font-size: 26px;
  339. line-height: 34px;
  340. letter-spacing: 0.02em;
  341. color: #232323;
  342. }
  343. .btn-border {
  344. border: $border-style;
  345. }
  346. .seperator {
  347. border-bottom: $border-style;
  348. text-align: center;
  349. height: 12px;
  350. margin: 20px 0 30px;
  351. }
  352. :deep(.v-text-field.v-text-field--enclosed .v-text-field__details) {
  353. margin-bottom: 0;
  354. padding: 0;
  355. .v-messages {
  356. display: none;
  357. }
  358. .v-messages.error--text {
  359. display: block;
  360. margin-top: 4px;
  361. margin-bottom: 16px;
  362. }
  363. }
  364. /* The container */
  365. .container-checkbox {
  366. display: block;
  367. position: relative;
  368. padding-left: 28px;
  369. cursor: pointer;
  370. -webkit-user-select: none;
  371. -moz-user-select: none;
  372. -ms-user-select: none;
  373. user-select: none;
  374. }
  375. /* Hide the browser's default checkbox */
  376. .container-checkbox input {
  377. position: absolute;
  378. opacity: 0;
  379. cursor: pointer;
  380. }
  381. /* Create a custom checkbox */
  382. .container-checkbox .checkmark {
  383. position: absolute;
  384. top: 0;
  385. left: 0;
  386. height: 18px;
  387. width: 18px;
  388. background-color: transparent;
  389. border: 1px solid #f48800;
  390. border-radius: 4px;
  391. }
  392. /* On mouse-over, add a grey background color */
  393. .container-checkbox:hover input~.checkmark {
  394. border-color: #f48800;
  395. }
  396. /* When the checkbox is checked, add a blue background */
  397. .container-checkbox input:checked~.checkmark {
  398. background-color: #f48800;
  399. border-color: #f48800;
  400. }
  401. /* Create the checkmark/indicator (hidden when not checked) */
  402. .container-checkbox .checkmark:after {
  403. content: "";
  404. position: absolute;
  405. display: none;
  406. }
  407. /* Show the checkmark when checked */
  408. .container-checkbox input:checked~.checkmark:after {
  409. display: block;
  410. }
  411. /* Style the checkmark/indicator */
  412. .container-checkbox .checkmark:after {
  413. left: 5px;
  414. top: 2px;
  415. width: 5px;
  416. height: 10px;
  417. border: solid #ffffff;
  418. border-width: 0 2px 2px 0;
  419. -webkit-transform: rotate(45deg);
  420. -ms-transform: rotate(45deg);
  421. transform: rotate(45deg);
  422. }
  423. </style>