许静 5 gadus atpakaļ
vecāks
revīzija
20e1c63a39
7 mainītis faili ar 143 papildinājumiem un 66 dzēšanām
  1. 3
    3
      config/dev.js
  2. 6
    14
      src/actions/shop.js
  3. 1
    1
      src/app.js
  4. 1
    0
      src/constants/api.js
  5. 111
    45
      src/pages/shop/index.js
  6. 4
    3
      src/pages/shop/index.scss
  7. 17
    0
      src/services/item.js

+ 3
- 3
config/dev.js Parādīt failu

@@ -3,14 +3,14 @@ module.exports = {
3 3
     NODE_ENV: '"development"'
4 4
   },
5 5
   defineConstants: {
6
-		// HOST: '"http://47.101.36.130:8085"',//测试
6
+    // HOST: '"http://47.101.36.130:8085"',//测试
7 7
     // WSS_HOST: '"wss://47.101.36.130:8085"',
8 8
     // HOST: '"https://dev.jinchengjiaye.com"',//测试
9 9
     // WSS_HOST: '"wss://dev.jinchengjiaye.com"',
10 10
     // HOST: '"https://lt.pawoma.cn"',
11 11
     // WSS_HOST: '"wss://lt.pawoma.cn"',
12
-    HOST: '"http://192.168.0.84:8080"',
13
-    WSS_HOST: '"ws://192.168.0.84:8080"',
12
+    HOST: '"http://192.168.0.172:8080"',
13
+    WSS_HOST: '"ws://192.168.0.172:8080"',
14 14
   },
15 15
   weapp: {},
16 16
   h5: {}

+ 6
- 14
src/actions/shop.js Parādīt failu

@@ -20,15 +20,7 @@ import {
20 20
 import { createAction } from '@utils/redux'
21 21
 
22 22
 
23
-/**
24
- * 商品列表
25
- * @param {*} payload
26
- */
27
-export const dispatchGoodsList = payload => createAction({
28
-  url: API_GOODS_LIST,
29
-  type: GOODS_LIST,
30
-  payload
31
-})
23
+
32 24
 
33 25
 
34 26
 
@@ -50,7 +42,7 @@ export const dispatchGoodsDetail = id => createAction({
50 42
 export const dispatchGoodsExchange = id => createAction({
51 43
   url: `${API_GOODS_EXCHANGE}/${id}`,
52 44
   type: GOODS_EXCHANGE,
53
-  method:'POST'
45
+  method: 'POST'
54 46
 })
55 47
 
56 48
 
@@ -80,7 +72,7 @@ export const dispatchPointsRecords = payload => createAction({
80 72
  * @param {*} payload
81 73
  */
82 74
 export const dispatchPointsRule = payload => createAction({
83
-  url:  API_POINTS_RULE,
75
+  url: API_POINTS_RULE,
84 76
   type: POINTS_RULE,
85 77
   payload
86 78
 })
@@ -90,8 +82,8 @@ export const dispatchPointsRule = payload => createAction({
90 82
  * @param {*} payload
91 83
  */
92 84
 export const dispatchPointsAddress = payload => createAction({
93
-  url:  `${API_POINTS_ADRESS}`,
94
-  type:POINTS_ADRESS,
85
+  url: `${API_POINTS_ADRESS}`,
86
+  type: POINTS_ADRESS,
95 87
   payload,
96
-  method:'PUT'
88
+  method: 'PUT'
97 89
 })

+ 1
- 1
src/app.js Parādīt failu

@@ -40,11 +40,11 @@ class App extends Component {
40 40
       }
41 41
     },
42 42
     pages: [
43
+      'pages/shop/index',
43 44
       'pages/project/index',
44 45
       'pages/person/index',
45 46
       'pages/activity/activity',
46 47
       'pages/person/profile/index',
47
-      'pages/shop/index',
48 48
       'pages/project/detail/index',
49 49
       'pages/activity/assemblePage',
50 50
       'pages/activity/assistancePage',

+ 1
- 0
src/constants/api.js Parādīt failu

@@ -49,6 +49,7 @@ export const API_ACTIVITY_GROUP = resolvePath('helpActivityAndGroup')
49 49
 
50 50
 // shop
51 51
 export const API_GOODS_LIST = resolvePath('goods')
52
+export const API_GOODS_BUILDING = resolvePath('goodsToBuilding')
52 53
 export const API_GOODS_EXCHANGE = resolvePath('goods/exchange')
53 54
 export const API_GOODS_EXCHANGE_RECORDS = resolvePath('taPointsExchange')
54 55
 export const API_POINTS_RECORDS = resolvePath('taPointsRecords')

+ 111
- 45
src/pages/shop/index.js Parādīt failu

@@ -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()}

+ 4
- 3
src/pages/shop/index.scss Parādīt failu

@@ -143,7 +143,7 @@
143 143
 .list__wrap {
144 144
   margin-top: 20px;
145 145
   overflow: hidden;
146
-  padding: 20px 30px;
146
+  padding: 20px;
147 147
   background-color: #fff;
148 148
   .at-tabs__item{
149 149
     display: block;
@@ -164,9 +164,10 @@
164 164
 
165 165
   .item {
166 166
     background: white;
167
-    width: 320px;
167
+    width: 335px;
168 168
     position: relative;
169
-    margin: 15px 0;
169
+    display: inline-block;
170
+    margin: 15px 10px;
170 171
     height: 440px;
171 172
     box-shadow:0px 6px 10px 0px rgba(0,0,0,0.12);
172 173
     border-radius:12px;

+ 17
- 0
src/services/item.js Parādīt failu

@@ -7,6 +7,8 @@ import {
7 7
   API_ITEMS_SHARE,
8 8
   API_ITEMS_TYPE,
9 9
   API_PROJECT_FAVOR,
10
+  API_GOODS_BUILDING,
11
+  API_GOODS_LIST
10 12
 } from '@constants/api'
11 13
 
12 14
 /**
@@ -14,6 +16,21 @@ import {
14 16
  * @param {*} payload 
15 17
  */
16 18
 export const getItemList = payload => fetch({ url: API_ITEMS_LIST, payload })
19
+/**
20
+ * 获取楼盘商品列表
21
+ * @param {*} payload 
22
+ */
23
+export const getGoodsBuilding = payload => fetch({ url: API_GOODS_BUILDING, payload })
24
+/**
25
+ * 获取楼盘商品列表
26
+ * @param {*} payload 
27
+ */
28
+export const getGoodsList = payload => fetch({ url: API_GOODS_LIST, payload })
29
+/**
30
+ * 商品列表
31
+ * @param {*} payload
32
+ */
33
+
17 34
 
18 35
 /**
19 36
  * 获取项目详情