Browse Source

avg index

begmoon 1 year ago
parent
commit
c2db461f83

+ 2 - 3
app.json

@@ -1,6 +1,5 @@
 {
   "pages": [
-    
     "pages/index/index",
     "pages/rank/rank",
     "pages/upload/upload",
@@ -36,8 +35,8 @@
     "pages/comment/comment",
     "pages/winlost/winlost",
     "pages/article/article",
-    
-    "pages/matchdetail/matchdetail"
+    "pages/matchdetail/matchdetail",
+    "pages/avg/avg"
   ],
   "window": {
     "backgroundTextStyle": "light",

+ 260 - 0
pages/avg/avg.js

@@ -0,0 +1,260 @@
+// pages/avg/avg.js
+import * as echarts from '../../ec-canvas/echarts';
+
+const $api = require('../../utils/api.js').API;
+
+var records = []
+Page({
+
+  /**
+   * 页面的初始数据
+   */
+  data: {
+    tab:['冠军组','千万组','百万组'],
+    list:[],
+    cur:0,
+    match_name:'',
+    ec: {
+      onInit: null
+    },
+    datas:[],
+    date:'',
+  },
+
+  /**
+   * 生命周期函数--监听页面加载
+   */
+  onLoad(options) {
+    let nlist = JSON.parse(decodeURIComponent(options.list))
+    this.setData({
+      cur:options.index,
+      list:nlist,
+      match_name:nlist[0].match_name,
+    })
+
+    if(options.index == -1){
+      this.loadAvg()
+    } else{
+      this.loadGroupAvg()
+    }
+
+  },
+
+  loadGroupAvg(){
+    var group = this.data.list[this.data.cur]
+
+    var param = {
+      match_id:group.match_id,
+      group_id:group.match_group,
+    }
+
+    $api.getAllDay(param).then(res => {
+      // console.log(res.data.data.list)
+      if(res.data.code == 0){
+        records = res.data.data.list
+
+        var data = records[0]
+        var date = data.stock_date.substring(0,7)
+        var days = [], w = new Date(date + '-01').getDay();
+        for (let i = 0; i < w; i++) {
+          days.push({
+            day: '',
+            income: ''
+          })
+        }
+        for (let i = 0; i < records.length; i++) {
+          days.push({
+            day: i+1,
+            income: records[i].today_income,
+          })
+        }
+
+        this.setData({
+          ec: {
+            onInit: initChart
+          },
+          days: days,
+          date:date,
+        })
+      }
+    })
+  },
+
+  loadAvg(){
+    var group = this.data.list[0]
+    var param = {
+      match_id:group.match_id,
+    }
+
+    $api.getAvg(param).then(res => {
+      if(res.data.code == 0){
+        records = res.data.data.list
+
+        var data = records[0]
+        var date = data.stock_date.substring(0,7)
+        var days = [], w = new Date(date + '-01').getDay();
+        for (let i = 0; i < w; i++) {
+          days.push({
+            day: '',
+            income: ''
+          })
+        }
+        for (let i = 0; i < records.length; i++) {
+          days.push({
+            day: i+1,
+            income: records[i].today_income,
+          })
+        }
+
+        this.setData({
+          ec: {
+            onInit: initChart
+          },
+          days: days,
+          date:date,
+        })
+      }
+    })
+  },
+
+  tabChange(e){
+    this.setData({
+      cur:e.target.dataset.id
+    })
+  },
+
+  /**
+   * 生命周期函数--监听页面初次渲染完成
+   */
+  onReady() {
+
+  },
+
+  /**
+   * 生命周期函数--监听页面显示
+   */
+  onShow() {
+
+  },
+
+  /**
+   * 生命周期函数--监听页面隐藏
+   */
+  onHide() {
+
+  },
+
+  /**
+   * 生命周期函数--监听页面卸载
+   */
+  onUnload() {
+
+  },
+
+  /**
+   * 页面相关事件处理函数--监听用户下拉动作
+   */
+  onPullDownRefresh() {
+
+  },
+
+  /**
+   * 页面上拉触底事件的处理函数
+   */
+  onReachBottom() {
+
+  },
+
+  /**
+   * 用户点击右上角分享
+   */
+  onShareAppMessage() {
+
+  }
+})
+
+/**折线图 */
+function initChart(canvas, width, height, dpr) {
+  var xdata = [], ydata = [];
+  for (let i = 0; i < records.length; i++) {
+    let date = records[i].stock_date.split('-');
+    xdata.push(date[1] + '/' + date[2])
+    let y = records[i].total_income.replace('%', '')
+    ydata.push(Number(y))
+  }
+  xdata = xdata.reverse()
+  ydata = ydata.reverse()
+  const chart = echarts.init(canvas, null, {
+    width: width,
+    height: height,
+    devicePixelRatio: dpr // new
+  });
+  canvas.setChart(chart);
+  var option = {
+    legend: {
+      show: false
+    },
+    grid: {
+      x: 40,
+      y: 10,
+      x2: 10,
+      y2: 35
+    },
+    tooltip: {
+      show: true,
+      trigger: 'axis',
+      formatter: '{b0}: {c0}%',
+    },
+    xAxis: {
+      type: 'category',
+      data: xdata,
+      axisLabel: {
+        interval: 0,
+        rotate: 40,
+        color: '#999999',
+        interval: 2
+      }
+    },
+    yAxis: {
+      axisLine: {
+        show: true,
+      },
+      type: 'value',
+      // name: '收益曲线',
+      axisLabel: {
+        color: '#999999',
+        formatter: function (value, index) {//隐藏 0
+          let texts = [];
+          texts.push(value + '%')
+          return texts;
+        },
+        show: true
+      },
+    },
+    series: [{
+      name: 'A',
+      type: 'line',
+      smooth: true,
+      symbolSize: 4,
+      lineStyle: {
+        color: '#FF2D68'
+        // color: new echarts.graphic.LinearGradient(1, 0, 0, 0, [{
+        //   offset: 0,
+        //   color: '#FF2D68'
+        // }, {
+        //   offset: 1,
+        //   color: '#4C4BFF'
+        // }]),
+      },
+      itemStyle: {
+        borderWidth: 5,
+        borderColor: '#FFAD52',
+        color: '#FFAD52'
+      },
+      data: ydata
+    }]
+  };
+
+  chart.setOption(option);
+  return chart;
+}

+ 6 - 0
pages/avg/avg.json

@@ -0,0 +1,6 @@
+{
+  "navigationBarTitleText": "指数",
+  "usingComponents": {
+    "ec-canvas": "../../ec-canvas/ec-canvas"
+  }
+}

+ 45 - 0
pages/avg/avg.wxml

@@ -0,0 +1,45 @@
+<!--pages/avg/avg.wxml-->
+<text>{{match_name}}</text>
+<view>当日人均盈亏(算术平均)
+</view>
+
+<view wx:if="{{cur >= 0}}" class="tab">
+    <view wx:for='{{list}}' bindtap="tabChange" data-id='{{index}}' class="{{index==cur?'act':''}}">{{item.name}}</view>
+</view>
+
+<view class="content">
+    <view class="container">
+          <ec-canvas   ec="{{ ec }}">
+          </ec-canvas>
+    </view>
+</view>
+
+<view class="content">
+  <view>每日指数</view>
+  <view class="month">
+    <image bindtap="prev" mode="heightFix"  src="../../images/left.png"></image>
+    <picker mode="date" fields="month" value="{{date}}"  bindchange="bindDateChange">
+                <view class="date-picker">
+                   {{date}}
+                   <image  mode="heightFix"  src="../../images/icon_down@2x.png"></image>
+                </view>
+    </picker>
+    <image bindtap="next" mode="heightFix"  src="../../images/right.png"></image>
+  </view>
+  <view class="day">
+    <text>日</text><text>一</text><text>二</text>
+    <text>三</text><text>四</text><text>五</text><text>六</text>
+  </view>
+  <view class="days">
+    <view wx:for='{{days}}'>
+      <view wx:if='{{!item.income}}' style="color:#999;">
+        {{item.day}}
+        <text>{{item.income}}</text>
+      </view>
+      <view   class="{{item.income[0]=='-' ? 'down1':'up1'}}"> 
+        {{item.day}}
+        <text>{{item.income}}</text>
+      </view>
+    </view>
+  </view>
+</view>

+ 128 - 0
pages/avg/avg.wxss

@@ -0,0 +1,128 @@
+/* pages/avg/avg.wxss */
+
+.tab{
+  background: #fff;
+  margin-top: 16rpx;
+  padding:0 20rpx;
+  display: flex;
+  border-bottom: 1px solid #f2f2f2;
+  
+}
+.tab view{
+  font-size: 32rpx;
+  color: #333;
+  line-height: 80rpx;
+  transition: all .1s linear;
+  margin-right: 30rpx;
+}
+.tab .act{
+  color: #FF583D;
+  border-bottom: 2px solid #FF583D;
+  font-size: 32rpx;
+}
+
+.content{
+  font-size: 30rpx;
+  font-weight: 500;
+}
+
+.container {
+  position: relative;
+  display: flex;
+  flex-direction: column;
+  align-items: center;
+  justify-content: space-between;
+  box-sizing: border-box; 
+  height: 50vh;
+  background: #fff;
+  z-index: 9;
+} 
+
+.ec-canvas {
+  width: 100%;
+  height: 100%;
+  position: relative;
+  z-index: 99;
+}
+
+.imgs,.content{
+  margin-bottom: 20rpx;
+  background: #fff;
+  padding: 30rpx;
+  position: relative;
+}
+
+.month{
+  text-align: right;
+  position: absolute;
+  right: 30rpx;
+  top: 30rpx;
+}
+.month>image{
+  height: 40rpx;
+  display: inline-block;
+  vertical-align: middle;
+}
+
+.picker{
+  display: inline-block;
+  vertical-align: middle;
+  margin: 0 20rpx;
+}
+
+.date-picker{
+  font-size: 36rpx;
+  font-weight: 500;
+}
+.date-picker image{
+  height: 24rpx;
+}
+.day{
+  display: flex;
+  justify-content: space-between;
+  padding: 10rpx;
+  background: #f5f5f5;
+  margin: 20rpx 0;
+}
+.day text{
+  color: #999;
+  width: 14%;
+  text-align: center;
+}
+.days{
+  display: flex;
+  flex-wrap: wrap;
+  /* justify-content: space-between; */
+}
+.days view{
+  width: 14%;
+  text-align: center;
+  font-weight: 500;
+  height: 96rpx;
+  /* margin-bottom: 10rpx; */
+}
+.days text{
+  display: block;
+  color: #666;
+  font-size: 20rpx;
+  position: relative;
+  top: -5rpx;
+  font-weight: 400;
+}
+.days view view{
+  width: 100% !important;
+}
+.days view view text{
+   color: #fff;
+}
+
+.down1{
+  background: #07B20B;
+  color: #fff;
+  
+}
+.up1{
+  background: #E90001;
+  color: #fff;
+}
+

+ 11 - 0
pages/index/index.js

@@ -176,6 +176,17 @@ Page({
       cur1:e.target.dataset.id
     })
 },
+tapGroup(e){
+  wx.navigateTo({
+    url: '../avg/avg?index='+e.currentTarget.dataset.index + '&list=' + encodeURIComponent(JSON.stringify(this.data.groups.group_win_lose_list)),
+  })
+},
+
+tapAvg(e){
+  wx.navigateTo({
+    url: '../avg/avg?index=-1' + '&list=' + encodeURIComponent(JSON.stringify(this.data.groups.group_win_lose_list)),
+  })
+},
   //预览
   preview(e){
     wx.previewImage({

+ 7 - 4
pages/index/index.wxml

@@ -89,25 +89,28 @@
   </view>
   <scroll-view style="height: 200rpx;" scroll-x='{{true}}' wx:if='{{groups}}'>
     <view class="group_list">
-      <view wx:for='{{groups.group_win_lose_list}}' class="g_list">
+      <view wx:for='{{groups.group_win_lose_list}}' class="g_list"  bindtap="tapGroup" data-index='{{index}}'>
         <image mode="widthFix" wx:if="{{item.today_income_avg[0]=='-'}}" src="../../images/indexlose@2x.png"></image>
         <image mode="widthFix" wx:else src="../../images/indexwin@2x.png"></image>
-        <view>{{item.match_group_name}}</view>
+        <view>{{item.name}}</view>
         <text class="fund {{item.today_income_avg[0]=='-' ?'down':'up'}}">{{item.today_fund}}</text>
+        
         <text class="{{item.today_income_avg[0]=='-' ?'down':'up'}}">{{item.today_income_avg}}</text>
+       
       </view>
+      
     </view>
   </scroll-view>
   <view class="today">
     今日盈亏人数比 <text class="up" style="font-weight: 500;">{{groups.win_cnt}}</text> : <text class="down" style="font-weight: 500;">{{groups.lose_cnt}} </text>
-    今日人均收益(算数平均)  <text class="{{groups.today_win_lose_avg[0]=='-' ?'down':'up'}}" style="font-weight: 500;">{{groups.today_win_lose_avg}}</text>
+    今日人均收益(算数平均)  <text class="{{groups.today_win_lose_avg[0]=='-' ?'down':'up'}}" style="font-weight: 500;text-decoration: underline;" bind:tap="tapAvg">{{groups.today_win_lose_avg}}</text>
   </view>
 
   <view class="tab">
     <view wx:for='{{tabs1}}' bindtap="tabChange1" data-id='{{index}}' class="{{index==cur1?'act':''}}">{{item}}</view>
 </view>
 
-<swiper class="swiper-content" style="padding:0rpx 20rpx;height: 95vh;" current='{{cur1}}'  bindchange='curChange1'>
+<swiper class="swiper-content" style="padding:0rpx 20rpx;height: 1000rpx;" current='{{cur1}}'  bindchange='curChange1'>
   <swiper-item class="up-down">
     <view class="title_1">
       <text>收益率</text><text>资产(w)</text><text>盈利(w)</text>

+ 8 - 1
pages/index/index.wxss

@@ -610,7 +610,7 @@ scroll-view{
 }
 .group_list{
   display: flex;
-  width: 1100rpx;
+  width: 100%;
 }
 .g_list{
   position: relative;
@@ -646,4 +646,11 @@ scroll-view{
 .today{
   padding: 25rpx;
   font-size: 26rpx;
+}
+
+.change{
+  color: #E90001;
+  font-size: 30rpx;
+  text-decoration: underline;
+  display: inline;
 }

+ 22 - 2
pages/winlost/winlost.js

@@ -10,6 +10,7 @@ Page({
   data: {
     winLost:[],
     tabs1:['收益榜','盈利榜','亏损榜'],
+    cur1:0
   },
 
   /**
@@ -20,16 +21,35 @@ Page({
       this.setData({
         winLost:res.data.data
       })
+      var tabs=[],curs=[]
+      res.data.data.forEach((item,index)=>{
+        tabs.push(['收益榜','盈利榜','亏损榜'])
+        curs.push(0)
+      })
+      this.setData({
+        tabs:tabs,
+        curs:curs
+      })
     })
   },
 
   pushToday(e){
     $push.pushToday(e.currentTarget.dataset)
   },
-  
+  curChange1(e){
+    if (e.detail.source == "touch"){
+      var curs=this.data.curs,index=e.target.dataset.tab
+      curs[index]=e.detail.current
+      this.setData({
+        curs:curs
+      })
+    }
+  },
   tabChange1(e){
+    var curs=this.data.curs,index=e.target.dataset.tab
+    curs[index]=e.target.dataset.id
     this.setData({
-      cur1:e.target.dataset.id
+      curs:curs
     })
 },
   

+ 2 - 2
pages/winlost/winlost.wxml

@@ -5,9 +5,9 @@
         {{list.match_name}}
   </view>
   <view class="tab">
-    <view wx:for='{{tabs1}}' bindtap="tabChange1" data-id='{{index}}' class="{{index==cur1?'act':''}}">{{item}}</view>
+    <view wx:for='{{tabs[index]}}' bindtap="tabChange1" wx:for-index='i' data-tab='{{index}}'  data-id='{{i}}' class="{{i==curs[index]?'act':''}}">{{item}}</view>
   </view>
-  <swiper class="swiper-content" style="padding:0rpx 20rpx;height: 85vh;" current='{{cur1}}'  bindchange='curChange1'>
+  <swiper class="swiper-content" style="padding:0rpx 20rpx;height: 1000rpx;" current='{{curs[index]}}' data-tab='{{index}}'   bindchange='curChange1'>
   <swiper-item class="up-down">
     <view class="title_1">
       <text>收益率</text><text>资产(w)</text><text>盈利(w)</text>

+ 6 - 2
utils/api.js

@@ -6,8 +6,8 @@ const DELETE = 'DELETE';
 // wxb299e10e65157301
 // wx2938132b773c7b5a
 // const baseURL = 'https://wx.scxjc.club';
-const baseURL = 'https://test.hunanwanzhu.com';
-// const baseURL = 'https://api.hunanwanzhu.com';
+// const baseURL = 'https://test.hunanwanzhu.com';
+const baseURL = 'https://api.hunanwanzhu.com';
 
 function request(method, url, data) {
   var token='';
@@ -213,7 +213,11 @@ const API = {
   getStockNbcomments: (data) => request(GET, `/api/wx/v3/stock/comments/list`, data),
   getWinLose: (data) => request(GET, `/api/wx/v3/match/group/winlose/statistic`, data),
   imageOcr: (data) => request(POST, `/api/wx/v3/ai/ocr`, data),
+  getAllDay: (data) => request(GET, `/api/wx/v3/match/group/winlose/allday`, data),
+  getAvg: (data) => request(GET, `/api/wx/v3/match/group/winlose/avg/allday`, data),
+
   initUser:() => initUser(),
+
 };
 
 const PUSH = {