Kaynağa Gözat

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

许静 5 yıl önce
ebeveyn
işleme
02ff437f67
1 değiştirilmiş dosya ile 121 ekleme ve 61 silme
  1. 121
    61
      src/pages/person/customerAnalysis/analysis.js

+ 121
- 61
src/pages/person/customerAnalysis/analysis.js Dosyayı Görüntüle

@@ -10,6 +10,7 @@ import { savePoint, updatePoint } from '@services/common'
10 10
 import { querySexInfo, getEchartDailyInfo, getEchartMonthInfo } from '@services/person'
11 11
 import { connect } from '@tarojs/redux'
12 12
 import LineChart from "../../../components/charts/Line";
13
+const nothing = require('@assets/person/nothing.png')
13 14
 
14 15
 
15 16
 @connect(({ user, city }) => ({ user, city }))
@@ -136,7 +137,7 @@ export default class analysis extends Taro.Component {
136 137
       } else if (params == 'follow') {
137 138
         getEchartMonthInfo(params).then(res => {
138 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 143
       } else {
@@ -165,77 +166,136 @@ export default class analysis extends Taro.Component {
165 166
         <AtTabs className="tab-bar" current={current} tabList={tabList} onClick={this.handleClick.bind(this)} swipeable="false">
166 167
           <AtTabsPane current={current} index={0} >
167 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 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 211
             </View>
190 212
           </AtTabsPane>
191 213
           <AtTabsPane current={current} index={1}>
192 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 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 255
             </View>
215 256
           </AtTabsPane>
216 257
           <AtTabsPane current={current} index={2}>
217 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 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 299
             </View>
240 300
           </AtTabsPane>
241 301
         </AtTabs>