Information.jsx 1.4KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. import { View, Image } from "@tarojs/components"
  2. import Taro from "@tarojs/taro"
  3. import { useEffect, useState } from "react"
  4. import withLayout from '@/layouts'
  5. import { getNewsList } from "@/services/news"
  6. import formatTimes from "@/utils/codeSegment"
  7. import ListPlaceholder from "@/components/ListPlaceholder"
  8. import './InformationCss/style.less'
  9. export default withLayout((props) => {
  10. const [newList, setNewList] = useState([])
  11. const goInfoMationInfo = (res) => {
  12. Taro.navigateTo({ url: `/pages/InformationInfo/index?id=${res}` })
  13. }
  14. useEffect(() => {
  15. getNewsList().then((res) => {
  16. setNewList(res.records)
  17. })
  18. }, [])
  19. return (
  20. <scroll-view scrollY style='height: 100%;' >
  21. <View >
  22. {
  23. newList?.length > 0 ? newList?.map((item, index) => {
  24. return (
  25. <View key={index} className='help-center-cell' onClick={() => goInfoMationInfo(item?.newsId)} >
  26. <Image src={item?.thumb} />
  27. <View className='help-center-cell-bottom' >
  28. <View className='help-center-cell-bottom-title' >{item?.title}</View>
  29. <View className='help-center-cell-bottom-content' >{formatTimes(item?.createDate, 'yyyy-mm-dd')}</View>
  30. </View>
  31. </View>
  32. )
  33. }) : <ListPlaceholder title='暂无农业资讯' />
  34. }
  35. </View>
  36. </scroll-view>
  37. )
  38. })