index.jsx 1.5KB

12345678910111213141516171819202122232425262728293031323334353637383940
  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 onlove from '@/assets/icons/housemantj/onlove.png'
  6. import love from '@/assets/icons/housemantj/bheart.png'
  7. import VideoStart from '@/assets/icons/housemantj/VideoStart.png'
  8. import './style.less'
  9. export default (props) => {
  10. const { className, item, style, } = props
  11. const uqClass = useMemo(() => random('f'), [])
  12. // const cls = useMemo(() => [className, 'contentCard', uqClass].filter(Boolean).join(' '), [className, uqClass])
  13. const [isSaved, toggleSave] = useSave(item.isSaved, 'note', item.noteId)
  14. const Detail = () => {
  15. Taro.navigateTo({ url: `/pages/details/NoteDetails/index?id=${item.noteId}` });
  16. }
  17. return (
  18. <view className={uqClass} style={{ overflow: 'hidden', backgroundColor: 'while' }}>
  19. <view className='contentCard' style={style}>
  20. <view className='cardTop'>
  21. <image mode='widthFix' src={compressImage(item.poster)} className='cCardimg' />
  22. <image className='lefttips' src={item.noteType == 'video' ? VideoStart : ''} />
  23. <image onClick={toggleSave} src={isSaved > 0 ? onlove : love} className='loveharde'></image>
  24. </view>
  25. <view className='bContent' onClick={Detail}>
  26. <view className='cCword'>{(item.summary).toString().length > 35 ? (item.summary).substring(0, 35) + '...' : (item.summary)}</view>
  27. </view>
  28. </view>
  29. </view>
  30. )
  31. }