Browse Source

客户分析无数据时给出默认图

许静 5 years ago
parent
commit
02ff437f67
1 changed files with 121 additions and 61 deletions
  1. 121
    61
      src/pages/person/customerAnalysis/analysis.js

+ 121
- 61
src/pages/person/customerAnalysis/analysis.js View File

10
 import { querySexInfo, getEchartDailyInfo, getEchartMonthInfo } from '@services/person'
10
 import { querySexInfo, getEchartDailyInfo, getEchartMonthInfo } from '@services/person'
11
 import { connect } from '@tarojs/redux'
11
 import { connect } from '@tarojs/redux'
12
 import LineChart from "../../../components/charts/Line";
12
 import LineChart from "../../../components/charts/Line";
13
+const nothing = require('@assets/person/nothing.png')
13
 
14
 
14
 
15
 
15
 @connect(({ user, city }) => ({ user, city }))
16
 @connect(({ user, city }) => ({ user, city }))
136
       } else if (params == 'follow') {
137
       } else if (params == 'follow') {
137
         getEchartMonthInfo(params).then(res => {
138
         getEchartMonthInfo(params).then(res => {
138
           this.setState({
139
           this.setState({
139
-            chartInfo2:  res.map(x => ({ name: `${x.month.substr(4)}月`, value: x.customerNum })) || []
140
+            chartInfo2: res.map(x => ({ name: `${x.month.substr(4)}月`, value: x.customerNum })) || []
140
           })
141
           })
141
         })
142
         })
142
       } else {
143
       } else {
165
         <AtTabs className="tab-bar" current={current} tabList={tabList} onClick={this.handleClick.bind(this)} swipeable="false">
166
         <AtTabs className="tab-bar" current={current} tabList={tabList} onClick={this.handleClick.bind(this)} swipeable="false">
166
           <AtTabsPane current={current} index={0} >
167
           <AtTabsPane current={current} index={0} >
167
             <View>
168
             <View>
168
-              <View style="height:40rpx;position: relative;margin-top:20rpx">
169
-                <View className="daily-month" >
170
-                  {
171
-                    dailyMonth.map((item, index) => (
172
-                      <View key={index + 'daily'} className={checkedWhich == index ? 'checked' : 'item'} onClick={this.changeDailyMonth.bind(this, index)}>
173
-                        {item}
174
-                      </View>))
175
-                  }
169
+              {
170
+                chartInfo.length &&
171
+                <View>
172
+                  <View style="height:40rpx;position: relative;margin-top:20rpx">
173
+                    <View className="daily-month" >
174
+                      {
175
+                        dailyMonth.map((item, index) => (
176
+                          <View key={index + 'daily'} className={checkedWhich == index ? 'checked' : 'item'} onClick={this.changeDailyMonth.bind(this, index)}>
177
+                            {item}
178
+                          </View>))
179
+                      }
180
+                    </View>
181
+                  </View>
182
+                  <View style="width:100vw;height:530rpx;position: relative;">
183
+                    <LineChart source={chartInfo} />
184
+                  </View>
176
                 </View>
185
                 </View>
177
-              </View>
178
-              <View style="width:100vw;height:530rpx;position: relative;">
179
-                <LineChart source={chartInfo} />
180
-              </View>
181
-              <View style="height:20rpx;background:#f5f5f5;"> </View>
182
-              <View style="padding: 40rpx;">
183
-                <View style="font-size: 36rpx;color: #666;margin-bottom:20rpx;">性别</View>
184
-                {sexInfo.map((item, index) => (
185
-                  <View key={index + 'sex1'} style="display: flex;align-items: center;"><View style="font-size: 32rpx;color: #666;min-width:80rpx">{item.genderType == 1 ? '男' : item.genderType == 2 ? '女' : '未知'}</View><AtProgress percent={(item.percentage * 100).toFixed(2)} strokeWidth={6} color={item.genderType == 1 ? '#BB9C79' : item.genderType == 2 ? '#F6B61D' : '#A2A2A2'} /></View>
186
-                ))
187
-                }
188
-              </View>
186
+              }
187
+              {
188
+                !chartInfo.length &&
189
+                <View >
190
+                  <Image style="width: 320rpx;height: 260rpx;margin: 60rpx auto 20rpx auto;display:block" src={nothing} />
191
+                  <View style="text-align:center;color:#999;font-size:30rpx;margin-bottom:100rpx;">
192
+                    暂无数据展示
193
+                </View>
194
+                </View>
195
+              }
196
+
197
+              {
198
+                sexInfo.length &&
199
+                <View>
200
+                  <View style="height:20rpx;background:#f5f5f5;"> </View>
201
+                  <View style="padding: 40rpx;">
202
+                    <View style="font-size: 36rpx;color: #666;margin-bottom:20rpx;">性别</View>
203
+                    {sexInfo.map((item, index) => (
204
+                      <View key={index + 'sex1'} style="display: flex;align-items: center;"><View style="font-size: 32rpx;color: #666;min-width:80rpx">{item.genderType == 1 ? '男' : item.genderType == 2 ? '女' : '未知'}</View><AtProgress percent={(item.percentage * 100).toFixed(2)} strokeWidth={6} color={item.genderType == 1 ? '#BB9C79' : item.genderType == 2 ? '#F6B61D' : '#A2A2A2'} /></View>
205
+                    ))
206
+                    }
207
+                  </View>
208
+                </View>
209
+              }
210
+
189
             </View>
211
             </View>
190
           </AtTabsPane>
212
           </AtTabsPane>
191
           <AtTabsPane current={current} index={1}>
213
           <AtTabsPane current={current} index={1}>
192
             <View>
214
             <View>
193
-              <View style="height:40rpx;position: relative;margin-top:20rpx">
194
-                <View className="daily-month" >
195
-                  {
196
-                    dailyMonth.map((item, index) => (
197
-                      <View key={index + 'month'} className={checkedWhich == index ? 'checked' : 'item'} onClick={this.changeDailyMonth.bind(this, index)}>
198
-                        {item}
199
-                      </View>))
200
-                  }
215
+              {chartInfo2.length &&
216
+                <View>
217
+                  <View style="height:40rpx;position: relative;margin-top:20rpx">
218
+                    <View className="daily-month" >
219
+                      {
220
+                        dailyMonth.map((item, index) => (
221
+                          <View key={index + 'month'} className={checkedWhich == index ? 'checked' : 'item'} onClick={this.changeDailyMonth.bind(this, index)}>
222
+                            {item}
223
+                          </View>))
224
+                      }
225
+                    </View>
226
+                  </View>
227
+                  <View style="width:100vw;height:530rpx;position: relative;">
228
+                    <LineChart source={chartInfo2} />
229
+                  </View>
230
+                </View>
231
+              }
232
+              {
233
+                !chartInfo2.length &&
234
+                <View >
235
+                  <Image style="width: 320rpx;height: 260rpx;margin: 60rpx auto 20rpx auto;display:block" src={nothing} />
236
+                  <View style="text-align:center;color:#999;font-size:30rpx;margin-bottom:100rpx;">
237
+                    暂无数据展示
201
                 </View>
238
                 </View>
202
-              </View>
203
-              <View style="width:100vw;height:530rpx;position: relative;">
204
-                <LineChart source={chartInfo2} />
205
-              </View>
206
-              <View style="height:20rpx;background:#f5f5f5;"> </View>
207
-              <View style="padding: 40rpx;">
208
-                <View style="font-size: 36rpx;color: #666;margin-bottom:20rpx;">性别</View>
209
-                {sexInfo.map((item, index) => (
210
-                  <View key={index + 'sex2'} style="display: flex;align-items: center;"><View style="font-size: 32rpx;color: #666;min-width:80rpx">{item.genderType == 1 ? '男' : item.genderType == 2 ? '女' : '未知'}</View><AtProgress percent={(item.percentage * 100).toFixed(2)} strokeWidth={6} color={item.genderType == 1 ? '#BB9C79' : item.genderType == 2 ? '#F6B61D' : '#A2A2A2'} /></View>
211
-                ))
212
-                }
213
-              </View>
239
+                </View>
240
+              }
241
+
242
+              {
243
+                sexInfo.length &&
244
+                <View>
245
+                  <View style="height:20rpx;background:#f5f5f5;"> </View>
246
+                  <View style="padding: 40rpx;">
247
+                    <View style="font-size: 36rpx;color: #666;margin-bottom:20rpx;">性别</View>
248
+                    {sexInfo.map((item, index) => (
249
+                      <View key={index + 'sex2'} style="display: flex;align-items: center;"><View style="font-size: 32rpx;color: #666;min-width:80rpx">{item.genderType == 1 ? '男' : item.genderType == 2 ? '女' : '未知'}</View><AtProgress percent={(item.percentage * 100).toFixed(2)} strokeWidth={6} color={item.genderType == 1 ? '#BB9C79' : item.genderType == 2 ? '#F6B61D' : '#A2A2A2'} /></View>
250
+                    ))
251
+                    }
252
+                  </View>
253
+                </View>
254
+              }
214
             </View>
255
             </View>
215
           </AtTabsPane>
256
           </AtTabsPane>
216
           <AtTabsPane current={current} index={2}>
257
           <AtTabsPane current={current} index={2}>
217
             <View>
258
             <View>
218
-              <View style="height:40rpx;position: relative;margin-top:20rpx">
219
-                <View className="daily-month" >
220
-                  {
221
-                    dailyMonth.map((item, index) => (
222
-                      <View key={index + 'day'} className={checkedWhich == index ? 'checked' : 'item'} onClick={this.changeDailyMonth.bind(this, index)}>
223
-                        {item}
224
-                      </View>))
225
-                  }
259
+              {
260
+                chartInfo3.length &&
261
+                <View>
262
+                  <View style="height:40rpx;position: relative;margin-top:20rpx">
263
+                    <View className="daily-month" >
264
+                      {
265
+                        dailyMonth.map((item, index) => (
266
+                          <View key={index + 'day'} className={checkedWhich == index ? 'checked' : 'item'} onClick={this.changeDailyMonth.bind(this, index)}>
267
+                            {item}
268
+                          </View>))
269
+                      }
270
+                    </View>
271
+                  </View>
272
+                  <View style="width:100vw;height:530rpx;position: relative;">
273
+                    <LineChart source={chartInfo3} />
274
+                  </View>
275
+                </View>
276
+              }
277
+              {
278
+                !chartInfo3.length &&
279
+                <View >
280
+                  <Image style="width: 320rpx;height: 260rpx;margin: 60rpx auto 20rpx auto;display:block" src={nothing} />
281
+                  <View style="text-align:center;color:#999;font-size:30rpx;margin-bottom:100rpx;">
282
+                    暂无数据展示
283
+                </View>
284
+                </View>
285
+              }
286
+              {
287
+                sexInfo.length &&
288
+                <View>
289
+                  <View style="height:20rpx;background:#f5f5f5;"> </View>
290
+                  <View style="padding: 40rpx;">
291
+                    <View style="font-size: 36rpx;color: #666;margin-bottom:20rpx;">性别</View>
292
+                    {sexInfo.map((item, index) => (
293
+                      <View key={index + 'sex3'} style="display: flex;align-items: center;"><View style="font-size: 32rpx;color: #666;min-width:80rpx">{item.genderType == 1 ? '男' : item.genderType == 2 ? '女' : '未知'}</View><AtProgress percent={(item.percentage * 100).toFixed(2)} strokeWidth={6} color={item.genderType == 1 ? '#BB9C79' : item.genderType == 2 ? '#F6B61D' : '#A2A2A2'} /></View>
294
+                    ))
295
+                    }
296
+                  </View>
226
                 </View>
297
                 </View>
227
-              </View>
228
-              <View style="width:100vw;height:530rpx;position: relative;">
229
-                <LineChart source={chartInfo3} />
230
-              </View>
231
-              <View style="height:20rpx;background:#f5f5f5;"> </View>
232
-              <View style="padding: 40rpx;">
233
-                <View style="font-size: 36rpx;color: #666;margin-bottom:20rpx;">性别</View>
234
-                {sexInfo.map((item, index) => (
235
-                  <View key={index + 'sex3'} style="display: flex;align-items: center;"><View style="font-size: 32rpx;color: #666;min-width:80rpx">{item.genderType == 1 ? '男' : item.genderType == 2 ? '女' : '未知'}</View><AtProgress percent={(item.percentage * 100).toFixed(2)} strokeWidth={6} color={item.genderType == 1 ? '#BB9C79' : item.genderType == 2 ? '#F6B61D' : '#A2A2A2'} /></View>
236
-                ))
237
-                }
238
-              </View>
298
+              }
239
             </View>
299
             </View>
240
           </AtTabsPane>
300
           </AtTabsPane>
241
         </AtTabs>
301
         </AtTabs>