index.vue 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899
  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. success: function (arr) {
  29. },
  30. fail: function (err) {
  31. console.log(err);
  32. }
  33. })
  34. }
  35. };
  36. // 查询
  37. const search = async () => {
  38. uni.getStorage({
  39. key: 'openid',
  40. success: function (res) {
  41. uni.reLaunch({
  42. url: `/pages/home/index`
  43. })
  44. },
  45. fail: function (err) {
  46. uni.login({
  47. success: async function (res) {
  48. if (res.code) {
  49. uni.reLaunch({
  50. url: `/pages/home/index`
  51. })
  52. // const aee = await $app('/wechat/api/login/app', 'GET', {
  53. // js_code: res.code,
  54. // config: $config.wx_projectkey
  55. // })
  56. // if (aee.errcode == '0') {
  57. // uni.setStorage({
  58. // key: "openid",
  59. // data: aee.data.openid
  60. // })
  61. // uni.reLaunch({
  62. // url: `/pages/home/index`
  63. // })
  64. // } else {
  65. // uni.showToast({
  66. // title: aee.errmsg,
  67. // icon: 'none'
  68. // })
  69. // }
  70. } else {
  71. uni.showToast({
  72. title: res.errMsg,
  73. icon: 'none'
  74. })
  75. }
  76. }
  77. });
  78. }
  79. })
  80. };
  81. </script>
  82. <style lang="scss" scoped>
  83. .content {
  84. display: flex;
  85. flex-direction: column;
  86. align-items: center;
  87. justify-content: center;
  88. width: 100vw;
  89. height: 100vh;
  90. .logo {
  91. width: 50vw;
  92. height: 50vw;
  93. border-radius: 90px;
  94. box-shadow: 0 0 5px #f1f1f1;
  95. }
  96. }
  97. </style>