You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

89 lines
1.9 KiB

  1. <template>
  2. <view class="main">
  3. <view :style="{height:iSMT+'px'}"></view>
  4. <view class="top">
  5. <view class="top-list">
  6. <text>标准</text>
  7. <radio value="0" class="radio-btn" activeBackgroundColor="red" :checked="selectedIndex === 0"
  8. @click="selectFont(0)" />
  9. </view>
  10. <view class="top-list">
  11. <text>中号</text>
  12. <radio value="1" class="radio-btn" activeBackgroundColor="red" :checked="selectedIndex === 1"
  13. @click="selectFont(1)" />
  14. </view>
  15. <view class="top-list">
  16. <text>大号</text>
  17. <radio value="2" class="radio-btn" activeBackgroundColor="red" :checked="selectedIndex === 2"
  18. @click="selectFont(2)" />
  19. </view>
  20. </view>
  21. </view>
  22. </template>
  23. <script setup>
  24. import {
  25. ref,
  26. onMounted
  27. } from 'vue'
  28. import {
  29. getSetting
  30. } from "@/api/setting/general"
  31. const iSMT = ref(0)
  32. const selectedIndex = ref(0)
  33. const getFont = async () => {
  34. try {
  35. const res = await getSetting()
  36. if (res.code === 200) {
  37. const fontSize = res.data.fontSize
  38. const sizeMap = {
  39. small: 0,
  40. medium: 1,
  41. large: 2
  42. }
  43. console.log('看看字体', res.data.fontSize)
  44. selectedIndex.value = sizeMap[fontSize] ?? 0;
  45. }
  46. } catch (err) {
  47. console.error("获取字体设置失败:", err);
  48. }
  49. }
  50. const selectFont = (index) => {
  51. selectedIndex.value = index
  52. console.log('看看选中状态', selectedIndex.value)
  53. }
  54. onMounted(() => {
  55. // 状态栏高度
  56. iSMT.value = uni.getSystemInfoSync().statusBarHeight;
  57. console.log('看看高度', iSMT.value)
  58. getFont()
  59. })
  60. </script>
  61. <style>
  62. .top {
  63. margin-top: 1.5vh;
  64. height: 21vh;
  65. background-color: white;
  66. }
  67. .top-list {
  68. width: 630rpx;
  69. height: 7vh;
  70. display: flex;
  71. align-items: center;
  72. margin: 0 40rpx;
  73. padding: 0 10rpx;
  74. border-bottom: 1rpx solid #eee;
  75. }
  76. .top-list:last-child {
  77. border-bottom: none;
  78. }
  79. .radio-btn {
  80. margin-left: auto;
  81. transform: scale(0.6);
  82. }
  83. </style>