lx 5 年 前
コミット
76272386d7
3 ファイル変更30 行追加16 行削除
  1. 23 11
      pages/index/index.js
  2. 3 3
      pages/index/index.wxml
  3. 4 2
      pages/index/index.wxss

+ 23 - 11
pages/index/index.js

@@ -164,14 +164,14 @@ Page({
 
     imagewidth: 0,//缩放后的宽 
     imageheight: 0,//缩放后的高 
-    chartData:{
-      actual:[552,586,3555,4454,552,556,4455],
-      prediction:[552,546,3585,4424,542,546,35,44,524,56,355,444,2224,421],
-      timeData : [
-        '2020/6/1', '2020/6/2', '2020/6/3', '2020/6/4', '2020/6/5', '2020/6/6', '2020/6/7', '2020/6/8', '2020/6/9', '2020/6/10','2020/6/11',
-        '2020/6/12','2020/6/13','2020/6/14',
-      ]
-    },
+    // chartData:{
+    //   actual:[552,586,3555,4454,552,556,4455],
+    //   prediction:[552,546,3585,4424,542,546,35,44,524,56,355,444,2224,421],
+    //   timeData : [
+    //     '2020/6/1', '2020/6/2', '2020/6/3', '2020/6/4', '2020/6/5', '2020/6/6', '2020/6/7', '2020/6/8', '2020/6/9', '2020/6/10','2020/6/11',
+    //     '2020/6/12','2020/6/13','2020/6/14',
+    //   ]
+    // },
       chartDatas:{
         actual:[572,556,3555,4744,552,576,3555],
         prediction:[352,246,385,2424,542,546,255],
@@ -323,13 +323,25 @@ Page({
     apiServer.getHushen().then((res) =>{
       if(res.statusCode == 200){
         console.log(res);
-        
-        this.setData({
-
+          this.setData({
+            chartDatas:this.recursion(res.data.data),
         })
       }
     })
   },
+  recursion:function(row,a=[],b=[],c=[],d){
+    for(let i in row.actuals){
+    a.unshift(row.actuals[i].industryDate)
+    b.unshift(row.actuals[i].close)
+    c.unshift(row.actuals[i].pred)
+    }
+    if(row.tag){
+      d="#D81E06"
+    }else{
+      d="#07c160"
+    }
+  return {"timeData":a,"actual":b,"prediction":c,"color":d}
+  },
   onReady: function (e) {
     this.computeScrollViewHeight();
     // var query = wx.createSelectorQuery()

+ 3 - 3
pages/index/index.wxml

@@ -8,7 +8,7 @@
     <!-- <view class="swiper-tab-list {{currentTab==0 ? 'on' : ''}}" data-current="0" bindtap="swichNav">沪深</view>
     <view class="swiper-tab-list {{currentTab==1 ? 'on' : ''}}" data-current="1" bindtap="swichNav">港股</view> -->
     <view class="swiper-tab-list">沪深</view>
-    <image class="image" src="./images/001.png" bindtap='choose'></image>
+    <!-- <image class="image" src="./images/001.png" bindtap='choose'></image> -->
   </view>
   <!-- <view class="userinfo">
     <button wx:if="{{!hasUserInfo && canIUse}}" open-type="getUserInfo" bindgetuserinfo="getUserInfo"> 获取头像昵称 </button>
@@ -43,9 +43,9 @@
        <ec-canvas  id="mychart-dom-line" canvas-id="mychart-line" tuData="{{ chartDatas }}" ec="{{ ec }}"></ec-canvas>
      </view>
     </swiper-item>
-    <swiper-item catchtouchmove='catchTouchMove'>
+    <!-- <swiper-item catchtouchmove='catchTouchMove'>
       <ec-canvas  id="mychart-dom-line" canvas-id="mychart-line" tuData="{{ chartData }}" ec="{{ ec }}"></ec-canvas>
-    </swiper-item>
+    </swiper-item> -->
    </swiper>
         <!-- <view class="middleCharts">
           <ec-canvas id="mychart-dom-line" canvas-id="mychart-line" tuData=" {{ chartData }}" ec="{{ ec }}"></ec-canvas>

+ 4 - 2
pages/index/index.wxss

@@ -43,16 +43,18 @@ ec-canvas {
 }
 .swiper-tab {
   width: 100%;
-  text-align: center;
+  margin-left: 80rpx;
+  /* text-align: center; */
   line-height: 80rpx;
   position: relative;
+  color: #fff;
 }
 
 .swiper-tab-list {
   font-size: 30rpx;
   display: inline-block;
   width: 20%;
-  color: #777;
+  /* color: #777; */
 }
 .on {
   color: #D81E06;