index.jsx 2.9KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114
  1. import Taro from '@tarojs/taro'
  2. import { View, Text } from '@tarojs/components'
  3. import DeleteTravel from '@/assets/icons/Travel/delete.png'
  4. import RecommendedCard from '@/components/foodCards/RecommendedCard'
  5. import SpinBox from "@/components/Spin/SpinBox";
  6. import { useState, useEffect } from 'react'
  7. import { deleteTravel, getRecommendList } from '@/services/travel'
  8. import './style.css'
  9. export default (props) => {
  10. const { frameTitle, onRecommend, flag, ico, textNext, location, dayNumber, travelId, handelAddTravel } = props
  11. // const [flag, setFlag] = useState(false)
  12. // const [wrapAnimate, setWrapAnimate] = useState('wrap wrapAnimate')
  13. // const [frameAnimate, setFrameAnimate] = useState('frame-wrapper frameAnimate')
  14. let wrapAnimate = 'wrap wrapAnimate'
  15. let frameAnimate = 'frame-wrapper frameAnimate'
  16. const [textNextSum, setTextNext] = useState(1)
  17. const [recommendContent, setRecommendContent] = useState([])
  18. const [loading, setLoading] = useState(false)
  19. const hideFrame = () => {
  20. wrapAnimate = 'wrap wrapAnimateOut'
  21. frameAnimate = 'frame-wrapper frameAnimateOut'
  22. onRecommend()
  23. }
  24. const catchNone = () => {
  25. //阻止冒泡
  26. }
  27. const handelText = () => {
  28. handleTextNext()
  29. }
  30. useEffect(() => {
  31. setLoading(true)
  32. getRecommendList({ location: location, pageNum: textNextSum, pageSize: 3 }).then(e => {
  33. setRecommendContent(e.records)
  34. setLoading(false)
  35. }).catch(s => {
  36. setLoading(false)
  37. })
  38. }, [location, textNextSum])
  39. //换一批
  40. const handleTextNext = (e) => {
  41. // setLoading(true)
  42. setTextNext(textNextSum + 1)
  43. e.stopPropagation()
  44. // getRecommendList({ location: location, pageNum: textNextSum, pageSize: 3 }).then(e => {
  45. // setRecommendContent(e.records)
  46. // setLoading(false)
  47. // }).catch(s => {
  48. // setLoading(false)
  49. // })
  50. }
  51. return (
  52. flag && <view >
  53. <view className={wrapAnimate} style='background:rgba(0,0,0,0);'></view>
  54. <view onClick={hideFrame} className={frameAnimate}>
  55. <view onClick={catchNone} className='frame'>
  56. {/* 标题 */}
  57. <view className='title-wrapper '>
  58. <view>{frameTitle}</view>
  59. {/* <image onClick={hideFrame} src={DeleteTravel} mode='widthFix'></image> */}
  60. </view>
  61. {/* 内容 */}
  62. <View style='overflow-x: hidden;'>
  63. <SpinBox loading={loading}>
  64. {
  65. recommendContent.map((item, index) =>
  66. <RecommendedCard key={index} item={item} det={item} editable='1' location={location} travelId={travelId} dayNumber={dayNumber} handelAddTravel={handelAddTravel} />
  67. )
  68. }
  69. {props.children}
  70. </SpinBox>
  71. <view className='bottom-text' onClick={handleTextNext}>
  72. <image src={ico} />
  73. <text>{textNext}</text>
  74. </view>
  75. </View>
  76. </view>
  77. </view>
  78. </view>
  79. )
  80. }