header.vue 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107
  1. <template>
  2. <view :class="'header'+(type==2?' fixed-header':'')" v-if="platform">
  3. <view class="name">
  4. <image class="logo" v-if="platform.site_logo" :src="platform.site_logo" mode=""></image>
  5. <text class="text">{{platform.site_name? platform.site_name : 'OTC168'}}</text>
  6. </view>
  7. <view class="lang" @click="switchLang">
  8. <text class="text zh-cn" v-if="this.locale == 'zh_cn'">{{lang.zh_cn}}</text>
  9. <text class="text en" v-else>{{lang.en}}</text>
  10. <image class="icon locale en" v-if="this.locale == 'zh_cn'" src="/static/icons/en_light.png" mode="">
  11. </image>
  12. <image class="icon locale zh-cn" v-else src="/static/icons/zh-light.png" mode=""></image>
  13. </view>
  14. </view>
  15. </template>
  16. <script>
  17. import {
  18. switchLocale
  19. } from '@/common/checker.js'
  20. export default {
  21. props: {
  22. platform: {
  23. type: Object
  24. },
  25. type: {
  26. type: Number,
  27. default: 1
  28. }
  29. },
  30. data() {
  31. return {}
  32. },
  33. methods: {
  34. switchLang() {
  35. let _this = this
  36. let lang = switchLocale();
  37. let locale = uni.getStorageSync('locale')
  38. console.log(locale)
  39. this.$request.sendToken('/api/lang/switch', {
  40. locale: locale == 'en' ? 'en' : 'zh-cn'
  41. }, 'POST').then(res => {
  42. if (res.success == true) {
  43. _this.lang = this.lang
  44. location.reload()
  45. }
  46. });
  47. },
  48. }
  49. }
  50. </script>
  51. <style lang="scss" scoped>
  52. .header {
  53. height: 120rpx;
  54. line-height: 120rpx;
  55. width: 100%;
  56. position: fixed;
  57. top: 0;
  58. left: 0;
  59. z-index: 996;
  60. display: flex;
  61. .logo {
  62. width: 60rpx;
  63. height: 60rpx;
  64. vertical-align: middle;
  65. margin-right: 10rpx;
  66. }
  67. .name {
  68. margin-left: 38rpx;
  69. color: #fff;
  70. font-size: 44rpx;
  71. font-weight: bold;
  72. width: calc(100% - 220rpx);
  73. }
  74. .lang {
  75. // width: 100rpx;
  76. float: right;
  77. text-align: center;
  78. margin-right: 19rpx;
  79. .icon {
  80. display: inline-block;
  81. width: 72rpx;
  82. height: 72rpx;
  83. vertical-align: middle;
  84. }
  85. .text {
  86. color: #fff;
  87. font-size: 28rpx;
  88. display: inline-block;
  89. vertical-align: middle;
  90. }
  91. }
  92. }
  93. .fixed-header {
  94. background: linear-gradient(-6deg, rgba(53, 53, 95, 1) -5%, #f1c1ad 100%);
  95. }
  96. </style>