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.

92 lines
2.5 KiB

2 years ago
2 years ago
2 years ago
2 years ago
  1. <template>
  2. <div
  3. class="changeCurrency tw-flex tw-items-center tw-border-solid tw-border-[1px] tw-border-neutrals-200 tw-bg-white tw-text-neutrals-800 tw-rounded-[16px] tw-mb-[16px]">
  4. <select v-model="price" @change="inputVal"
  5. class="customselect t14 tw-font-normal tw-w-full tw-my-[12px] tw-mx-[25px] md:t16 focus:tw-outline-none">
  6. <!-- <option value="USD">
  7. <div class="option">USD</div>
  8. <div class="">{{$t('U.S. Dollar')}}</div>
  9. </option> -->
  10. <option value="NTD">
  11. <div class="option">NTD</div>
  12. <div class="">{{$t('New Taiwan Dollar')}}</div>
  13. </option>
  14. <!--
  15. <option class="tw-mb-[30px]">
  16. <div class="t14 tw-font-normal">JPY</div>
  17. <div class="t12 tw-font-normal">Japanese Yen</div>
  18. </option>
  19. <option class="tw-mb-[30px]">
  20. <div class="t12 tw-font-normal">EUR</div>
  21. <div class="t12 tw-font-normal">Euro</div>
  22. </option> -->
  23. </select>
  24. <img src="@/assets/svg/down-arrow.svg" class="tw-mr-[20px]" alt="" />
  25. </div>
  26. </template>
  27. <script>
  28. export default {
  29. data() {
  30. return {
  31. show: false,
  32. price: "",
  33. changeCurrency: false,
  34. };
  35. },
  36. mounted() {
  37. this.change();
  38. },
  39. computed: {
  40. currentLang() {
  41. return this.$i18n.locale;
  42. },
  43. hideSwitchPrice() {
  44. let vm = this;
  45. if (vm.$route.matched.length > 0) {
  46. if (vm.$route.matched[0].path == '/service/checkout/:id?') {
  47. vm.$store.dispatch("hideSwitchPrice", true);
  48. } else {
  49. vm.$store.dispatch("hideSwitchPrice", false);
  50. }
  51. }
  52. return this.$store.getters.getHidePrice;
  53. },
  54. },
  55. watch: {
  56. currentLang: {
  57. handler: function () {
  58. this.change();
  59. }
  60. }
  61. },
  62. methods: {
  63. change() {
  64. if (process.browser) {
  65. let storageprice = localStorage.getItem("currency");
  66. if (storageprice) {
  67. this.price = storageprice;
  68. this.$store.dispatch("updateCurrency", storageprice);
  69. } else {
  70. if (this.$i18n.locale == 'zh-tw') {
  71. this.price = "NTD";
  72. this.$store.dispatch("updateCurrency", "NTD");
  73. }
  74. else {
  75. this.price = "USD";
  76. this.$store.dispatch("updateCurrency", "USD");
  77. }
  78. }
  79. }
  80. },
  81. inputVal() {
  82. localStorage.setItem("currency", this.price);
  83. this.$store.dispatch("updateCurrency", this.price);
  84. this.show = false;
  85. },
  86. },
  87. };
  88. </script>
  89. <style lang="scss" scoped>
  90. </style>