|
@@ -9,6 +9,7 @@ import Banner from './banner'
|
9
|
9
|
import ready from '@utils/ready'
|
10
|
10
|
// import { ROLE_CODE } from '@constants/user'
|
11
|
11
|
import { queryBanners } from '@services/common'
|
|
12
|
+import { getGoodsBuilding, getGoodsList } from '@services/item'
|
12
|
13
|
import { connect } from '@tarojs/redux'
|
13
|
14
|
import * as actions from '@actions/shop'
|
14
|
15
|
// import { queryUserInfo, doUserSignin } from '@services/user'
|
|
@@ -32,14 +33,17 @@ export default class Shop extends Component {
|
32
|
33
|
'https://estateagents.oss-cn-shanghai.aliyuncs.com/images/banner/5.jpg'
|
33
|
34
|
],
|
34
|
35
|
user: {},
|
35
|
|
- cityName: ''
|
|
36
|
+ cityName: '',
|
|
37
|
+ goodsBuilding: [],
|
|
38
|
+ goodsList: [],
|
36
|
39
|
}
|
37
|
40
|
|
38
|
41
|
componentDidShow() {
|
39
|
42
|
Taro.showLoading()
|
40
|
43
|
ready.queue(() => {
|
41
|
44
|
this.loadBannerList()
|
42
|
|
- this.loadList()
|
|
45
|
+ this.loadGoodsBuilding()
|
|
46
|
+
|
43
|
47
|
// this.loadCity()
|
44
|
48
|
// this.loadUserInfo()
|
45
|
49
|
})
|
|
@@ -86,22 +90,65 @@ export default class Shop extends Component {
|
86
|
90
|
})
|
87
|
91
|
}
|
88
|
92
|
|
89
|
|
- onSearch(val) {
|
90
|
|
- // App.zhuge.track('搜索商品', {
|
91
|
|
- // '商品名称': val
|
92
|
|
- // })
|
93
|
|
- this.setState({
|
94
|
|
- keywords: val,
|
95
|
|
- }, this.loadList)
|
96
|
|
- }
|
|
93
|
+ // onSearch(val) {
|
|
94
|
+ // // App.zhuge.track('搜索商品', {
|
|
95
|
+ // // '商品名称': val
|
|
96
|
+ // // })
|
|
97
|
+ // this.setState({
|
|
98
|
+ // keywords: val,
|
|
99
|
+ // }, this.loadList)
|
|
100
|
+ // }
|
97
|
101
|
|
98
|
102
|
loadList() {
|
99
|
|
- // const payload = { buildingId: '369b7d7e5bc6e6b91f2e8f5e775035e2' }
|
|
103
|
+
|
100
|
104
|
Taro.showLoading()
|
101
|
|
- this.props.dispatchGoodsList().then(res => {
|
|
105
|
+ const params = {
|
|
106
|
+ pageNum: '1',
|
|
107
|
+ pageSize: '9999',
|
|
108
|
+ buildingId: this.state.goodsBuilding[0].buildingId
|
|
109
|
+ }
|
|
110
|
+ console.log(params, "params")
|
|
111
|
+ getGoodsList(params).then(res => {
|
|
112
|
+ this.setState({
|
|
113
|
+ goodsList: res.records || []
|
|
114
|
+ })
|
102
|
115
|
Taro.hideLoading()
|
103
|
116
|
})
|
104
|
117
|
}
|
|
118
|
+ loadGoodsBuilding() {
|
|
119
|
+ getGoodsBuilding().then(res => {
|
|
120
|
+
|
|
121
|
+ res.map(item => {
|
|
122
|
+ item.title = item.buildingName
|
|
123
|
+
|
|
124
|
+ })
|
|
125
|
+ this.setState({
|
|
126
|
+ goodsBuilding: res || []
|
|
127
|
+
|
|
128
|
+ }, () => {
|
|
129
|
+ this.loadList()
|
|
130
|
+ }
|
|
131
|
+ )
|
|
132
|
+ })
|
|
133
|
+ }
|
|
134
|
+
|
|
135
|
+ handleClick(value) {
|
|
136
|
+
|
|
137
|
+ const payload = {
|
|
138
|
+ pageNum: '1',
|
|
139
|
+ pageSize: '9999',
|
|
140
|
+ buildingId: this.state.goodsBuilding[value].buildingId
|
|
141
|
+ }
|
|
142
|
+ getGoodsList(payload).then(res => {
|
|
143
|
+ this.setState({
|
|
144
|
+ goodsList: res.records || []
|
|
145
|
+ })
|
|
146
|
+ console.log(res, "9999999999999999999999")
|
|
147
|
+ })
|
|
148
|
+ this.setState({
|
|
149
|
+ current: value
|
|
150
|
+ })
|
|
151
|
+ }
|
105
|
152
|
|
106
|
153
|
onViewDetail(item) {
|
107
|
154
|
Taro.navigateTo({
|
|
@@ -155,48 +202,67 @@ export default class Shop extends Component {
|
155
|
202
|
current: 0,
|
156
|
203
|
}
|
157
|
204
|
|
158
|
|
- handleClick(value) {
|
159
|
|
- this.setState({
|
160
|
|
- current: value
|
161
|
|
- })
|
162
|
|
- }
|
|
205
|
+
|
163
|
206
|
|
164
|
207
|
renderGoods() {
|
165
|
208
|
const { goods: { records = [] } } = this.props
|
|
209
|
+ const { goodsList, goodsBuilding, current } = this.state
|
166
|
210
|
|
167
|
211
|
return (
|
168
|
212
|
|
|
213
|
+
|
|
214
|
+
|
169
|
215
|
<View className="list__wrap">
|
170
|
|
- <AtTabs current={this.state.current} tabList={[{ title: '热门活动' }, { title: '最新资讯' }]} onClick={this.handleClick.bind(this)}>
|
171
|
|
- <AtTabsPane current={this.state.current} index={0} >
|
172
|
|
- <View >
|
173
|
|
-
|
174
|
|
- {
|
175
|
|
- records.map(item => (
|
176
|
|
- <View className="item" key={item.goodsId} onClick={this.onViewDetail.bind(this, item)}>
|
177
|
|
- <Image className="item__img" src={item.imgUrl} />
|
178
|
|
- <View className="item__title">{item.goodsName}</View>
|
179
|
|
- <View className="item__des">
|
180
|
|
- <View>
|
181
|
|
- 剩余数量{item.inventory}
|
182
|
|
- </View>
|
183
|
|
- <View >
|
184
|
|
- <Text className="item__jifen">{item.pointPrice}</Text>积分
|
185
|
|
- </View>
|
|
216
|
+ {
|
|
217
|
+
|
|
218
|
+ goodsBuilding && goodsBuilding.length < 2 &&
|
|
219
|
+ <View>
|
|
220
|
+ <View className="hot_title">热门商品</View>
|
|
221
|
+ {
|
|
222
|
+ goodsList.map(item => (
|
|
223
|
+ <View className="item" key={item.goodsId} onClick={this.onViewDetail.bind(this, item)}>
|
|
224
|
+ <Image className="item__img" src={item.imgUrl} />
|
|
225
|
+ <View className="item__title">{item.goodsName}</View>
|
|
226
|
+ <View className="item__des">
|
|
227
|
+ <View>
|
|
228
|
+ 剩余数量{item.inventory}
|
186
|
229
|
</View>
|
187
|
|
-
|
|
230
|
+ <View >
|
|
231
|
+ <Text className="item__jifen">{item.pointPrice}</Text>积分
|
|
232
|
+ </View>
|
188
|
233
|
</View>
|
189
|
|
- ))
|
190
|
|
- }
|
191
|
|
-
|
192
|
|
- </View>
|
193
|
|
- </AtTabsPane>
|
194
|
|
- <AtTabsPane current={this.state.current} index={1}>
|
195
|
|
- <View >
|
196
|
|
- 123
|
|
234
|
+ </View>
|
|
235
|
+ ))
|
|
236
|
+ }
|
197
|
237
|
</View>
|
198
|
|
- </AtTabsPane>
|
199
|
|
- </AtTabs>
|
|
238
|
+ }
|
|
239
|
+ {
|
|
240
|
+ goodsBuilding && goodsBuilding.length > 2 &&
|
|
241
|
+ <AtTabs current={current} tabList={goodsBuilding} onClick={this.handleClick.bind(this)}>
|
|
242
|
+ <AtTabsPane current={current} >
|
|
243
|
+ <View>
|
|
244
|
+ {
|
|
245
|
+ goodsList.map(item => (
|
|
246
|
+ <View className="item" key={item.goodsId} onClick={this.onViewDetail.bind(this, item)}>
|
|
247
|
+ <Image className="item__img" src={item.imgUrl} />
|
|
248
|
+ <View className="item__title">{item.goodsName}</View>
|
|
249
|
+ <View className="item__des">
|
|
250
|
+ <View>
|
|
251
|
+ 剩余数量{item.inventory}
|
|
252
|
+ </View>
|
|
253
|
+ <View >
|
|
254
|
+ <Text className="item__jifen">{item.pointPrice}</Text>积分
|
|
255
|
+ </View>
|
|
256
|
+ </View>
|
|
257
|
+
|
|
258
|
+ </View>
|
|
259
|
+ ))
|
|
260
|
+ }
|
|
261
|
+
|
|
262
|
+ </View>
|
|
263
|
+ </AtTabsPane>
|
|
264
|
+ </AtTabs>
|
|
265
|
+ }
|
200
|
266
|
</View>
|
201
|
267
|
|
202
|
268
|
|
|
@@ -247,7 +313,7 @@ export default class Shop extends Component {
|
247
|
313
|
</View>
|
248
|
314
|
|
249
|
315
|
|
250
|
|
- {/* <View className="hot_title">热门商品</View> */}
|
|
316
|
+
|
251
|
317
|
<Banner list={this.state.bannerList} indicatorDots={false}></Banner>
|
252
|
318
|
|
253
|
319
|
{this.renderGoods()}
|