Parcourir la source

初始化提交-添加话题选择

liyongli il y a 3 ans
Parent
commit
56be3966fe
50 fichiers modifiés avec 2884 ajouts et 0 suppressions
  1. 14 0
      .gitignore
  2. 10 0
      app.js
  3. 18 0
      app.json
  4. 26 0
      app.wxss
  5. 257 0
      components/Chart/Chart.js
  6. 6 0
      components/Chart/Chart.json
  7. 11 0
      components/Chart/Chart.wxml
  8. 26 0
      components/Chart/Chart.wxss
  9. 241 0
      components/lineChart/lineChart.js
  10. 6 0
      components/lineChart/lineChart.json
  11. 6 0
      components/lineChart/lineChart.wxml
  12. 26 0
      components/lineChart/lineChart.wxss
  13. 40 0
      components/tab/tab.js
  14. 5 0
      components/tab/tab.json
  15. 11 0
      components/tab/tab.wxml
  16. 23 0
      components/tab/tab.wxss
  17. 13 0
      components/table/filter.wxs
  18. 46 0
      components/table/table.js
  19. 4 0
      components/table/table.json
  20. 19 0
      components/table/table.wxml
  21. 24 0
      components/table/table.wxss
  22. 132 0
      components/wordCloud/wordCloud.js
  23. 5 0
      components/wordCloud/wordCloud.json
  24. 4 0
      components/wordCloud/wordCloud.wxml
  25. 6 0
      components/wordCloud/wordCloud.wxss
  26. 176 0
      components/wordCloud/wordCloud__.js
  27. 250 0
      ec-canvas/ec-canvas.js
  28. 4 0
      ec-canvas/ec-canvas.json
  29. 4 0
      ec-canvas/ec-canvas.wxml
  30. 4 0
      ec-canvas/ec-canvas.wxss
  31. 21 0
      ec-canvas/echarts.js
  32. 121 0
      ec-canvas/wx-canvas.js
  33. 51 0
      pages/home/components/contrast/contrast.js
  34. 10 0
      pages/home/components/contrast/contrast.json
  35. 11 0
      pages/home/components/contrast/contrast.wxml
  36. 9 0
      pages/home/components/contrast/contrast.wxss
  37. 349 0
      pages/home/components/topic/topic.js
  38. 10 0
      pages/home/components/topic/topic.json
  39. 103 0
      pages/home/components/topic/topic.wxml
  40. 40 0
      pages/home/components/topic/topic.wxss
  41. 155 0
      pages/home/home.js
  42. 7 0
      pages/home/home.json
  43. 16 0
      pages/home/home.wxml
  44. 23 0
      pages/home/home.wxss
  45. 337 0
      pages/sonTopic/sonTopic.js
  46. 10 0
      pages/sonTopic/sonTopic.json
  47. 90 0
      pages/sonTopic/sonTopic.wxml
  48. 19 0
      pages/sonTopic/sonTopic.wxss
  49. 76 0
      project.config.json
  50. 9 0
      sitemap.json

+ 14 - 0
.gitignore

@@ -0,0 +1,14 @@
+# Windows
+[Dd]esktop.ini
+Thumbs.db
+$RECYCLE.BIN/
+
+# macOS
+.DS_Store
+.fseventsd
+.Spotlight-V100
+.TemporaryItems
+.Trashes
+
+# Node.js
+node_modules/

+ 10 - 0
app.js

@@ -0,0 +1,10 @@
+//app.js
+App({
+  onLaunch: function () {
+    let test = wx.getAccountInfoSync().miniProgram.envVersion;
+    if(test !== 'release') { // 非正式环境
+      this.baseUrl = "https://bigdata.smcic.net"
+    }
+  },
+  baseUrl: "https://bigdata.smcic.net"
+})

+ 18 - 0
app.json

@@ -0,0 +1,18 @@
+{
+  "pages": [
+    "pages/home/home",
+    "pages/sonTopic/sonTopic"
+  ],
+  "window": {
+    "backgroundTextStyle": "light",
+    "navigationBarBackgroundColor": "#20223b",
+    "navigationBarTitleText": "陕西广电融媒体集团创新中心",
+    "navigationBarTextStyle": "white",
+    "navigationStyle": "default"
+  },
+  "style": "v2",
+  "sitemapLocation": "sitemap.json",
+  "useExtendedLib": {
+    "weui": true
+  }
+}

+ 26 - 0
app.wxss

@@ -0,0 +1,26 @@
+/**app.wxss**/
+page{
+  width: 100%;
+  height: 100vh;
+  background-color: #20223b;
+}
+.container {
+  position: absolute;
+  top: 0;
+  bottom: 0;
+  left: 0;
+  right: 0;
+  display: flex;
+  flex-direction: column;
+  align-items: center;
+  justify-content: space-between;
+  box-sizing: border-box;
+} 
+.basePage{
+  min-height: 100vh;
+  width: 100vw;
+  color: #bfcbd9;
+  font-size: 14px;
+  font-family: PingFang SC;
+  padding-bottom: 2em;
+}

+ 257 - 0
components/Chart/Chart.js

@@ -0,0 +1,257 @@
+// 柱图
+import * as echarts from '../../ec-canvas/echarts';
+Component({
+  /**
+   * 组件的属性列表
+   */
+  properties: {
+    canvasId: {
+      type: String,
+      value: "mychart-dom-bar"
+    },
+    id: {
+      type: String,
+      value: "mychart-bar"
+    },
+    type: {
+      type: String,
+      value: "bar"
+    },
+    btnList: {
+      type: Array,
+      value: [],
+      observer: function (n, o) {
+        if (!n || n === o) return
+        this.setData({
+          select: n[0].type
+        })
+      }
+    },
+    list: {
+      type: Array,
+      value: [],
+      observer: function (n, o) {
+        if (!n || !n.length) return
+        let xData = [], yData = [];
+        let type = this.data.select || this.data.yType;
+        n.map((v, i) => {
+          yData[i] = {
+            type: this.data.type,
+            barMaxWidth: 30,
+            label: {
+              show: true,
+              shadowColor: 'transparent',
+              position: 'top',
+              color: "#fff",
+              formatter: function (d) {
+                let v = d.value;
+                if (isNaN(v)) {
+                  return 0
+                } else if (v >= 10000 && v < 100000) {
+                  return (v / 10000).toFixed(2) - 0 + '万'
+                } else if (v >= 100000 && v < 100000000) {
+                  return (v / 10000).toFixed(0) - 0 + '万'
+                } else if (v >= 100000000) {
+                  return (v / 100000000).toFixed(2) - 0 + '亿'
+                }
+                return v
+              }
+            },
+            data: []
+          }
+
+          if (v.length) {
+            v = v.sort((a, b) => {
+              return b[type] - a[type]
+            })
+            let sLi = JSON.parse(JSON.stringify(v));
+            if (v.length > 10) sLi = sLi.splice(0, 10);
+            sLi.map(val => {
+              i === 0 && xData.push(val[this.data.xType]);
+              yData[i].data.push(val[type]);
+            })
+          }
+        })
+        if (this.chart) {
+          const option = this.chart.getOption();
+          option.series = yData;
+          option.xAxis[0].data = xData;
+          option.series = yData;
+          this.chart.clear();
+          this.chart.setOption(option);
+          this.setData({
+            xData,
+            yData,
+            show: true,
+          })
+        } else {
+          this.setData({
+            ec: {
+              onInit: this.initChart.bind(this)
+            },
+            xData,
+            yData,
+            show: true,
+          })
+        }
+      }
+    },
+    yType: {
+      type: String,
+      value: ""
+    },
+    xType: {
+      type: String,
+      value: ""
+    }
+  },
+  chart: undefined,
+
+  // 销毁组件
+  detached: function () {
+    this.chart && this.chart.dispose && this.chart.dispose();
+  },
+
+  /**
+   * 组件的初始数据
+   */
+  data: {
+    show: false,
+    ec: {
+      onInit: undefined
+    },
+    xData: [],
+    yData: [],
+    select: ""
+  },
+
+  /**
+   * 组件的方法列表
+   */
+  methods: {
+    initChart: function (canvas, width, height, dpr) {
+      this.chart && this.chart.dispose && this.chart.dispose();
+      this.chart = echarts.init(canvas, null, {
+        width: width,
+        height: height,
+        devicePixelRatio: dpr // 像素
+      });
+      canvas.setChart(this.chart);
+      var option = {
+        animation: false,
+        tooltip: {
+          show: false,
+          textStyle: {
+            color: "#fff"
+          },
+          trigger: 'axis',
+          backgroundColor: 'rgba(0,0,0,.5)',
+          axisPointer: {            // 坐标轴指示器,坐标轴触发有效
+            type: 'shadow',        // 默认为直线,可选为:'line' | 'shadow'
+            shadowStyle: {
+              color: "rgba(150,150,150,0.2)"
+            },
+          },
+          formatter: "{b}\n{c}",
+        },
+        color: ['#1890ff'],
+        grid: {
+          top: "20px",
+          left: '3%',
+          right: '4%',
+          bottom: '3%',
+          containLabel: true
+        },
+        xAxis: {
+          type: 'category',
+          splitLine: { show: false },
+          data: this.data.xData,
+          axisTick: {
+            show: false
+          },
+          axisLine: {
+            show: false,
+            lineStyle: {
+              color: "#bfcbd9"
+            }
+          },
+          axisLabel: {
+            interval: 0,
+            formatter: function (v, index) {
+              const li = v.split("");
+              v = li.map((nameString, i) => {
+                i !== 0 && (i + 1) % 2 === 0 && (nameString = nameString + "\n");
+                return nameString
+              }).join("");
+              return v
+            }
+          }
+        },
+        yAxis: {
+          type: 'value',
+          splitLine: { show: true, lineStyle: { type: "dotted", color: '#4e5358' } },
+          axisLine: {
+            show: false,
+            lineStyle: {
+              type: "dotted",
+              color: "#bfcbd9",
+            }
+          },
+          axisLabel: {
+            formatter: function (val, index) {
+              let out = val;
+              if (val >= 1000 && val < 10000) {
+                out = (val / 1000).toFixed(2) - 0 + "千"
+              } else if (val >= 10000 && val < 100000) {
+                out = (val / 10000).toFixed(2) - 0 + "万"
+              } else if (val >= 100000 && val < 100000000) {
+                return (val / 10000).toFixed(0) - 0 + '万'
+              } else if (val >= 100000000) {
+                out = (val / 100000000).toFixed(2) - 0 + "亿"
+              }
+              return out
+            }
+          }
+        },
+        series: this.data.yData
+      };
+      // this.chart.on("finished", () => {
+      //   console.log("绘图结束");
+      // })
+      this.chart.setOption(option);
+      return this.chart;
+    },
+    changeselect: function (e) {
+      let type = e.currentTarget.dataset.type;
+      if (type === this.data.select) return;
+      let yData = [], xData = [];
+      this.data.list.map((v, i) => {
+        yData[i] = {
+          type: this.data.type,
+          data: []
+        }
+        if (v.length) {
+          v = v.sort((a, b) => {
+            return b[type] - a[type]
+          })
+          let sLi = JSON.parse(JSON.stringify(v));
+          if (v.length > 10) sLi = sLi.splice(0, 10);
+          sLi.map(val => {
+            yData[i].data.push(val[type]);
+            i === 0 && xData.push(val[this.data.xType]);
+          })
+        }
+      })
+      this.setData({
+        select: type,
+        yData,
+        xData
+      }, () => {
+        let option = this.chart.getOption();
+        option.series = yData;
+        option.xAxis[0].data = xData;
+        this.chart.setOption(option);
+      })
+    },
+  }
+})

+ 6 - 0
components/Chart/Chart.json

@@ -0,0 +1,6 @@
+{
+  "component": true,
+  "usingComponents": {
+    "ec-canvas": "../../ec-canvas/ec-canvas"
+  }
+}

+ 11 - 0
components/Chart/Chart.wxml

