吃个甘蔗嚼一年 3 anni fa
parent
commit
34c9f7d8ed
1 ha cambiato i file con 147 aggiunte e 0 eliminazioni
  1. 147
    0
      src/components/CollectList/FoodCollect/index.jsx

+ 147
- 0
src/components/CollectList/FoodCollect/index.jsx Vedi File

@@ -0,0 +1,147 @@
1
+import Taro from '@tarojs/taro'
2
+import useSave from "@/utils/hooks/useSave"
3
+import useLike from "@/utils/hooks/useLike"
4
+
5
+import { getShopDetail, getShopcity } from '@/services/home'
6
+import { useState, useEffect } from 'react'
7
+import { View } from '@tarojs/components'
8
+
9
+import Star from '@/components/Star/Star.jsx'
10
+import position from '@/assets/icons/GuideCheck/position_logo.png'
11
+import SeeDetails from '@/assets/icons/GuideCheck/SeeDetails.png'
12
+import Attractions from '@/assets/icons/GuideCheck/Attractions.png'
13
+import baozan from '@/assets/icons/housemantj/爆赞.png'
14
+import weibaozan from '@/assets/icons/housemantj/未赞.png'
15
+import starOn from '@/assets/icons/housemantj/onlove.png'
16
+import starOff from '@/assets/icons/housemantj/景点爆赞.png'
17
+import food from '@/assets/icons/ProCard/food.png'
18
+import ProCard_hot from '@/assets/icons/ProCard/ProCard_hot.png'
19
+
20
+
21
+
22
+
23
+import './style.less'
24
+
25
+export default (props) => {
26
+  const { item, cardNavigateTo } = props
27
+  const shopId = props.item
28
+  const [isSaved, toggleSave] = useSave(item.isSaved, 'shop_package', item.targetId)
29
+  const [isLike, toggleLike] = useLike(item.isLike, 'shop', item.targetId)
30
+
31
+  const [city, setCity] = useState({})
32
+  const [detail, setDetail] = useState({})
33
+  const [hotStyle, setHotStyle] = useState('none')
34
+  const targetType = item.targetType
35
+  // item.targetType !== 'shop_package'
36
+
37
+
38
+  const goFood = () => {
39
+    // Taro.navigateTo({ url: `/pages/details/foodDetails/foodDetails?id=${shopId}` })
40
+  }
41
+
42
+  // useEffect(() => {
43
+  //   if (shopId) {
44
+  //     getShopDetail(item.shopId).then((res) => {
45
+  //       setDetail(res)
46
+  //       getShopcity(res.cityId).then((x) => {
47
+  //         setCity(x)
48
+  //       })
49
+  //     })
50
+  //   }
51
+
52
+  // }, [shopId, targetType])
53
+
54
+  // useEffect(() => {
55
+  //   if (item.targetType !== 'shop_package') {
56
+  //     console.log(item.targetType);
57
+  //   }
58
+
59
+  // }, [item.targetType])
60
+
61
+
62
+
63
+  const star = parseFloat(((item.sweetScore + item.environmentScore + item.serviceScore) / 3).toFixed(1));
64
+  return (
65
+    <View>
66
+      {
67
+        targetType === "shop_package" && (
68
+          <view class='wrapper'>
69
+            <view class='left-complete-one'   >
70
+              <image className='left-image-1' src={ProCard_hot} style={{ display: item.targetType === 'shop_package' ? '' : 'none' }} ></image>
71
+              <view className='left-viewText'  >
72
+                返现¥{item.cashback / 100}
73
+              </view>
74
+              {/* 评分 */}
75
+              <view className='card-box-star' style={{ display: item.targetType === 'shop_package' ? '' : 'none' }} >
76
+                <Star star={star} />
77
+                <text className='card-star-text' >{star}</text>
78
+              </view>
79
+              <view className='title-image' onClick={() => { goFood() }}>
80
+                <image className='image-1' mode='scaleToFill' src={item.poster}></image>
81
+                <image className='image-2' src={item.targetType === 'tourist' ? Attractions : food}></image>
82
+              </view>
83
+              <view className='title-content'>
84
+                <view className='Pro-title' onClick={() => { goFood() }} >
85
+                  <view className='title-text'>{(item.title).toString().length > 25 ? (item.title).substring(0, 25) + '...' : (item.title)}</view>
86
+                </view>
87
+                <text className='title-money' >¥{item.actualPrice / 100}元<text className='title-money-2'>门市价{item.standardPrice / 100}元</text></text>
88
+                <view className='title-position-on'>
89
+                  <image className='title-position' src={position} />
90
+                  <text className='title-position-image'>{item.areaPName}/{item.areaName}</text>
91
+                </view>
92
+              </view>
93
+            </view>
94
+            <view class='right-complete-two'>
95
+              <view className='right-content' onClick={() => { Taro.navigateTo({ url: `/pages/PayOrder/index?packageId=${item.packageId}` }); }}>
96
+                {/* <view className='right-number'>×1</view> */}
97
+                <image className='right-image' src={SeeDetails} />
98
+                <view className='right-title'>查看详情</view>
99
+              </view>
100
+            </view>
101
+          </view>
102
+        )
103
+      }
104
+      <View>
105
+        {
106
+          targetType !== "shop_package" && (
107
+            <view class='wrapper-tourist'>
108
+              <view class='left-complete-one'   >
109
+                <view className='title-image' onClick={() => { goFood() }}>
110
+                  <image className='image-1' mode='scaleToFill' src={item.poster}></image>
111
+                  <image className='image-2' src={item.targetType === 'tourist' ? Attractions : food}></image>
112
+                </view>
113
+                <view className='title-content'>
114
+                  <view className='Pro-title' onClick={() => { goFood() }} >
115
+                    <view className='title-text'>{(item.title).toString().length > 25 ? (item.title).substring(0, 25) + '...' : (item.title)}</view>
116
+                  </view>
117
+                  <text className='title-money' >¥{item.actualPrice / 100}元<text className='title-money-2'>门市价{item.standardPrice / 100}元</text></text>
118
+                  <view onClick={toggleSave}>
119
+                    <image className='title-on' src={isLike > 0 ? baozan : weibaozan} />
120
+                    <text onClick={toggleLike} className='title-on-text'>{isLike > 0 ? '已爆赞' : '爆赞'}</text>
121
+                  </view>
122
+                  <view className='title-position-on'>
123
+
124
+                    <image className='title-position' src={position} />
125
+
126
+                    <text className='title-position-image'>{item.areaPName}/{item.areaName}</text>
127
+
128
+                  </view>
129
+                </view>
130
+              </view>
131
+              <view class='right-complete-two'>
132
+                <view className='right-content' onClick={() => { Taro.navigateTo({ url: `/pages/PayOrder/index?packageId=${item.packageId}` }); }}>
133
+                  {/* <view className='right-number'>×1</view> */}
134
+                  <image className='right-image' src={SeeDetails} />
135
+                  <view className='right-title'>查看详情</view>
136
+                </view>
137
+              </view>
138
+            </view>
139
+          )
140
+        }
141
+      </View>
142
+
143
+    </View>
144
+
145
+
146
+  )
147
+}