config.vue 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990
  1. <template>
  2. <hc-sys class="hc-config-page" :isNavBar="false">
  3. <view class="cu-list menu sm-border mt-1">
  4. <view class="cu-item arrow" @click="toPageClick('/pages/my/info')">
  5. <view class="content hc-flex">
  6. <text class="i-ri-user-3-fill text-blue text-32 mr-1"/>
  7. <text class="text-gray-4">个人资料</text>
  8. </view>
  9. <view class="action">{{userInfo.real_name}}</view>
  10. </view>
  11. <view class="cu-item">
  12. <view class="content hc-flex">
  13. <text class="i-solar-calendar-search-outline text-red-4 text-32 mr-1"/>
  14. <text class="text-gray-4">填报提醒</text>
  15. </view>
  16. <view class="action">
  17. <switch class="red" :class="appCheck?'checked':''" :checked="appCheck" @change="fillSwitchChange" style="transform:scale(0.9)"/>
  18. </view>
  19. </view>
  20. </view>
  21. <view class="cu-list menu sm-border">
  22. <view class="cu-item">
  23. <view class="content hc-flex">
  24. <text class="i-ri-pantone-fill text-purple text-32 mr-1"/>
  25. <text class="text-gray-4">当前版本</text>
  26. </view>
  27. <view class="action text-gray-5">v{{appInfo.appVersion}}</view>
  28. </view>
  29. <view class="cu-item" @click="detectUpgrades">
  30. <view class="content hc-flex">
  31. <text class="i-ri-rocket-fill text-cyan text-32 mr-1"/>
  32. <text class="text-gray-4">检测升级</text>
  33. </view>
  34. <view class="action">
  35. <view class="cu-tag round bg-blue light" v-if="appInfo.isUpdate">v{{appInfo.version}}</view>
  36. <text class="text-26 text-gray-5" v-else>暂无新版本</text>
  37. </view>
  38. </view>
  39. </view>
  40. </hc-sys>
  41. </template>
  42. <script setup>
  43. import {ref, watch} from "vue";
  44. import {onLoad} from '@dcloudio/uni-app'
  45. import {useAppStore} from "@/store";
  46. import userApi from '~api/user/index';
  47. //初始变量
  48. const store = useAppStore()
  49. const userInfo = ref(store.userInfo);
  50. const appInfo = ref(store.appUpdate)
  51. //渲染完成
  52. onLoad(() => {
  53. userConfigInfo()
  54. })
  55. //监听
  56. watch(() => [
  57. store.appUpdate
  58. ], ([val]) => {
  59. appInfo.value = val
  60. })
  61. const toPageClick = (url) => {
  62. uni.navigateTo({url: url});
  63. }
  64. //获取配置
  65. const appCheck = ref(true)
  66. const userConfigInfo = async () => {
  67. const { data } = await userApi.userConfigInfo()
  68. appCheck.value = data?.appCheck !== 2
  69. }
  70. //填报弹窗
  71. const fillSwitchChange = ({detail}) => {
  72. const check = detail.value ? 1 : 2
  73. userApi.userConfigSave({
  74. appCheck: check
  75. })
  76. appCheck.value = detail.value
  77. }
  78. //检测升级
  79. const detectUpgrades = () => {
  80. store.setOnUpdate(new Date().getTime())
  81. }
  82. </script>