@@ -0,0 +1,11 @@
+<!--components/Chart/Chart.wxml-->
+<view wx:if="{{show}}" class="canvas">
+  <view class="btnType" wx:if="{{btnList.length}}">
+    <view 
+    bindtap="changeselect" 
+    data-type="{{item.type}}" 
+    class="{{'chartBtn' + (item.type === select ? ' active' : '')}}" 
+    wx:for="{{btnList}}" wx:key="name">{{item.name}}</view>
+  </view>
+  <ec-canvas id="{{id}}" canvasId="{{canvasId}}" ec="{{ ec }}"></ec-canvas>
+</view>

+ 26 - 0
components/Chart/Chart.wxss

@@ -0,0 +1,26 @@
+/* components/Chart/Chart.wxss */
+.canvas {
+  width: 100%;
+  height: 200px;
+  font-size: 14px;
+}
+.canvas .btnType{
+  float: right;
+  margin-top: -30px;
+  border: 1px solid #1989fa;
+  border-radius: 3px;
+  right: 5px;
+  color: #fff;
+  height: 1.4em;
+  text-align: center;
+  line-height: 1.4em;
+}
+.canvas .btnType .chartBtn{
+  display: inline-block;
+  min-width: 2.5em;
+  height: 1.4em;
+  line-height: 1.4em;
+}
+.canvas .btnType .active{
+  background-color: #1989fa
+}

+ 241 - 0
components/lineChart/lineChart.js

@@ -0,0 +1,241 @@
+// 线图
+import * as echarts from '../../ec-canvas/echarts';
+Component({
+  /**
+   * 组件的属性列表
+   */
+  properties: {
+    canvasId:{
+      type: String,
+      value: "mychart-dom-bar"
+    },
+    id:{
+      type: String,
+      value: "mychart-bar"
+    },
+    type: {
+      type: String,
+      value: "bar"
+    },
+    isShow: {
+      type: Boolean,
+      value: false,
+      observer: function (n) {
+        const select = this.data.select === '6m' || this.data.select === '24h';
+        if (!select) return
+        console.log("需要更新");
+        if (n) this.triggerEvent("lineChenge", this.data.select);
+      }
+    },
+    select: {
+      type: String,
+      value: ""
+    },
+    btnList: {
+      type: Array,
+      value: [],
+    },
+    list: {
+      type: Array,
+      value: [],
+      observer: function (n, o) {
+        if (!n || !n.length) return;
+        if (this.data.select !== '24h' && this.data.select !== '6m' && this.setInterval) clearInterval(this.setInterval)
+        if (this.data.select !== '24h' && this.data.select !== '6m' && this.setTimeout) clearInterval(this.setTimeout)
+        let xData = [], yData = [];
+        yData = {
+          type: this.data.type,
+          smooth: 0.6,
+          symbolSize: 1,
+          itemStyle: {
+            color: "#1890ff"
+          },
+          lineStyle: {
+            width: 1
+          },
+          areaStyle: {
+            color: new echarts.graphic.LinearGradient(
+              0, 0, 0, 1,
+              [
+                { offset: 0, color: 'rgba(24,144,255, .8)' },
+                { offset: 1, color: 'rgba(24,144,255, 0)' },
+              ]
+            )
+          },
+          data: []
+        }
+
+        n.map((v, i) => {
+          yData.data.push(v[this.data.yType]);
+          xData.push(v[this.data.xType])
+        })
+        if (this.chart) {
+          const option = this.chart.getOption();
+          option.series = yData;
+          option.xAxis[0].data = xData;
+          option.series = yData;
+          this.chart.setOption(option);
+          this.setData({
+            xData,
+            yData,
+            show: true
+          })
+        } else {
+          this.setData({
+            ec: {
+              onInit: this.initChart.bind(this)
+            },
+            xData,
+            yData,
+            show: true
+          })
+        }
+      }
+    },
+    yType: {
+      type: String,
+      value: ""
+    },
+    xType: {
+      type: String,
+      value: ""
+    }
+  },
+  chart: undefined,
+  setInterval: undefined,
+  setTimeout: undefined,
+  ready() {
+    wx.setStorageSync('nextTime', 0)
+  },
+
+  // 销毁组件
+  detached: function () {
+    this.chart && this.chart.dispose && this.chart.dispose();
+    this.setInterval && clearInterval(this.setInterval);
+    this.setTimeout && clearInterval(this.setTimeout);
+  },
+
+  /**
+   * 组件的初始数据
+   */
+  data: {
+    show: false,
+    ec: {
+      onInit: undefined
+    },
+    xData: [],
+    yData: [],
+  },
+
+  /**
+   * 组件的方法列表
+   */
+  methods: {
+    initChart: function (canvas, width, height, dpr) {
+      this.chart && this.chart.dispose && this.chart.dispose();
+      this.chart = echarts.init(canvas, null, {
+        width: width,
+        height: height,
+        devicePixelRatio: dpr // 像素
+      });
+      canvas.setChart(this.chart);
+      var option = {
+        animation: false,
+        tooltip: {
+          show: true,
+          textStyle: {
+            color: "#fff"
+          },
+          backgroundColor: 'rgba(0,0,0,.5)',
+          trigger: 'axis',
+          axisPointer: {            // 坐标轴指示器,坐标轴触发有效
+            type: 'line',        // 默认为直线,可选为:'line' | 'shadow'
+            shadowStyle: {
+              color: "rgba(150,150,150,0.2)"
+            },
+          },
+          formatter: "{b}\n{c}",
+        },
+        color: ['#1890ff'],
+        grid: {
+          top: "10px",
+          left: '3%',
+          right: '4%',
+          bottom: '3%',
+          containLabel: true
+        },
+        xAxis: {
+          interval: 0,
+          type: 'category',
+          boundaryGap: false,
+          data: this.data.xData,
+          splitLine: { show: false },
+          axisTick: {
+            show: false
+          },
+          axisLine: {
+            show: false,
+            lineStyle: {
+              color: '#bfcbd9',
+            }
+          }
+        },
+        yAxis: {
+          type: 'value',
+          splitLine: { show: true, lineStyle: { type: "dotted", color: '#4e5358' } },
+          axisLine: {
+            show: false,
+            lineStyle: {
+              color: '#bfcbd9',
+            }
+          },
+          axisLabel: {
+            formatter: function (val, index) {
+              let out = val;
+              if (val >= 1000 && val < 10000) {
+                out = (val / 1000).toFixed(2) - 0 + "千"
+              } else if (val >= 10000 && val < 100000000) {
+                out = (val / 10000).toFixed(0) - 0 + "万"
+              } else if (val >= 100000000) {
+                out = (val / 100000000).toFixed(2) - 0 + "亿"
+              }
+              return out
+            }
+          }
+        },
+        series: this.data.yData
+      };
+      this.chart.setOption(option);
+      return this.chart;
+    },
+    changeselect: function (e) {
+      let type = e.currentTarget.dataset.type;
+      if (type === this.data.select) return;
+      this.setInterval && clearInterval(this.setInterval);
+      this.setTimeout && clearInterval(this.setTimeout);
+      if (type === '24h' || type === '6m') this.countFun(type);
+      this.triggerEvent("lineChenge", type)
+    },
+    countFun(type) {
+      let time = new Date();
+      let min = time.getMinutes();
+      let remainder = min % 10;
+      if (remainder === 1) {
+        this.setInterval = setInterval(() => {
+          console.log("定时")
+          this.triggerEvent("lineChenge", type);
+        }, 600000)
+      } else {
+        this.setTimeout = setTimeout(() => {
+          clearTimeout(this.setTimeout);
+          this.triggerEvent("lineChenge", type);
+          this.setInterval = setInterval(() => {
+            console.log("定时")
+            this.triggerEvent("lineChenge", type);
+          }, 600000)
+        }, (11 - remainder) * 1000 * 60);
+      }
+
+    }
+  }
+})

+ 6 - 0
components/lineChart/lineChart.json

@@ -0,0 +1,6 @@
+{
+  "component": true,
+  "usingComponents": {
+    "ec-canvas": "../../ec-canvas/ec-canvas"
+  }
+}

+ 6 - 0
components/lineChart/lineChart.wxml

@@ -0,0 +1,6 @@
+<view wx:if="{{show}}" class="canvas">
+  <view class="btnType" wx:if="{{btnList.length}}">
+    <view bindtap="changeselect" data-type="{{item.type}}" class="{{'chartBtn' + (item.type === select ? ' active' : '')}}" wx:for="{{btnList}}" wx:key="name">{{item.name}}</view>
+  </view>
+  <ec-canvas id="{{id}}" canvasId="{{canvasId}}" ec="{{ ec }}"></ec-canvas>
+</view>

+ 26 - 0
components/lineChart/lineChart.wxss

@@ -0,0 +1,26 @@
+/* components/lineChart/lineChart.wxss */
+.canvas {
+  width: 100%;
+  height: 200px;
+  font-size: 14px;
+}
+.canvas .btnType{
+  float: right;
+  margin-top: -30px;
+  border: 1px solid #1989fa;
+  border-radius: 3px;
+  right: 5px;
+  color: #fff;
+  height: 1.4em;
+  line-height: 1.4em;
+  text-align: center;
+}
+.canvas .btnType .chartBtn{
+  display: inline-block;
+  min-width: 4em;
+  height: 1.4em;
+  line-height: 1.4em;
+}
+.canvas .btnType .active{
+  background-color: #1989fa
+}

+ 40 - 0
components/tab/tab.js

@@ -0,0 +1,40 @@
+// components/tab/tab.js
+Component({
+  /**
+   * 组件的属性列表
+   */
+  properties: {
+    tabList: {
+      type: Array,
+      value: [],
+    },
+    type:{
+      type: String,
+      value: ''
+    }
+  },
+
+  /**
+   * 组件的初始数据
+   */
+  data: {
+  },
+
+  /**
+   * 组件的方法列表
+   */
+  methods: {
+    click: function (e) {
+      let data = e.currentTarget.dataset;
+      let p = {
+        type: data.type,
+        title: data.title,
+        worldURL: data.worldurl,
+        worldImgURL: data.worldimgurl,
+        index: data.index,
+        isUpdata: data.isupdate
+      }
+      this.triggerEvent("changeBar", p);
+    }
+  }
+})

+ 5 - 0
components/tab/tab.json

@@ -0,0 +1,5 @@
+{
+  "component": true,
+  "usingComponents": {
+  }
+}

+ 11 - 0
components/tab/tab.wxml

@@ -0,0 +1,11 @@
+<!--components/tab/tab.wxml-->
+<view class="Tab">
+  <view wx:for="{{tabList}}" class="{{'tabItem ' + (type == item.type ? 'active' : '')}}" wx:key="type">
+    <view class="item" bindtap="click" data-type="{{item.type}}" data-title="{{item.name}}"
+      data-isUpdate="{{item.isUpdate}}"
+      data-index="{{index}}"
+      data-worldImgURL="{{item.worldImgURL}}" data-worldURL="{{item.worldURL}}">
+      {{item.name}}
+    </view>
+  </view>
+</view>

+ 23 - 0
components/tab/tab.wxss

@@ -0,0 +1,23 @@
+/* components/tab/tab.wxss */
+.Tab{
+  overflow-y: hidden;
+  overflow-x: scroll;
+  white-space: nowrap;
+  font-size: 16px;
+  font-weight: 400;
+  background-color: #20223b;
+  -webkit-overflow-scrolling: touch;
+}
+.Tab .tabItem{
+  display: inline-block;
+  padding: 10px 15px;
+}
+.Tab .item{
+  border-bottom: 2px solid #20223b;
+  padding-bottom: 2px;
+}
+.Tab .active .item{
+  border-bottom-color:red;
+  color: red;
+  padding-bottom: 2px;
+}

+ 13 - 0
components/table/filter.wxs

@@ -0,0 +1,13 @@
+// fliter
+function valueFormat(val) {
+  var out = val;
+  if (val >= 10000 && val < 100000000) {
+    out = (val / 10000).toFixed(2) - 0 + '万';
+  } else if (val >= 100000000) {
+    out = (val / 100000000).toFixed(2) - 0 + "亿";
+  }
+  return out
+}
+module.exports = {
+  valueFormat: valueFormat
+}

