多租户商城-商户小程序端
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.

99 lines
1.8 KiB

  1. <!-- 语言列表 -->
  2. <template>
  3. <view class="container">
  4. <view class="locale-list">
  5. <view class="locale-item" v-for="(item, index) in locales" :key="index" @click="onLocaleChange(item)">
  6. <text class="text">{{item.text}}</text>
  7. <text class="icon-check" v-if="item.code == applicationLocale"></text>
  8. </view>
  9. </view>
  10. </view>
  11. </template>
  12. <script>
  13. export default {
  14. data() {
  15. return {
  16. applicationLocale: ''
  17. }
  18. },
  19. computed:{
  20. locales() {
  21. return [
  22. // {
  23. // text: this.$t('locale.auto'),
  24. // code: 'auto'
  25. // },
  26. {
  27. text: this.$t('navbar.english'),
  28. code: 'en'
  29. },
  30. {
  31. text: this.$t('navbar.chinese'),
  32. code: 'zh-Hans'
  33. }
  34. ]
  35. }
  36. },
  37. onLoad() {
  38. this.applicationLocale = uni.getLocale();
  39. uni.onLocaleChange((e) => {
  40. this.applicationLocale = e.locale;
  41. })
  42. },
  43. methods: {
  44. onLocaleChange(e) {
  45. uni.setLocale(e.code);
  46. this.$i18n.locale = e.code;
  47. }
  48. }
  49. }
  50. </script>
  51. <style lang="scss">
  52. .container {
  53. padding: 0 24rpx;
  54. .locale-setting {
  55. font-size: 16px;
  56. font-weight: bold;
  57. margin-top: 25px;
  58. margin-bottom: 5px;
  59. padding-bottom: 5px;
  60. border-bottom: 1px solid #f0f0f0;
  61. }
  62. .list-item {
  63. font-size: 14px;
  64. padding: 10px 0;
  65. }
  66. .list-item .v {
  67. margin-left: 5px;
  68. }
  69. .locale-item {
  70. display: flex;
  71. flex-direction: row;
  72. padding: 10px 0;
  73. }
  74. .locale-item .text {
  75. flex: 1;
  76. }
  77. .icon-check {
  78. margin-right: 5px;
  79. border: 2px solid #007aff;
  80. border-left: 0;
  81. border-top: 0;
  82. height: 12px;
  83. width: 6px;
  84. transform-origin: center;
  85. /* #ifndef APP-NVUE */
  86. transition: all 0.3s;
  87. /* #endif */
  88. transform: rotate(45deg);
  89. }
  90. }
  91. </style>