index.jsx 1.6KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. import { useMemo } from 'react'
  2. import Taro from '@tarojs/taro'
  3. import useSave from "@/utils/hooks/useSave"
  4. import { compressImage, random } from '@/utils'
  5. import msTip from '@/assets/icons/housemantj/foodtip.png'
  6. import mjTip from '@/assets/icons/housemantj/mjtip.png'
  7. import location from '@/assets/icons/housemantj/location.png'
  8. import onlove from '@/assets/icons/housemantj/onlove.png'
  9. import love from '@/assets/icons/housemantj/bheart.png'
  10. import './style.less'
  11. export default (props) => {
  12. const { className, item, style, } = props
  13. const uqClass = useMemo(() => random('f'), [])
  14. // const cls = useMemo(() => [className, 'contentCard', uqClass].filter(Boolean).join(' '), [className, uqClass])
  15. const [isSaved, toggleSave] = useSave(item.isSaved, item.targetType, item.targetId)
  16. const Detail = () => {
  17. Taro.navigateTo({ url: `/pages/details/NoteDetails/index?id=${item.noteId}` });
  18. }
  19. return (
  20. <view className={uqClass} style={{ overflow: 'hidden' }}>
  21. <view className='contentCard' style={style}>
  22. <view className='cardTop'>
  23. <image mode='widthFix' onClick={Detail} src={compressImage(item.poster)} className='cCardimg' />
  24. {/* <image className='lefttips' src={item.targetType === 'tourist' ? mjTip : msTip} /> */}
  25. <image onClick={toggleSave} src={isSaved > 0 ? onlove : love} className='loveharde'></image>
  26. </view>
  27. <view className='bContent' onClick={Detail}>
  28. <view className='cCword'>{(item.summary).toString().length > 35 ? (item.summary).substring(0, 35) + '...' : (item.summary)}</view>
  29. </view>
  30. </view>
  31. </view>
  32. )
  33. }