+ 46 - 0
components/table/table.js

@@ -0,0 +1,46 @@
+// components/table/table.js
+Component({
+  /**
+   * 组件的属性列表
+   */
+  properties: {
+    title: {
+      type: String,
+      value: ""
+    },
+    list: {
+      type: Array,
+      value: []
+    },
+    listAll:{
+      type: Array,
+      value:[]
+    },
+    noHead:{
+      type: Boolean,
+      value: false
+    }
+  },
+
+  // 初始化组件
+  attached: function () {
+    this.setData({
+      'scrollHeight': wx.getSystemInfoSync().screenHeight - 63
+    })
+  },
+
+  /**
+   * 组件的初始数据
+   */
+  data: {
+    scrollHeight: 0,
+  },
+
+  /**
+   * 组件的方法列表
+   */
+  methods: {
+    toChannl: function () {
+    },
+  }
+})

+ 4 - 0
components/table/table.json

@@ -0,0 +1,4 @@
+{
+  "component": true,
+  "usingComponents": {}
+}

+ 19 - 0
components/table/table.wxml

@@ -0,0 +1,19 @@
+<!--components/table/table.wxml-->
+<wxs module="filter" src="./filter.wxs" />
+<scroll-view scroll-x="{{true}}" class="table">
+  <view class="table_row">
+    <view class="table_rd">
+      <view class="viewRd" wx:if="{{!noHead}}"></view>
+      <view class="viewRd" wx:for="{{listAll}}" wx:key="type" wx:for-item="pItem" wx:for-index="pIndex" bindtap="toChannl">
+        {{pItem.name}}</view>
+    </view>
+    <view class="table_rd" wx:for="{{list}}" wx:key="type" wx:for-item="pItem" wx:for-index="pIndex" bindtap="toChannl">
+      <view class="{{pIndex%2 === 0 ? 'debuRow viewRd': 'viewRd'}}">
+        {{pItem.topic_name}}
+      </view>
+      <view class="{{pIndex%2 === 0 ? 'debuRow viewRd': 'viewRd'}}" wx:for="{{listAll}}" wx:key="type" wx:for-item="sItem" wx:for-index="sIndex">
+        {{filter.valueFormat(pItem[sItem.type])}}
+      </view>
+    </view>
+  </view>
+</scroll-view>

+ 24 - 0
components/table/table.wxss

@@ -0,0 +1,24 @@
+/* components/table/table.wxss */
+.table{
+  color: #fff;
+  border-top: 1px solid #515266;
+}
+.table .table_row {
+  white-space: nowrap;
+}
+.table .table_rd {
+  min-width: 4em;
+  text-align: center;
+  white-space: nowrap;
+  display: inline-block;
+  vertical-align:middle;
+  border-bottom: 1px solid #515266;
+}
+.table .table_rd .viewRd{
+  padding: 0 15px;
+  line-height: 35px;
+  height: 35px;
+}
+.table .table_rd .debuRow{
+  background-color: #1c1f32;
+}

+ 132 - 0
components/wordCloud/wordCloud.js

@@ -0,0 +1,132 @@
+// 词云
+Component({
+  /**
+   * 组件的属性列表
+   */
+  properties: {
+    width: {
+      type: Number | String,
+      value: "100%"
+    },
+    height: {
+      type: Number,
+      value: 330
+    },
+    minFont: {
+      type: Number,
+      value: 12
+    },
+    maxFont: {
+      type: Number,
+      value: 35
+    },
+    fontColor: {
+      type: String,
+      value: "#f4347a"
+    },
+    wordsCloud: {
+      type: Array,
+      value: [],
+      observer(words) {
+        this.texts = [];
+        this.ctx && this.ctx.clearRect(0, 0, this.width, this.height);
+        if (words.length > 0) {
+          //排序
+          words.sort((a, b) => {
+            return parseFloat(b.value) - parseFloat(a.value)
+          })
+          this.maxVal = words[0].value;
+          this.minVal = words[words.length - 1].value;
+          words.forEach((v, i) => {
+            let point = this.creatText(v, i);
+            this.texts.push(point);
+            this.drawText(point);
+          })
+        }
+        this.ctx && this.ctx.draw()
+      }
+    }
+  },
+
+  minVal: 0,
+  maxVal: 0,
+  /**
+   * 组件的初始数据
+   */
+  data: {
+    texts: []
+  },
+
+  attached() {
+    this.ctx = wx.createCanvasContext('canvas', this);
+    this.height = this.data.height;
+    this.width = wx.getSystemInfoSync().screenWidth;
+    this.texts = [];
+  },
+
+  /**
+   * 组件的方法列表
+   */
+  methods: {
+    drawText(word) {
+      let colorLi = ['8', '9', 'a', 'b', 'c', 'd', 'e', 'f'];
+      let color = "#";
+      for (let i = 0, len = 6; i < len; i++) {
+        color += colorLi[Math.floor(Math.random() * len)]
+      }
+      this.ctx.translate(word.x, word.y);
+      this.ctx.rotate(word.angle);
+      this.ctx.setFillStyle(color);
+      this.ctx.textAlign = "left";
+      this.ctx.textBaseline = "top";
+      this.ctx.font = word.height + "px arial";
+      this.ctx.fillText(word.name, 0, 0);
+      this.ctx.rotate(-1 * word.angle);
+      this.ctx.translate(-1 * word.x, -1 * word.y);
+    },
+    creatText(v, i) {
+      const maxf = this.data.maxFont;
+      const minf = this.data.minFont;
+      let fen = (this.maxVal - this.minVal) / (maxf - minf);
+      let fontsize = Math.ceil((v.value - this.minVal) / fen + minf)
+      this.ctx.setFontSize(fontsize)
+      let textWidth = this.ctx.measureText(v.name).width //文字所占宽度
+      const createPoint = {
+        x: 0,
+        y: 0,
+        width: textWidth,
+        height: fontsize,
+        angle: Math.random() * Math.PI / 4,
+      }
+      if (i === 0) {
+        createPoint.x = this.width / 2 - textWidth / 2;
+        createPoint.y = this.data.height / 2 - fontsize / 2;
+        createPoint.angle = 0;
+      } else {
+        createPoint.x = Math.floor(Math.random() * (this.width));
+        createPoint.y = Math.floor(Math.random() * (this.data.height));
+      }
+      // else{
+      //   createPoint.x = Math.floor(Math.random() * (this.width));
+      //   createPoint.y = Math.floor(Math.random() * (this.data.height));
+      // }
+      // 边界碰撞
+      let c = Math.ceil(Math.sqrt(Math.pow(fontsize, 2) + Math.pow(textWidth, 2)));
+      let cosx = Math.cos(createPoint.angle);
+      let cosy = Math.cos(Math.PI / 2 - createPoint.angle);
+      let jH = Math.asin(fontsize / textWidth);
+      let cosyR = Math.cos(jH);
+      let height = c * cosyR;
+      let width = textWidth * cosx;
+      let leftX = fontsize * cosy;
+      createPoint.x < leftX && (createPoint.x = leftX);
+      createPoint.x > this.width - width && (createPoint.x = this.width - width - 5);
+      createPoint.y > this.data.height - height && (createPoint.y = this.data.height - height);
+
+      return {
+        ...v,
+        ...createPoint
+      }
+    }
+  }
+})

+ 5 - 0
components/wordCloud/wordCloud.json

@@ -0,0 +1,5 @@
+{
+  "component": true,
+  "usingComponents": {
+  }
+}

+ 4 - 0
components/wordCloud/wordCloud.wxml

@@ -0,0 +1,4 @@
+<!--components/wordCloud/wordCloud.wxml-->
+<view class="f2-chart">
+  <canvas style="width:100%;height:{{height}}px;display:block;" canvas-id="canvas"></canvas>
+</view>

+ 6 - 0
components/wordCloud/wordCloud.wxss

@@ -0,0 +1,6 @@
+/* components/wordCloud/wordCloud.wxss */
+.f2-chart {
+  width: 100%;
+  height: 330px;
+  position:relative;
+}

+ 176 - 0
components/wordCloud/wordCloud__.js

@@ -0,0 +1,176 @@
+// 词云
+function Bounds(min, max) {
+  this.min = min;
+  this.max = max;
+}
+Component({
+  /**
+   * 组件的属性列表
+   */
+  properties: {
+    width: {
+      type: Number | String,
+      value: "100%"
+    },
+    height: {
+      type: Number,
+      value: 200
+    },
+    minFont: {
+      type: Number,
+      value: 12
+    },
+    maxFont: {
+      type: Number,
+      value: 35
+    },
+    fontColor: {
+      type: String,
+      value: "#f4347a"
+    },
+    wordsCloud: {
+      type: Array,
+      value: [],
+      observer(words) {
+        this.texts = [];
+        this.value = 0;
+        if (words.length > 0) {
+          //排序
+          words.sort((a, b) => {
+            return parseFloat(b.value) - parseFloat(a.value)
+          })
+          let maxval = words[0].value;
+          let minval = words[words.length - 1].value;
+          const percent = this.data.maxFont / maxval
+          words.forEach(item => {
+            let value = isNaN(parseFloat(item.value)) ? this.data.minFont : parseFloat(item.value);
+            let size = value * percent;
+            item.fontSize = size < 10 ? size + 10 : size;
+            return item
+          })
+          this.words = words;
+          this.ctx.clearRect(0, 0, this.width, this.height)
+          this.draw(this.words)
+        } else {
+          wx.createCanvasContext('canvas', this).draw()
+        }
+      }
+    }
+  },
+
+  /**
+   * 组件的初始数据
+   */
+  data: {
+  },
+
+  attached() {
+    this.ctx = wx.createCanvasContext('canvas', this);
+    this.height = this.data.height;
+    this.width = wx.getSystemInfoSync().screenWidth - 48;
+    this.texts = [];
+    this.value = 0;
+    this.canvasBound = new Bounds({
+      x: 0,
+      y: 0
+    }, {
+      x: this.width,
+      y: this.height
+    })
+  },
+
+  /**
+   * 组件的方法列表
+   */
+  methods: {
+
+    draw(words) {
+      words.forEach((item, index) => {
+        this.isDraw(item, index == 0)
+      })
+      this.ctx.draw();
+    },
+
+    isDraw(item, center) {
+      let bound = this.createText(item, center)
+      for (let i = 0; i < this.texts.length; i++) {
+        let hasDraw = this.texts[i];
+        if (this.intersects(hasDraw)) {
+          this.value++;
+          return;
+        }
+      }
+      this.drawText(item.name, item.value)
+      this.texts.push(new Bounds(this.min, this.max))
+    },
+
+    drawText(word, value) {
+      this.ctx.textAlign = "left";
+      this.ctx.textBaseline = "top";
+      let colorLi = ['8','9', 'a', 'b', 'c', 'd', 'e', 'f'];
+      let color = "#";
+      for (let i = 0,len = 6; i < len; i++) {
+        color += colorLi[Math.floor(Math.random() * len)]
+      }
+      this.ctx.setFillStyle(color);
+      this.ctx.fillText(word, this.min.x, this.min.y);
+    },
+
+    //生成文本坐标
+    createText(item, center, random) {
+      let textRect = this.getTextRect(item)
+      if (center) {
+        this.min = {
+          x: this.width / 2 - textRect.width / 2,
+          y: this.height / 2 - textRect.height / 2
+        }
+      } else {
+        this.min = this.getRandom()
+      }
+      this.max = {
+        x: this.min.x + textRect.width,
+        y: this.min.y + textRect.height
+      }
+      const bound = new Bounds(this.min, this.max);
+      if (this.inAll(bound)) return;
+      else this.createText(item)
+    },
+
+    //获取随机值
+    getRandom() {
+      return {
+        x: Math.floor(Math.random() * this.width),
+        y: Math.floor(Math.random() * this.height)
+      }
+    },
+
+    //获取文字宽高
+    getTextRect(item) {
+      this.ctx.setFontSize(item.fontSize)
+      let textWidth = this.ctx.measureText(item.word).width //文字所占宽度
+      return {
+        width: textWidth + 2,
+        height: item.fontSize
+      }
+    },
+
+    //检测是否有碰撞, 返回true是有碰撞
+    intersects(bound) {
+      var min = this.min,
+        max = this.max,
+        min2 = bound.min,
+        max2 = bound.max,
+        xIntersects = max2.x >= min.x && min2.x <= max.x,
+        yIntersects = max2.y >= min.y && min2.y <= max.y;
+      return xIntersects && yIntersects;
+    },
+
+    inAll(bound) {
+      var min = bound.min,
+        max = bound.max,
+        start = this.canvasBound.min,
+        end = this.canvasBound.max;
+      return min.x >= start.x && min.y >= start.y && max.x <= end.x && max.y <= end.y
+    }
+  }
+})

