zjh 5 năm trước cách đây
mục cha
commit
46f215930e
8 tập tin đã thay đổi với 257 bổ sung167 xóa
  1. 1 1
      components/commom.wxs
  2. 168 116
      pages/drop/drop.js
  3. 2 0
      pages/drop/drop.json
  4. 45 37
      pages/drop/drop.wxml
  5. 16 3
      pages/drop/drop.wxss
  6. 6 6
      pages/item/item.js
  7. 4 4
      pages/rise/rise.js
  8. 15 0
      utils/api.js

+ 1 - 1
components/commom.wxs

@@ -1,5 +1,5 @@
 function Intercept(row){
-  console.log(row)
+  // console.log(row)
   // return Math.round(row * 100)
   return row.toFixed(2)
 }

+ 168 - 116
pages/drop/drop.js

@@ -1,5 +1,6 @@
 import * as echarts from '../../ec-canvas/echarts';
-
+var Api = require('../../utils/api.js');
+var wxRequest = require('../../utils/wxRequest.js') 
 var app = getApp()
 function initChart(canvas, width, height, dpr, data) {
   const chart = echarts.init(canvas, null, {
@@ -34,12 +35,11 @@ function initChart(canvas, width, height, dpr, data) {
       smooth: true,
       symbol: 'none',
       lineStyle: {
-        color: '#07c160',
+        color: '#D81E06',
     },
       data:data,
       areaStyle: {
-        color: '#07c160',
-
+        color: '#D81E06',
       },
     }]
   };
@@ -59,127 +59,178 @@ Page({
     ec: {
       onInit: initChart
     },
-    array:[
-      {
-        title:'BK0422',
-        subtitle:"交运物流",
-        Increase:"+1.22",
-        digital:"33",
-        color:'#07c160',
-        keep:"已关注",
-        data:[52,56,355,444]
-      },
-      {
-        title:'BK0738',
-        subtitle:"多元金融",
-        Increase:"+1.22",
-        digital:"33",
-        color:'#07c160',
-        keep:"已关注",
-        data:[52,56,355,444]
-      },
-      {
-        title:'BK0450',
-        subtitle:"港口水运",
-        Increase:"+1.22",
-        digital:"33",
-        color:'#07c160',
-        keep:"已关注",
-        data:[52,56,355,444,52,56,355,444,52,56,355,444,2]
-      },
-      {
-        title:'BK0734',
-        subtitle:"珠宝首饰",
-        Increase:"+1.22",
-        digital:"33",
-        color:'#07c160',
-        keep:"关注",
-        data:[52,56,355,44554]
-      },
-      {
-        title:'BK0471',
-        subtitle:"化纤行业",
-        Increase:"+1.22",
-        digital:"33",
-        keep:"关注",
-        color:'#07c160',
-        data:[52,56,355,444]
-      },
-      {
-        title:'BK0485',
-        subtitle:"旅游酒店",
-        Increase:"+1.22",
-        digital:"33",
-        color:'#07c160',
-        keep:"关注",
-        data:[52,56,355,444]
-      },
-      {
-        title:'BK0475',
-        subtitle:"银行",
-        Increase:"+1.22",
-        digital:"33",
-        keep:"关注",
-        color:'#07c160',
-        data:[52,56,355,44554]
-      },
-      {
-        title:'BK0473',
-        subtitle:"券商信托",
-        Increase:"+1.22",
-        digital:"33",
-        color:'#07c160',
-        keep:"关注",
-        data:[52,56,355,444]
-      },
-      {
-        title:'BK0474',
-        subtitle:"保险",
-        Increase:"+1.22",
-        color:'#07c160',
-        keep:"关注",
-        digital:"33",
-        data:[52,56,355,444]
-      },
-      {
-        title:'BK0478',
-        subtitle:"有色金属",
-        Increase:"+1.22",
-        keep:"关注",
-        digital:"33",
-        color:'#07c160',
-        data:[52,56,355,44554]
-      },
-      {
-        title:'BK0738',
-        subtitle:"多元金融",
-        Increase:"+1.22",
-        digital:"33",
-        keep:"关注",
-        color:'#07c160',
-        data:[52,56,355,44554]
-      }
+    realData:[
+      // {
+      //   title:'BK0422',
+      //   subtitle:"交运物流",
+      //   Increase:"+1.22",
+      //   digital:"33",
+      //   color:'crimson',
+      //   keep:"已关注",
+      //   data:[52,56,355,444]
+      // },
+      // {
+      //   title:'BK0738',
+      //   subtitle:"多元金融",
+      //   Increase:"+1.22",
+      //   digital:"33",
+      //   color:'crimson',
+      //   keep:"已关注",
+      //   data:[52,56,355,444]
+      // },
+      // {
+      //   title:'BK0450',
+      //   subtitle:"港口水运",
+      //   Increase:"+1.22",
+      //   digital:"33",
+      //   color:'crimson',
+      //   keep:"已关注",
+      //   data:[52,56,355,444,52,56,355,444,52,56,355,444,2]
+      // },
+      // {
+      //   title:'BK0734',
+      //   subtitle:"珠宝首饰",
+      //   Increase:"+1.22",
+      //   digital:"33",
+      //   color:'crimson',
+      //   keep:"关注",
+      //   data:[52,56,355,44554]
+      // },
+      // {
+      //   title:'BK0471',
+      //   subtitle:"化纤行业",
+      //   Increase:"+1.22",
+      //   digital:"33",
+      //   keep:"关注",
+      //   color:'crimson',
+      //   data:[52,56,355,444]
+      // },
+      // {
+      //   title:'BK0485',
+      //   subtitle:"旅游酒店",
+      //   Increase:"+1.22",
+      //   digital:"33",
+      //   color:'crimson',
+      //   keep:"关注",
+      //   data:[52,56,355,444]
+      // },
+      // {
+      //   title:'BK0475',
+      //   subtitle:"银行",
+      //   Increase:"+1.22",
+      //   digital:"33",
+      //   keep:"关注",
+      //   color:'crimson',
+      //   data:[52,56,355,44554]
+      // },
+      // {
+      //   title:'BK0473',
+      //   subtitle:"券商信托",
+      //   Increase:"+1.22",
+      //   digital:"33",
+      //   color:'crimson',
+      //   keep:"关注",
+      //   data:[52,56,355,444]
+      // },
+      // {
+      //   title:'BK0474',
+      //   subtitle:"保险",
+      //   Increase:"+1.22",
+      //   color:'crimson',
+      //   keep:"关注",
+      //   digital:"33",
+      //   data:[52,56,355,444]
+      // },
+      // {
+      //   title:'BK0478',
+      //   subtitle:"有色金属",
+      //   Increase:"+1.22",
+      //   keep:"关注",
+      //   digital:"33",
+      //   color:'crimson',
+      //   data:[52,56,355,44554]
+      // },
+      // {
+      //   title:'BK0738',
+      //   subtitle:"多元金融",
+      //   Increase:"+1.22",
+      //   digital:"33",
+      //   keep:"关注",
+      //   color:'crimson',
+      //   data:[52,56,355,44554]
+      // }
     ],
+    onperData:[],
+    uperData:[],
 
   },
+
   onLoad: function() {
     var that = this;
     // 获取系统信息 
     wx.getSystemInfo({
       success: function(res) {
-        let navHeight,
-        isiOS = res.system.indexOf('iOS') > -1
-        if(isiOS){
-          navHeight=44
-        }else{
-          navHeight=48
-        }
-      that.setData({
-        winWidth: res.windowWidth,
-        winHeight: res.windowHeight - res.statusBarHeight - navHeight
-      });
+          let navHeight,
+          isiOS = res.system.indexOf('iOS') > -1
+          if(isiOS){
+            navHeight=44
+          }else{
+            navHeight=48
+            
+          }
+        that.setData({
+          winWidth: res.windowWidth,
+          winHeight: res.windowHeight - res.statusBarHeight - navHeight
+        });
       }
     });
+    that.getdeclast()
+    that.getdeclpred()
+    that.getdecnpred()
+  },
+  onPullDownRefresh: function () {
+    wx.showNavigationBarLoading()
+    var that = this;
+    this.onLoad(); //重新加载onLoad()
+  },
+  //获取上周实际
+  getdeclast:function(){
+    var that = this;
+    var getinclast = wxRequest.postRequest(Api.getdeclast());
+    getinclast.then((res)=>{
+      // console.log(res)
+      if(res.statusCode==200){
+       that.setData({
+        realData:res.data.value
+       })
+      }
+    })
+  },
+    //获取上周预测
+    getdeclpred:function(){
+      var that = this;
+      var getinclast = wxRequest.postRequest(Api.getdeclpred());
+      getinclast.then((res)=>{
+        // console.log(res)
+        if(res.statusCode==200){
+         that.setData({
+          onperData:res.data.value
+         })
+        }
+      })
+    },
+      //获取下周预测
+      getdecnpred:function(){
+        var that = this;
+    var getinclast = wxRequest.postRequest(Api.getdecnpred());
+    getinclast.then((res)=>{
+      // console.log(res)
+      if(res.statusCode==200){
+       that.setData({
+        uperData:res.data.value
+       })
+      }
+    })
   },
   // 滑动切换tab 
   bindChange: function(e) {
@@ -200,9 +251,10 @@ Page({
     }
   },
   open: function (e) {
-    console.log(e)
+    // console.log(e)
     wx.navigateTo({
       url: '../item/item?row='+JSON.stringify(e.currentTarget.dataset.row)
     });
+
   }
 })

+ 2 - 0
pages/drop/drop.json

@@ -1,5 +1,7 @@
 {
   "navigationStyle": "custom",
+  "enablePullDownRefresh":true,
+  "backgroundTextStyle": "dark",
   "usingComponents": {
     "navBar": "/components/navBar/navBar",
     "ec-canvas": "../../ec-canvas/ec-canvas"

+ 45 - 37
pages/drop/drop.wxml

@@ -1,4 +1,5 @@
 <navBar></navBar>
+<wxs module="commom" src="../../components/commom.wxs"></wxs>
 <view class="swiper-tab">
   <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>
@@ -8,18 +9,20 @@
 <swiper current="{{currentTab}}" class="swiper-box" duration="300"  style="height:{{winHeight - 48}}px" bindchange="bindChange">
   <swiper-item>
     <scroll-view scroll-y style="height: 100%;">
-      <view wx:for="{{array}}"class="swiper-box-view" wx:key="index" bindtap="open" data-row='{{item}}'>
-        <view class="swiper-box-left">
-          <view>{{item.title}}</view>
-          <view class="swiper-box-subtitle">{{item.subtitle}}</view>
-        </view>
-        <view class="swiper-box-right">
-          <!-- <view class="swiper-box-canvas">
-            <ec-canvas  id="mychart-dom-line" canvas-id="mychart-line" tuData="{{ item.data }}" ec="{{ ec }}"></ec-canvas>
-          </view> -->
-          <view class="swiper-box-button">
-            <!-- <view>{{item.digital}}</view> -->
-            <button  class="mini-btn" type="primary" size="mini" >{{item.Increase}}</button>
+      <view class="swiper-box-list">
+        <view wx:for="{{uperData}}"class="swiper-box-view" wx:key="index" bindtap="open" data-row='{{item}}'>
+          <view class="swiper-box-left">
+            <view>{{item.Name}}</view>
+            <!-- <view class="swiper-box-subtitle">{{item.subtitle}}</view> -->
+          </view>
+          <view class="swiper-box-right">
+            <!-- <view class="swiper-box-canvas">
+              <ec-canvas  id="mychart-dom-line" canvas-id="mychart-line" tuData="{{ item.data }}" ec="{{ ec }}"></ec-canvas>
+            </view> -->
+            <view class="swiper-box-button">
+              <!-- <view>{{item.digital}}</view> -->
+              <button  class="mini-btn" type="warn" size="mini" >+{{commom.Intercept(item.Value)}}%</button>
+            </view>
           </view>
         </view>
       </view>
@@ -27,18 +30,20 @@
   </swiper-item>
   <swiper-item>
     <scroll-view scroll-y style="height: 100%;">
-      <view wx:for="{{array}}"class="swiper-box-view" wx:key="index" bindtap="open" data-row='{{item}}'>
-        <view class="swiper-box-left">
-          <view>{{item.title}}</view>
-          <view class="swiper-box-subtitle">{{item.subtitle}}</view>
-        </view>
-        <view class="swiper-box-right">
-          <!-- <view class="swiper-box-canvas">
-            <ec-canvas  id="mychart-dom-line" canvas-id="mychart-line" tuData="{{ item.data }}" ec="{{ ec }}"></ec-canvas>
-          </view> -->
-          <view class="swiper-box-button">
-            <!-- <view>{{item.digital}}</view> -->
-            <button class="mini-btn" type="primary" size="mini">{{item.Increase}}</button>
+      <view class="swiper-box-list">
+        <view wx:for="{{realData}}"class="swiper-box-view" wx:key="index" bindtap="open" data-row='{{item}}'>
+          <view class="swiper-box-left">
+            <view>{{item.Name}}</view>
+            <!-- <view class="swiper-box-subtitle">{{item.subtitle}}</view> -->
+          </view>
+          <view class="swiper-box-right">
+            <!-- <view class="swiper-box-canvas">
+              <ec-canvas  id="mychart-dom-line" canvas-id="mychart-line" tuData="{{ item.data }}" ec="{{ ec }}"></ec-canvas>
+            </view> -->
+            <view class="swiper-box-button">
+              <!-- <view>{{item.digital}}</view> -->
+              <button class="mini-btn" type="warn" size="mini">+{{commom.Intercept(item.Value)}}%</button>
+            </view>
           </view>
         </view>
       </view>
@@ -46,21 +51,24 @@
   </swiper-item>
     <swiper-item>
     <scroll-view scroll-y style="height: 100%;">
-      <view wx:for="{{array}}"class="swiper-box-view" wx:key="index" bindtap="open" data-row='{{item}}'>
-        <view class="swiper-box-left">
-          <view>{{item.title}}</view>
-          <view class="swiper-box-subtitle">{{item.subtitle}}</view>
-        </view>
-        <view class="swiper-box-right">
-          <!-- <view class="swiper-box-canvas">
-            <ec-canvas  id="mychart-dom-line" canvas-id="mychart-line" tuData="{{ item.data }}" ec="{{ ec }}"></ec-canvas>
-          </view> -->
-          <view class="swiper-box-button">
-            <!-- <view>{{item.digital}}</view> -->
-            <button class="mini-btn" type="primary" size="mini">{{item.Increase}}</button>
+      <view class="swiper-box-list">
+        <view wx:for="{{onperData}}"class="swiper-box-view" wx:key="index" bindtap="open" data-row='{{item}}'>
+          <view class="swiper-box-left">
+            <view>{{item.Name}}</view>
+            <!-- <view class="swiper-box-subtitle">{{item.subtitle}}</view> -->
+          </view>
+          <view class="swiper-box-right">
+            <!-- <view class="swiper-box-canvas">
+              <ec-canvas  id="mychart-dom-line" canvas-id="mychart-line" tuData="{{ item.data }}" ec="{{ ec }}"></ec-canvas>
+            </view> -->
+            <view class="swiper-box-button">
+              <!-- <view>{{item.digital}}</view> -->
+              <button class="mini-btn" type="warn" size="mini">+{{commom.Intercept(item.Value)}}%</button>
+            </view>
           </view>
         </view>
       </view>
     </scroll-view>
   </swiper-item>
-</swiper>
+</swiper>
+

+ 16 - 3
pages/drop/drop.wxss

@@ -1,5 +1,6 @@
 page {
   background: #000;
+
 }  
 .swiper-tab {
   width: 100%;
@@ -26,13 +27,21 @@ page {
   overflow: hidden;
   color: #fff;
 }
-
+.swiper-box .swiper-box-list{
+  overflow:auto;
+  margin:auto;
+  position:absolute;
+  top:0;
+  bottom:0;
+  left:0;
+  right:0;
+}
 .swiper-box .swiper-box-view {
  display: flex;
  justify-content: space-between;
  align-items: center;
- margin: 20rpx;
- padding-bottom: 10rpx;
+  margin: 20rpx;
+  padding-bottom: 10rpx;
  border-bottom: 1rpx slategray solid;
 }
 ec-canvas {
@@ -54,3 +63,7 @@ ec-canvas {
 .swiper-box .swiper-box-view .swiper-box-right .swiper-box-button{
   text-align: right;
 }
+.swiper-box .swiper-box-view .swiper-box-right .swiper-box-button button{
+  color: #fff;
+  background: #07c160;
+}

+ 6 - 6
pages/item/item.js

@@ -38,7 +38,7 @@ function initChart(canvas, width, height, dpr, data) {
   },
     renderAsImage: true, //支持渲染为图片模式
 
-    color: ["#DF3E3E", "#80CDF8"],//图例图标颜色
+    color: [data.color, "#80CDF8"],//图例图标颜色
 
     legend: {
 
@@ -347,7 +347,7 @@ Page({
    * 生命周期函数--监听页面加载
    */
   onLoad: function (options) {
-    console.log(JSON.parse(options.row))
+    // console.log(options)
     var Name = "object.Name"
     var value = "object.value"
     var color='object.color'
@@ -376,8 +376,8 @@ Page({
       var that = this;
       var postbyiid = wxRequest.postRequest(Api.postbyiid(),{'iid':'12'});
       postbyiid.then((res)=>{
-        console.log(res)
-        console.log(that.recursion(res.data))
+        // console.log(res)
+        // console.log(that.recursion(res.data))
         if(res.statusCode==200){
          that.setData({
           realchartData:that.recursion(res.data)
@@ -404,7 +404,7 @@ Page({
       var that = this;
       var postbyiid = wxRequest.postRequest(Api.postnewsbyiid(),{'iid':'12'});
       postbyiid.then((res)=>{
-        console.log(res)
+        // console.log(res)
         // NID: "新闻id"
         // Title: "标题"
         // From: "来源"
@@ -412,7 +412,7 @@ Page({
         // EID: ""
         // Date: "时间"
         // Tag: "情绪"
-        console.log(that.recursion(res.data))
+        // console.log(that.recursion(res.data))
         if(res.statusCode==200){
          that.setData({
           newsData:res.data.data

+ 4 - 4
pages/rise/rise.js

@@ -198,7 +198,7 @@ Page({
     var that = this;
     var getinclast = wxRequest.postRequest(Api.getinclast());
     getinclast.then((res)=>{
-      console.log(res)
+      // console.log(res)
       if(res.statusCode==200){
        that.setData({
         realData:res.data.value
@@ -211,7 +211,7 @@ Page({
       var that = this;
       var getinclast = wxRequest.postRequest(Api.getinclpred());
       getinclast.then((res)=>{
-        console.log(res)
+        // console.log(res)
         if(res.statusCode==200){
          that.setData({
           onperData:res.data.value
@@ -224,7 +224,7 @@ Page({
         var that = this;
     var getinclast = wxRequest.postRequest(Api.getincnpred());
     getinclast.then((res)=>{
-      console.log(res)
+      // console.log(res)
       if(res.statusCode==200){
        that.setData({
         uperData:res.data.value
@@ -251,7 +251,7 @@ Page({
     }
   },
   open: function (e) {
-    console.log(e)
+    // console.log(e)
     wx.navigateTo({
       url: '../item/item?row='+JSON.stringify(e.currentTarget.dataset.row)
     });

+ 15 - 0
utils/api.js

@@ -16,6 +16,21 @@ module.exports = {
     var url =HOST_URI + '/inc/npred';
     return url;
   },
+    // 获取跌幅上周实际
+    getdeclast: function (obj) {
+      var url =HOST_URI + '/dec/last';
+      return url;
+    },
+      // 获取跌幅上周预测
+      getdeclpred: function (obj) {
+        var url =HOST_URI + '/dec/lpred';
+        return url;
+      },
+        // 获取跌幅下周预测
+    getdecnpred: function (obj) {
+      var url =HOST_URI + '/dec/npred';
+      return url;
+    },
   // 获取详情
   postbyiid: function (obj) {
     var url =HOST_URI + '/his/byiid';