index.vue 2.9 KB

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