index.tsx 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. import { Button, Popup } from 'vant'
  2. import {} from 'vant'
  3. import { defineComponent, nextTick, onMounted, reactive, ref, watch } from 'vue'
  4. import state from '/src/pages/detail/state'
  5. import styles from './index.module.less'
  6. import Tip1 from './tip1'
  7. import Tip2 from './tip2'
  8. import { modelType } from '../buttons'
  9. export default defineComponent({
  10. name: 'tips-step',
  11. setup(props, ctx) {
  12. const tipShow = ref(false)
  13. const guide = reactive({
  14. tip1: false,
  15. tip2: false
  16. })
  17. watch(
  18. () => state.initRendered,
  19. () => {
  20. const isFirstTip = localStorage.getItem('isFirstTip')
  21. if (state.initRendered && !isFirstTip) {
  22. // tipShow.value = true
  23. // guide.tip1 = true
  24. // guide.tip2 = false
  25. console.log('首次渲染结束')
  26. }
  27. }
  28. )
  29. watch(modelType, () => {
  30. console.log(modelType.value)
  31. const isFirstModel = localStorage.getItem('isFirstModel')
  32. if(modelType.value === 'practice' && !isFirstModel){
  33. // tipShow.value = true
  34. // guide.tip1 = false
  35. // guide.tip2 = true
  36. console.log('模式更改')
  37. }
  38. })
  39. const setLocalData = (key: string) => {
  40. localStorage.setItem(key, 'ok')
  41. }
  42. return () => (
  43. <Popup teleport="body" closeOnClickOverlay={false} class={styles.tipsContainer} v-model:show={tipShow.value}>
  44. {guide.tip1 && <Tip1 onHanldeStop={() => {
  45. tipShow.value = false
  46. setLocalData('isFirstTip')
  47. }} />}
  48. {guide.tip2 && <Tip2 onHanldeStop={() => {
  49. tipShow.value = false
  50. setLocalData('isFirstModel')
  51. }} />}
  52. </Popup>
  53. )
  54. },
  55. })