|
@@ -1,8 +1,15 @@
|
1
|
1
|
import { Component } from "react";
|
2
|
2
|
import { View, Text, Image, Button } from "@tarojs/components";
|
3
|
|
-import { AtIcon } from "taro-ui";
|
|
3
|
+import { AtIcon, AtActivityIndicator } from "taro-ui";
|
4
|
4
|
import "./index.less";
|
5
|
|
-import { getMyShopList, getMyShopDetail, getShareShopDetail, getShareShopProductList, getShareJump,bindShareJump } from "../../../service";
|
|
5
|
+import {
|
|
6
|
+ getMyShopList,
|
|
7
|
+ getMyShopDetail,
|
|
8
|
+ getShareShopDetail,
|
|
9
|
+ getShareShopProductList,
|
|
10
|
+ getShareJump,
|
|
11
|
+ bindShareJump,
|
|
12
|
+} from "../../../service";
|
6
|
13
|
import storeManagement from "../../../images/storeManagement/storeManagement.png";
|
7
|
14
|
import storeManagementIcon from "../../../images/storeManagement/storeManagementIcon.png";
|
8
|
15
|
import ProductCard from "../../../components/ProductCard"; //卡片模块
|
|
@@ -17,13 +24,16 @@ export default class Index extends Component {
|
17
|
24
|
loading: false, //加载状态
|
18
|
25
|
totalPages: 1, // 添加总页数
|
19
|
26
|
isShare: false, // 是否是分享进入
|
20
|
|
- shopId: '', // 店铺id
|
|
27
|
+ shopId: "", // 店铺id
|
|
28
|
+ isNoMore: false, // 是否没有更多
|
21
|
29
|
};
|
22
|
30
|
// 获取店铺详情
|
23
|
31
|
getMyShopDetail = async () => {
|
24
|
|
- const res = this.state.isShare ? await getShareShopDetail({
|
25
|
|
- store_id: this.state.shopId
|
26
|
|
- }) : await getMyShopDetail();
|
|
32
|
+ const res = this.state.isShare
|
|
33
|
+ ? await getShareShopDetail({
|
|
34
|
+ store_id: this.state.shopId,
|
|
35
|
+ })
|
|
36
|
+ : await getMyShopDetail();
|
27
|
37
|
this.setState({
|
28
|
38
|
shopDetail: res,
|
29
|
39
|
});
|
|
@@ -33,36 +43,44 @@ export default class Index extends Component {
|
33
|
43
|
const { page } = this.state;
|
34
|
44
|
this.setState({ loading: true });
|
35
|
45
|
|
36
|
|
- const res = this.state.isShare ? await getShareShopProductList({
|
37
|
|
- store_id: this.state.shopId,
|
38
|
|
- page,
|
39
|
|
- page_size: 10,
|
40
|
|
- tag_name:'全部'
|
41
|
|
- }) : await getMyShopList({
|
42
|
|
- page,
|
43
|
|
- page_size: 10,
|
44
|
|
- tag_name:'全部'
|
45
|
|
- });
|
|
46
|
+ const res = this.state.isShare
|
|
47
|
+ ? await getShareShopProductList({
|
|
48
|
+ store_id: this.state.shopId,
|
|
49
|
+ page,
|
|
50
|
+ page_size: 10,
|
|
51
|
+ tag_name: "全部",
|
|
52
|
+ })
|
|
53
|
+ : await getMyShopList({
|
|
54
|
+ page,
|
|
55
|
+ page_size: 10,
|
|
56
|
+ tag_name: "全部",
|
|
57
|
+ });
|
46
|
58
|
|
47
|
59
|
this.setState((prevState) => ({
|
48
|
|
- productList: isBack ? res.goods_list : [...prevState.productList, ...res.goods_list],
|
|
60
|
+ productList: isBack
|
|
61
|
+ ? res.goods_list
|
|
62
|
+ : [...prevState.productList, ...res.goods_list],
|
49
|
63
|
totalPages: res.total_pages,
|
50
|
64
|
loading: false,
|
|
65
|
+ isNoMore: res.total_pages <= page,
|
51
|
66
|
}));
|
52
|
67
|
};
|
53
|
68
|
|
54
|
69
|
componentDidShow() {
|
55
|
70
|
const { router } = Taro.getCurrentInstance();
|
56
|
71
|
const params = router.params;
|
57
|
|
-
|
58
|
|
- this.setState({
|
59
|
|
- isManager: JSON.parse(params.isManager), //是否是店长
|
60
|
|
- isShare: params.isShare||false, // 是否是分享进入
|
61
|
|
- shopId: params.shopId||'', // 店铺id
|
62
|
|
- },()=>{
|
63
|
|
- this.getMyShopDetail(); //获取店铺详情
|
64
|
|
- this.getMyShopList(true); //获取店铺数据
|
65
|
|
- });
|
|
72
|
+
|
|
73
|
+ this.setState(
|
|
74
|
+ {
|
|
75
|
+ isManager: JSON.parse(params.isManager), //是否是店长
|
|
76
|
+ isShare: params.isShare || false, // 是否是分享进入
|
|
77
|
+ shopId: params.shopId || "", // 店铺id
|
|
78
|
+ },
|
|
79
|
+ () => {
|
|
80
|
+ this.getMyShopDetail(); //获取店铺详情
|
|
81
|
+ this.getMyShopList(true); //获取店铺数据
|
|
82
|
+ }
|
|
83
|
+ );
|
66
|
84
|
}
|
67
|
85
|
// 页面上拉触底
|
68
|
86
|
onReachBottom = () => {
|
|
@@ -82,38 +100,38 @@ export default class Index extends Component {
|
82
|
100
|
};
|
83
|
101
|
// 配置分享内容
|
84
|
102
|
onShareAppMessage() {
|
85
|
|
- const name = Taro.getStorageSync('userInfo').name;
|
|
103
|
+ const name = Taro.getStorageSync("userInfo").name;
|
86
|
104
|
return {
|
87
|
105
|
title: `${name}的店铺`,
|
88
|
106
|
path: `/pages/memberSub/storeManagement/index?shopId=${this.state.shopDetail.id}&isShare=true&isManager=false`,
|
89
|
|
- imageUrl: ''
|
90
|
|
- }
|
|
107
|
+ imageUrl: "",
|
|
108
|
+ };
|
91
|
109
|
return getShareJump({
|
92
|
|
- share_type:2,
|
93
|
|
- share_id: this.state.shopDetail.id
|
94
|
|
- }).then(res=>{
|
|
110
|
+ share_type: 2,
|
|
111
|
+ share_id: this.state.shopDetail.id,
|
|
112
|
+ }).then((res) => {
|
95
|
113
|
return {
|
96
|
114
|
title: "店铺",
|
97
|
115
|
path: `/pages/memberSub/storeManagement/index?shopId=${this.state.shopDetail.id}&isShare=true&isManager=false&&shareJump=${res.share_unique_value}`,
|
98
|
|
- imageUrl: ''
|
99
|
|
- }
|
100
|
|
- })
|
|
116
|
+ imageUrl: "",
|
|
117
|
+ };
|
|
118
|
+ });
|
101
|
119
|
}
|
102
|
120
|
render() {
|
103
|
|
- const { shopDetail, productList } = this.state;
|
|
121
|
+ const { shopDetail, productList, loading, isNoMore } = this.state;
|
104
|
122
|
return (
|
105
|
123
|
<View className="index">
|
106
|
124
|
{/* 头部卡片 */}
|
107
|
125
|
<View className="header-card">
|
108
|
126
|
<Image className="bg-image" src={storeManagement} mode="widthFix" />
|
109
|
|
- {/* 分享店铺 */}
|
|
127
|
+ {/* 分享���铺 */}
|
110
|
128
|
{!this.state.isShare && (
|
111
|
|
- <View className="share-shop">
|
112
|
|
- <Button onClick={this.handleShare} openType="share">
|
113
|
|
- <Text>分享店铺</Text>
|
114
|
|
- <AtIcon value="chevron-right" size="10" color="#fff"></AtIcon>
|
115
|
|
- </Button>
|
116
|
|
- </View>
|
|
129
|
+ <View className="share-shop">
|
|
130
|
+ <Button onClick={this.handleShare} openType="share">
|
|
131
|
+ <Text>分享店铺</Text>
|
|
132
|
+ <AtIcon value="chevron-right" size="10" color="#fff"></AtIcon>
|
|
133
|
+ </Button>
|
|
134
|
+ </View>
|
117
|
135
|
)}
|
118
|
136
|
{/* 个人信息 */}
|
119
|
137
|
<View className="user-info">
|
|
@@ -169,6 +187,25 @@ export default class Index extends Component {
|
169
|
187
|
</View>
|
170
|
188
|
)}
|
171
|
189
|
</View>
|
|
190
|
+ {/* 加载中 */}
|
|
191
|
+ {loading && (
|
|
192
|
+ <View className="loading-container">
|
|
193
|
+ <AtActivityIndicator
|
|
194
|
+ content="加载中..."
|
|
195
|
+ isOpened={loading}
|
|
196
|
+ mode="center"
|
|
197
|
+ color="#fdf764"
|
|
198
|
+ />
|
|
199
|
+ </View>
|
|
200
|
+ )}
|
|
201
|
+ {/* 没有更多 */}
|
|
202
|
+ {isNoMore && (
|
|
203
|
+ <View className="no-more">
|
|
204
|
+ <View className="no-more-line">
|
|
205
|
+ <Text className="no-more-text">我是有底线的</Text>
|
|
206
|
+ </View>
|
|
207
|
+ </View>
|
|
208
|
+ )}
|
172
|
209
|
</View>
|
173
|
210
|
);
|
174
|
211
|
}
|