index.tsx 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  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. onRefresh: {
  18. type: Function,
  19. default: () => {}
  20. }
  21. },
  22. setup(props, { emit, slots }) {
  23. const state = reactive({
  24. fullState: false
  25. })
  26. watch(
  27. () => props.modelValue,
  28. (val: boolean) => {
  29. state.fullState = val
  30. }
  31. )
  32. watch(
  33. () => state.fullState,
  34. (val: boolean) => {
  35. emit('update:modelValue', val)
  36. }
  37. )
  38. return () => (
  39. <PullRefresh v-model:modelValue={state.fullState} onRefresh={props.onRefresh}>
  40. {{
  41. loading: () => (
  42. <div>
  43. {<Vue3Lottie class={styles.animateWrap} animationData={AstronautJSON}></Vue3Lottie>}
  44. </div>
  45. ),
  46. pulling: () => (
  47. <div>
  48. {<Vue3Lottie class={styles.animateWrap} animationData={AstronautJSON}></Vue3Lottie>}
  49. </div>
  50. ),
  51. loosing: () => (
  52. <div>
  53. {<Vue3Lottie class={styles.animateWrap} animationData={AstronautJSON}></Vue3Lottie>}
  54. </div>
  55. ),
  56. default: () => <> {slots.default && slots.default()}</>
  57. }}
  58. </PullRefresh>
  59. )
  60. }
  61. })