浏览代码

Merge branch 'main' of http://git.ycjcjy.com/marketing/miniapp into main

Your Name 3 年前
父节点
当前提交
9608d9bc0d

+ 135
- 0
src/components/ec-canvas/ec-canvas.js 查看文件

1
+import WxCanvas from './wx-canvas';
2
+import * as echarts from './echarts';
3
+
4
+let ctx;
5
+
6
+Component({
7
+  properties: {
8
+    canvasId: {
9
+      type: String,
10
+      value: 'ec-canvas'
11
+    },
12
+
13
+    ec: {
14
+      type: Object
15
+    }
16
+  },
17
+
18
+  data: {
19
+
20
+  },
21
+
22
+  ready: function () {
23
+    if (!this.data.ec) {
24
+      console.warn('组件需绑定 ec 变量,例:<ec-canvas id="mychart-dom-bar" '
25
+        + 'canvas-id="mychart-bar" ec="{{ ec }}"></ec-canvas>');
26
+      return;
27
+    }
28
+
29
+    if (!this.data.ec.lazyLoad) {
30
+      this.init();
31
+    }
32
+  },
33
+
34
+  methods: {
35
+    init: function (callback) {
36
+      const version = wx.version.version.split('.').map(n => parseInt(n, 10));
37
+      const isValid = version[0] > 1 || (version[0] === 1 && version[1] > 9)
38
+        || (version[0] === 1 && version[1] === 9 && version[2] >= 91);
39
+      if (!isValid) {
40
+        console.error('微信基础库版本过低,需大于等于 1.9.91。'
41
+          + '参见:https://github.com/ecomfe/echarts-for-weixin'
42
+          + '#%E5%BE%AE%E4%BF%A1%E7%89%88%E6%9C%AC%E8%A6%81%E6%B1%82');
43
+        return;
44
+      }
45
+
46
+      ctx = wx.createCanvasContext(this.data.canvasId, this);
47
+
48
+      const canvas = new WxCanvas(ctx, this.data.canvasId);
49
+
50
+      echarts.setCanvasCreator(() => {
51
+        return canvas;
52
+      });
53
+
54
+      var query = wx.createSelectorQuery().in(this);
55
+      query.select('.ec-canvas').boundingClientRect(res => {
56
+        if (typeof callback === 'function') {
57
+          this.chart = callback(canvas, res.width, res.height);
58
+        }
59
+        else if (this.data.ec && typeof this.data.ec.onInit === 'function') {
60
+          this.chart = this.data.ec.onInit(canvas, res.width, res.height);
61
+        }
62
+        else {
63
+          this.triggerEvent('init', {
64
+            canvas: canvas,
65
+            width: res.width,
66
+            height: res.height
67
+          });
68
+        }
69
+      }).exec();
70
+    },
71
+
72
+    canvasToTempFilePath(opt) {
73
+      if (!opt.canvasId) {
74
+        opt.canvasId = this.data.canvasId;
75
+      }
76
+
77
+      ctx.draw(true, () => {
78
+        wx.canvasToTempFilePath(opt, this);
79
+      });
80
+    },
81
+
82
+    touchStart(e) {
83
+      if (this.chart && e.touches.length > 0) {
84
+        var touch = e.touches[0];
85
+        var handler = this.chart.getZr().handler;
86
+        handler.dispatch('mousedown', {
87
+          zrX: touch.x,
88
+          zrY: touch.y
89
+        });
90
+        handler.dispatch('mousemove', {
91
+          zrX: touch.x,
92
+          zrY: touch.y
93
+        });
94
+        handler.processGesture(wrapTouch(e), 'start');
95
+      }
96
+    },
97
+
98
+    touchMove(e) {
99
+      if (this.chart && e.touches.length > 0) {
100
+        var touch = e.touches[0];
101
+        var handler = this.chart.getZr().handler;
102
+        handler.dispatch('mousemove', {
103
+          zrX: touch.x,
104
+          zrY: touch.y
105
+        });
106
+        handler.processGesture(wrapTouch(e), 'change');
107
+      }
108
+    },
109
+
110
+    touchEnd(e) {
111
+      if (this.chart) {
112
+        const touch = e.changedTouches ? e.changedTouches[0] : {};
113
+        var handler = this.chart.getZr().handler;
114
+        handler.dispatch('mouseup', {
115
+          zrX: touch.x,
116
+          zrY: touch.y
117
+        });
118
+        handler.dispatch('click', {
119
+          zrX: touch.x,
120
+          zrY: touch.y
121
+        });
122
+        handler.processGesture(wrapTouch(e), 'end');
123
+      }
124
+    }
125
+  }
126
+});
127
+
128
+function wrapTouch(event) {
129
+  for (let i = 0; i < event.touches.length; ++i) {
130
+    const touch = event.touches[i];
131
+    touch.offsetX = touch.x;
132
+    touch.offsetY = touch.y;
133
+  }
134
+  return event;
135
+}

