index.jsx 5.8KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128
  1. import Taro from '@tarojs/taro'
  2. import useLike from "@/utils/hooks/useLike"
  3. import { View } from '@tarojs/components'
  4. import formatPrice from "@/utils/formatPrice";
  5. import Star from '@/components/Star/Star.jsx'
  6. import position from '@/assets/icons/GuideCheck/position_logo.png'
  7. import SeeDetails from '@/assets/icons/GuideCheck/SeeDetails.png'
  8. import Attractions from '@/assets/icons/GuideCheck/Attractions.png'
  9. import baozan from '@/assets/icons/housemantj/爆赞.png'
  10. import weibaozan from '@/assets/icons/housemantj/未赞.png'
  11. import food from '@/assets/icons/ProCard/food.png'
  12. import ProCard_hot from '@/assets/icons/ProCard/ProCard_hot.png'
  13. import './style.less'
  14. export default (props) => {
  15. const { item, cardNavigateTo } = props
  16. // const [isSaved, toggleSave] = useSave(item.isSaved, 'shop_package', item.targetId)
  17. const [isLike, toggleLike] = useLike(item.isLike, 'tourist', item.targetId)
  18. const targetType = item.targetType
  19. const star = parseFloat(((item.sweetScore + item.environmentScore + item.serviceScore) / 3).toFixed(1));
  20. return (
  21. <View>
  22. {
  23. targetType === "shop_package" && (
  24. <view class='wrapper'>
  25. <view class='left-complete-one' >
  26. <image className='left-image-1' src={ProCard_hot} style={{ display: item.targetType === 'shop_package' ? '' : 'none' }} ></image>
  27. <view className='left-viewText' >
  28. 返现¥{formatPrice(item.cashback)}
  29. </view>
  30. {/* 评分 */}
  31. <view className='card-box-star' style={{ display: item.targetType === 'shop_package' ? '' : 'none' }} >
  32. <Star star={star} />
  33. <text className='card-star-text' >{star}</text>
  34. </view>
  35. <view className='title-image' >
  36. <image className='image-1' mode='scaleToFill' src={item.poster}></image>
  37. <image className='image-2' src={item.targetType === 'tourist' ? Attractions : food}></image>
  38. </view>
  39. <view className='title-content'>
  40. <view className='Pro-title' >
  41. <view className='title-text'>{(item.title).toString().length > 25 ? (item.title).substring(0, 25) + '...' : (item.title)}</view>
  42. </view>
  43. <text className='title-money' >¥{formatPrice(item.actualPrice)}元<text className='title-money-2'>门市价{formatPrice(item.standardPrice)}元</text></text>
  44. <view className='title-position-on'>
  45. <image className='title-position' src={position} />
  46. <text className='title-position-image'>
  47. {
  48. targetType === "shop_package" && (
  49. item.areaPName == null ? item.areaName : item.areaPName + '/' + item.areaName
  50. )
  51. }
  52. </text>
  53. </view>
  54. </view>
  55. </view>
  56. <view class='right-complete-two'>
  57. <view className='right-content' onClick={() => { Taro.navigateTo({ url: `/pages/details/foodDetails/foodDetails?id=${item.shopId}` }); }}>
  58. <image className='right-image' src={SeeDetails} />
  59. <view className='right-title'>查看详情</view>
  60. </view>
  61. </view>
  62. </view>
  63. )
  64. }
  65. <View>
  66. {
  67. targetType !== "shop_package" && (
  68. <view class='wrapper-tourist'>
  69. <view class='left-complete-one' >
  70. <view className='title-image'>
  71. <image className='image-1' mode='scaleToFill' src={item.poster}></image>
  72. <image className='image-2' src={item.targetType === 'tourist' ? Attractions : food}></image>
  73. </view>
  74. <view className='title-content'>
  75. <view className='Pro-title' >
  76. <view className='title-text'>{(item.title).toString().length > 25 ? (item.title).substring(0, 25) + '...' : (item.title)}</view>
  77. </view>
  78. <text className='title-money' >¥{formatPrice(item.actualPrice)}元<text className='title-money-2'>门市价{formatPrice(item.standardPrice)}元</text></text>
  79. <view onClick={toggleLike}>
  80. <image className='title-on' src={isLike === 1 ? baozan : weibaozan} />
  81. <text className='title-on-text'>{isLike === 1 ? '已爆赞' : '爆赞'}</text>
  82. </view>
  83. <view className='title-position-on'>
  84. <image className='title-position' src={position} />
  85. <text className='title-position-image'>
  86. {
  87. targetType === "tourist" && (
  88. item.areaPName == null ? item.areaName : (item.areaPName + '/' + item.areaName)
  89. )
  90. }
  91. {
  92. targetType === "shop" && (
  93. item.areaPName === null ? item.areaName : (item.areaPName + '/' + item.areaName)
  94. )
  95. }</text>
  96. </view>
  97. </view>
  98. </view>
  99. <view class='right-complete-two'>
  100. <view className='right-content' onClick={() => {
  101. if (item.targetType === "tourist") {
  102. return Taro.navigateTo({ url: `/pages/details/mjDetails/sceneryDetails?id=${item.targetId}` });
  103. } else {
  104. return Taro.navigateTo({ url: `/pages/details/mjDetails/sceneryDetails?shop=${item.shopId}` });
  105. }
  106. }}
  107. >
  108. <image className='right-image' src={SeeDetails} />
  109. <view className='right-title'>查看详情</view>
  110. </view>
  111. </view>
  112. </view>
  113. )
  114. }
  115. </View>
  116. </View>
  117. )
  118. }