index.vue 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115
  1. <template>
  2. <view class="settings-v">
  3. <u-cell-group class="u-p-l-20 u-p-r-20" :border="false">
  4. <!-- #ifndef MP-WEIXIN -->
  5. <u-cell-item :title="$t('app.my.settings.language')" @click="selectLocaleShow=true"
  6. :title-style="titleStyle"></u-cell-item>
  7. <!-- #endif -->
  8. <!-- #ifdef APP-PLUS -->
  9. <u-cell-item :title="$t('app.my.settings.userAgreement')" @click='openPage(agreement)'
  10. :title-style="titleStyle"></u-cell-item>
  11. <u-cell-item :title="$t('app.my.settings.privacyPolicy')" @click='openPage(policy)'
  12. :title-style="titleStyle"></u-cell-item>
  13. <!-- #endif -->
  14. <u-cell-item :title="$t('app.my.settings.contact')" @click="modifyPsd('/pages/my/contactUs/index')"
  15. :title-style="titleStyle">
  16. </u-cell-item>
  17. <u-cell-item :title="$t('app.my.settings.about')" @click="modifyPsd('/pages/my/abouts/index')"
  18. :title-style="titleStyle" :border-bottom="false">
  19. </u-cell-item>
  20. </u-cell-group>
  21. <u-select v-model="selectLocaleShow" :list="localeList" mode="single-column" :default-value="defaultLocale"
  22. @confirm="localeConfirm"></u-select>
  23. </view>
  24. </template>
  25. <script>
  26. import resources from '@/libs/resources.js'
  27. import {
  28. useLocale
  29. } from '@/locale/useLocale';
  30. export default {
  31. data() {
  32. return {
  33. // #ifdef APP-PLUS
  34. agreement: resources.userAgreement,
  35. policy: resources.privacyPolicy,
  36. // #endif
  37. titleStyle: {
  38. color: '#303133'
  39. },
  40. localeList: [{
  41. label: '简体中文',
  42. value: 'zh-Hans'
  43. },
  44. {
  45. label: '繁体中文',
  46. value: 'zh-Hant'
  47. },
  48. {
  49. label: 'English',
  50. value: 'en'
  51. }
  52. ],
  53. selectLocaleShow: false,
  54. defaultLocale: []
  55. };
  56. },
  57. onLoad() {
  58. this.defaultLocale = [this.localeList.findIndex(o => o.value === uni.getLocale())];
  59. },
  60. methods: {
  61. modifyPsd(path) {
  62. if (!path) return
  63. uni.navigateTo({
  64. url: path
  65. })
  66. },
  67. // #ifdef APP-PLUS
  68. openPage(url) {
  69. plus.runtime.openURL(url);
  70. },
  71. // #endif
  72. localeConfirm(e) {
  73. if (e[0].index === this.defaultLocale[0]) return
  74. const systemInfo = uni.getSystemInfoSync();
  75. const isAndroid = systemInfo.platform.toLowerCase() === 'android';
  76. if (isAndroid) {
  77. uni.showModal({
  78. content: '应用此设置将重启App',
  79. success: (res) => {
  80. if (res.confirm) {
  81. this.handleChangeLocale(e[0])
  82. }
  83. }
  84. })
  85. } else {
  86. this.handleChangeLocale(e[0])
  87. }
  88. },
  89. handleChangeLocale(e) {
  90. this.defaultLocale = [e.index];
  91. const {
  92. changeLocale
  93. } = useLocale();
  94. changeLocale(e.value)
  95. },
  96. }
  97. }
  98. </script>
  99. <style lang="scss">
  100. page {
  101. background-color: #f0f2f6;
  102. }
  103. :deep(.u-cell) {
  104. height: 112rpx;
  105. padding: 20rpx 0;
  106. }
  107. .settings-v {
  108. background-color: #fff;
  109. }
  110. </style>