foodCards.jsx 3.0KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
  1. import Taro from '@tarojs/taro'
  2. import { View, Text, Image, Button, ScrollView } from '@tarojs/components'
  3. import CouponCard from '@/components/CouponCard'
  4. import Location from '@/components/Location'
  5. import { compressImage } from '@/utils'
  6. import SaveIcon from '@/components/SaveIcon'
  7. import Pay from '@/assets/icons/housemantj/pay.png'
  8. import Popup from '@/components/Popup'
  9. import { useState } from 'react'
  10. import './style.less'
  11. const CouponMedia = CouponCard.Media
  12. const Action = CouponCard.Action
  13. //套餐卡片
  14. export default (props) => {
  15. const { item, st, det, editable, setScroll, goshop, scene, subOrderId, id } = props
  16. const { shopId } = props.item
  17. const goFood = () => {
  18. Taro.navigateTo({ url: `/pages/details/foodDetails/foodDetails?id=${shopId}` })
  19. }
  20. const [showCutover, setShowCutover] = useState(false)
  21. const goDetail = () => {
  22. //打开当前套餐详情弹窗
  23. setShowCutover(true)
  24. //使父组件禁止滚动
  25. setScroll(false)
  26. }
  27. const onClose = () => {
  28. //关闭当前套餐详情弹窗
  29. setShowCutover(false)
  30. //使父组件恢复滚动
  31. setScroll(true)
  32. }
  33. const handlePayClick = () => {
  34. Taro.navigateTo({ url: `/pages/PayOrder/index?packageId=${item.packageId}&scene=${scene || ''}&subOrderId=${subOrderId}&id=${id}` })
  35. }
  36. const PayAction = <Action.Icon icon={Pay} text='支付' onClick={handlePayClick} />
  37. return (
  38. <View style={{ margin: '15px 5px' }} >
  39. <View className='packageDetail' style={{ display: goshop ? '' : 'none' }}>
  40. <Popup show={showCutover} maskClosable={showCutover} onClose={onClose}>
  41. <ScrollView
  42. scrollY
  43. style={{ maxHeight: '60vh' }}
  44. >
  45. <Image mode='widthFix' src={item.details ? item.details : item.poster} />
  46. </ScrollView>
  47. </Popup >
  48. </View>
  49. <CouponCard action={PayAction}>
  50. <CouponMedia onClick={goshop ? goDetail : goFood}>
  51. <CouponMedia.Header
  52. cashback={item.cashback}
  53. image={compressImage(item.poster)}
  54. badge='food'
  55. />
  56. <CouponMedia.Body star={st}>
  57. <View className='foodCard'>
  58. <View className='cpn-card-text'>
  59. {(item.description).toString().length > 25 ? (item.description).substring(0, 25) + '...' : (item.description)}
  60. </View>
  61. <View className='cpn-card-text' style={{ marginTop: '10rpx' }}>
  62. <Text className='cpn-card-text_mn'>¥{`${(item.actualPrice / 100)?.toFixed(2)}元`}</Text>
  63. <Text className='cpn-card-text_rm'>{`门市价${(item.standardPrice / 100)?.toFixed(2)}元`}</Text>
  64. </View>
  65. <View className='cpn-md-act'>
  66. <Location {...det} />
  67. <SaveIcon saved={item.isSaved > 0} targetType='shop_package' editable={editable} targetId={item.packageId} />
  68. </View>
  69. </View>
  70. </CouponMedia.Body>
  71. </CouponMedia>
  72. </CouponCard>
  73. </View>
  74. )
  75. }