+ 4
- 0
src/components/ec-canvas/ec-canvas.json 查看文件

1
+{
2
+  "component": true,
3
+  "usingComponents": {}
4
+}

+ 4
- 0
src/components/ec-canvas/ec-canvas.wxml 查看文件

1
+<canvas class="ec-canvas" canvas-id="{{ canvasId }}"
2
+bindinit="init"
3
+bindtouchstart="{{ ec.disableTouch ? '' : 'touchStart' }}" bindtouchmove="{{ ec.disableTouch ? '' : 'touchMove' }}" bindtouchend="{{ ec.disableTouch ? '' : 'touchEnd' }}">
4
+</canvas>

+ 4
- 0
src/components/ec-canvas/ec-canvas.wxss 查看文件

1
+.ec-canvas {
2
+  width: 100%;
3
+  height: 100%;
4
+}

+ 40673
- 0
src/components/ec-canvas/echarts.js
文件差异内容过多而无法显示
查看文件


+ 97
- 0
src/components/ec-canvas/wx-canvas.js 查看文件

1
+export default class WxCanvas {
2
+  constructor(ctx, canvasId) {
3
+    this.ctx = ctx;
4
+    this.canvasId = canvasId;
5
+    this.chart = null;
6
+
7
+    // this._initCanvas(zrender, ctx);
8
+    this._initStyle(ctx);
9
+    this._initEvent();
10
+  }
11
+
12
+  getContext(contextType) {
13
+    if (contextType === '2d') {
14
+      return this.ctx;
15
+    }
16
+  }
17
+
18
+  // canvasToTempFilePath(opt) {
19
+  //   if (!opt.canvasId) {
20
+  //     opt.canvasId = this.canvasId;
21
+  //   }
22
+
23
+  //   return wx.canvasToTempFilePath(opt, this);
24
+  // }
25
+
26
+  setChart(chart) {
27
+    this.chart = chart;
28
+  }
29
+
30
+  attachEvent () {
31
+    // noop
32
+  }
33
+
34
+  detachEvent() {
35
+    // noop
36
+  }
37
+
38
+  _initCanvas(zrender, ctx) {
39
+    zrender.util.getContext = function () {
40
+      return ctx;
41
+    };
42
+
43
+    zrender.util.$override('measureText', function (text, font) {
44
+      ctx.font = font || '12px sans-serif';
45
+      return ctx.measureText(text);
46
+    });
47
+  }
48
+
49
+  _initStyle(ctx) {
50
+    var styles = ['fillStyle', 'strokeStyle', 'globalAlpha', 
51
+      'textAlign', 'textBaseAlign', 'shadow', 'lineWidth',
52
+      'lineCap', 'lineJoin', 'lineDash', 'miterLimit', 'fontSize'];
53
+
54
+    styles.forEach(style => {
55
+      Object.defineProperty(ctx, style, {
56
+        set: value => {
57
+          if (style !== 'fillStyle' && style !== 'strokeStyle' 
58
+            || value !== 'none' && value !== null
59
+          ) {
60
+            ctx['set' + style.charAt(0).toUpperCase() + style.slice(1)](value);
61
+          }
62
+        }
63
+      });
64
+    });
65
+
66
+    ctx.createRadialGradient = () => {
67
+      return ctx.createCircularGradient(arguments);
68
+    };
69
+  }
70
+
71
+  _initEvent() {
72
+    this.event = {};
73
+    const eventNames = [{
74
+      wxName: 'touchStart',
75
+      ecName: 'mousedown'
76
+    }, {
77
+      wxName: 'touchMove',
78
+      ecName: 'mousemove'
79
+    }, {
80
+      wxName: 'touchEnd',
81
+      ecName: 'mouseup'
82
+    }, {
83
+      wxName: 'touchEnd',
84
+      ecName: 'click'
85
+    }];
86
+
87
+    eventNames.forEach(name => {
88
+      this.event[name.wxName] = e => {
89
+        const touch = e.touches[0];
90
+        this.chart.getZr().handler.dispatch(name.ecName, {
91
+          zrX: name.wxName === 'tap' ? touch.clientX : touch.x,
92
+          zrY: name.wxName === 'tap' ? touch.clientY : touch.y
93
+        });
94
+      };
95
+    });
96
+  }
97
+}

+ 135
- 13
src/pages/mine/addCustomer/index.jsx 查看文件

1
-import React, { useState, useEffect } from 'react'
1
+import { useState, useEffect } from 'react'
2
 import withLayout from '@/layout'
2
 import withLayout from '@/layout'
3
-import './index.scss'
4
-import { ScrollView, Input, Image } from '@tarojs/components'
3
+import { ScrollView, Input, Image, Picker } from '@tarojs/components'
5
 import '@/assets/css/iconfont.css'