+ 250 - 0
ec-canvas/ec-canvas.js

@@ -0,0 +1,250 @@
+import WxCanvas from './wx-canvas';
+import * as echarts from './echarts';
+
+let ctx;
+
+function compareVersion(v1, v2) {
+  v1 = v1.split('.')
+  v2 = v2.split('.')
+  const len = Math.max(v1.length, v2.length)
+
+  while (v1.length < len) {
+    v1.push('0')
+  }
+  while (v2.length < len) {
+    v2.push('0')
+  }
+
+  for (let i = 0; i < len; i++) {
+    const num1 = parseInt(v1[i])
+    const num2 = parseInt(v2[i])
+
+    if (num1 > num2) {
+      return 1
+    } else if (num1 < num2) {
+      return -1
+    }
+  }
+  return 0
+}
+
+Component({
+  properties: {
+    canvasId: {
+      type: String,
+      value: 'ec-canvas'
+    },
+
+    ec: {
+      type: Object
+    },
+
+    forceUseOldCanvas: {
+      type: Boolean,
+      value: false
+    }
+  },
+
+  data: {
+    isUseNewCanvas: false
+  },
+
+  ready: function () {
+    // Disable prograssive because drawImage doesn't support DOM as parameter
+    // See https://developers.weixin.qq.com/miniprogram/dev/api/canvas/CanvasContext.drawImage.html
+    echarts.registerPreprocessor(option => {
+      if (option && option.series) {
+        if (option.series.length > 0) {
+          option.series.forEach(series => {
+            series.progressive = 0;
+          });
+        }
+        else if (typeof option.series === 'object') {
+          option.series.progressive = 0;
+        }
+      }
+    });
+
+    if (!this.data.ec) {
+      console.warn('组件需绑定 ec 变量,例:<ec-canvas id="mychart-dom-bar" '
+        + 'canvas-id="mychart-bar" ec="{{ ec }}"></ec-canvas>');
+      return;
+    }
+
+    if (!this.data.ec.lazyLoad) {
+      this.init();
+    }
+  },
+
+  methods: {
+    init: function (callback) {
+      const version = wx.getSystemInfoSync().SDKVersion
+
+      const canUseNewCanvas = compareVersion(version, '2.9.0') >= 0;
+      const forceUseOldCanvas = this.data.forceUseOldCanvas;
+      // const isUseNewCanvas = canUseNewCanvas && !forceUseOldCanvas;
+      // this.setData({ isUseNewCanvas });
+
+      if (forceUseOldCanvas && canUseNewCanvas) {
+        console.warn('开发者强制使用旧canvas,建议关闭');
+      }
+
+      if (this.isUseNewCanvas) {
+        // console.log('微信基础库版本大于2.9.0,开始使用<canvas type="2d"/>');
+        // 2.9.0 可以使用 <canvas type="2d"></canvas>
+        this.initByNewWay(callback);
+      } else {
+        const isValid = compareVersion(version, '1.9.91') >= 0
+        if (!isValid) {
+          console.error('微信基础库版本过低,需大于等于 1.9.91。'
+            + '参见:https://github.com/ecomfe/echarts-for-weixin'
+            + '#%E5%BE%AE%E4%BF%A1%E7%89%88%E6%9C%AC%E8%A6%81%E6%B1%82');
+          return;
+        } else {
+          console.warn('建议将微信基础库调整大于等于2.9.0版本。升级后绘图将有更好性能');
+          this.initByOldWay(callback);
+        }
+      }
+    },
+
+    initByOldWay(callback) {
+      // 1.9.91 <= version < 2.9.0:原来的方式初始化
+      ctx = wx.createCanvasContext(this.data.canvasId, this);
+      const canvas = new WxCanvas(ctx, this.data.canvasId, false);
+
+      echarts.setCanvasCreator(() => {
+        return canvas;
+      });
+      // const canvasDpr = wx.getSystemInfoSync().pixelRatio // 微信旧的canvas不能传入dpr
+      const canvasDpr = 1
+      var query = wx.createSelectorQuery().in(this);
+      query.select('.ec-canvas').boundingClientRect(res => {
+        if (typeof callback === 'function') {
+          this.chart = callback(canvas, res.width, res.height, canvasDpr);
+        }
+        else if (this.data.ec && typeof this.data.ec.onInit === 'function') {
+          this.chart = this.data.ec.onInit(canvas, res.width, res.height, canvasDpr);
+        }
+        else {
+          this.triggerEvent('init', {
+            canvas: canvas,
+            width: res.width,
+            height: res.height,
+            canvasDpr: canvasDpr // 增加了dpr,可方便外面echarts.init
+          });
+        }
+      }).exec();
+    },
+
+    initByNewWay(callback) {
+      // version >= 2.9.0:使用新的方式初始化
+      const query = wx.createSelectorQuery().in(this)
+      query
+        .select('.ec-canvas')
+        .fields({ node: true, size: true })
+        .exec(res => {
+          const canvasNode = res[0].node
+          this.canvasNode = canvasNode
+
+          const canvasDpr = wx.getSystemInfoSync().pixelRatio
+          const canvasWidth = res[0].width
+          const canvasHeight = res[0].height
+
+          const ctx = canvasNode.getContext('2d')
+
+          const canvas = new WxCanvas(ctx, this.data.canvasId, true, canvasNode)
+          echarts.setCanvasCreator(() => {
+            return canvas
+          })
+
+          if (typeof callback === 'function') {
+            this.chart = callback(canvas, canvasWidth, canvasHeight, canvasDpr)
+          } else if (this.data.ec && typeof this.data.ec.onInit === 'function') {
+            this.chart = this.data.ec.onInit(canvas, canvasWidth, canvasHeight, canvasDpr)
+          } else {
+            this.triggerEvent('init', {
+              canvas: canvas,
+              width: canvasWidth,
+              height: canvasHeight,
+              dpr: canvasDpr
+            })
+          }
+        })
+    },
+    canvasToTempFilePath(opt) {
+      if (this.data.isUseNewCanvas) {
+        // 新版
+        const query = wx.createSelectorQuery().in(this)
+        query
+          .select('.ec-canvas')
+          .fields({ node: true, size: true })
+          .exec(res => {
+            const canvasNode = res[0].node
+            opt.canvas = canvasNode
+            wx.canvasToTempFilePath(opt)
+          })
+      } else {
+        // 旧的
+        if (!opt.canvasId) {
+          opt.canvasId = this.data.canvasId;
+        }
+        ctx.draw(true, () => {
+          wx.canvasToTempFilePath(opt, this);
+        });
+      }
+    },
+
+    touchStart(e) {
+      if (this.chart && e.touches.length > 0) {
+        var touch = e.touches[0];
+        var handler = this.chart.getZr().handler;
+        handler.dispatch('mousedown', {
+          zrX: touch.x,
+          zrY: touch.y
+        });
+        handler.dispatch('mousemove', {
+          zrX: touch.x,
+          zrY: touch.y
+        });
+        handler.processGesture(wrapTouch(e), 'start');
+      }
+    },
+
+    touchMove(e) {
+      if (this.chart && e.touches.length > 0) {
+        var touch = e.touches[0];
+        var handler = this.chart.getZr().handler;
+        handler.dispatch('mousemove', {
+          zrX: touch.x,
+          zrY: touch.y
+        });
+        handler.processGesture(wrapTouch(e), 'change');
+      }
+    },
+
+    touchEnd(e) {
+      if (this.chart) {
+        const touch = e.changedTouches ? e.changedTouches[0] : {};
+        var handler = this.chart.getZr().handler;
+        handler.dispatch('mouseup', {
+          zrX: touch.x,
+          zrY: touch.y
+        });
+        handler.dispatch('click', {
+          zrX: touch.x,
+          zrY: touch.y
+        });
+        handler.processGesture(wrapTouch(e), 'end');
+      }
+    }
+  }
+});
+
+function wrapTouch(event) {
+  for (let i = 0; i < event.touches.length; ++i) {
+    const touch = event.touches[i];
+    touch.offsetX = touch.x;
+    touch.offsetY = touch.y;
+  }
+  return event;
+}

+ 4 - 0
ec-canvas/ec-canvas.json

@@ -0,0 +1,4 @@
+{
+  "component": true,
+  "usingComponents": {}
+}

+ 4 - 0
ec-canvas/ec-canvas.wxml

@@ -0,0 +1,4 @@
+<!-- 新的:接口对其了H5 -->
+<canvas wx:if="{{isUseNewCanvas}}" type="2d" class="ec-canvas" canvas-id="{{ canvasId }}" bindinit="init" bindtouchstart="{{ ec.disableTouch ? '' : 'touchStart' }}" bindtouchmove="{{ ec.disableTouch ? '' : 'touchMove' }}" bindtouchend="{{ ec.disableTouch ? '' : 'touchEnd' }}"></canvas>
+<!-- 旧的 -->
+<canvas wx:else class="ec-canvas" canvas-id="{{ canvasId }}" bindinit="init" bindtouchstart="{{ ec.disableTouch ? '' : 'touchStart' }}" bindtouchmove="{{ ec.disableTouch ? '' : 'touchMove' }}" bindtouchend="{{ ec.disableTouch ? '' : 'touchEnd' }}"></canvas>

+ 4 - 0
ec-canvas/ec-canvas.wxss

@@ -0,0 +1,4 @@
+.ec-canvas {
+  width: 100%;
+  height: 100%;
+}

Fichier diff supprimé car celui-ci est trop grand
+ 21 - 0
ec-canvas/echarts.js


+ 121 - 0
ec-canvas/wx-canvas.js

