language_currency.vue 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168
  1. <template>
  2. <Theme>
  3. <view class="wrap">
  4. <Navbar title="语言/币种" fixed border>
  5. <template #right>
  6. <navMenu :options="{ icon: 'icon-home', text: '主页' }" />
  7. </template>
  8. </Navbar>
  9. <view class="content">
  10. <view class="cont">
  11. <view class="wrapper">
  12. <view class="title">
  13. <trans _t="语言" />
  14. </view>
  15. <view class="wrapper_item">
  16. <view
  17. class="_item"
  18. :class="lang == item.code ? 'active' : ''"
  19. v-for="(item, index) in langeuageList"
  20. :key="index"
  21. @click="langClick(item)"
  22. >
  23. <up-avatar
  24. :src="item.icon"
  25. size="22"
  26. style="margin-right: 8rpx"
  27. ></up-avatar>
  28. {{ item.title }}
  29. </view>
  30. </view>
  31. </view>
  32. <view class="wrapper">
  33. <view class="title">
  34. <trans _t="币种" />
  35. </view>
  36. <view class="wrapper_item">
  37. <view
  38. class="_item"
  39. :class="currency == item.title ? 'active' : ''"
  40. v-for="(item, index) in rateList"
  41. :key="index"
  42. @click="currencySelect(item)"
  43. >
  44. {{ item.title }}
  45. </view>
  46. </view>
  47. </view>
  48. </view>
  49. <view class="btn">
  50. <view class="btns" @click="confirm">
  51. <trans _t="好的" />
  52. </view>
  53. </view>
  54. </view>
  55. </view>
  56. </Theme>
  57. </template>
  58. <script setup>
  59. import Navbar from "@/components/navbar";
  60. import navMenu from "@/components/nav_menu";
  61. import { computed, ref } from "vue";
  62. import { useSystemStore, useShopStore } from "@/store";
  63. import { setLan } from "@/locale";
  64. const useSystem = useSystemStore();
  65. const useShop = useShopStore();
  66. const rateList = computed(() => useSystem.getRateList);
  67. const langeuageList = computed(() => useSystem.getLangeuage);
  68. const _lang = computed(() => useSystem.getLang);
  69. const _currency = computed(() => useSystem.getCurrency);
  70. const lang = ref(_lang.value);
  71. const currency = ref(_currency.value);
  72. const langClick = (item) => {
  73. lang.value = item.code;
  74. };
  75. const currencySelect = (item) => {
  76. currency.value = item.title;
  77. };
  78. const confirm = () => {
  79. if (_lang.value === lang.value && currency.value === _currency.value)
  80. return uni.navigateBack();
  81. if (_lang.value != lang.value) {
  82. useSystem.setLan(lang.value);
  83. setLan(lang.value, () => {
  84. useSystem.setWinnotice();
  85. useShop.setHotLink();
  86. // useSystem.setBanner();
  87. });
  88. }
  89. useSystem.setCurrency(currency.value);
  90. uni.navigateBack();
  91. };
  92. </script>
  93. <style lang="less" scoped>
  94. @import url("@/style.less");
  95. .wrap {
  96. background: var(--bg);
  97. min-height: 100vh;
  98. .content {
  99. padding: 0 24rpx;
  100. .cont {
  101. padding: 32rpx 24rpx;
  102. border-radius: 16rpx;
  103. background-color: var(--light);
  104. margin-top: 24rpx;
  105. .flex();
  106. flex-direction: column;
  107. row-gap: 40rpx;
  108. .wrapper {
  109. .title {
  110. color: var(--text);
  111. .size(28rpx);
  112. font-weight: 700;
  113. line-height: 60rpx;
  114. }
  115. &_item {
  116. display: grid;
  117. gap: 24rpx;
  118. grid-template-columns: repeat(3, 1fr);
  119. ._item {
  120. display: flex;
  121. border-radius: 30rpx;
  122. .size(24rpx);
  123. height: 60rpx;
  124. padding: 16rpx;
  125. border: 1px solid var(--text-02);
  126. color: var(--text-02);
  127. cursor: pointer;
  128. font-weight: 700;
  129. text-align: center;
  130. white-space: nowrap;
  131. .flex_center();
  132. }
  133. .active {
  134. border-color: var(--black);
  135. background-color: var(--black);
  136. color: var(--bg);
  137. }
  138. }
  139. }
  140. }
  141. .btn {
  142. padding: 32rpx 0;
  143. .btns {
  144. background-color: var(--black);
  145. padding: 16rpx 30rpx;
  146. border-radius: 16rpx;
  147. height: 48px;
  148. .flex_center();
  149. .size(24rpx);
  150. color: var(--light);
  151. }
  152. }
  153. }
  154. }
  155. </style>