index.vue 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  1. <route lang="json5" type="home">
  2. {
  3. style: {
  4. navigationStyle: 'custom',
  5. navigationBarTitleText: '',
  6. },
  7. }
  8. </route>
  9. <template>
  10. <view>
  11. <view id="lottieContainer" class="box"></view>
  12. <button @click="show = !show">Solana Wallet</button>
  13. <Dialog v-model:show-value="show" position="top" width="100%"></Dialog>
  14. <button>1</button>
  15. </view>
  16. </template>
  17. <script setup lang="ts">
  18. import { useLaunchParams } from '@telegram-apps/sdk-vue'
  19. import lottie from 'lottie-web'
  20. import animationData from '@/static/Animation.json'
  21. import Dialog from '@/components/common/Dialog/index.vue'
  22. import { useUserStore } from '@/store/user'
  23. import { getShareCode } from '@/service/team'
  24. const pl = useLaunchParams()
  25. const useStore = useUserStore()
  26. const show = ref(false)
  27. const initUser = async (user: any, shareCode: string) => {
  28. const data = await useStore.setUserInfo(user, shareCode)
  29. }
  30. onShow(async () => {
  31. await initUser(pl.initData.user, uni.getStorageSync('shareCode') || '')
  32. const { data } = await getShareCode()
  33. nextTick(() => {
  34. const query = uni.createSelectorQuery()
  35. query
  36. .select('#lottieContainer')
  37. .boundingClientRect((rect) => {
  38. if (rect) {
  39. lottie.loadAnimation({
  40. container: document.getElementById('lottieContainer'),
  41. renderer: 'svg',
  42. loop: true,
  43. autoplay: true,
  44. animationData,
  45. })
  46. } else {
  47. console.error('Container element not found')
  48. }
  49. })
  50. .exec()
  51. })
  52. })
  53. </script>
  54. <style lang="scss" scoped>
  55. .box {
  56. width: 690rpx;
  57. height: 500rpx;
  58. overflow: hidden; /* 如果动画超出容器大小,确保它不会溢出 */
  59. }
  60. </style>