@@ -0,0 +1,121 @@
+export default class WxCanvas {
+  constructor(ctx, canvasId, isNew, canvasNode) {
+    this.ctx = ctx;
+    this.canvasId = canvasId;
+    this.chart = null;
+    this.isNew = isNew
+    if (isNew) {
+      this.canvasNode = canvasNode;
+    }
+    else {
+      this._initStyle(ctx);
+    }
+
+    // this._initCanvas(zrender, ctx);
+
+    this._initEvent();
+  }
+
+  getContext(contextType) {
+    if (contextType === '2d') {
+      return this.ctx;
+    }
+  }
+
+  // canvasToTempFilePath(opt) {
+  //   if (!opt.canvasId) {
+  //     opt.canvasId = this.canvasId;
+  //   }
+  //   return wx.canvasToTempFilePath(opt, this);
+  // }
+
+  setChart(chart) {
+    this.chart = chart;
+  }
+
+  attachEvent() {
+    // noop
+  }
+
+  detachEvent() {
+    // noop
+  }
+
+  _initCanvas(zrender, ctx) {
+    zrender.util.getContext = function () {
+      return ctx;
+    };
+
+    zrender.util.$override('measureText', function (text, font) {
+      ctx.font = font || '12px sans-serif';
+      return ctx.measureText(text);
+    });
+  }
+
+  _initStyle(ctx) {
+    var styles = ['fillStyle', 'strokeStyle', 'globalAlpha',
+      'textAlign', 'textBaseAlign', 'shadow', 'lineWidth',
+      'lineCap', 'lineJoin', 'lineDash', 'miterLimit', 'fontSize'];
+
+    styles.forEach(style => {
+      Object.defineProperty(ctx, style, {
+        set: value => {
+          if (style !== 'fillStyle' && style !== 'strokeStyle'
+            || value !== 'none' && value !== null
+          ) {
+            ctx['set' + style.charAt(0).toUpperCase() + style.slice(1)](value);
+          }
+        }
+      });
+    });
+
+    ctx.createRadialGradient = () => {
+      return ctx.createCircularGradient(arguments);
+    };
+  }
+
+  _initEvent() {
+    this.event = {};
+    const eventNames = [{
+      wxName: 'touchStart',
+      ecName: 'mousedown'
+    }, {
+      wxName: 'touchMove',
+      ecName: 'mousemove'
+    }, {
+      wxName: 'touchEnd',
+      ecName: 'mouseup'
+    }, {
+      wxName: 'touchEnd',
+      ecName: 'click'
+    }];
+
+    eventNames.forEach(name => {
+      this.event[name.wxName] = e => {
+        const touch = e.touches[0];
+        this.chart.getZr().handler.dispatch(name.ecName, {
+          zrX: name.wxName === 'tap' ? touch.clientX : touch.x,
+          zrY: name.wxName === 'tap' ? touch.clientY : touch.y
+        });
+      };
+    });
+  }
+
+  set width(w) {
+    if (this.canvasNode) this.canvasNode.width = w
+  }
+  set height(h) {
+    if (this.canvasNode) this.canvasNode.height = h
+  }
+
+  get width() {
+    if (this.canvasNode)
+      return this.canvasNode.width
+    return 0
+  }
+  get height() {
+    if (this.canvasNode)
+      return this.canvasNode.height
+    return 0
+  }
+}

+ 51 - 0
pages/home/components/contrast/contrast.js

@@ -0,0 +1,51 @@
+// pages/home/components/contrast/contrast.js
+const app = getApp()
+Component({
+  /**
+   * 组件的属性列表
+   */
+  properties: {
+    tablelist:{
+      type: Array,
+      value: [],
+    }
+  },
+
+  /**
+   * 组件的初始数据
+   */
+  data: {
+    error: "",
+    listAll: [
+      {
+        name: "总浏览量",
+        type: "total_pv",
+      },
+      {
+        name: "原创量",
+        type: "total_ori",
+      },
+      {
+        name: "总点赞数",
+        type: "total_digg",
+      },
+      {
+        name: "总评论数",
+        type: "total_comment",
+      },
+      {
+        name: "总转发量",
+        type: "total_forward",
+      },
+    ],
+  },
+
+  ready() {
+  },
+
+  /**
+   * 组件的方法列表
+   */
+  methods: {
+  }
+})

+ 10 - 0
pages/home/components/contrast/contrast.json

@@ -0,0 +1,10 @@
+{
+  "component": true,
+  "usingComponents": {
+    "chart" : "/components/Chart/Chart",
+    "table": "/components/table/table",
+    "mp-toptips": "weui-miniprogram/toptips/toptips",
+    "mp-cells": "weui-miniprogram/cells/cells",
+    "mp-cell": "weui-miniprogram/cell/cell"
+  }
+}

+ 11 - 0
pages/home/components/contrast/contrast.wxml

@@ -0,0 +1,11 @@
+<!--pages/home/components/contrast/contrast.wxml-->
+<view class="contrast basePage">
+  <table list="{{tablelist}}" listAll="{{listAll}}" />
+  <view class="itemView" wx:for="{{listAll}}" wx:key="name">
+    <view class="localCells">{{item.name}}</view>
+    <chart list="{{tablelist.length ? [tablelist] : []}}" id="{{'id' + index}}" canvasId="{{'canvasId' + index}}" yType="{{item.type}}"
+      xType="topic_name" />
+  </view>
+  <!-- 错误提示 -->
+  <mp-toptips msg="{{error}}" ext-class="toptips" type="error" show="{{error}}"></mp-toptips>
+</view>

+ 9 - 0
pages/home/components/contrast/contrast.wxss

@@ -0,0 +1,9 @@
+/* pages/home/components/contrast/contrast.wxss */
+.contrast .itemView{
+  padding: 5px 15px
+}
+.contrast .localCells {
+  height: 40px;
+  line-height: 40px;
+  color: #fff;
+}

+ 349 - 0
pages/home/components/topic/topic.js

@@ -0,0 +1,349 @@
+// pages/home/components/contrast/contrast.js
+const app = getApp();
+let toUrl = true;
+Component({
+  /**
+   * 组件的属性列表
+   */
+  isUp: undefined,
+  properties: {
+    imgURL: {
+      type: String,
+      value: ""
+    },
+    sonList: {
+      type: Array,
+      value: []
+    },
+    isShow: {
+      type: Boolean,
+      value: false,
+    },
+    isUpdata: {
+      type: Boolean,
+      value: false,
+      observer: function (newUp) {
+        if (!newUp) return;
+        let n = this.data.title;
+        this.isUp && clearInterval(this.isUp);
+        this.isUp = setInterval(() => {
+          this.getData({ topic_name: n });
+          this.getPing({ topic_name: n });
+          this.getAccount({ topic_name: n, platform: "ALL", type: "all" });
+        }, 3000);
+      }
+    },
+    title: {
+      type: String,
+      value: "",
+      observer: function (newShow) {
+        !this.data.isUpdata && this.isUp && clearInterval(this.isUp);
+        let n = newShow;
+        this.setData({
+          selectread: "30d",
+          selectme: "30d",
+          selectori: "30d",
+        })
+        this.getData({ topic_name: n });
+        this.getPing({ topic_name: n });
+        this.getAccount({ topic_name: n, platform: "ALL", type: "all" });
+        this.getAccount({ topic_name: n, platform: "douyin", type: "douyin" });
+        this.getAccount({ topic_name: n, platform: "kuaishou", type: "kuaishou" });
+        this.getAccount({ topic_name: n, platform: "yangshi", type: "yangshi" });
+        // this.getWorld();
+        this.getWeibo({ topic_name: n, time: "30d" })
+      }
+    },
+    type: {
+      type: String,
+      value: ""
+    },
+    jsonURL: {
+      type: String,
+      value: ""
+    },
+  },
+  // created(){
+  //   console.log("实例刚刚被创建时执行")
+  // },
+  // attached(){
+  //   console.log("实例进入页面节点树时执行")
+  // },
+  // ready() {
+  // console.log("组件布局完成后执行", this.data.title)
+  // },
+  // moved(){
+  //   console.log("组件实例被移动到节点树另一个位置时执行")
+  // },
+  // detached(){
+  //   console.log("组件实例被从页面节点树移除时执行")
+  // },
+
+  /**
+   * 组件的初始数据
+   */
+  data: {
+    error: "",
+    headData: {},
+    contrast: [],
+    all: [],
+    douyin: [],
+    kuaishou: [],
+    yangshi: [],
+    wordList: [],
+    weiboori: [],
+    weiboread: [],
+    weibome: [],
+    selectread: "30d",
+    selectme: "30d",
+    selectori: "30d",
+    weiboBtnListread: [],
+    weiboBtnListme: [],
+    weiboBtnListori: [],
+    height: 0
+  },
+
+  detached: function () {
+    this.isUp && clearInterval(this.isUp);
+  },
+
+  /**
+   * 组件的方法列表
+   */
+  methods: {
+    lineChengeread: function (val) {
+      this.setData({
+        selectread: val.detail
+      })
+      this.getWeibo({ topic_name: this.data.title, time: val.detail }, "read")
+    },
+    lineChengeme: function (val) {
+      this.setData({
+        selectme: val.detail
+      })
+      this.getWeibo({ topic_name: this.data.title, time: val.detail }, "me")
+    },
+    lineChengeori: function (val) {
+      this.setData({
+        selectori: val.detail
+      })
+      this.getWeibo({ topic_name: this.data.title, time: val.detail }, "ori")
+    },
+    getData: function (data) {
+      const _this = this;
+      /**
+       * @description
+       * data
+       * topic_name: 聚劲延安
+       */
+      wx.request({
+        url: app.baseUrl + '/overview',
+        success: function (res) {
+          if (res.statusCode === 200) {
+            let oldHead = JSON.stringify(_this.data.headData);
+            let newHead = JSON.stringify(res.data || {});
+            if (oldHead != newHead)
+              _this.setData({
+                headData: res.data || {}
+              })
+          } else _this.setData({
+            error: '请重启后查看'
+          })
+        },
+        data,
+        fail: function (err) {
+          _this.setData({
+            error: '数据错误'
+          })
+        },
+        complete: function (res) { }
+      })
+    },
+    getPing: function (data) {
+      const _this = this;
+      /**
+       * @description
+       * data
+       * topic_name: 聚劲延安
+       */
+      wx.request({
+        url: app.baseUrl + '/platform',
+        success: function (res) {
+          if (res.statusCode === 200) {
+            let contrast = res.data && res.data.length ? [res.data] : [];
+            let oldContrast = JSON.stringify(_this.data.contrast);
+            let newContrast = JSON.stringify(contrast);
+            if (oldContrast != newContrast)
+              _this.setData({
+                contrast
+              })
+          } else _this.setData({
+            error: '请重启后查看'
+          })
+        },
+        data,
+        fail: function (err) {
+          _this.setData({
+            error: '数据错误'
+          })
+        },
+        complete: function (res) { }
+      })
+    },
+    getAccount: function (data) {
+      const _this = this;
+      /**
+       * @description
+       * data
+       * topic_name: 聚劲延安
+       */
+      wx.request({
+        url: app.baseUrl + '/name',
+        success: function (res) {
+          if (res.statusCode === 200) {
+            let list = res.data && res.data.length ? [res.data] : [];
+            const setD = {};
+            let isIntUser = {};
+            let user = {
+              'pv': { name: '浏览', type: 'pv' },
+              'digg_count': { name: '点赞', type: 'digg_count' },
+              'comment_count': { name: '评论', type: 'comment_count' },
+              'forward_count': { name: '转发', type: 'forward_count' }
+            };
+            let userSort = [];
+            (res.data || []).map(v => {
+              !isIntUser.pv && v.pv && userSort.push(user.pv) && (isIntUser.pv = true);
+              !isIntUser.digg_count && v.digg_count && userSort.push(user.digg_count) && (isIntUser.digg_count = true);
+              !isIntUser.comment_count && v.comment_count && userSort.push(user.comment_count) && (isIntUser.comment_count = true);
+              !isIntUser.forward_count && v.forward_count && userSort.push(user.forward_count) && (isIntUser.forward_count = true);
+            })
+            if (userSort.length) {
+              setD[data.type] = list;
+              setD.userSort = userSort;
+            } else {
+              setD[data.type] = [];
+              setD.userSort = [];
+            }
+            let oldType = JSON.stringify(_this.data[data.type]);
+            let newType = JSON.stringify(list);
+            if (oldType != newType)
+              _this.setData(setD)
+          } else _this.setData({
+            error: '请重启后查看'
+          })
+        },
+        data,
+        fail: function (err) {
+          _this.setData({
+            error: '数据错误'
+          })
+        },
+        complete: function (res) { }
+      })
+    },
+    getWorld: function (data) {
+      const _this = this;
+      /**
+       * @description
+       * data
+       * topic_name: 聚劲延安
+       */
+      wx.request({
+        url: this.data.jsonURL,
+        success: function (res) {
+          if (res.statusCode === 200) {
+            _this.setData({
+              wordList: res.data || []
+            })
+          } else _this.setData({
+            error: '请重启后查看'
+          })
+        },
+        data,
+        fail: function (err) {
+          _this.setData({
+            error: '数据错误'
+          })
+        },
+        complete: function (res) { }
+      })
+    },
+    getWeibo: function (data, type) {
+      const _this = this;
+      /**
+       * @description
+       * data
+       * topic_name: 聚劲延安
+       */
+      wx.request({
+        url: app.baseUrl + '/time/v2',
+        success: function (res) {
+          if (res.statusCode === 200) {
+            let server = res && res.data ? res.data : {};
+            let p = {};
+            let weiboBtn = {
+              '6m': { name: '1小时', type: '6m' },
+              '24h': { name: '24小时', type: '24h' },
+              '7d': { name: '7天', type: '7d' },
+              '30d': { name: '30天', type: '30d' },
+            }
+            if (type) {
+              p["weibo" + type] = server[_this.data['select' + type]][type] || [];
+              p["weiboBtnList" + type] = [];
+            } else {
+              p["weiboBtnListread"] = [];
+              p["weiboBtnListme"] = [];
+              p["weiboBtnListori"] = [];
+              let pOri = server[_this.data['selectori']] || {};
+              p.weiboori = pOri.ori || [];
+              p.weiboread = pOri.read || [];
+              p.weibome = pOri.me || [];
+            }
+            for (const key in weiboBtn) {
+              if (weiboBtn.hasOwnProperty(key)) {
+                const element = weiboBtn[key];
+                if (type) {
+                  server[key] && server[key][type] && p["weiboBtnList" + type].push(element);
+                } else {
+                  server[key] && server[key].read && p.weiboBtnListread.push(element);
+                  server[key] && server[key].me && p.weiboBtnListme.push(element);
+                  server[key] && server[key].ori && p.weiboBtnListori.push(element);
+                }
+              }
+            }
+            _this.setData(p)
+          } else _this.setData({
+            error: '请重启后查看'
+          })
+        },
+        data,
+        fail: function (err) {
+          _this.setData({
+            error: '数据错误'
+          })
+        },
+        complete: function (res) { }
+      })
+    },
+    imgLoad: function (e) {
+      var img_ratio = e.detail.height / e.detail.width;
+      var rWidth = wx.getSystemInfoSync().windowWidth;
+      rWidth > 441 && (rWidth = 441)
+      this.setData({
+        height: (rWidth * img_ratio).toFixed(0) - 0
+      })
+    },
+    toSecond: function () {
+      if (!toUrl) return;
+      toUrl = false;
+      let asciiList = encodeURIComponent(JSON.stringify(this.data.sonList));
+      let title = encodeURIComponent(this.data.title);
+      wx.navigateTo({
+        url: "/pages/sonTopic/sonTopic?sonList=" + asciiList + "&title=" + title + "&type=" + this.data.type,
+        complete: function (res) {
+          toUrl = true;
+        }
+      })
+    }
+  }
+})

