index.tsx 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. import { postMessage } from '@/helpers/native-message'
  2. import { browser } from '@/helpers/utils'
  3. import { PullRefresh } from 'vant'
  4. import { defineComponent, PropType, reactive, Teleport, watch } from 'vue'
  5. import styles from './index.module.less'
  6. import { Vue3Lottie } from 'vue3-lottie'
  7. import AstronautJSON from './datas/data.json'
  8. import 'vue3-lottie/dist/style.css'
  9. export default defineComponent({
  10. name: 'o-full-refresh',
  11. props: {
  12. title: String,
  13. modelValue: {
  14. type: Boolean,
  15. default: false
  16. }
  17. },
  18. emits: ['refresh', 'update:modelValue'],
  19. setup(props, { emit, slots }) {
  20. const state = reactive({
  21. fullState: false
  22. })
  23. watch(
  24. () => props.modelValue,
  25. (val: boolean) => {
  26. state.fullState = val
  27. }
  28. )
  29. watch(
  30. () => state.fullState,
  31. (val: boolean) => {
  32. emit('update:modelValue', val)
  33. }
  34. )
  35. return () => (
  36. <PullRefresh
  37. v-model:modelValue={state.fullState}
  38. onRefresh={() => emit('refresh')}
  39. loadingText=" "
  40. class={styles.pullRefresh}
  41. >
  42. {{
  43. loading: () => (
  44. <div>
  45. {<Vue3Lottie class={styles.animateWrap} animationData={AstronautJSON}></Vue3Lottie>}
  46. </div>
  47. ),
  48. pulling: () => (
  49. <div>
  50. {<Vue3Lottie class={styles.animateWrap} animationData={AstronautJSON}></Vue3Lottie>}
  51. </div>
  52. ),
  53. loosing: () => (
  54. <div>
  55. {<Vue3Lottie class={styles.animateWrap} animationData={AstronautJSON}></Vue3Lottie>}
  56. </div>
  57. ),
  58. default: () => <> {slots.default && slots.default()}</>
  59. }}
  60. </PullRefresh>
  61. )
  62. }
  63. })