import Star from '@/components/Star/Star.jsx'
import Taro from '@tarojs/taro'
import pay from '@/assets/icons/housemantj/pay.png'
import msTip from '@/assets/icons/housemantj/foodtip.png'
import wz from '@/assets/icons/housemantj/location.png'
import hongxin from '@/assets/icons/housemantj/已收藏.png'
import baixin from '@/assets/icons/housemantj/收藏.png'
import './style.less'
import useSave from "@/utils/hooks/useSave"


//套餐卡片
export default (props) => {
  const { star, item, city } = props
  const [isSaved, toggleSave] = useSave(item.isSaved, 'shop_package', item.packageId)
  const Detail = () => {
    Taro.navigateTo({ url: `/pages/PayOrder/index?id=${item.packageId}&shopId=${item.shopId}` });

  }

  return (
    <view className='foodCard'>
      <view className='fCleft'>
        <view className='backMoney'>
          返现￥{item.cashback}
        </view>
        <view className='appraise'>
          <Star star={star} />
          <text className='storezf'>{star}</text>
        </view>
        <view>
          <view className='contentImg'>
            <image src={item.poster} className='img1' ></image>
            <image src={msTip} className='mstip'></image>
          </view>
          <view className='neirong'>
            <view className='textword'>{item.description}</view>
            <view className='jiage'>
              <text className='rmb' >￥&nbsp;&nbsp;</text>
              <text className='p1'><text className='price' >{item.actualPrice}</text>元&nbsp;&nbsp;</text>
              <text className='p2'>门市价<text className='oldprice' >{item.standardPrice}</text>元</text>
            </view>
            <view className='address'>
              <image className='dw' src={wz} />
              <text className='wz'>{city.areaPName}/{city.areaName}</text>
              <view style={{ display: 'inline-block' }} onClick={toggleSave}>
                <image className='star' src={isSaved > 0 ? hongxin : baixin}></image>
                <text className='collection'>{isSaved > 0 ? '已收藏' : '加入收藏'}</text>
              </view>
            </view>
          </view>
        </view>
      </view>
      <view className='fCright' onClick={() => Detail()} >
        <image src={pay} />
        <view>支付</view>
      </view>
      <view className='columnLine'></view>
    </view>

  )
}