index.tsx 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  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. // console.log('刷新结束')
  31. // emit('update:modelValue', val)
  32. }
  33. )
  34. watch(
  35. () => state.fullState,
  36. (val: boolean) => {
  37. console.log('刷新结束')
  38. emit('update:modelValue', val)
  39. }
  40. )
  41. return () => (
  42. <PullRefresh v-model:modelValue={state.fullState} onRefresh={props.onRefresh}>
  43. {{
  44. pulling: () => (
  45. <div>
  46. {<Vue3Lottie class={styles.animateWrap} animationData={AstronautJSON}></Vue3Lottie>}
  47. </div>
  48. ),
  49. loading: () => (
  50. <div>
  51. {<Vue3Lottie class={styles.animateWrap} animationData={AstronautJSON}></Vue3Lottie>}
  52. </div>
  53. ),
  54. loosing: () => (
  55. <div>
  56. {<Vue3Lottie class={styles.animateWrap} animationData={AstronautJSON}></Vue3Lottie>}
  57. </div>
  58. ),
  59. default: () => <> {slots.default && slots.default()}</>
  60. }}
  61. </PullRefresh>
  62. )
  63. }
  64. })