index.vue 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. <template>
  2. <view class="content">
  3. <view class="one">
  4. </view>
  5. </view>
  6. </template>
  7. <script setup lang="ts">
  8. import {
  9. getCurrentInstance,
  10. computed,
  11. ref
  12. } from 'vue';
  13. //该依赖已内置不需要单独安装
  14. import { onPullDownRefresh, onShow } from "@dcloudio/uni-app";
  15. // 请求接口
  16. const $api = getCurrentInstance()?.appContext.config.globalProperties.$api;
  17. // openid
  18. const openid = computed(() => {
  19. return uni.getStorageSync('openid');
  20. })
  21. // 基本信息
  22. const config = ref({});
  23. onShow(() => {
  24. uni.hideHomeButton();
  25. })
  26. // 下拉刷新
  27. onPullDownRefresh(() => {
  28. uni.stopPullDownRefresh()
  29. })
  30. // 用户信息
  31. const initUser = async () => {
  32. const res = await $api(`/system/matchUser/find`, 'GET', {
  33. openid: openid.value
  34. });
  35. if (res.code === 200) {
  36. if (res.data) console.log(res.data);
  37. } else {
  38. uni.showToast({
  39. title: res.msg || '',
  40. icon: 'error',
  41. });
  42. }
  43. };
  44. // config信息
  45. const searchConfig = async () => {
  46. config.value = uni.getStorageSync('config');
  47. };
  48. initUser();
  49. searchConfig();
  50. </script>
  51. <style lang="scss" scoped>
  52. .content {
  53. display: flex;
  54. flex-direction: column;
  55. .one {
  56. height: 50vw;
  57. background-color: var(--f12Color);
  58. }
  59. }
  60. </style>