page-nav.vue 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798
  1. <template>
  2. <view class="nav-wrap">
  3. <view class="nav-title">
  4. <image class="logo" src="https://cdn.uviewui.com/uview/common/logo.png" mode="widthFix"></image>
  5. <view class="nav-info">
  6. <view class="nav-title__text">
  7. {{$t('common.title')}}
  8. </view>
  9. <view class="nav-slogan">
  10. {{$t('common.intro')}}
  11. </view>
  12. </view>
  13. </view>
  14. <view class="nav-desc">
  15. {{desc}}
  16. </view>
  17. <view class="lang" @tap="switchLang">
  18. <u-icon size="46" color="warning" :name="lang"></u-icon>
  19. </view>
  20. </view>
  21. </template>
  22. <script>
  23. export default {
  24. props: {
  25. desc: String,
  26. title: String,
  27. },
  28. computed: {
  29. lang() {
  30. return this.$i18n.locale == 'zh' ? 'zh' : 'en';
  31. }
  32. },
  33. methods: {
  34. switchLang() {
  35. this.$i18n.locale = this.$i18n.locale == 'en' ? 'zh' : 'en';
  36. this.vuex_tabbar[0].text = this.$t('nav.components')
  37. this.vuex_tabbar[1].text = this.$t('nav.js')
  38. this.vuex_tabbar[2].text = this.$t('nav.template')
  39. uni.setNavigationBarTitle({
  40. title: this.$t(this.title)
  41. });
  42. }
  43. }
  44. }
  45. </script>
  46. <style lang="scss" scoped>
  47. .nav-wrap {
  48. padding: 15px;
  49. position: relative;
  50. }
  51. .lang {
  52. position: absolute;
  53. top: 15px;
  54. right: 15px;
  55. }
  56. .nav-title {
  57. /* #ifndef APP-NVUE */
  58. display: flex;
  59. /* #endif */
  60. flex-direction: row;
  61. align-items: center;
  62. }
  63. .nav-info {
  64. margin-left: 15px;
  65. }
  66. .nav-title__text {
  67. /* #ifndef APP-NVUE */
  68. display: flex;
  69. /* #endif */
  70. color: $u-main-color;
  71. font-size: 25px;
  72. font-weight: bold;
  73. }
  74. .logo {
  75. width: 70px;
  76. /* #ifndef APP-NVUE */
  77. height: auto;
  78. /* #endif */
  79. }
  80. .nav-slogan {
  81. color: $u-tips-color;
  82. font-size: 14px;
  83. }
  84. .nav-desc {
  85. margin-top: 10px;
  86. font-size: 14px;
  87. color: $u-content-color;
  88. }
  89. </style>