+ 10 - 0
pages/home/components/topic/topic.json

@@ -0,0 +1,10 @@
+{
+  "component": true,
+  "usingComponents": {
+    "chart" : "/components/Chart/Chart",
+    "table" : "/components/table/table",
+    "mp-toptips": "weui-miniprogram/toptips/toptips",
+    "wordCloud": "/components/wordCloud/wordCloud",
+    "lineChart": "/components/lineChart/lineChart"
+  }
+}

+ 103 - 0
pages/home/components/topic/topic.wxml

@@ -0,0 +1,103 @@
+<!--pages/home/components/contrast/contrast.wxml-->
+<wxs module="filter" src="/components/table/filter.wxs" />
+
+<view class="topic">
+  <view class="topicTable">
+    <view class="topicItem">总浏览量:</view>
+    <view class="topicItem">{{filter.valueFormat(headData.total_pv)}}</view>
+    <view class="topicItem">原创量:</view>
+    <view class="topicItem">{{filter.valueFormat(headData.total_ori)}}</view>
+  </view>
+  <view class="topicTable">
+    <view class="topicItem">总点赞数:</view>
+    <view class="topicItem">{{filter.valueFormat(headData.total_digg)}}</view>
+    <view class="topicItem">总评论数:</view>
+    <view class="topicItem">{{filter.valueFormat(headData.total_comment)}}</view>
+  </view>
+  <view class="topicTable">
+    <view class="topicItem">总转发量:</view>
+    <view class="topicItem">{{filter.valueFormat(headData.total_forward)}}</view>
+    <view class="topicItem"></view>
+    <view class="topicItem"></view>
+  </view>
+  <view class="pKvm">
+    <view class="kvm" bindtap="toSecond" wx:if="{{sonList && sonList.length}}">
+      <view class="kvmText">二次传播</view>
+    </view>
+  </view>
+  <view class="itemView" wx:if="{{contrast.length}}">
+    <view class="localCells">平台对比</view>
+    <chart list="{{contrast}}" id="{{'id' + 1}}" canvasId="{{'canvasId' + 1}}" wx:if="{{contrast && contrast.length}}"
+      yType="total_pv" xType="platform" />
+  </view>
+  <view class="itemView" wx:if="{{all.length}}">
+    <view class="localCells">账号排名</view>
+    <chart id="{{'id' + 2}}" canvasId="{{'canvasId' + 2}}"
+      btnList="{{[{name:'点赞', type:'digg_count'},{name:'评论', type:'comment_count'},{name:'转发', type:'forward_count'}]}}"
+      list="{{all}}" yType="digg_count" xType="nickname" />
+  </view>
+  <view class="itemView" style="padding: 0" wx:if="{{!!imgURL}}">
+    <view class="localCells" style="padding: 5px 10px;">词云</view>
+    <image bindload="imgLoad"
+      style="{{'display: block;width: 100%;max-width: 441px;margin:0 auto;height:'+ height + 'px'}}" src="{{imgURL}}" />
+    <!-- <wordCloud wordsCloud="{{wordList}}" yType="value" xType="name" /> -->
+  </view>
+  <view class="itemView" wx:if="{{douyin.length}}">
+    <view class="localCells">抖音-评论排行</view>
+    <chart id="{{'id' + 3}}" canvasId="{{'canvasId' + 3}}" list="{{douyin}}" wx:if="{{douyin && douyin.length}}"
+      yType="comment_count" xType="nickname" />
+  </view>
+  <view class="itemView" wx:if="{{douyin.length}}">
+    <view class="localCells">抖音-点赞排行</view>
+    <chart id="{{'id' + 4}}" canvasId="{{'canvasId' + 4}}" list="{{douyin}}" wx:if="{{douyin && douyin.length}}"
+      yType="digg_count" xType="nickname" />
+  </view>
+  <view class="itemView" wx:if="{{douyin.length && title !== '西安'}}">
+    <view class="localCells">抖音-粉丝量排行</view>
+    <chart id="{{'id' + 5}}" canvasId="{{'canvasId' + 5}}" list="{{douyin}}" wx:if="{{douyin && douyin.length}}"
+      yType="mplatform_followers_count" xType="nickname" />
+  </view>
+
+
+  <view class="itemView" wx:if="{{kuaishou.length}}">
+    <view class="localCells">快手-播放量排行</view>
+    <chart id="{{'id' + 6}}" canvasId="{{'canvasId' + 6}}" list="{{kuaishou}}" wx:if="{{kuaishou && kuaishou.length}}"
+      yType="pv" xType="nickname" />
+  </view>
+  <view class="itemView" wx:if="{{kuaishou.length}}">
+    <view class="localCells">快手-评论排行</view>
+    <chart id="{{'id' + 7}}" canvasId="{{'canvasId' + 7}}" list="{{kuaishou}}" wx:if="{{kuaishou && kuaishou.length}}"
+      yType="comment_count" xType="nickname" />
+  </view>
+
+
+  <view class="itemView" wx:if="{{weiboBtnListread.length}}">
+    <view class="localCells">微博-阅读量趋势</view>
+    <lineChart id="{{'id' + 11}}" canvasId="{{'canvasId' + 11}}" type="line" select="{{selectread}}"
+      bindlineChenge="lineChengeread"
+      btnList="{{weiboBtnListread}}"
+      isShow="{{isShow}}" wx:if="{{weiboBtnListread && weiboBtnListread.length}}" list="{{weiboread}}" yType="value" xType="time" />
+  </view>
+  <view class="itemView" wx:if="{{weiboBtnListme.length}}">
+    <view class="localCells">微博-讨论趋势</view>
+    <lineChart id="{{'id' + 10}}" canvasId="{{'canvasId' + 10}}" type="line" select="{{selectme}}"
+      bindlineChenge="lineChengeme"
+      btnList="{{weiboBtnListme}}"
+      wx:if="{{weiboBtnListme && weiboBtnListme.length}}" isShow="{{isShow}}" list="{{weibome}}" yType="value" xType="time" />
+  </view>
+  <view class="itemView" wx:if="{{weiboBtnListori.length}}">
+    <view class="localCells">微博-原创趋势</view>
+    <lineChart id="{{'id' + 9}}" canvasId="{{'canvasId' + 9}}" type="line" select="{{selectori}}"
+      bindlineChenge="lineChengeori"
+      btnList="{{weiboBtnListori}}"
+      isShow="{{isShow}}" wx:if="{{weiboBtnListori && weiboBtnListori.length}}" list="{{weiboori}}" yType="value" xType="time" />
+  </view>
+  <view class="itemView" wx:if="{{yangshi.length}}">
+    <view class="localCells">央视-浏览排行</view>
+    <chart id="{{'id' + 8}}" canvasId="{{'canvasId' + 8}}" wx:if="{{yangshi && yangshi.length}}" list="{{yangshi}}"
+      yType="pv" xType="nickname" />
+  </view>
+
+  <!-- 错误提示 -->
+  <mp-toptips msg="{{error}}" ext-class="toptips" type="error" show="{{error}}"></mp-toptips>
+</view>

+ 40 - 0
pages/home/components/topic/topic.wxss

@@ -0,0 +1,40 @@
+/* pages/home/components/topic/topic.wxss */
+.topic .topicTable {
+  display: flex;
+}
+
+.topic .topicTable .topicItem {
+  flex: 1;
+  padding: 5px 10px;
+}
+
+.topic .itemView{
+  padding: 5px 10px
+}
+.topic .localCells {
+  height: 40px;
+  line-height: 40px;
+}
+.topic .pKvm{
+  text-align: right;
+  margin-right: 10px;
+  margin-top: -20px;
+}
+.topic .kvm{
+  display: inline-block;
+  width: 3.5em;
+  color: #fff;
+  background-color: #1989fa;
+  height: 3.5em;
+  border-radius: 50%;
+  text-align: center;
+  box-shadow: 0 0 7px #1989fa;
+}
+.topic .kvmText{
+  padding-top: 0.7em;
+  width: 2em;
+  margin: 0 auto;
+  line-height: 1.1em;
+  color: #bfcbd9;
+  font-weight: 400;
+}

+ 155 - 0
pages/home/home.js

