index.vue 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687
  1. <template>
  2. <view class="content">
  3. <image class="logo" :src="config.logoUrl||'/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({ logoUrl: [] });
  16. onLoad(async () => {
  17. await searchConfig();
  18. await search();
  19. })
  20. // config信息
  21. const searchConfig = async () => {
  22. config.value = uni.getStorageSync('config');
  23. };
  24. // 查询
  25. const search = async () => {
  26. uni.getStorage({
  27. key: 'openid',
  28. success: function (res) {
  29. uni.reLaunch({
  30. url: `/pages/home/index`
  31. })
  32. },
  33. fail: function (err) {
  34. uni.login({
  35. success: async function (res) {
  36. if (res.code) {
  37. uni.reLaunch({
  38. url: `/pages/home/index`
  39. })
  40. // const aee = await $app('/wechat/api/login/app', 'GET', {
  41. // js_code: res.code,
  42. // config: $config.wx_projectkey
  43. // })
  44. // if (aee.errcode == '0') {
  45. // uni.setStorage({
  46. // key: "openid",
  47. // data: aee.data.openid
  48. // })
  49. // uni.reLaunch({
  50. // url: `/pages/home/index`
  51. // })
  52. // } else {
  53. // uni.showToast({
  54. // title: aee.errmsg,
  55. // icon: 'none'
  56. // })
  57. // }
  58. } else {
  59. uni.showToast({
  60. title: res.errMsg,
  61. icon: 'none'
  62. })
  63. }
  64. }
  65. });
  66. }
  67. })
  68. };
  69. </script>
  70. <style lang="scss" scoped>
  71. .content {
  72. display: flex;
  73. flex-direction: column;
  74. align-items: center;
  75. justify-content: center;
  76. width: 100vw;
  77. height: 100vh;
  78. .logo {
  79. width: 50vw;
  80. height: 50vw;
  81. border-radius: 90px;
  82. box-shadow: 0 0 5px #f1f1f1;
  83. }
  84. }
  85. </style>