|
@@ -2,13 +2,14 @@ import { Component } from "react";
|
2
|
2
|
import { View, Image } from "@tarojs/components";
|
3
|
3
|
import "./index.less";
|
4
|
4
|
import Taro from "@tarojs/taro";
|
5
|
|
-import seckillImg from "../../../images/seckill/seckillTop.jpg";
|
6
|
5
|
import ProductList from "../../../components/index/ProductList";
|
7
|
6
|
import { getRecommendProductList, addLog } from "../../../service";
|
8
|
7
|
import { formatDate } from "../../../common/time";
|
9
|
8
|
import { getShareContent } from "../../../common/share";
|
10
|
9
|
export default class Index extends Component {
|
11
|
10
|
state = {
|
|
11
|
+ title: "", // 页面标题
|
|
12
|
+ id: "", // 页面类型id
|
12
|
13
|
productList: [], //推荐商品列表
|
13
|
14
|
page: 1, //页数
|
14
|
15
|
loading: false, //加载状态
|
|
@@ -18,9 +19,10 @@ export default class Index extends Component {
|
18
|
19
|
isBanner: false, // 是否是banner跳转
|
19
|
20
|
isShare: false, // 是否是分享跳转
|
20
|
21
|
shareUserId: "", // 分享用户id
|
|
22
|
+ img: "", // 图片
|
21
|
23
|
};
|
22
|
24
|
componentDidMount() {
|
23
|
|
- const { isDirect, isBanner, isShare, shareUserId } =
|
|
25
|
+ const { isDirect, isBanner, isShare, shareUserId, title, id } =
|
24
|
26
|
Taro.getCurrentInstance().router.params || "";
|
25
|
27
|
this.setState(
|
26
|
28
|
{
|
|
@@ -28,20 +30,26 @@ export default class Index extends Component {
|
28
|
30
|
isBanner: isBanner || false,
|
29
|
31
|
isShare: isShare || false,
|
30
|
32
|
shareUserId: shareUserId || "",
|
|
33
|
+ title: title || "",
|
|
34
|
+ id: id || "",
|
31
|
35
|
},
|
32
|
36
|
() => {
|
|
37
|
+ // 设置页面标题
|
|
38
|
+ Taro.setNavigationBarTitle({
|
|
39
|
+ title: this.state.title || "鱼市",
|
|
40
|
+ });
|
33
|
41
|
this.handleLog(
|
34
|
42
|
isDirect
|
35
|
|
- ? "direct_to_fish_seckill"
|
|
43
|
+ ? `direct_to_${this.state.id}_${this.state.title}`
|
36
|
44
|
: isBanner
|
37
|
|
- ? "banner_to_fish_seckill"
|
|
45
|
+ ? `banner_to_${this.state.id}_${this.state.title}`
|
38
|
46
|
: isShare
|
39
|
|
- ? "share_to_fish_seckill"
|
40
|
|
- : "direct_to_fish_seckill"
|
|
47
|
+ ? `share_to_${this.state.id}_${this.state.title}`
|
|
48
|
+ : `direct_to_${this.state.id}_${this.state.title}`
|
41
|
49
|
);
|
|
50
|
+ this.getRecommendProductList();
|
42
|
51
|
}
|
43
|
52
|
);
|
44
|
|
- this.getRecommendProductList();
|
45
|
53
|
}
|
46
|
54
|
// 获取推荐商品列表
|
47
|
55
|
getRecommendProductList = async () => {
|
|
@@ -49,7 +57,7 @@ export default class Index extends Component {
|
49
|
57
|
this.setState({ loading: true });
|
50
|
58
|
|
51
|
59
|
const res = await getRecommendProductList({
|
52
|
|
- tag_id: 120,
|
|
60
|
+ tag_id: this.state.id,
|
53
|
61
|
page,
|
54
|
62
|
page_size: 10,
|
55
|
63
|
});
|
|
@@ -59,19 +67,20 @@ export default class Index extends Component {
|
59
|
67
|
totalPages: res.total_pages,
|
60
|
68
|
loading: false,
|
61
|
69
|
isNoMore: res.total_pages <= page,
|
|
70
|
+ img: res.img,
|
62
|
71
|
}));
|
63
|
72
|
};
|
64
|
73
|
// 埋点
|
65
|
74
|
handleLog = (event_type) => {
|
66
|
75
|
const dayid = formatDate(new Date(), "YYYY-MM-DD");
|
67
|
76
|
const event_type_title =
|
68
|
|
- event_type == "banner_to_fish_seckill"
|
69
|
|
- ? "从banner 跳转到鱼市秒杀"
|
70
|
|
- : event_type == "share_to_fish_seckill"
|
71
|
|
- ? "从分享链接跳转到鱼市秒杀"
|
72
|
|
- : event_type == "direct_to_fish_seckill"
|
73
|
|
- ? "直接点击进入鱼市秒杀"
|
74
|
|
- : "直接点击进入鱼市秒杀";
|
|
77
|
+ event_type == `banner_to_${this.state.id}_${this.state.title}`
|
|
78
|
+ ? `从banner 跳转到${this.state.title}`
|
|
79
|
+ : event_type == `share_to_${this.state.id}_${this.state.title}`
|
|
80
|
+ ? `从分享链接跳转到${this.state.title}`
|
|
81
|
+ : event_type == `direct_to_${this.state.id}_${this.state.title}`
|
|
82
|
+ ? `直接点击进入${this.state.title}`
|
|
83
|
+ : `直接点击进入${this.state.title}`;
|
75
|
84
|
let userId = "";
|
76
|
85
|
if (Taro.getStorageSync("loginInfo")) {
|
77
|
86
|
userId = Taro.getStorageSync("loginInfo").id;
|
|
@@ -84,7 +93,7 @@ export default class Index extends Component {
|
84
|
93
|
});
|
85
|
94
|
}
|
86
|
95
|
addLog({
|
87
|
|
- users_id: userId||0,
|
|
96
|
+ users_id: userId || 0,
|
88
|
97
|
goods_id: 0,
|
89
|
98
|
event_type_title,
|
90
|
99
|
event_type,
|
|
@@ -98,11 +107,10 @@ export default class Index extends Component {
|
98
|
107
|
if (Taro.getStorageSync("loginInfo")) {
|
99
|
108
|
shareUserId = Taro.getStorageSync("loginInfo").id;
|
100
|
109
|
}
|
101
|
|
- const shareConfig = getShareContent();
|
102
|
110
|
if (res.from == "menu") {
|
103
|
111
|
return {
|
104
|
|
- title: "鱼市秒杀",
|
105
|
|
- path: `/pages/indexSub/seckillIndex/index?isShare=true&shareUserId=${shareUserId}`,
|
|
112
|
+ title: `${this.state.title}`,
|
|
113
|
+ path: `/pages/indexSub/seckillIndex/index?isShare=true&shareUserId=${shareUserId}&title=${this.state.title}&id=${this.state.id}`,
|
106
|
114
|
imageUrl: "",
|
107
|
115
|
};
|
108
|
116
|
} else {
|
|
@@ -122,7 +130,7 @@ export default class Index extends Component {
|
122
|
130
|
render() {
|
123
|
131
|
return (
|
124
|
132
|
<View className="index">
|
125
|
|
- <Image className="seckill" src={seckillImg} mode="aspectFill" />
|
|
133
|
+ <Image className="seckill" src={this.state.img} mode="widthFix" />
|
126
|
134
|
{/* 商品列表 */}
|
127
|
135
|
<View className="product-list">
|
128
|
136
|
<ProductList
|
|
@@ -131,6 +139,7 @@ export default class Index extends Component {
|
131
|
139
|
loading={this.state.loading}
|
132
|
140
|
isNoMore={this.state.isNoMore}
|
133
|
141
|
shareUserId={this.state.shareUserId}
|
|
142
|
+ tagTitle={this.state.title}
|
134
|
143
|
/>
|
135
|
144
|
</View>
|
136
|
145
|
</View>
|