Bläddra i källkod

feat: b2 市场数据

wjc 1 vecka sedan
förälder
incheckning
5fd7a5d3f3
2 ändrade filer med 23 tillägg och 15 borttagningar
  1. 0 2
      src/views/hui-jia/b1-screen/index.vue
  2. 23 13
      src/views/hui-jia/components/market.vue

+ 0 - 2
src/views/hui-jia/b1-screen/index.vue

@@ -148,12 +148,10 @@
             (key) => this.state.service_last_month[key]
           ),
         }
-        console.log("----1231-3", result)
         this.serviceData = result
       },
       getData() {
         huiJiaApi.getScreenData().then((res) => {
-          console.log("大屏数据----", res.data.data)
           if (res && res.data) {
             this.state = res.data.data
             this.getServiceData()

+ 23 - 13
src/views/hui-jia/components/market.vue

@@ -46,18 +46,16 @@
     },
     computed: {
       ...mapState(["entCode", "communityId"]),
-      lastMonthData() {
-        const data = this.data || {}
-        return Object.keys(data).map((key, index) => {
-          return -data[key].last_month
-        }).reverse()
+    },
+    watch: {
+      data: {
+        handler(newVal, oldVal) {
+          if (newVal) {
+            this.initChart()
+          }
+        },
+        deep: true,
       },
-      thisMonthData() {
-        const data = this.data || {}
-        return Object.keys(data).map((key, index) => {
-          return data[key].this_month
-        }).reverse()
-      }
     },
     mounted() {
       this.init()
@@ -84,6 +82,18 @@
           document.getElementById("marketChart2")
         )
 
+        const lastMonthData = Object.keys(this.data)
+          .map((key, index) => {
+            return -this.data[key].last_month
+          })
+          .reverse()
+
+        const thisMonthData = Object.keys(this.data)
+          .map((key, index) => {
+            return this.data[key].this_month
+          })
+          .reverse()
+
         const optionA = {
           tooltip: {
             trigger: "axis",
@@ -146,7 +156,7 @@
               name: "上月",
               type: "bar",
               // barMinHeight: 20,
-              data: this.lastMonthData,
+              data: lastMonthData,
               itemStyle: {
                 // 左侧渐变色:从#F66757到#FCE2B4
                 color: new echarts.graphic.LinearGradient(1, 0, 0, 0, [
@@ -234,7 +244,7 @@
               name: "本月",
               type: "bar",
               // barMinHeight: 20,
-              data: this.thisMonthData,
+              data: thisMonthData,
               itemStyle: {
                 // 右侧渐变色:从#1620D4到#3AB3E3
                 color: new echarts.graphic.LinearGradient(0, 0, 1, 0, [