|
@@ -3,69 +3,55 @@ import { View, Image, Text, ScrollView } from "@tarojs/components";
|
3
|
3
|
import { AtTabs, AtActivityIndicator } from "taro-ui";
|
4
|
4
|
import "./index.less";
|
5
|
5
|
import Taro from "@tarojs/taro";
|
|
6
|
+import {
|
|
7
|
+ getNewYearTab,
|
|
8
|
+ getNewYearProductList,
|
|
9
|
+} from "../../../service/activity";
|
|
10
|
+import { addLog } from "../../../service/index";
|
|
11
|
+import { formatDate } from "../../../common/time";
|
6
|
12
|
export default class Index extends Component {
|
7
|
13
|
state = {
|
8
|
14
|
current: 0,
|
9
|
15
|
page: 1, //页数
|
10
|
16
|
loading: false, //加载状态
|
11
|
17
|
totalPages: 1, // 添加总页数
|
12
|
|
- isNoMore: false, // 是否没有更多
|
|
18
|
+ tabList: [], //tab列表
|
13
|
19
|
productList: [], //商品列表
|
14
|
|
- tags: [
|
15
|
|
- { title: "全部" },
|
16
|
|
- { title: "限时秒杀" },
|
17
|
|
- { title: "限时秒杀" },
|
18
|
|
- { title: "限时秒杀" },
|
19
|
|
- { title: "限时秒杀" },
|
20
|
|
- { title: "限时秒杀" },
|
21
|
|
- { title: "限时秒杀" },
|
22
|
|
- ],
|
23
|
|
- productList: [
|
24
|
|
- {
|
25
|
|
- id: 1,
|
26
|
|
- name: "新款时尚连衣裙2024春新款时尚连衣裙2024春新款时尚连衣裙2024春",
|
27
|
|
- price: "29.00",
|
28
|
|
- commission: "29.9",
|
29
|
|
- image: "https://yushi.tos-cn-beijing.volces.com/products/product1.png",
|
30
|
|
- },
|
31
|
|
- {
|
32
|
|
- id: 2,
|
33
|
|
- name: "轻奢真皮小方包",
|
34
|
|
- price: "458.00",
|
35
|
|
- commission: "45.8",
|
36
|
|
- image: "https://yushi.tos-cn-beijing.volces.com/products/product2.png",
|
37
|
|
- },
|
38
|
|
- {
|
39
|
|
- id: 3,
|
40
|
|
- name: "高端蚕丝围巾披肩",
|
41
|
|
- price: "199.00",
|
42
|
|
- commission: "19.9",
|
43
|
|
- image: "https://yushi.tos-cn-beijing.volces.com/products/product3.png",
|
44
|
|
- },
|
45
|
|
- {
|
46
|
|
- id: 4,
|
47
|
|
- name: "925纯银项链女",
|
48
|
|
- price: "328.00",
|
49
|
|
- commission: "32.8",
|
50
|
|
- image: "https://yushi.tos-cn-beijing.volces.com/products/product4.png",
|
51
|
|
- },
|
52
|
|
- {
|
53
|
|
- id: 5,
|
54
|
|
- name: "小众设计感衬衫",
|
55
|
|
- price: "268.00",
|
56
|
|
- commission: "26.8",
|
57
|
|
- image: "https://yushi.tos-cn-beijing.volces.com/products/product5.png",
|
58
|
|
- },
|
59
|
|
- ],
|
|
20
|
+ isShare: false, // 是否是分享跳转
|
|
21
|
+ isShowBack: false, // 是否显示返回按钮
|
|
22
|
+ };
|
|
23
|
+ componentDidMount() {
|
|
24
|
+ const { isShare, isShowBack,shareUserId } =
|
|
25
|
+ Taro.getCurrentInstance().router.params || "";
|
|
26
|
+ this.setState(
|
|
27
|
+ { isShare: isShare || false, isShowBack: isShowBack || false,shareUserId:shareUserId||'' },
|
|
28
|
+ () => {
|
|
29
|
+ if (isShare) {
|
|
30
|
+ Taro.hideHomeButton(); //隐藏返回首页
|
|
31
|
+ }
|
|
32
|
+ this.getTab(); //获取tab
|
|
33
|
+ this.handleLog(); //埋点
|
|
34
|
+ }
|
|
35
|
+ );
|
|
36
|
+ }
|
|
37
|
+ // 获取tab
|
|
38
|
+ getTab = async () => {
|
|
39
|
+ const res = await getNewYearTab();
|
|
40
|
+ const arr = [];
|
|
41
|
+ res.forEach((item) => {
|
|
42
|
+ arr.push({ title: item.title, id: item.id, name: item.name });
|
|
43
|
+ });
|
|
44
|
+ this.setState({ tabList: arr }, () => {
|
|
45
|
+ this.getProductList(true);
|
|
46
|
+ });
|
60
|
47
|
};
|
61
|
|
- componentDidMount() {}
|
62
|
48
|
// 获取商品列表
|
63
|
|
- getBrowseShopProductList = async (isRefresh = false) => {
|
|
49
|
+ getProductList = async (isRefresh = false) => {
|
64
|
50
|
const { page } = this.state;
|
65
|
51
|
this.setState({ loading: true });
|
66
|
52
|
|
67
|
|
- const res = await getBrowseShopProductList({
|
68
|
|
- tag_name: this.state.tabList[this.state.current].title,
|
|
53
|
+ const res = await getNewYearProductList({
|
|
54
|
+ tag_id: this.state.tabList[this.state.current].id,
|
69
|
55
|
page,
|
70
|
56
|
page_size: 10,
|
71
|
57
|
});
|
|
@@ -78,44 +64,97 @@ export default class Index extends Component {
|
78
|
64
|
loading: false,
|
79
|
65
|
}));
|
80
|
66
|
};
|
|
67
|
+ // 埋点
|
|
68
|
+ handleLog = () => {
|
|
69
|
+ const dayid = formatDate(new Date(), "YYYY-MM-DD");
|
|
70
|
+ let userId = "";
|
|
71
|
+ if (Taro.getStorageSync("loginInfo")) {
|
|
72
|
+ userId = Taro.getStorageSync("loginInfo").id;
|
|
73
|
+ }
|
|
74
|
+ // 构建ext对象,包含share_id
|
|
75
|
+ let ext = "";
|
|
76
|
+ if (this.state.shareUserId) {
|
|
77
|
+ ext = JSON.stringify({
|
|
78
|
+ share_users_id: this.state.shareUserId,
|
|
79
|
+ });
|
|
80
|
+ }
|
|
81
|
+ addLog({
|
|
82
|
+ users_id: userId || 0,
|
|
83
|
+ goods_id: 0,
|
|
84
|
+ event_type: this.state.isShare ? "share_to_activity" : "click_to_activity",
|
|
85
|
+ event_type_title: this.state.isShare ? "从分享链接进入春节活动页" : "直接点击进入春节活动页",
|
|
86
|
+ dayid,
|
|
87
|
+ ext,
|
|
88
|
+ });
|
|
89
|
+ };
|
81
|
90
|
// 返回
|
82
|
91
|
handleBack = () => {
|
83
|
92
|
Taro.navigateBack();
|
84
|
93
|
};
|
|
94
|
+ // 专场点击
|
|
95
|
+ siteClick = (title, index) => {
|
|
96
|
+ const item = this.state.tabList.find((item) => item.name === title);
|
|
97
|
+ const id = item ? item.id : "";
|
|
98
|
+ Taro.navigateTo({
|
|
99
|
+ url: `/pages/indexSub/seckillIndex/index?id=${id}&&title=${title}&&isShowBack=${this.state.isShowBack}&&isShare=${this.state.isShare}&&isDirect=true`,
|
|
100
|
+ });
|
|
101
|
+ };
|
85
|
102
|
// 切换tab
|
86
|
103
|
tabClick = (index) => {
|
87
|
|
- this.setState({
|
88
|
|
- current: index,
|
89
|
|
- // page: 1,
|
90
|
|
- // productList: [],
|
91
|
|
- // isNoMore: false,
|
92
|
|
- // isLoading: false,
|
|
104
|
+ this.setState(
|
|
105
|
+ {
|
|
106
|
+ current: index,
|
|
107
|
+ page: 1,
|
|
108
|
+ productList: [],
|
|
109
|
+ isLoading: false,
|
|
110
|
+ },
|
|
111
|
+ () => {
|
|
112
|
+ this.getProductList(true);
|
|
113
|
+ }
|
|
114
|
+ );
|
|
115
|
+ };
|
|
116
|
+ // 商品详情
|
|
117
|
+ handleProductDetail = (product) => {
|
|
118
|
+ Taro.navigateTo({
|
|
119
|
+ url: `/pages/indexSub/productDetail/index?id=${product.id}&&isShare=${this.state.isShare}&&isShowBack=${this.state.isShowBack}`,
|
93
|
120
|
});
|
94
|
|
- // this.getBrowseShopProductList(true);
|
95
|
121
|
};
|
96
|
122
|
// 滚动到底部
|
97
|
123
|
handleScrollToLower = () => {
|
98
|
|
- console.log("滚动到底部");
|
99
|
|
- return;
|
100
|
124
|
const { page, totalPages, loading } = this.state;
|
101
|
125
|
if (page < totalPages && !loading) {
|
102
|
126
|
this.setState(
|
103
|
127
|
(prevState) => ({ page: prevState.page + 1 }),
|
104
|
|
- () => this.getBrowseShopProductList()
|
|
128
|
+ () => this.getProductList()
|
105
|
129
|
);
|
106
|
130
|
}
|
107
|
131
|
};
|
|
132
|
+ // 配置分享内容
|
|
133
|
+ onShareAppMessage() {
|
|
134
|
+ let shareUserId = "";
|
|
135
|
+ if (Taro.getStorageSync("loginInfo")) {
|
|
136
|
+ shareUserId = Taro.getStorageSync("loginInfo").id;
|
|
137
|
+ }
|
|
138
|
+ return {
|
|
139
|
+ title: "新春活动",
|
|
140
|
+ path: `/pages/indexSub/activity/index?isShare=true&&isShowBack=true&&shareUserId=${shareUserId}`,
|
|
141
|
+ imageUrl: "",
|
|
142
|
+ };
|
|
143
|
+ }
|
108
|
144
|
render() {
|
109
|
145
|
return (
|
110
|
146
|
<View className="index">
|
111
|
147
|
{/* 返回按钮 */}
|
112
|
|
- <Image
|
113
|
|
- onClick={this.handleBack}
|
114
|
|
- style={{ top: Taro.navigationBarHeight + "px" }}
|
115
|
|
- className="top-back"
|
116
|
|
- src="https://yushi.tos-cn-beijing.volces.com/activity/back.png"
|
117
|
|
- mode="widthFix"
|
118
|
|
- />
|
|
148
|
+ {
|
|
149
|
+ !this.state.isShare && (
|
|
150
|
+ <Image
|
|
151
|
+ onClick={this.handleBack}
|
|
152
|
+ style={{ top: Taro.navigationBarHeight + "px" }}
|
|
153
|
+ className="top-back"
|
|
154
|
+ src="https://yushi.tos-cn-beijing.volces.com/activity/back.png"
|
|
155
|
+ mode="widthFix"
|
|
156
|
+ />
|
|
157
|
+ )}
|
119
|
158
|
{/* 顶部图片包裹盒子 */}
|
120
|
159
|
<View className="top-img-wrap">
|
121
|
160
|
<Image
|
|
@@ -130,68 +169,100 @@ export default class Index extends Component {
|
130
|
169
|
/>
|
131
|
170
|
</View>
|
132
|
171
|
{/* 专场 */}
|
133
|
|
- <View className="activity-wrap">
|
134
|
|
- <View className="topBox">
|
135
|
|
- <View className="item">
|
136
|
|
- <View className="item-title">下午茶专场</View>
|
137
|
|
- <Image
|
138
|
|
- className="item-img"
|
139
|
|
- src="https://yushi.tos-cn-beijing.volces.com/activity/topOne.png"
|
140
|
|
- mode="widthFix"
|
141
|
|
- />
|
142
|
|
- <View className="item-text">点击进入</View>
|
|
172
|
+ {this.state.tabList.length > 0 && (
|
|
173
|
+ <View className="activity-wrap">
|
|
174
|
+ <View className="topBox">
|
|
175
|
+ <View
|
|
176
|
+ className="item"
|
|
177
|
+ onClick={() => {
|
|
178
|
+ this.siteClick("下午茶专场", "0");
|
|
179
|
+ }}
|
|
180
|
+ >
|
|
181
|
+ <View className="item-title">下午茶专场</View>
|
|
182
|
+ <Image
|
|
183
|
+ className="item-img"
|
|
184
|
+ src="https://yushi.tos-cn-beijing.volces.com/activity/topOne.png"
|
|
185
|
+ mode="widthFix"
|
|
186
|
+ />
|
|
187
|
+ <View className="item-text">点击进入</View>
|
|
188
|
+ </View>
|
|
189
|
+ <View
|
|
190
|
+ className="item"
|
|
191
|
+ onClick={() => {
|
|
192
|
+ this.siteClick("餐饮美食专场", "1");
|
|
193
|
+ }}
|
|
194
|
+ >
|
|
195
|
+ <View className="item-title">餐饮美食专场</View>
|
|
196
|
+ <Image
|
|
197
|
+ className="item-img"
|
|
198
|
+ src="https://yushi.tos-cn-beijing.volces.com/activity/topTwo.png"
|
|
199
|
+ mode="widthFix"
|
|
200
|
+ />
|
|
201
|
+ <View className="item-text">点击进入</View>
|
|
202
|
+ </View>
|
143
|
203
|
</View>
|
144
|
|
- <View className="item">
|
145
|
|
- <View className="item-title">餐饮美食专场</View>
|
146
|
|
- <Image
|
147
|
|
- className="item-img"
|
148
|
|
- src="https://yushi.tos-cn-beijing.volces.com/activity/topTwo.png"
|
149
|
|
- mode="widthFix"
|
150
|
|
- />
|
151
|
|
- <View className="item-text">点击进入</View>
|
152
|
|
- </View>
|
153
|
|
- </View>
|
154
|
|
- <View className="centerBox">
|
155
|
|
- <View className="item">
|
156
|
|
- <View className="item-title">酒店出行专场</View>
|
157
|
|
- <Image
|
158
|
|
- className="item-img"
|
159
|
|
- src="https://yushi.tos-cn-beijing.volces.com/activity/centerOne.png"
|
160
|
|
- mode="widthFix"
|
161
|
|
- />
|
162
|
|
- <View className="item-text">点击进入</View>
|
|
204
|
+ <View className="centerBox">
|
|
205
|
+ <View
|
|
206
|
+ className="item"
|
|
207
|
+ onClick={() => {
|
|
208
|
+ this.siteClick("酒店出行专场", "2");
|
|
209
|
+ }}
|
|
210
|
+ >
|
|
211
|
+ <View className="item-title">酒店出行专场</View>
|
|
212
|
+ <Image
|
|
213
|
+ className="item-img"
|
|
214
|
+ src="https://yushi.tos-cn-beijing.volces.com/activity/centerOne.png"
|
|
215
|
+ mode="widthFix"
|
|
216
|
+ />
|
|
217
|
+ <View className="item-text">点击进入</View>
|
|
218
|
+ </View>
|
|
219
|
+ <View
|
|
220
|
+ className="item"
|
|
221
|
+ onClick={() => {
|
|
222
|
+ this.siteClick("清洗服务专场", "3");
|
|
223
|
+ }}
|
|
224
|
+ >
|
|
225
|
+ <View className="item-title">清洗服务专场</View>
|
|
226
|
+ <Image
|
|
227
|
+ className="item-img"
|
|
228
|
+ src="https://yushi.tos-cn-beijing.volces.com/activity/centerTwo.png"
|
|
229
|
+ mode="widthFix"
|
|
230
|
+ />
|
|
231
|
+ <View className="item-text">点击进入</View>
|
|
232
|
+ </View>
|
|
233
|
+ <View
|
|
234
|
+ className="item"
|
|
235
|
+ onClick={() => {
|
|
236
|
+ this.siteClick("游玩娱乐专场", "4");
|
|
237
|
+ }}
|
|
238
|
+ >
|
|
239
|
+ <View className="item-title">游玩娱乐专场</View>
|
|
240
|
+ <Image
|
|
241
|
+ className="item-img"
|
|
242
|
+ src="https://yushi.tos-cn-beijing.volces.com/activity/centerThree.png"
|
|
243
|
+ mode="widthFix"
|
|
244
|
+ />
|
|
245
|
+ <View className="item-text">点击进入</View>
|
|
246
|
+ </View>
|
163
|
247
|
</View>
|
164
|
|
- <View className="item">
|
165
|
|
- <View className="item-title">清洗服务专场</View>
|
166
|
|
- <Image
|
167
|
|
- className="item-img"
|
168
|
|
- src="https://yushi.tos-cn-beijing.volces.com/activity/centerTwo.png"
|
169
|
|
- mode="widthFix"
|
170
|
|
- />
|
171
|
|
- <View className="item-text">点击进入</View>
|
172
|
|
- </View>
|
173
|
|
- <View className="item">
|
174
|
|
- <View className="item-title">游玩娱乐专场</View>
|
175
|
|
- <Image
|
176
|
|
- className="item-img"
|
177
|
|
- src="https://yushi.tos-cn-beijing.volces.com/activity/centerThree.png"
|
178
|
|
- mode="widthFix"
|
179
|
|
- />
|
180
|
|
- <View className="item-text">点击进入</View>
|
181
|
|
- </View>
|
182
|
|
- </View>
|
183
|
|
- <View className="bottomBox">
|
184
|
|
- <View className="item">
|
185
|
|
- <View className="item-title">咖啡专场</View>
|
186
|
|
- <Image
|
187
|
|
- className="item-img"
|
188
|
|
- src="https://yushi.tos-cn-beijing.volces.com/activity/bottom.png"
|
189
|
|
- mode="widthFix"
|
190
|
|
- />
|
191
|
|
- <View className="item-text">点击进入</View>
|
|
248
|
+ <View className="bottomBox">
|
|
249
|
+ <View
|
|
250
|
+ className="item"
|
|
251
|
+ onClick={() => {
|
|
252
|
+ this.siteClick("咖啡专场", "5");
|
|
253
|
+ }}
|
|
254
|
+ >
|
|
255
|
+ <View className="item-title">咖啡专场</View>
|
|
256
|
+ <Image
|
|
257
|
+ className="item-img"
|
|
258
|
+ src="https://yushi.tos-cn-beijing.volces.com/activity/bottom.png"
|
|
259
|
+ mode="widthFix"
|
|
260
|
+ />
|
|
261
|
+ <View className="item-text">点击进入</View>
|
|
262
|
+ </View>
|
192
|
263
|
</View>
|
193
|
264
|
</View>
|
194
|
|
- </View>
|
|
265
|
+ )}
|
195
|
266
|
<Image
|
196
|
267
|
className="bottom-title-img"
|
197
|
268
|
src="https://yushi.tos-cn-beijing.volces.com/activity/titleImgOne.png"
|
|
@@ -204,7 +275,7 @@ export default class Index extends Component {
|
204
|
275
|
<AtTabs
|
205
|
276
|
current={this.state.current}
|
206
|
277
|
scroll
|
207
|
|
- tabList={this.state.tags}
|
|
278
|
+ tabList={this.state.tabList}
|
208
|
279
|
onClick={this.tabClick}
|
209
|
280
|
/>
|
210
|
281
|
</View>
|
|
@@ -215,24 +286,24 @@ export default class Index extends Component {
|
215
|
286
|
>
|
216
|
287
|
<View className="product-list-container">
|
217
|
288
|
{this.state.productList.map((product) => (
|
218
|
|
- <View key={product.id} className="product-list-item">
|
|
289
|
+ <View onClick={() => this.handleProductDetail(product)} key={product.id} className="product-list-item">
|
219
|
290
|
<Image
|
220
|
291
|
className="product-img"
|
221
|
|
- src={product.image}
|
|
292
|
+ src={product.image_url}
|
222
|
293
|
mode="aspectFill"
|
223
|
294
|
/>
|
224
|
295
|
<View className="product-content">
|
225
|
|
- <Text className="product-title">{product.name}</Text>
|
|
296
|
+ <Text className="product-title">{product.item_title}</Text>
|
226
|
297
|
<View className="product-price">
|
227
|
298
|
<View className="product-price-left">
|
228
|
299
|
<Text className="product-price-text">到手价</Text>
|
229
|
300
|
<Text className="product-price-text-price">
|
230
|
|
- ¥{product.price}
|
|
301
|
+ ¥{product.reserve_price}
|
231
|
302
|
</Text>
|
232
|
303
|
</View>
|
233
|
304
|
<View className="product-commission">
|
234
|
305
|
<Text className="product-commission-text">
|
235
|
|
- 赚¥{product.commission}
|
|
306
|
+ 赚¥{product.estimated_commission_promotion}
|
236
|
307
|
</Text>
|
237
|
308
|
</View>
|
238
|
309
|
</View>
|