font_size.vue 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159
  1. <template>
  2. <view class="">
  3. <view class="show_font right">
  4. <view class="show_text">
  5. <view class="text" :style="{'font-size': value+'px'}">
  6. 预览字体大小
  7. </view>
  8. </view>
  9. <view class="avatar">
  10. <image mode="aspectFill" src="../../static/theme/default/push/default_photo_path.png" alt="">
  11. </view>
  12. </view>
  13. <view class="show_font left">
  14. <view class="avatar">
  15. <image mode="aspectFill" src="../../static/img/logo.png" alt="">
  16. </view>
  17. <view class="show_text">
  18. <view class="text" :style="{'font-size': value+'px'}">
  19. 拖动下面的滑块,可设置字体大小
  20. </view>
  21. </view>
  22. </view>
  23. <view class="slider-block">
  24. <view class="slider-item">
  25. <text style="font-size:12px">A</text>
  26. <text style="font-size:24px">A</text>
  27. </view>
  28. <slider min="12" block-size="20" block-color="#fff" max="24" :value="value" @change="sliderChange"
  29. step="1" />
  30. </view>
  31. </view>
  32. </template>
  33. <script>
  34. import {
  35. mapState,
  36. mapGetters,
  37. mapMutations
  38. } from 'vuex'
  39. export default {
  40. data() {
  41. return {
  42. value: 14
  43. }
  44. },
  45. computed: {
  46. ...mapState({
  47. custom_font_size: state => state.common.custom_font_size,
  48. }),
  49. },
  50. mounted() {
  51. this.value = this.custom_font_size;
  52. },
  53. methods: {
  54. ...mapMutations(['setFontSize']),
  55. sliderChange(e) {
  56. this.value = e.detail.value;
  57. },
  58. },
  59. onNavigationBarButtonTap(e) {
  60. this.setFontSize(this.value);
  61. uni.switchTab({
  62. url: '/pages/my/index'
  63. })
  64. },
  65. }
  66. </script>
  67. <style lang="scss" scoped>
  68. .show_font {
  69. display: flex;
  70. align-items: flex-start;
  71. box-sizing: border-box;
  72. padding: 10rpx 20rpx;
  73. width: 100vw;
  74. .show_text {
  75. padding-top: 20rpx;
  76. }
  77. .text {
  78. color: #333;
  79. border-radius: 4px;
  80. box-sizing: border-box;
  81. padding: 10rpx 20rpx;
  82. position: relative;
  83. max-width: 500rpx;
  84. }
  85. .avatar {
  86. width: 80rpx;
  87. height: 80rpx;
  88. image {
  89. width: 100%;
  90. height: 100%;
  91. border-radius: 8rpx;
  92. }
  93. }
  94. }
  95. .left {
  96. justify-content: flex-start;
  97. .text {
  98. background: #fff;
  99. margin-left: 30rpx;
  100. }
  101. .text::before {
  102. content: " ";
  103. position: absolute;
  104. top: 0;
  105. left: -6px;
  106. border: 6px solid transparent;
  107. border-top-color: #fff;
  108. }
  109. }
  110. .right {
  111. justify-content: flex-end;
  112. .text {
  113. background: #7dccc6;
  114. margin-right: 30rpx;
  115. }
  116. .text::before {
  117. content: " ";
  118. position: absolute;
  119. left: calc(100% - 6px);
  120. top: 0;
  121. border: 6px solid transparent;
  122. border-right-color: transparent;
  123. border-top-color: #7dccc6;
  124. }
  125. }
  126. .slider-block {
  127. background: #fff;
  128. height: 200rpx;
  129. display: flex;
  130. flex-direction: column;
  131. box-sizing: border-box;
  132. padding: 20rpx 0;
  133. position: fixed;
  134. bottom: 0;
  135. left: 0;
  136. width: 100vw;
  137. .slider-item {
  138. display: flex;
  139. justify-content: space-between;
  140. align-items: center;
  141. box-sizing: border-box;
  142. padding: 0 40rpx;
  143. }
  144. }
  145. </style>