@@ -0,0 +1,155 @@
+// pages/home/home.js
+const app = getApp()
+Page({
+
+  /**
+   * 页面的初始数据
+   */
+  data: {
+    activityList: ["第一季", "第二季"],
+    select: "1",
+    pageName: "话题",
+    tableHead: [],
+    tabList: [],
+    tablelist: [],
+    type: 0,
+    title: "",
+    jsonURL: "",
+    imgURL: "",
+    indexNum: 0,
+    isShow: false,
+    isUpdata: false
+  },
+
+  /**
+   * 生命周期函数--监听页面加载
+   */
+  onLoad: function (options) {
+  },
+
+  /**
+   * 生命周期函数--监听页面初次渲染完成
+   */
+  onReady: function () {
+    this.getData();
+    wx.setStorageSync('nextTime', 0)
+  },
+
+  /**
+   * 生命周期函数--监听页面显示
+   */
+  onShow: function () {
+    this.setData({
+      isShow: true
+    })
+  },
+
+  /**
+   * 生命周期函数--监听页面隐藏
+   */
+  onHide: function () {
+    this.setData({
+      isShow: false
+    })
+  },
+
+  /**
+   * 生命周期函数--监听页面卸载
+   */
+  // onUnload: function () {
+  //   // 返回时触发
+
+  // },
+
+  /**
+   * 页面相关事件处理函数--监听用户下拉动作
+   */
+  onPullDownRefresh: function () {
+
+  },
+
+  /**
+   * 页面上拉触底事件的处理函数
+   */
+  onReachBottom: function () {
+
+  },
+
+  /**
+   * 用户点击右上角分享
+   */
+  onShareAppMessage: function () { },
+
+  getData: function (data) {
+    const _this = this;
+    wx.request({
+      url: app.baseUrl + '/overview',
+      success: function (res) {
+        if (res.statusCode === 200) {
+          const tablelist = (res.data || [])
+          const tab = tablelist.map((v, i) => {
+            v.child_list = (v.child_list || []).map((val, o) => {
+              return {
+                name: val,
+                type: o,
+                // worldURL: app.baseUrl + '/data/' + jsonName + ".json",
+                // worldImgURL: app.baseUrl + '/data/' + img + ".png"
+                worldImgURL: v.word_cloud_url
+              }
+            })
+            return {
+              childList: v.child_list,
+              name: v.topic_name,
+              type: v.topic_id,
+              isUpdate: v.is_update,
+              // worldURL: app.baseUrl + '/data/' + jsonName + ".json",
+              // worldImgURL: v.word_cloud_url ? v.word_cloud_url : img ? app.baseUrl + '/data/' + img + ".png" : ""
+              worldImgURL: v.word_cloud_url
+            }
+          })
+          if (_this.data.select === "0")
+            tab.unshift({
+              name: "话题对比",
+              type: -1
+            })
+          const setD = {
+            tabList: tab,
+            tablelist
+          }
+          !_this.data.type && (setD.type = tab[0].type);
+          !_this.data.title && (setD.title = tab[0].name);
+          _this.setData(setD)
+        } else _this.setData({
+          error: '请重启后查看'
+        })
+      },
+      data,
+      fail: function (err) {
+        this.setData({
+          error: '数据错误'
+        })
+      },
+      complete: function (res) {
+      }
+    })
+  },
+  changeBar: function (type) {
+    if (type.detail.title === this.data.title) return;
+    this.setData({
+      type: type.detail.type,
+      title: type.detail.title,
+      jsonURL: type.detail.worldURL || "",
+      imgURL: type.detail.worldImgURL || "",
+      indexNum: type.detail.index || 0,
+      isUpdata: type.detail.isUpdata
+    })
+  },
+  bindPickerChange(r) {
+    console.log(r.detail.value)
+    this.setData({
+      select: r.detail.value
+    }, () => {
+      this.getData()
+    })
+  }
+})

+ 7 - 0
pages/home/home.json

@@ -0,0 +1,7 @@
+{
+  "usingComponents": {
+    "tab" : "/components/tab/tab",
+    "home": "/pages/home/components/contrast/contrast",
+    "topic": "/pages/home/components/topic/topic"
+  }
+}

+ 16 - 0
pages/home/home.wxml

@@ -0,0 +1,16 @@
+<!--pages/home/home.wxml-->
+<view class="basePage home">
+  <view>
+    <picker bindchange="bindPickerChange" value="{{select}}" range="{{activityList}}">
+      <view class="picker">
+        选择话题:我爱我的家乡-{{activityList[select]}}
+      </view>
+    </picker>
+    <view class="tabScrollBtn">
+      <tab tabList="{{tabList}}" type="{{type}}" bindchangeBar="changeBar"></tab>
+    </view>
+  </view>
+  <home wx:if="{{ type === -1 }}" tablelist="{{tablelist}}" />
+  <topic wx:if="{{ type !== -1 }}" isUpdata="{{isUpdata}}" isShow="{{isShow}}" type="{{type}}" title="{{title}}"
+    jsonURL="{{jsonURL}}" imgURL="{{imgURL}}" sonList="{{tabList[indexNum].childList || []}}" />
+</view>

+ 23 - 0
pages/home/home.wxss

@@ -0,0 +1,23 @@
+/* pages/home/home.wxss */
+.home .baseITem {
+  position: relative;
+  border-radius: 3px;
+  margin: 1em 1em 0 1em;
+  min-height: 50px;
+  overflow: hidden;
+}
+
+
+.home .mainBody {
+  max-height: calc(100% - 95px);
+}
+
+.home .toptips {
+  top: 100px;
+}
+
+.picker{
+  padding-left: 10rpx;
+  font-weight: 500;
+  font-size: 16px;
+}

+ 337 - 0
pages/sonTopic/sonTopic.js

@@ -0,0 +1,337 @@
+// pages/sonTopic/sonTopic.js
+const app = getApp();
+Page({
+
+  /**
+   * 页面的初始数据
+   */
+  data: {
+    userSort: [],
+    sonTitle: "",
+    imgURL: "",
+    pTitle: "",
+    pId: "",
+    type: "",
+    tabList: [],
+    error: "",
+    headData: {},
+    contrast: [],
+    all: [],
+    douyin: [],
+    kuaishou: [],
+    yangshi: [],
+    wordList: [],
+    weiboori: [],
+    weiboread: [],
+    weibome: [],
+    selectread: "30d",
+    selectme: "30d",
+    selectori: "30d",
+    weiboBtnListread: [],
+    weiboBtnListme: [],
+    weiboBtnListori: [],
+    height: 0,
+    isShow: false,
+    loading: true,
+  },
+
+
+  /**
+   * 生命周期函数--监听页面加载
+   */
+  onLoad: function (options) {
+    let sonlist = options.sonList ? JSON.parse(decodeURIComponent(options.sonList)) : [];
+    let title = options.title ? decodeURIComponent(options.title) : "";
+    let second_name = sonlist[0] ? sonlist[0].name : "";
+    let imgURL = sonlist[0] ? sonlist[0].worldImgURL : "";
+    let type = sonlist[0] ? sonlist[0].type : "";
+    this.setData({
+      pTitle: title,
+      pId: options.type,
+      tabList: sonlist,
+      imgURL,
+      type,
+      sonTitle: second_name
+    })
+    this.getData({ topic_name: second_name || title });
+    this.getPing({ topic_name: second_name || title });
+    this.getAccount({ topic_name: second_name || title, platform: "ALL", type: "all" });
+    this.getAccount({ topic_name: second_name || title, platform: "douyin", type: "douyin" });
+    this.getAccount({ topic_name: second_name || title, platform: "kuaishou", type: "kuaishou" });
+    this.getAccount({ topic_name: second_name || title, platform: "yangshi", type: "yangshi" });
+    // this.getWorld();
+    this.getWeibo({ topic_name: second_name || title, time: "30d", type: "yangshi" });
+  },
+
+  /**
+   * 生命周期函数--监听页面初次渲染完成
+   */
+  onReady: function () { },
+
+  /**
+   * 生命周期函数--监听页面显示
+   */
+  onShow: function () {
+    this.setData({
+      isShow: true
+    })
+  },
+
+  /**
+   * 生命周期函数--监听页面隐藏
+   */
+  onHide: function () {
+    this.setData({
+      isShow: false
+    })
+  },
+
+  /**
+   * 生命周期函数--监听页面卸载
+   */
+  onUnload: function () {
+
+  },
+
+  /**
+   * 页面相关事件处理函数--监听用户下拉动作
+   */
+  onPullDownRefresh: function () {
+
+  },
+
+  /**
+   * 页面上拉触底事件的处理函数
+   */
+  onReachBottom: function () {
+
+  },
+
+  /**
+   * 用户点击右上角分享
+   */
+  onShareAppMessage: function () {
+
+  },
+
+  lineChengeread: function (val) {
+    this.setData({
+      selectread: val.detail
+    })
+    this.getWeibo({ topic_name: this.data.sonTitle, time: val.detail, type: "weiboread" }, "read")
+  },
+  lineChengeme: function (val) {
+    this.setData({
+      selectme: val.detail
+    })
+    this.getWeibo({ topic_name: this.data.sonTitle, time: val.detail, type: "weibome" }, "me")
+  },
+  lineChengeori: function (val) {
+    this.setData({
+      selectori: val.detail
+    })
+    this.getWeibo({ topic_name: this.data.sonTitle, time: val.detail, type: "weiboori" }, "ori")
+  },
+
+  getData: function (data) {
+    const _this = this;
+    wx.request({
+      url: app.baseUrl + '/overview',
+      success: function (res) {
+        if (res.statusCode === 200) {
+          _this.setData({
+            headData: res.data || {}
+          })
+        } else _this.setData({
+          error: '请重启后查看'
+        })
+      },
+      data,
+      fail: function (err) {
+        _this.setData({
+          error: '数据错误'
+        })
+      },
+      complete: function (res) { }
+    })
+  },
+  getPing: function (data) {
+    const _this = this;
+    /**
+     * @description
+     * data
+     * topic_name: 聚劲延安
+     */
+    wx.request({
+      url: app.baseUrl + '/platform',
+      success: function (res) {
+        if (res.statusCode === 200) {
+          let contrast = res.data && res.data.length ? [res.data] : [];
+          _this.setData({
+            contrast
+          })
+        } else _this.setData({
+          error: '请重启后查看'
+        })
+      },
+      data,
+      fail: function (err) {
+        _this.setData({
+          error: '数据错误'
+        })
+      },
+      complete: function (res) { }
+    })
+  },
+  getAccount: function (data) {
+    const _this = this;
+    /**
+     * @description
+     * data
+     * topic_name: 聚劲延安
+     */
+    wx.request({
+      url: app.baseUrl + '/name',
+      success: function (res) {
+        if (res.statusCode === 200) {
+          let list = res.data && res.data.length ? [res.data] : [];
+          const setD = {};
+          let isIntUser = {};
+          let user = {
+            'digg_count': { name: '点赞', type: 'digg_count' },
+            'pv': { name: '浏览', type: 'pv' },
+            'comment_count': { name: '评论', type: 'comment_count' },
+            'forward_count': { name: '转发', type: 'forward_count' }
+          };
+          let userSort = [];
+          (res.data || []).map(v => {
+            !isIntUser.pv && v.pv && userSort.push(user.pv) && (isIntUser.pv = true);
+            !isIntUser.digg_count && v.digg_count && userSort.push(user.digg_count) && (isIntUser.digg_count = true);
+            !isIntUser.comment_count && v.comment_count && userSort.push(user.comment_count) && (isIntUser.comment_count = true);
+            !isIntUser.forward_count && v.forward_count && userSort.push(user.forward_count) && (isIntUser.forward_count = true);
+          })
+          if (userSort.length)
+            setD.userSort = userSort;
+          setD[data.type] = list;
+          _this.setData(setD)
+        } else _this.setData({
+          error: '请重启后查看'
+        })
+      },
+      data,
+      fail: function (err) {
+        _this.setData({
+          error: '数据错误'
+        })
+      },
+      complete: function (res) { }
+    })
+  },
+  getWorld: function (data) {
+    const _this = this;
+    wx.request({
+      url: this.data.jsonURL,
+      success: function (res) {
+        if (res.statusCode === 200) {
+          _this.setData({
+            wordList: res.data || []
+          })
+        } else _this.setData({
+          error: '请重启后查看'
+        })
+      },
+      data,
+      fail: function (err) {
+        _this.setData({
+          error: '数据错误'
+        })
+      },
+      complete: function (res) { }
+    })
+  },
+  getWeibo: function (data, type) {
+    const _this = this;
+    /**
+     * @description
+     * data
+     * topic_name: 聚劲延安
+     */
+    wx.request({
+      url: app.baseUrl + '/time/v2',
+      success: function (res) {
+        if (res.statusCode === 200) {
+          let server = res ? res.data : {};
+          let p = {};
+          let weiboBtn = {
+            '6m': { name: '1小时', type: '6m' },
+            '24h': { name: '24小时', type: '24h' },
+            '7d': { name: '7天', type: '7d' },
+            '30d': { name: '30天', type: '30d' },
+          }
+          if (type) {
+            console.log(server, _this.data['select' + type], type)
+            p["weibo" + type] = server[_this.data['select' + type]][type] || [];
+            p["weiboBtnList" + type] = [];
+          } else {
+            p["weiboBtnListread"] = [];
+            p["weiboBtnListme"] = [];
+            p["weiboBtnListori"] = [];
+            p.weiboori = server[_this.data['selectori']].ori || [];
+            p.weiboread = server[_this.data['selectori']].read || [];
+            p.weibome = server[_this.data['selectori']].me || [];
+          }
+          for (const key in weiboBtn) {
+            if (weiboBtn.hasOwnProperty(key)) {
+              const element = weiboBtn[key];
+              if (type) {
+                server[key] && server[key][type] && p["weiboBtnList" + type].push(element);
+              } else {
+                server[key] && server[key].read && p.weiboBtnListread.push(element);
+                server[key] && server[key].me && p.weiboBtnListme.push(element);
+                server[key] && server[key].ori && p.weiboBtnListori.push(element);
+              }
+            }
+          }
+          _this.setData(p)
+        } else _this.setData({
+          error: '请重启后查看'
+        })
+      },
+      data,
+      fail: function (err) {
+        _this.setData({
+          error: '数据错误'
+        })
+      },
+      complete: function (res) { }
+    })
+  },
+  imgLoad: function (e) {
+    var img_ratio = e.detail.height / e.detail.width;
+    var rWidth = wx.getSystemInfoSync().windowWidth;
+    rWidth > 441 && (rWidth = 441)
+    this.setData({
+      height: (rWidth * img_ratio).toFixed(0) - 0
+    })
+  },
+  changeBar: function (type) {
+    let detail = type.detail || {};
+    let second_name = detail.title || this.data.pTitle;
+    this.setData({
+      type: detail.type,
+      selectread: "30d",
+      selectme: "30d",
+      selectori: "30d",
+      sonTitle: second_name
+    })
+    this.getData({ topic_name: second_name });
+    this.getPing({ topic_name: second_name });
+    this.getAccount({ topic_name: second_name, platform: "ALL", type: "all" });
+    this.getAccount({ topic_name: second_name, platform: "douyin", type: "douyin" });
+    this.getAccount({ topic_name: second_name, platform: "kuaishou", type: "kuaishou" });
+    this.getAccount({ topic_name: second_name, platform: "yangshi", type: "yangshi" });
+    // this.getWorld();
+
+    this.getWeibo({ topic_name: second_name, time: "30d", type: "yangshi" });
+  }
+})