4
 import '@/assets/css/iconfont.css'
5
+import { useSelector } from 'react-redux'
6
+import { fetch } from '@/utils/request'
7
+import { API_ITEMS_LIST, API_CARDS_LIST, API_RECOMENT_CLIENT } from '@/constants/api'
8
+import Taro from '@tarojs/taro'
9
+import './index.scss'
6
 
10
 
7
 const defaultSpecialImage = 'https://yz-websit.oss-cn-hangzhou.aliyuncs.com/xlk/index-icon19.jpg'
11
 const defaultSpecialImage = 'https://yz-websit.oss-cn-hangzhou.aliyuncs.com/xlk/index-icon19.jpg'
8
 
12
 
9
-export default withLayout((props) => {
13
+export default withLayout(() => {
14
+
15
+  const user = useSelector(state => state.user)
16
+  const [PersonId, setPersonId] = useState(null)
17
+  const [BuildingName, setBuildingName] = useState(null)
18
+  const [CanSubmit, setCanSubmit] = useState(false)
19
+  const [BuildingId, setBuildingId] = useState(null)
20
+  const [CardName, setCardName] = useState(null)
21
+  const [CardId, setCardId] = useState(null)
22
+  const [BuildingList, setBuildingList] = useState([])
23
+  const [CardList, setCardList] = useState([])
24
+  const [SexList] = useState([
25
+    { name: '男', id: '1' },
26
+    { name: '女', id: '2' }
27
+  ])
28
+  const [SexName, setSexName] = useState(null)
29
+  const [SexId, setSexId] = useState(null)
30
+  const [FormData, setFormData] = useState({
31
+    name: '', // 姓名
32
+    phone: '', // 电话
33
+    sex: '', // 性别
34
+    intention: '', // 意向楼盘
35
+    realtyConsultant: '', // 置业顾问
36
+    describe: '', // 描述
37
+  })
38
+  
39
+
40
+  useEffect(() => {
41
+    if (PersonId !== user.userInfo.person.personId) {
42
+      setPersonId(user.userInfo.person.personId)
43
+    }
44
+  }, [user])
45
+  
46
+  useEffect(() => {
47
+    if (CanSubmit) {
48
+      const params = {...FormData, sex: SexId, intention: BuildingId, realtyConsultant: CardId}
49
+      fetch({ url: API_RECOMENT_CLIENT, method: 'post', payload: params }).then(() => {
50
+        Taro.showToast({title: '添加成功', icon: 'none'})
51
+        Taro.navigateBack({delta: 1})
52
+      })
53
+    }
54
+  }, [CanSubmit])
55
+
56
+  useEffect(() => {
57
+    if (PersonId) {
58
+      GetBuildingList()
59
+    }
60
+  }, [PersonId])
61
+
62
+  useEffect(() => {
63
+    if (BuildingId) {
64
+      GetCardList()
65
+    }
66
+  }, [BuildingId])
67
+
68
+  const GetBuildingList = () => {
69
+    fetch({ url: API_ITEMS_LIST, method: 'get', params: { pageNumber: 1, pageSize: 1000, buildingId: BuildingId } }).then((res) => {
70
+      setBuildingList((res.records || [].map((item) => { return { id: item.buildingId, name: item.name } })))
71
+    })
72
+  }
73
+
74
+  const GetCardList = () => {
75
+    fetch({ url: API_CARDS_LIST, method: 'get', params: { pageNumber: 1, pageSize: 1000 } }).then((res) => {
76
+      setCardList((res.records || [].map((item) => { return { id: item.buildingId, name: item.name } })))
77
+    })
78
+  }
79
+
80
+  const PickerChange = (e) => {
81
+    setBuildingId(BuildingList[e.detail.value - 0].buildingId)
82
+    setBuildingName(BuildingList[e.detail.value - 0].name)
83
+    setCardId(null)
84
+    setCardName(null)
85
+  }
86
+
87
+  const CardPickerChange = (e) => {
88
+    setCardId(CardList[e.detail.value - 0].id)
89
+    setCardName(CardList[e.detail.value - 0].name)
90
+  }
91
+
92
+  const SexPickerChange = (e) => {
93
+    setSexId(SexList[e.detail.value - 0].id)
94
+    setSexName(SexList[e.detail.value - 0].name)
95
+  }
96
+
97
+  const FormInput = (e) => {
98
+    let Data = {...FormData}
99
+    Data[e.currentTarget.dataset.type] = e.detail.value
100
+    setFormData(Data)
101
+  }
10
 
102
 
11
-  // const [PageProps] = useState(props)
103
+  const ToSubmit = () => {
104
+    if(FormData.name === '') {
105
+      Taro.showToast({title: '请填写客户姓名', icon: 'none'})
106
+      return false
107
+    }
108
+    if(SexId === null) {
109
+      Taro.showToast({title: '请选择客户性别', icon: 'none'})
110
+      return false
111
+    }
112
+    if(FormData.phone === '') {
113
+      Taro.showToast({title: '请填写客户电话', icon: 'none'})
114
+      return false
115
+    }
116
+    if(!(/^1[3|4|5|6|7|8|9][0-9]\d{4,8}$/.test(FormData.phone)) || FormData.phone.length != 11) {
117
+      Taro.showToast({title: '请填写正确的客户电话', icon: 'none'})
118
+      return false
119
+    }
120
+    if(BuildingId === null) {
121
+      Taro.showToast({title: '请选择客户的意向楼盘', icon: 'none'})
122
+      return false
123
+    }
124
+    if(!CanSubmit) {
125
+      setCanSubmit(true)
126
+    }
127
+  }
12
 
128
 
13
   return (
129
   return (
14
     <view className='Page addCustomer'>
130
     <view className='Page addCustomer'>
15
 
131
 
16
-      <ScrollView scroll-y={true} refresher-enabled={false} refresher-background='#fff'>
132
+      <ScrollView scroll-y refresher-enabled={false} refresher-background='#fff'>
17
         <view className='PageContent'>
133
         <view className='PageContent'>
18
 
134
 
19
           <text>客户姓名</text>
135
           <text>客户姓名</text>
20
           <view className='FormLine flex-h'>
136
           <view className='FormLine flex-h'>
21
             <view className='flex-item'>
137
             <view className='flex-item'>
22
-              <Input placeholder='请输入客户真实姓名'></Input>
138
+              <Input placeholder='请输入客户真实姓名' data-type='name' onInput={FormInput.bind(this)}></Input>
23
             </view>
139
             </view>
24
           </view>
140
           </view>
25
 
141
 
26
           <text>客户电话</text>
142
           <text>客户电话</text>
27
           <view className='FormLine flex-h'>
143
           <view className='FormLine flex-h'>
28
             <view className='flex-item'>
144
             <view className='flex-item'>
29
-              <Input placeholder='请输入手机号'></Input>
145
+              <Input placeholder='请输入手机号' data-type='phone' onInput={FormInput.bind(this)}></Input>
30
             </view>
146
             </view>
31
           </view>
147
           </view>
32
 
148
 
33
           <text>性别</text>
149
           <text>性别</text>
34
           <view className='FormLine flex-h'>
150
           <view className='FormLine flex-h'>
35
             <view className='flex-item'>
151
             <view className='flex-item'>
36
-              <text>请选择</text>
152
+              <Picker range-key='name' onChange={SexPickerChange} value={0} range={SexList}>
153
+                <text>{SexName || '请选择'}</text>
154
+              </Picker>
37
             </view>
155
             </view>
38
             <text className='iconfont icon-jiantoudown'></text>
156
             <text className='iconfont icon-jiantoudown'></text>
39
           </view>
157
           </view>
41
           <text>意向楼盘</text>
159
           <text>意向楼盘</text>
42
           <view className='FormLine flex-h'>
160
           <view className='FormLine flex-h'>
43
             <view className='flex-item'>
161
             <view className='flex-item'>
44
-              <Input placeholder='请输入楼盘名称'></Input>
162
+              <Picker range-key='name' onChange={PickerChange} value={0} range={BuildingList}>
163
+                <text>{BuildingName || '请选择'}</text>
164
+              </Picker>
45
             </view>
165
             </view>
46
           </view>
166
           </view>
47
 
167
 
48
           <text>内场接待(选填)</text>
168
           <text>内场接待(选填)</text>
49
           <view className='FormLine flex-h'>
169
           <view className='FormLine flex-h'>
50
             <view className='flex-item'>
170
             <view className='flex-item'>
51
-              <text>请选择</text>
171
+              <Picker range-key='name' onChange={CardPickerChange} value={0} range={CardList}>
172
+                <text>{CardName || '请选择'}</text>
173
+              </Picker>
52
             </view>
174
             </view>
53
             <Image mode='heightFix' src={defaultSpecialImage}></Image>
175
             <Image mode='heightFix' src={defaultSpecialImage}></Image>
54
             <text>选择</text>
176
             <text>选择</text>
57
           <text>备注</text>
179
           <text>备注</text>
58
           <view className='FormLine flex-h'>
180
           <view className='FormLine flex-h'>
59
             <view className='flex-item'>
181
             <view className='flex-item'>
60
-              <Input placeholder='补充说明(选填)'></Input>
182
+              <Input placeholder='补充说明(选填)' data-type='describe' onInput={FormInput.bind(this)}></Input>
61
             </view>
183
             </view>
62
           </view>
184
           </view>
63
 
185
 
64
           <view className='Btn'>
186
           <view className='Btn'>
65
-            <text>提交</text>
187
+            <text onClick={ToSubmit}>提交</text>
66
           </view>
188
           </view>
67
 
189
 
68
         </view>
190
         </view>

+ 4
- 1
src/pages/mine/customerAnalyse/index.config.js 查看文件

1
 export default {
1
 export default {
2
-  navigationBarTitleText: '客户分析'
2
+  navigationBarTitleText: '客户分析',
3
+  usingComponents: {
4
+    'ec-canvas': '@/components/ec-canvas/ec-canvas'
5
+  }
3
 }
6
 }

+ 131
- 12
src/pages/mine/customerAnalyse/index.jsx 查看文件

1
-import React, { useState, useEffect } from 'react'
1
+import { useState, useEffect } from 'react'
2
 import withLayout from '@/layout'
2
 import withLayout from '@/layout'
3
-import './index.scss'
4
 import '@/assets/css/iconfont.css'
3
 import '@/assets/css/iconfont.css'
5
 import { ScrollView } from '@tarojs/components'
4
 import { ScrollView } from '@tarojs/components'
5
+import { useSelector } from 'react-redux'
6
+import { fetch } from '@/utils/request'
7
+import { API_SEX_INFO, API_ECHERTS_DAILY } from '@/constants/api'
8
+import echarts from '@/components/ec-canvas/echarts'
9
+// import dayjs from 'dayjs'
10
+import './index.scss'
6
 
11
 
7
-export default withLayout((props) => {
12
+export default withLayout(() => {
8
 
13
 
9
-  // const [PageProps] = useState(props)
10
   const [MenuList] = useState([
14
   const [MenuList] = useState([
11
     { name: '新增客户', id: 1 },
15
     { name: '新增客户', id: 1 },
12
     { name: '跟进客户', id: 2 },
16
     { name: '跟进客户', id: 2 },
20
   ])
24
   ])
21
   const [CurrentChartMenuId, setCurrentChartMenuId] = useState(1)
25
   const [CurrentChartMenuId, setCurrentChartMenuId] = useState(1)
22
 
26
 
23
-  const [SexList, setSexList] = useState([
24
-    { name: '男', per: 0.6 },
25
-    { name: '女', per: 0.3 },
26
-    { name: '未知', per: 0.1 }
27
-  ])
27
+  const [ChartList, setChartList] = useState([])
28
+  const [SexList, setSexList] = useState([])
29
+  const user = useSelector(state => state.user)
30
+  const [PersonId, setPersonId] = useState(null)
31
+
32
+  useEffect(() => {
33
+    if (PersonId !== user.userInfo.person.personId) {
34
+      setPersonId(user.userInfo.person.personId)
35
+    }
36
+  }, [user])
37
+
38
+  useEffect(() => {
39
+    setChartList([])
40
+    GetSexInfo()
41
+  }, [CurrentMenuId])
42
+
43
+  useEffect(() => {
44
+    if(!ChartList.length) {
45
+      GetChartInfo()
46
+    } else {
47
+      // const chart = echarts.init(canvas, null, { width: '100%', height: '100%' })
48
+      // canvas.setChart(chart)
49
+    }
50
+  }, [ChartList])
51
+
52
+  const GetSexInfo = () => {
53
+    fetch({ url: `${API_SEX_INFO}/${CurrentMenuId === 1 ? 'new' : CurrentMenuId === 2 ? 'follow' : 'visite'}`, method: 'get' }).then((res) => {
54
+      const SexRes = (res || []).map((item) => {
55
+        return { name: item.genderType == 1 ? '男' : item.genderType == 2 ? '女' : '未知', per: item.percentage }
56
+      })
57
+      setSexList(SexRes.length ? SexRes : [
58
+        { name: '男', per: 0 },
59
+        { name: '女', per: 0 },
60
+        { name: '未知', per: 0 }
61
+      ])
62
+    })
63
+  }
64
+
65
+  const GetChartInfo = () => {
66
+    fetch({ url: `${API_ECHERTS_DAILY}/${CurrentMenuId === 1 ? 'new' : CurrentMenuId === 2 ? 'follow' : 'visite'}`, method: 'get' }).then((res) => {
67
+      const Arr = (res || []).reverse()
68
+      setChartList(Arr.map(x => ({ name: x.day, value: x.customerNum })))
69
+    })
70
+  }
28
 
71
 
29
   const CutMenu = (item) => {
72
   const CutMenu = (item) => {
30
     return () => {
73
     return () => {
38
     }
81
     }
39
   }
82
   }
40
 
83
 
84
+  const createLineOptions = (source = []) => {
85
+    const colorWithOpacity = op => `rgba(187,156,121, ${op})`
86
+
87
+    const defaultOpt = {
88
+      color: [colorWithOpacity(1)],
89
+      xAxis: {
90
+        type: 'category',
91
+        boundaryGap: false,
92
+        axisLabel: {
93
+          textStyle: {
94
+            color: '#666'
95
+          }
96
+        }
97
+
98
+      },
99
+      yAxis: {
100
+        type: 'value',
101
+        axisLabel: {
102
+          textStyle: {
103
+            color: '#666'
104
+          }
105
+        }
106
+      },
107
+      grid: {
108
+        left: '10%',
109
+        right: '8%',
110
+        bottom: '12%',
111
+        top: '15%',
112
+      },
113
+      series: [],
114
+    }
115
+    // 数据展示只展示 5 个
116
+    const endValue = source.length - 1 > 0 ? source.length - 1 : 0
117
+    const startValue = endValue - 5 > 0 ? endValue - 5 : 0
118
+
119
+    return {
120
+      ...defaultOpt,
121
+      dataset: { source },
122
+      dataZoom: [{
123
+        type: 'inside',
124
+        startValue, endValue,
125
+        show: true,
126
+      }],
127
+      series: [{
128
+        type: 'line',
129
+        dimensions: ['name', 'value'],
130
+        symbolSize: 6,
131
+        smooth: true,
132
+        label: {
133
+          show: true,
134
+          formatter: '{@value}人'
135
+        },
136
+        lineStyle: {
137
+          shadowColor: colorWithOpacity(0.5),
138
+          shadowBlur: 5,
139
+          shadowOffsetY: 7
140
+        },
141
+        areaStyle: {
142
+          color: {
143
+            type: 'linear',
144
+            x: 0,
145
+            y: 0,
146
+            x2: 0,
147
+            y2: 1,
148
+            colorStops: [{
149
+              offset: 0, color: colorWithOpacity(0.2) // 0% 处的颜色
150
+            }, {
151
+              offset: 1, color: colorWithOpacity(0) // 100% 处的颜色
152
+            }],
153
+            global: false,
154
+          }
155
+        },
156
+      }],
157
+    }
158
+  }
159
+
41
   return (
160
   return (
42
     <view className='Page customerAnalyse flex-v'>
161
     <view className='Page customerAnalyse flex-v'>
43
 
162
 
53
 
172
 
54
       <view className='flex-item'>
173
       <view className='flex-item'>
55
         <view>
174
         <view>
56
-          <ScrollView scroll-y={true} refresher-enabled={false}>
175
+          <ScrollView scroll-y refresher-enabled={false}>
57
             <view className='PageContent'>
176
             <view className='PageContent'>
58
 
177
 
59
               {/* 图表 */}
178
               {/* 图表 */}
66
                   }
185
                   }
67
                 </view>
186
                 </view>
68
                 <view className='LineChart'>
187
                 <view className='LineChart'>
69
-
188
+                  <ec-canvas id='CanvasChart' canvas-id='CanvasChart' ec={{ lazyLoad: true }}></ec-canvas>
70
                 </view>
189
                 </view>
71
               </view>
190
               </view>
72
 
191
 
78
                     <view className='flex-h' key={`SexItem-${index}`}>
197
                     <view className='flex-h' key={`SexItem-${index}`}>
79
                       <text>{item.name}</text>
198
                       <text>{item.name}</text>
80
                       <view className='flex-item'>
199
                       <view className='flex-item'>
81
-                        <view style={{width: `${Math.floor(item.per * 100)}%`}}></view>
200
+                        <view style={{ width: `${Math.floor(item.per * 100)}%` }}></view>
82
                       </view>
201
                       </view>
83
                       <text>{Math.floor(item.per * 100)}%</text>
202
                       <text>{Math.floor(item.per * 100)}%</text>
84
                     </view>
203
                     </view>

+ 4
- 0
src/pages/mine/customerAnalyse/index.scss 查看文件

99
                 height: 450px;
99
                 height: 450px;
100
                 position: relative;
100
                 position: relative;
101
                 overflow: hidden;
101
                 overflow: hidden;
102
+                // >#CanvasChart{
103
+                //   width: 100%;
104
+                //   height: 100%;
105
+                // }
102
               }
106
               }
103
             }
107
             }
104
             &.Sex {
108
             &.Sex {

+ 70
- 34
src/pages/mine/myHomepage/index.jsx 查看文件

1
-import React, { useState, useEffect } from 'react'
1
+import { useState, useEffect } from 'react'
2
+import Taro from '@tarojs/taro'
2
 import withLayout from '@/layout'
3
 import withLayout from '@/layout'
3
-import './index.scss'
4
 import { ScrollView, Image } from '@tarojs/components'
4
 import { ScrollView, Image } from '@tarojs/components'
5
 import '@/assets/css/iconfont.css'
5
 import '@/assets/css/iconfont.css'
6
+import { useSelector } from 'react-redux'
7
+import { fetch } from '@/utils/request'
8
+import { API_AGENT_CURRENT, API_ITEMS_DETAIL } from '@/constants/api'
9
+import './index.scss'
6
 import ProjectListItem from '../../../components/ProjectListItem/index'
10
 import ProjectListItem from '../../../components/ProjectListItem/index'
7
 
11
 
8
-export default withLayout((props) => {
9
-
10
-  // const [PageProps] = useState(props)
11
-  const [PageList, setPageList] = useState(['', ''])
12
+export default withLayout(() => {
13
+  
12
   const [IsPull, setPull] = useState(false)
14
   const [IsPull, setPull] = useState(false)
13
   const [ShowPopup, setShowPopup] = useState(false)
15
   const [ShowPopup, setShowPopup] = useState(false)
14
   const [PullTimer, setPullTimer] = useState(null)
16
   const [PullTimer, setPullTimer] = useState(null)
17
+  const [UserInfo, setUserInfo] = useState({})
18
+  const [BuildingInfo, setBuildingInfo] = useState({})
19
+
20
+  const user = useSelector(state => state.user)
21
+  const [PersonId, setPersonId] = useState(null)
22
+
23
+  useEffect(() => {
24
+    if (PersonId !== user.userInfo.person.personId) {
25
+      setPersonId(user.userInfo.person.personId)
26
+    }
27
+  }, [user])
28
+
29
+  useEffect(() => {
30
+    if (PersonId) {
31
+      GetUserInfo()
32
+    }
33
+  }, [PersonId])
34
+
35
+  useEffect(() => {
36
+    if (UserInfo.buildingId) {
37
+      GetBuildingInfo()
38
+    }
39
+  }, [UserInfo])
40
+
41
+  const GetUserInfo = () => {
42
+    fetch({ url: API_AGENT_CURRENT, method: 'get' }).then((res) => {
43
+      setUserInfo(res)
44
+    })
45
+  }
46
+
47
+  const GetBuildingInfo = () => {
48
+    fetch({ url: `${API_ITEMS_DETAIL}/${UserInfo.buildingId}`, method: 'get', showToast: false }).then((res) => {
49
+      setBuildingInfo(res)
50
+    })
51
+  }
15
 
52
 
16
   const PageRefresh = () => { // 页面下拉刷新回调
53
   const PageRefresh = () => { // 页面下拉刷新回调
17
     setPull(true)
54
     setPull(true)
29
   return (
66
   return (
30
     <view className='Page myHomepage'>
67
     <view className='Page myHomepage'>
31
 
68
 
32
-      <ScrollView scroll-y={true} refresher-enabled={true} refresher-triggered={IsPull} onrefresherrefresh={PageRefresh} refresher-background='#fff'>
69
+      <ScrollView scroll-y refresher-enabled refresher-triggered={IsPull} onrefresherrefresh={PageRefresh} refresher-background='#fff'>
33
         <view className='PageContent'>
70
         <view className='PageContent'>
34
 
71
 
35
           <view className='Card UserInfo'>
72
           <view className='Card UserInfo'>
36
             <view className='flex-h Top'>
73
             <view className='flex-h Top'>
37
               <view className='Icon'>
74
               <view className='Icon'>
38
-                <Image mode='aspectFill' src={null}></Image>
75
+                <Image mode='aspectFill' src={UserInfo.avatarurl}></Image>
39
               </view>
76
               </view>
40
               <view className='flex-item'>
77
               <view className='flex-item'>
41
                 <view className='flex-h'>
78
                 <view className='flex-h'>
42
                   <view className='flex-item'>
79
                   <view className='flex-item'>
43
-                    <text>陆毅 13045678976</text>
80
+                    <text>{UserInfo.nickname} {UserInfo.phone}</text>
44
                   </view>
81
                   </view>
45
                   <text className='iconfont icon-dianzan'></text>
82
                   <text className='iconfont icon-dianzan'></text>
46
-                  <text>23赞</text>
83
+                  <text>{UserInfo.likeNum || 0}赞</text>
47
                 </view>
84
                 </view>
48
                 <view className='Tag'>
85
                 <view className='Tag'>
49
                   <view>
86
                   <view>
55
             </view>
92
             </view>
56
             <view className='Work flex-h'>
93
             <view className='Work flex-h'>
57
               <view className='flex-item'>
94
               <view className='flex-item'>
58
-                <text>营销</text>
95
+                <text>{UserInfo.department || '-'}</text>
59
                 <text>部门</text>
96
                 <text>部门</text>
60
               </view>
97
               </view>
61
               <view className='flex-item'>
98
               <view className='flex-item'>
62
-                <text>营销经理</text>
99
+                <text>{UserInfo.post || '-'}</text>
63
                 <text>职位</text>
100
                 <text>职位</text>
64
               </view>
101
               </view>
65
               <view className='flex-item'>
102
               <view className='flex-item'>
66
-                <text>香颂·蔚澜半岛</text>
103
+                <text>{UserInfo.buildingName || '-'}</text>
67
                 <text>楼盘</text>
104
                 <text>楼盘</text>
68
               </view>
105
               </view>
69
             </view>
106
             </view>
70
             <view className='Hot flex-h'>
107
             <view className='Hot flex-h'>
71
               <view className='flex-item'>
108
               <view className='flex-item'>
72
                 {
109
                 {
73
-                  ['', '', '', '', '', ''].map((item, index) => (
110
+                  (UserInfo.visitRecords || []).map((item, index) => (
74
                     <view key={`UserItem-${index}`}>
111
                     <view key={`UserItem-${index}`}>
75
-                      <Image mode='aspectFill' src={null}></Image>
112
+                      <Image mode='aspectFill' src={item.avatar}></Image>
76
                     </view>
113
                     </view>
77
                   ))
114
                   ))
78
                 }
115
                 }
79
               </view>
116
               </view>
80
               <text className='iconfont icon-renqi'></text>
117
               <text className='iconfont icon-renqi'></text>
81
-              <text>人气值6</text>
118
+              <text>人气值{UserInfo.hotNum || 0}</text>
82
             </view>
119
             </view>
83
           </view>
120
           </view>
84
 
121
 
88
               <text className='iconfont icon-dianhua'></text>
125
               <text className='iconfont icon-dianhua'></text>
89
               <text>手机:</text>
126
               <text>手机:</text>
90
               <view className='flex-item'>
127
               <view className='flex-item'>
91
-                <text>136 1394 9434</text>
128
+                <text>{UserInfo.phone}</text>
92
               </view>
129
               </view>
93
             </view>
130
             </view>
94
             <view className='flex-h'>
131
             <view className='flex-h'>
95
               <text className='iconfont icon-dingwei'></text>
132
               <text className='iconfont icon-dingwei'></text>
96
               <text>地址:</text>
133
               <text>地址:</text>
97
               <view className='flex-item'>
134
               <view className='flex-item'>
98
-                <text>江苏省南京市雨花台区汇智大厦</text>
135
+                <text>{UserInfo.address || '暂无地址'}</text>
99
               </view>
136
               </view>
100
             </view>
137
             </view>
101
             <view className='Btn'>
138
             <view className='Btn'>
103
             </view>
140
             </view>
104
           </view>
141
           </view>
105
 
142
 
106
-          <view className='ProjectList'>
107
-            <view className='flex-h'>
108
-              <view className='flex-item'>
109
-                <text>项目信息</text>
143
+          {
144
+            BuildingInfo.buildingId &&
145
+            <view className='ProjectList'>
146
+              <view className='flex-h'>
147
+                <view className='flex-item'>
148
+                  <text>项目信息</text>
149
+                </view>
150
+                <text onClick={() => { Taro.navigateTo({ url: `/pages/index/buildingList/index` }) }}>更多</text>
151
+                <text className='iconfont icon-jiantouright'></text>
152
+              </view>
153
+              <view className='List'>
154
+                <ProjectListItem data={BuildingInfo}></ProjectListItem>
110
               </view>
155
               </view>
111
-              <text>更多</text>
112
-              <text className='iconfont icon-jiantouright'></text>
113
-            </view>
114
-            <view className='List'>
115
-              {
116
-                PageList.map((item, index) => (
117
-                  <ProjectListItem key={`ListItem-${index}`} data={item}></ProjectListItem>
118
-                ))
119
-              }
120
             </view>
156
             </view>
121
-          </view>
157
+          }
122
 
158
 
123
 
159
 
124
           {/* bottom */}
160
           {/* bottom */}
127
           </view>
163
           </view>
128
 
164
 
129
           <view className='Share'>
165
           <view className='Share'>
130
-            <text onClick={() => {setShowPopup(true)}}>生成海报分享好友</text>
166
+            <text onClick={() => { setShowPopup(true) }}>生成海报分享好友</text>
131
           </view>
167
           </view>
132
 
168
 
133
         </view>
169
         </view>
142
                 <view className='flex-item'>
178
                 <view className='flex-item'>
143
                   <text>保存后分享图片</text>
179
                   <text>保存后分享图片</text>
144
                 </view>
180
                 </view>
145
-                <text className='iconfont icon-guanbi' onClick={() => {setShowPopup(false)}}></text>
181
+                <text className='iconfont icon-guanbi' onClick={() => { setShowPopup(false) }}></text>
146
               </view>
182
               </view>
147
               <view className='flex-item'>
183
               <view className='flex-item'>
148
                 <view>
184
                 <view>