index.vue 2.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697
  1. <template>
  2. <view class="content">
  3. <image class="logo" :src="config?.logo[0]?.url||'/static/logo.png'"></image>
  4. </view>
  5. </template>
  6. <script setup lang="ts">
  7. import { getCurrentInstance, ref } from 'vue';
  8. //该依赖已内置不需要单独安装
  9. import { onLoad } from "@dcloudio/uni-app";
  10. // 请求接口
  11. const $api = getCurrentInstance()?.appContext.config.globalProperties.$api;
  12. const $app = getCurrentInstance()?.appContext.config.globalProperties.$app;
  13. const $config = getCurrentInstance()?.appContext.config.globalProperties.$config;
  14. // 基本信息
  15. const config = ref({ logo: [] });
  16. onLoad(async () => {
  17. await searchConfig();
  18. await search();
  19. })
  20. // config信息
  21. const searchConfig = async () => {
  22. let res = await $api(`config`, 'GET', {});
  23. if (res.errcode == 0) {
  24. config.value = res.data
  25. uni.setStorage({
  26. key: 'config',
  27. data: res.data,
  28. })
  29. }
  30. };
  31. // 查询
  32. const search = async () => {
  33. uni.reLaunch({
  34. url: `/pages/home/index`
  35. })
  36. // uni.getStorage({
  37. // key: 'openid',
  38. // success: function (res) {
  39. // uni.reLaunch({
  40. // url: `/pages/home/index`
  41. // })
  42. // },
  43. // fail: function (err) {
  44. // uni.login({
  45. // success: async function (res) {
  46. // if (res.code) {
  47. // uni.reLaunch({
  48. // url: `/pages/home/index`
  49. // })
  50. // const aee = await $app('/wechat/api/login/app', 'GET', {
  51. // js_code: res.code,
  52. // config: $config.wx_projectkey
  53. // })
  54. // if (aee.errcode == '0') {
  55. // uni.setStorage({
  56. // key: "openid",
  57. // data: aee.data.openid
  58. // })
  59. // uni.reLaunch({
  60. // url: `/pages/home/index`
  61. // })
  62. // } else {
  63. // uni.showToast({
  64. // title: aee.errmsg,
  65. // icon: 'none'
  66. // })
  67. // }
  68. // } else {
  69. // uni.showToast({
  70. // title: res.errMsg,
  71. // icon: 'none'
  72. // })
  73. // }
  74. // }
  75. // });
  76. // }
  77. // })
  78. };
  79. </script>
  80. <style lang="scss" scoped>
  81. .content {
  82. display: flex;
  83. flex-direction: column;
  84. align-items: center;
  85. justify-content: center;
  86. width: 100vw;
  87. height: 100vh;
  88. .logo {
  89. width: 50vw;
  90. height: 50vw;
  91. border-radius: 90px;
  92. box-shadow: 0 0 5px #f1f1f1;
  93. }
  94. }
  95. </style>