index.jsx 3.4KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889
  1. import Taro from '@tarojs/taro'
  2. import useSave from "@/utils/hooks/useSave"
  3. import { getShopDetail, getShopcity } from '@/services/home'
  4. import { useState, useEffect } from 'react'
  5. import Star from '@/components/Star/Star.jsx'
  6. import position from '@/assets/icons/GuideCheck/position_logo.png'
  7. import Pay from '@/assets/icons/GuideCheck/Pay_logo.png'
  8. import starOn from '@/assets/icons/housemantj/onlove.png'
  9. import starOff from '@/assets/icons/housemantj/景点爆赞.png'
  10. import food from '@/assets/icons/ProCard/food.png'
  11. import ProCard_hot from '@/assets/icons/ProCard/ProCard_hot.png'
  12. //入住指引--老板推荐
  13. import './style.less'
  14. export default (props) => {
  15. const { item, cardNavigateTo } = props
  16. const { shopId } = props.item
  17. const [isSaved, toggleSave] = useSave(item.isSaved, 'shop_package', item.packageId)
  18. const [city, setCity] = useState({})
  19. const [detail, setDetail] = useState({})
  20. const goFood = () => {
  21. Taro.navigateTo({ url: `/pages/details/foodDetails/foodDetails?id=${shopId}` })
  22. }
  23. useEffect(() => {
  24. getShopDetail(item.shopId).then((res) => {
  25. setDetail(res)
  26. getShopcity(res.cityId).then((x) => {
  27. setCity(x)
  28. })
  29. })
  30. }, [])
  31. const star = parseFloat(((detail.sweetScore + detail.environmentScore + detail.serviceScore) / 3).toFixed(1));
  32. return (
  33. <view class='container'>
  34. <view class='wrapper'>
  35. <view class='left-complete-one' >
  36. <image className='left-image-1' src={ProCard_hot}></image>
  37. <view className='left-viewText'>
  38. 返现¥{(item.cashback / 100)?.toFixed(2)}
  39. </view>
  40. {/* 评分 */}
  41. <view className='card-box-star'>
  42. <Star star={star} />
  43. <text className='card-star-text' >{star}</text>
  44. </view>
  45. <view className='title-image' onClick={() => { goFood() }}>
  46. <image className='image-1' mode='scaleToFill' src={item.poster}></image>
  47. <image className='image-2' src={food}></image>
  48. </view>
  49. <view className='title-content'>
  50. <view className='Pro-title' onClick={() => { goFood() }} >
  51. <view className='title-text'>{(item.description).toString().length > 25 ? (item.description).substring(0, 25) + '...' : (item.description)}</view>
  52. </view>
  53. <text className='title-money' >¥{(item.actualPrice / 100)?.toFixed(2)}元<text className='title-money-2'>门市价{(item.standardPrice / 100)?.toFixed(2)}元</text></text>
  54. <view className='title-position-on'>
  55. <image className='title-position' src={position} />
  56. <text className='title-position-image'>{city.areaPName}/{city.areaName}</text>
  57. <view style={{ display: 'inline-block' }} onClick={toggleSave}>
  58. <image className='title-on' src={isSaved > 0 ? starOn : starOff} />
  59. <text className='title-on-text'>{isSaved > 0 ? '已收藏' : '加入收藏'}</text>
  60. </view>
  61. </view>
  62. </view>
  63. </view>
  64. <view class='right-complete-two'>
  65. <view className='right-content' onClick={() => { Taro.navigateTo({ url: `/pages/PayOrder/index?packageId=${item.packageId}` }); }}>
  66. {/* <view className='right-number'>×1</view> */}
  67. <image className='right-image' src={Pay} />
  68. <view className='right-title'>支付</view>
  69. </view>
  70. </view>
  71. </view>
  72. </view>
  73. )
  74. }