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.

368 lines
14 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
  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 md:tw-rounded-[24px] md:tw-mt-[30px] md:tw-pt-[60px] md:tw-pb-[150px] md:tw-px-[30px]">
  18. <v-spacer v-if="emailSignUp">
  19. <h1 class="tw-text-[40px] tw-font-bold tw-mb-[20px] md:tw-text-[24px] md:tw-mb-[14px]">{{ $t("Sign Up") }}</h1>
  20. <p class="tw-body-3 tw-text-neutral-400 tw-mb-[16px] md:tw-mb-[12px]">
  21. {{ $t("Welcome to ShowEasy!") }}
  22. </p>
  23. <p class="tw-body-3 tw-mb-[45px] md:tw-mb-[32px]">
  24. {{ $t("Already have an account?") }}
  25. <nuxt-link :to="localePath('/user')" class="primary--text text-decoration-none">{{ $t("Login") }}</nuxt-link>
  26. </p>
  27. <div class="tw-grid tw-grid-cols-1 tw-gap-[10px] md:tw-gap-[12px]">
  28. <!-- <button @click="googleLogin"
  29. class="tw-flex tw-justify-center tw-items-center tw-w-full tw-py-[8px] tw-rounded-[16px] tw-border tw-border-solid tw-text-black tw-border-neutrals-200"><img
  30. width="24px" height="24px" src="~/assets/img/g-normal.png" class="mr-5" />{{ $t("Sign up with Google")
  31. }}</button>
  32. <button @click="facebookLogin"
  33. class="tw-flex tw-justify-center tw-items-center tw-w-full tw-py-[8px] tw-rounded-[16px] tw-border tw-border-solid tw-text-black tw-border-neutrals-200"><img
  34. width="20px" height="20px" src="~/assets/img/f_logo_RGB-Blue_72.png" class="mr-5" />
  35. {{ $t("Sign up with Facebook") }}
  36. </button> -->
  37. <button @click="emailSignUp = !emailSignUp"
  38. class="tw-flex tw-justify-center tw-items-center tw-w-full tw-py-[8px] tw-rounded-[16px] tw-border tw-border-solid tw-text-black tw-border-neutrals-200">
  39. <unicon name="envelope" width="20px" height="20px"
  40. class="tw-flex tw-justify-center tw-items-center tw-mr-[20px]">
  41. </unicon>{{ $t("Sign up with Email") }}
  42. </button>
  43. </div>
  44. </v-spacer>
  45. <v-spacer v-if="!emailSignUp">
  46. <p class="title">{{ $t("Sign up with Email") }}</p>
  47. <p class="neutrals--text text--darken-3 text-size-14">
  48. {{ $t("Welcome to ShowEasy!") }}
  49. </p>
  50. <v-form v-model="valid">
  51. <v-text-field v-model="userData.FirstName" background-color="neutrals darken-1"
  52. :label="this.$t('First Name') + '*'" placeholder="" filled rounded dense single-line :rules="[rules.require]">
  53. </v-text-field>
  54. <v-text-field v-model="userData.LastName" background-color="neutrals darken-1"
  55. :label="this.$t('Last Name') + '*'" placeholder="" filled rounded dense single-line :rules="[rules.require]">
  56. </v-text-field>
  57. <v-text-field v-model="userData.Email" background-color="neutrals darken-1" :label="this.$t('Email') + '*'"
  58. filled rounded dense single-line :rules="[rules.email, rules.require]" validate-on-blur></v-text-field>
  59. <v-text-field v-model="userData.Password" background-color="neutrals darken-1"
  60. :label="this.$t('Password') + '*'" :type="showPass ? 'text' : 'password'" placeholder="" filled rounded dense
  61. single-line :rules="[rules.checkPassword, rules.require]" :hint="
  62. this.$t(
  63. 'userProfile.passwordsHint'
  64. )
  65. " persistent-hint :append-icon="showPass ? 'mdi-eye' : 'mdi-eye-off'" @click:append="showPass = !showPass"
  66. validate-on-blur></v-text-field>
  67. <v-text-field v-model="confirmPasswordText" background-color="neutrals darken-1"
  68. :label="this.$t('Confirm Password') + '*'" :type="showConfirmPass ? 'text' : 'password'" placeholder="" filled
  69. rounded dense single-line :rules="[rules.checkConfirmPassword, rules.require]"
  70. :append-icon="showConfirmPass ? 'mdi-eye' : 'mdi-eye-off'" @click:append="showConfirmPass = !showConfirmPass"
  71. validate-on-blur></v-text-field>
  72. </v-form>
  73. <v-checkbox v-model="userData.Subscribe" class="mt-n2 ml-1"><template v-slot:label><span
  74. class="neutrals--text text--darken-4 text-size-14">{{
  75. $t("Subscribe to ShowEasy\’s newsletter")
  76. }}</span></template></v-checkbox>
  77. <div class="md:tw-flex md:tw-justify-center md:tw-items-center"> <button @click="userRegister"
  78. :disabled="!validFormat"
  79. :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']">
  80. {{ $t("Sign Up") }}
  81. </button></div>
  82. <v-dialog v-model="dialog" :width="$vuetify.breakpoint.smAndUp ? 423 : 294"
  83. @click:outside="$router.push(localePath('/user'))">
  84. <v-card class="pa-7" :height="$vuetify.breakpoint.smAndUp ? 249 : 290">
  85. <v-spacer class="d-flex align-center text-size-20 neutrals--text text--darken-5">
  86. {{ $t("Verify your email") }}
  87. <v-spacer></v-spacer>
  88. <v-btn @click="$router.push(localePath('/user'))" icon>
  89. <v-icon> mdi-close </v-icon>
  90. </v-btn>
  91. </v-spacer>
  92. <v-spacer class="text-size-16 my-7 neutrals--text text--darken-4">{{ $t("We've sent a verification email to")
  93. }}<br />
  94. <span class="primary--text">{{ userData.Email }}</span>{{
  95. $t(". Please click the link within to activate your account.")
  96. }}
  97. </v-spacer>
  98. <v-btn @click="resendVerifyEmail" class="primary no-text-transform" width="153px" rounded
  99. :disabled="countdown > 0">
  100. {{ $t("Resend") }}
  101. <span v-if="countdown > 0">
  102. {{ `(${this.countdown})` }}
  103. </span>
  104. </v-btn>
  105. </v-card>
  106. </v-dialog>
  107. <v-dialog v-model="errorDialog" :width="$vuetify.breakpoint.smAndUp ? 423 : 294">
  108. <v-card class="pa-7 border-radius-16" :max-height="$vuetify.breakpoint.smAndUp ? 249 : 290">
  109. <v-spacer class="d-flex align-center text-size-20 neutrals--text text--darken-5">
  110. {{ $t("Error") }}
  111. <v-spacer></v-spacer>
  112. <v-btn @click="errorDialog = !errorDialog" icon>
  113. <v-icon> mdi-close </v-icon>
  114. </v-btn>
  115. </v-spacer>
  116. <v-spacer class="text-size-16 my-7 neutrals--text text--darken-4">
  117. {{ $t("Same email has been created already.") }}
  118. </v-spacer>
  119. <v-spacer class="d-flex justify-center">
  120. <v-btn class="border-radius-16" color="primary" @click="errorDialog = !errorDialog">{{ $t("ok") }}</v-btn>
  121. </v-spacer>
  122. </v-card>
  123. </v-dialog>
  124. <p align="center" class="neutrals--text text--darken-3 text-size-14 mt-7">
  125. {{ $t("By signing up,") }}<br />
  126. {{ $t("you agree to the") }}
  127. <nuxt-link :to="localePath('/termsandconditions')" target="_blank" class="text-decoration-none">
  128. {{ $t("Terms & Conditions") }}</nuxt-link>
  129. {{ $t("and") }}
  130. <nuxt-link :to="localePath('/privacypolicy')" target="_blank" class="text-decoration-none">
  131. {{ $t("Privacy Policy") }}</nuxt-link>
  132. </p>
  133. <p align="center" class="neutrals--text text--darken-5 text-size-14">
  134. {{ $t("Already have an account?") }}
  135. <nuxt-link :to="localePath('/user')" class="primary--text text-decoration-none">{{ $t("Login") }}</nuxt-link>
  136. </p>
  137. </v-spacer>
  138. <loading :isLoading="isPageLoading"></loading>
  139. </div>
  140. </div>
  141. </div>
  142. </div>
  143. </template>
  144. <script>
  145. import loading from "@/components/newComponent/loading/loading.vue";
  146. export default {
  147. name: "SignUp",
  148. layout: "login",
  149. auth: false,
  150. components: {
  151. loading,
  152. },
  153. data() {
  154. return {
  155. valid: false,
  156. showPass: false,
  157. showConfirmPass: false,
  158. emailSignUp: true,
  159. Subscribe: true,
  160. dialog: false,
  161. errorDialog: false,
  162. btnText: "Sign up",
  163. confirmPasswordText: "",
  164. countdown: 60,
  165. isPageLoading: false,
  166. rules: {
  167. require: (value) => !!value || this.$t("Required."),
  168. email: (v) =>
  169. /^([a-zA-Z0-9_\-\.]+)@([a-zA-Z0-9_\-\.]+)\.([a-zA-Z]{2,5})$/.test(
  170. v
  171. ) || this.$t("Invalid email"),
  172. checkPassword: (v) =>
  173. (/(?=.*[0-9])(?=.*[a-z])(?=.*[A-Z])/.test(v) &&
  174. v.length >= 8 &&
  175. v.length <= 20) ||
  176. this.$t(
  177. "Passwords must be 8-20 characters with at least 1 number, 1 lower case letter and 1 upper case letter"
  178. ),
  179. checkConfirmPassword: (v) =>
  180. this.confirmPasswordText === this.userData.Password ||
  181. this.$t("Your password and confirmation password do not match"),
  182. },
  183. userData: {
  184. FirstName: "",
  185. LastName: "",
  186. Account: "",
  187. Password: "",
  188. Email: "",
  189. Subscribe: true,
  190. },
  191. signUp: false,
  192. };
  193. },
  194. watch: {
  195. signUp: {
  196. handler: function () {
  197. if (this.signUp == true) {
  198. this.$auth.$storage.removeUniversal("userPassword");
  199. this.$auth.$storage.removeUniversal("userAccount");
  200. console.log("帳號: " + this.$auth.$storage.getUniversal('userAccount'));
  201. console.log("密碼: " + this.$auth.$storage.getUniversal('userPassword'));
  202. console.log("都給我刪掉");
  203. }
  204. },
  205. },
  206. },
  207. methods: {
  208. userRegister() {
  209. const postUserData = { ...this.userData };
  210. this.isPageLoading = true;
  211. this.$axios
  212. .post(
  213. `/trending/api/Signup/SignupWithEmail`, postUserData
  214. )
  215. .then((response) => {
  216. //console.log(JSON.stringify(response));
  217. if(response.data.STATUSCODE == "400"){
  218. this.errorDialog = true;
  219. this.isPageLoading = false;
  220. }
  221. if(response && response.data && response.data.DATA && response.data.DATA.rel){
  222. let data = response.data.DATA.rel
  223. if(data){
  224. this.signUp = true;
  225. this.timer = setInterval(() => {
  226. if (this.countdown > 0) {
  227. this.countdown--;
  228. }
  229. if (this.countdown === 0) {
  230. clearInterval(this.timer);
  231. }
  232. }, 1000);
  233. console.log("pageloading:" + this.isPageLoading);
  234. this.isPageLoading = false;
  235. this.dialog = !this.dialog;
  236. }
  237. }
  238. })
  239. .catch((err) => {
  240. console.log(err);
  241. });
  242. },
  243. resendVerifyEmail() {
  244. this.countdown = 60;
  245. this.$axios
  246. .post(
  247. `/trending/api/Signup/ReSendVerifyMail?Email=${this.userData.Email}`
  248. )
  249. .then((res) => {
  250. //console.log(JSON.stringify(res));
  251. clearInterval(this.timer);
  252. this.timer = setInterval(() => {
  253. if (this.countdown > 0) {
  254. this.countdown--;
  255. }
  256. if (this.countdown === 0) {
  257. clearInterval(this.timer);
  258. }
  259. }, 1000);
  260. })
  261. .catch((err) => {
  262. console.log(err);
  263. });
  264. },
  265. async facebookLogin() {
  266. try {
  267. await this.$auth.loginWith("facebook");
  268. } catch (err) {
  269. console.log(err);
  270. }
  271. },
  272. async googleLogin() {
  273. try {
  274. await this.$auth.loginWith("google");
  275. } catch (err) {
  276. console.log(err);
  277. }
  278. },
  279. },
  280. computed: {
  281. validFormat() {
  282. if (this.valid && this.userData.Password === this.confirmPasswordText) {
  283. return true;
  284. } else {
  285. return false;
  286. }
  287. },
  288. },
  289. beforeUnmount() {
  290. clearInterval(this.timer);
  291. },
  292. };
  293. </script>
  294. <style lang="scss" scoped>
  295. #app {
  296. overflow-y: hidden;
  297. }
  298. .welcome {
  299. color: #f5cda8;
  300. font-family: Damion;
  301. font-size: 48px;
  302. margin-bottom: 0px;
  303. font-weight: 400;
  304. line-height: 66px;
  305. letter-spacing: 0.02em;
  306. }
  307. .sub {
  308. color: #9c9c9c;
  309. font-style: italic;
  310. font-weight: 400;
  311. font-size: 22px;
  312. line-height: 29px;
  313. letter-spacing: 0.02em;
  314. }
  315. :deep(.v-text-field.v-text-field--enclosed .v-text-field__details) {
  316. padding: 0;
  317. margin: 0;
  318. }
  319. :deep(.v-messages__message) {
  320. font-size: 14px;
  321. }
  322. $border-style: 1px solid #e5e5e5;
  323. .title {
  324. font-weight: 700;
  325. font-size: 26px;
  326. line-height: 34px;
  327. letter-spacing: 0.02em;
  328. color: #232323;
  329. }
  330. :deep(.v-text-field.v-text-field--enclosed .v-text-field__details) {
  331. margin-bottom: 0;
  332. padding: 0;
  333. .v-messages {
  334. color: #9c9c9c;
  335. display: none;
  336. }
  337. .v-messages.error--text {
  338. display: block;
  339. margin-top: 4px;
  340. margin-bottom: 16px;
  341. }
  342. }
  343. .btn-border {
  344. border: $border-style;
  345. }
  346. </style>