+ 10 - 0
pages/sonTopic/sonTopic.json

@@ -0,0 +1,10 @@
+{
+  "usingComponents": {
+    "tab" : "/components/tab/tab",
+    "chart" : "/components/Chart/Chart",
+    "table" : "/components/table/table",
+    "mp-toptips": "weui-miniprogram/toptips/toptips",
+    "wordCloud": "/components/wordCloud/wordCloud",
+    "lineChart": "/components/lineChart/lineChart"
+  }
+}

+ 90 - 0
pages/sonTopic/sonTopic.wxml

@@ -0,0 +1,90 @@
+<!--pages/home/components/contrast/contrast.wxml-->
+<wxs module="filter" src="/components/table/filter.wxs" />
+<view class="topic basePage">
+  <view class="mainTitle">{{pTitle}}</view>
+  <tab tabList="{{tabList}}" type="{{type}}" bindchangeBar="changeBar"></tab>
+  <view class="topicTable">
+    <view class="topicItem">总浏览量:</view>
+    <view class="topicItem">{{filter.valueFormat(headData.total_pv)}}</view>
+    <view class="topicItem">原创量:</view>
+    <view class="topicItem">{{filter.valueFormat(headData.total_ori)}}</view>
+  </view>
+  <view class="topicTable">
+    <view class="topicItem">总点赞数:</view>
+    <view class="topicItem">{{filter.valueFormat(headData.total_digg)}}</view>
+    <view class="topicItem">总评论数:</view>
+    <view class="topicItem">{{filter.valueFormat(headData.total_comment)}}</view>
+  </view>
+  <view class="topicTable">
+    <view class="topicItem">总转发量:</view>
+    <view class="topicItem">{{filter.valueFormat(headData.total_forward)}}</view>
+    <view class="topicItem"></view>
+    <view class="topicItem"></view>
+  </view>
+  <view class="itemView" wx:if="{{contrast.length}}">
+    <view class="localCells">平台对比</view>
+    <chart id="{{'id' + 1}}" canvasId="{{'canvasId' + 1}}"  list="{{contrast}}" wx:if="{{contrast && contrast.length}}" yType="total_pv" xType="platform" />
+  </view>
+  <view class="itemView" wx:if="{{all.length}}">
+    <view class="localCells">账号排名</view>
+    <chart
+    id="{{'id' + 2}}" canvasId="{{'canvasId' + 2}}" 
+      btnList="{{userSort}}"
+      wx:if="{{all && all.length}}" list="{{all}}" yType="{{btnList[0].type}}" xType="nickname" />
+  </view>
+  <!-- <view class="itemView" style="padding: 0" wx:if="{{!!imgURL}}">
+    <view class="localCells" style="padding: 5px 10px;">词云</view>
+    <image bindload="imgLoad"
+      style="{{'display: block;width: 100%;max-width: 441px;margin:0 auto;height:'+ height + 'px'}}" src="{{imgURL}}" />
+    <wordCloud wordsCloud="{{wordList}}" yType="value" xType="name" />
+  </view> -->
+  <view class="itemView" wx:if="{{douyin.length}}">
+    <view class="localCells">抖音-评论排行</view>
+    <chart id="{{'id' + 3}}" canvasId="{{'canvasId' + 3}}"  list="{{douyin}}" wx:if="{{douyin && douyin.length}}" yType="comment_count" xType="nickname" />
+  </view>
+  <view class="itemView" wx:if="{{douyin.length}}">
+    <view class="localCells">抖音-点赞排行</view>
+    <chart id="{{'id' + 4}}" canvasId="{{'canvasId' + 4}}"  list="{{douyin}}" wx:if="{{douyin && douyin.length}}" yType="digg_count" xType="nickname" />
+  </view>
+  <view class="itemView" wx:if="{{douyin.length && title !== '西安'}}">
+    <view class="localCells">抖音-粉丝量排行</view>
+    <chart id="{{'id' + 5}}" canvasId="{{'canvasId' + 5}}"  list="{{douyin}}" wx:if="{{douyin && douyin.length}}" yType="mplatform_followers_count" xType="nickname" />
+  </view>
+
+
+  <view class="itemView" wx:if="{{kuaishou.length}}">
+    <view class="localCells">快手-播放量排行</view>
+    <chart id="{{'id' + 6}}" canvasId="{{'canvasId' + 6}}"  list="{{kuaishou}}" wx:if="{{kuaishou && kuaishou.length}}" yType="pv" xType="nickname" />
+  </view>
+  <view class="itemView" wx:if="{{kuaishou.length}}">
+    <view class="localCells">快手-评论排行</view>
+    <chart id="{{'id' + 7}}" canvasId="{{'canvasId' + 7}}"  list="{{kuaishou}}" wx:if="{{kuaishou && kuaishou.length}}" yType="comment_count" xType="nickname" />
+  </view>
+
+
+  <view class="itemView" wx:if="{{weiboBtnListread.length}}">
+    <view class="localCells">微博-阅读量趋势</view>
+    <lineChart id="{{'id' + 11}}" canvasId="{{'canvasId' + 11}}" type="line" select="{{selectread}}" bindlineChenge="lineChengeread"
+      btnList="{{weiboBtnListread}}"
+      isShow="{{isShow}}" wx:if="{{weiboBtnListread && weiboBtnListread.length}}" list="{{weiboread}}" yType="value" xType="time" />
+  </view>
+  <view class="itemView" wx:if="{{weiboBtnListme.length}}">
+    <view class="localCells">微博-讨论趋势</view>
+    <lineChart id="{{'id' + 10}}" canvasId="{{'canvasId' + 10}}" type="line" select="{{selectme}}" bindlineChenge="lineChengeme"
+      btnList="{{weiboBtnListme}}"
+      isShow="{{isShow}}" wx:if="{{weiboBtnListme && weiboBtnListme.length}}" list="{{weibome}}" yType="value" xType="time" />
+  </view>
+  <view class="itemView" wx:if="{{weiboBtnListori.length}}">
+    <view class="localCells">微博-原创趋势</view>
+    <lineChart id="{{'id' + 9}}" canvasId="{{'canvasId' + 9}}"  type="line" select="{{selectori}}" bindlineChenge="lineChengeori"
+      btnList="{{weiboBtnListori}}"
+      isShow="{{isShow}}" wx:if="{{weiboBtnListori && weiboBtnListori.length}}" list="{{weiboori}}" yType="value" xType="time" />
+  </view>
+  <view class="itemView" wx:if="{{yangshi.length}}">
+    <view class="localCells">央视-浏览排行</view>
+    <chart id="{{'id' + 8}}" canvasId="{{'canvasId' + 8}}"  wx:if="{{yangshi && yangshi.length}}" list="{{yangshi}}" yType="pv" xType="nickname" />
+  </view>
+
+  <!-- 错误提示 -->
+  <mp-toptips msg="{{error}}" ext-class="toptips" type="error" show="{{error}}"></mp-toptips>
+</view>

+ 19 - 0
pages/sonTopic/sonTopic.wxss

@@ -0,0 +1,19 @@
+/* pages/sonTopic/sonTopic.wxss */
+.topic .topicTable {
+  display: flex;
+}
+
+.topic .topicTable .topicItem {
+  flex: 1;
+  padding: 5px 10px;
+}
+.topic .itemView,
+.topic .mainTitle{
+  padding: 5px 10px;
+}
+
+.topic .mainTitle{
+  font-size: 18px;
+  font-weight: 400;
+  border-bottom-color:red;
+}

+ 76 - 0
project.config.json

@@ -0,0 +1,76 @@
+{
+  "description": "项目配置文件",
+  "packOptions": {
+    "ignore": []
+  },
+  "setting": {
+    "urlCheck": true,
+    "es6": true,
+    "enhance": false,
+    "postcss": true,
+    "preloadBackgroundData": false,
+    "minified": true,
+    "newFeature": false,
+    "coverView": true,
+    "nodeModules": false,
+    "autoAudits": false,
+    "showShadowRootInWxmlPanel": true,
+    "scopeDataCheck": false,
+    "uglifyFileName": false,
+    "checkInvalidKey": true,
+    "checkSiteMap": false,
+    "uploadWithSourceMap": true,
+    "compileHotReLoad": false,
+    "useMultiFrameRuntime": true,
+    "useApiHook": true,
+    "useApiHostProcess": false,
+    "babelSetting": {
+      "ignore": [],
+      "disablePlugins": [],
+      "outputPath": ""
+    },
+    "enableEngineNative": false,
+    "bundle": false,
+    "useIsolateContext": true,
+    "useCompilerModule": true,
+    "userConfirmedUseCompilerModuleSwitch": false,
+    "userConfirmedBundleSwitch": false,
+    "packNpmManually": true,
+    "packNpmRelationList": [
+      {
+        "packageJsonPath": "./package.json",
+        "miniprogramNpmDistDir": "./"
+      }
+    ],
+    "minifyWXSS": true
+  },
+  "compileType": "miniprogram",
+  "libVersion": "2.17.0",
+  "appid": "wx9dbe0362bafd3d6f",
+  "projectname": "bigData",
+  "debugOptions": {
+    "hidedInDevtools": []
+  },
+  "scripts": {},
+  "isGameTourist": false,
+  "condition": {
+    "plugin": {
+      "list": []
+    },
+    "game": {
+      "list": []
+    },
+    "gamePlugin": {
+      "list": []
+    },
+    "miniprogram": {
+      "list": [
+        {
+          "name": "pages/sonTopic/sonTopic",
+          "pathName": "pages/sonTopic/sonTopic",
+          "scene": null
+        }
+      ]
+    }
+  }
+}

+ 9 - 0
sitemap.json

@@ -0,0 +1,9 @@
+{
+  "desc": "关于本文件的更多信息,请参考文档 https://developers.weixin.qq.com/miniprogram/dev/framework/sitemap.html",
+  "rules": [
+    {
+      "action": "disallow",
+      "page": "*"
+    }
+  ]
+}

Certains fichiers n'ont pas été affichés car il y a eu trop de fichiers modifiés dans ce diff