xiaoyi 2 mēneši atpakaļ
vecāks
revīzija
a26de0f74c

BIN
pages/.DS_Store


+ 2 - 3
pages/apply/apply.wxml

@@ -16,9 +16,8 @@
         <!-- <view class="date" wx:for="{{info.groups}}">{{item.name}}</view> -->
         
         <view class="date">
-          <text>千万组:300W以上</text>
-          <text>百万组:50W到300W</text>
-          <text>十万组:10W到50W</text>
+          <text>千百万组:100W以上</text>
+          <text>十万组:10W到100W</text>
           <text>菜鸟组:10W以下</text>
           <text>{{info.awards_content}}</text>
         </view>

+ 23 - 16
pages/avg/avg.js

@@ -10,7 +10,6 @@ Page({
    * 页面的初始数据
    */
   data: {
-    tab:['全体选手','冠军组','千万组','百万组'],
     list:[],
     cur:0,
     match_name:'',
@@ -19,28 +18,37 @@ Page({
     },
     datas:[],
     days:[],
+    match_id:0,
   },
 
   /**
    * 生命周期函数--监听页面加载
    */
   onLoad(options) {
-    let nlist = JSON.parse(decodeURIComponent(options.list))
-    nlist.unshift(nlist[0])
-    // nlist[0].name='全体选手'
-    console.log(nlist)
     this.setData({
       cur:options.index,
-      list:nlist,
-      match_name:nlist[0].match_name,
+      match_id:options.match_id,
+      match_name:options.match_name,
     })
 
-    if(options.index == 0){
-      this.loadAvg()
-    } else{
-      this.loadGroupAvg()
-    }
+    this.loadGroupList()
+  },
 
+  loadGroupList(){
+    $api.getMatchGroupList({match_id:this.data.match_id}).then(res => {
+      var nlist = [{'name':'全体选手'}]
+      nlist = nlist.concat(res.data.data)
+
+      this.setData({
+        list:nlist
+      })
+
+      if(this.data.cur == 0){
+        this.loadAvg()
+      } else{
+        this.loadGroupAvg()
+      }
+    })
   },
 
   loadGroupAvg(){
@@ -48,7 +56,7 @@ Page({
 
     var param = {
       match_id:group.match_id,
-      group_id:group.match_group,
+      group_id:group.id,
     }
 
     $api.getAllDay(param).then(res => {
@@ -111,16 +119,15 @@ Page({
   return weeks + 1; // 因为getWeek返回的是年初至今的周数,所以加1得到完整的周数
 },
   loadAvg(){
-    var group = this.data.list[0]
     var param = {
-      match_id:group.match_id,
+      match_id:this.data.match_id,
     }
     $api.getAvg(param).then(res => {
       if(res.data.code == 0){
         records = res.data.data.list.reverse()
         var days=res.data.data.list,weeks=[]
         days=days
-        for(let i=0;i<55;i++){
+        for(let i=0;i<100;i++){
           weeks.push({
             name:'',
             data:[],

+ 1 - 1
pages/avg/avg.json

@@ -1,5 +1,5 @@
 {
-  "navigationBarTitleText": "指数",
+  "navigationBarTitleText": "顽主杯指数",
   "usingComponents": {
     "ec-canvas": "../../ec-canvas/ec-canvas"
   }

+ 2 - 2
pages/avg/avg.wxml

@@ -2,7 +2,7 @@
 <view class="title"><text>{{match_name}}</text></view>
 <view wx:if="{{cur >= 0}}" class="tab">
     <view wx:for='{{list}}' bindtap="tabChange" data-id='{{index}}' class="{{index==cur?'act':''}}">
-    {{index==0 ? '全体选手':item.name}}
+    {{item.name}}
    </view>
 </view>
 <view class="title_1">
@@ -33,7 +33,7 @@
         </view>
         </view>
         <view class="week_total">
-          周收益
+          <view>周收益</view>
           <text class="{{item.total < 0 ?'down':'up'}}">{{item.total}}%</text>
         </view>
       </view>

+ 153 - 5
pages/index/index.js

@@ -1,8 +1,11 @@
 // index.js
 // 获取应用实例
+import * as echarts from '../../ec-canvas/echarts';
+
 const app = getApp()
-const $api = require('../../utils/api.js').API;
-const $push = require('../../utils/api.js').PUSH;
+const $api = require('../../utils/api.js').API
+const $push = require('../../utils/api.js').PUSH
+var records = []
 
 Page({
   data: {
@@ -45,7 +48,12 @@ Page({
     isWeek:0,
     scoredays:[],
     nochoose:false,
+    cangwei:[],
+    ec: {
+      onInit: null
+    },
   },
+  
   onLoad() {
     var w=new Date().getDay()
     if(w == 0 || w == 6){
@@ -100,7 +108,6 @@ Page({
     $api.getMark().then(res=>{
       var days=res.data.data.reverse(),weeks=[]
       var pre=0
-      console.log(days)
         days.forEach(item=>{
           item.week=getYearWeek(item.stock_date)
           if(item.week < pre){
@@ -261,6 +268,9 @@ Page({
           days:weeks.reverse()
         })
       })
+      
+      this.getCangwei(res.data.data[0].match_id)
+
       $api.getWinLose({match_id:res.data.data[0].match_id}).then(res1=>{
           this.setData({
             groups:res1.data.data
@@ -293,6 +303,58 @@ Page({
       })
     })
   },
+  getCangwei(mid){
+    $api.getCangweiList({match_id:mid}).then(res=>{
+      var days=res.data.data.list,weeks=[]
+      days=days.reverse()
+      var ncangwei = []
+
+      for(let i=0;i<100;i++){
+        ncangwei.push({
+          name:'',
+          data:[],
+          total:0
+        })
+      }
+      var pre=0;
+      days.forEach(item=>{
+        var w=this.getWeekNumber(item.stock_date)
+        if(w<pre){
+          if(w==1){
+            ncangwei[pre-1].data.push(item)
+          }else{
+            ncangwei[pre+w-2].data.push(item)
+          }
+        }else{
+          ncangwei[w-1].data.push(item)
+          pre=w
+        } 
+      })
+      
+      ncangwei=ncangwei.filter(item=>item.data.length>0)
+      
+      var w_text=['一','二','三','四','五','六','七','八','九','十','十一','十二','十三','十四','十五']
+      ncangwei.forEach((item,index)=>{
+        if(item.data.length>0){
+          item.name='第'+w_text[index]+'周'
+          var total=0
+          var money = 10000.0
+          item.data.forEach(i=>{
+            i.date=(new Date(i.stock_date).getMonth()+1)+'/'+(new Date(i.stock_date).getDate())
+          })
+        }
+      })
+
+      records = res.data.data.list
+      this.setData({
+        ec: {
+          onInit:initChart
+        },
+        cangwei:ncangwei.reverse()
+      })
+
+    })
+  },
   //计算周数
   getWeekNumber:function(dateString) {
     const date = new Date(dateString);
@@ -379,13 +441,15 @@ Page({
 },
 tapGroup(e){
   wx.navigateTo({
-    url: '../avg/avg?index='+e.currentTarget.dataset.index + '&list=' + encodeURIComponent(JSON.stringify(this.data.groups.group_win_lose_list)),
+    url: '../avg/avg?index='+e.currentTarget.dataset.index + '&match_id=' + this.data.groups.group_win_lose_list[0].match_id +
+    '&match_name=' + this.data.groups.group_win_lose_list[0].match_name,
   })
 },
 
 tapAvg(e){
   wx.navigateTo({
-    url: '../avg/avg?index=0' + '&list=' + encodeURIComponent(JSON.stringify(this.data.groups.group_win_lose_list)),
+    url: '../avg/avg?index=0' + '&match_id=' + this.data.groups.group_win_lose_list[0].match_id +
+    '&match_name=' + this.data.groups.group_win_lose_list[0].match_name,
   })
 },
   //预览
@@ -493,6 +557,7 @@ tapAvg(e){
 
     }
   },
+  
   onShow: function (e) {
     $api.initUser()
     
@@ -510,3 +575,86 @@ tapAvg(e){
     }
   },
 })
+function initChart(canvas, width, height, dpr) {
+  var xdata = [], ydata = [];
+  records = records
+  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: 50,
+      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: {
+        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;
+}

+ 3 - 1
pages/index/index.json

@@ -1,3 +1,5 @@
 {
-  "usingComponents": {}
+  "usingComponents": {
+    "ec-canvas": "../../ec-canvas/ec-canvas"
+  }
 }

+ 21 - 1
pages/index/index.wxml

@@ -120,13 +120,33 @@
         </view>
         </view>
         <view class="week_total">
-          周收益
+          <view>周收益</view>
           <text class="{{item.total < 0 ?'down':'up'}}">{{item.total}}%</text>
         </view>
       </view>
   </view>
 </view>
 
+<view class="up-down-view" style="padding: 25rpx;">
+  <view class="article-title" > 选手人均仓位</view>
+  <view wx:if='{{cangwei.length>0}}' class=" ">
+      <view wx:for='{{cangwei}}' wx:if='{{item.data.length>0}}' class="yk">
+        <view class="week_name">{{item.name}}</view>
+        <view class="week_incom">
+          <view wx:for='{{item.data}}' wx:for-item='week' class="{{week.today_income=='0.0%' ?'none':''}} {{week.today_income[0]=='-' ?'down':'up'}}">
+            {{week.date}}
+            <text>{{week.today_cangwei_avg}}</text>
+        </view>
+        </view>
+      </view>
+  </view>
+</view>
+
+<view class="container">
+  <ec-canvas   ec="{{ ec }}">
+  </ec-canvas>
+</view>
+
 <view wx:if="{{isWeek || isScore}}" class="up-down-view" style="padding: 25rpx;">
   <view class="article-title" > 今日市场打分</view>
   <view wx:if='{{scoredays.length>0}}' class=" ">

+ 19 - 1
pages/index/index.wxss

@@ -677,7 +677,7 @@ scroll-view{
 .week_total{
   width: 15%;
   text-align: center;
-  padding: 10rpx 0;
+  /* padding: 0rpx 0; */
 }
 .week_incom{
   width: 70%;
@@ -719,4 +719,22 @@ scroll-view{
 }
 .score view view{
   height: 15rpx;
+}
+.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;
 }

+ 14 - 4
pages/matchdetail/matchdetail.js

@@ -111,7 +111,7 @@ Page({
       let stock_date=res.data.data.today_record.stock_date.split('-')
       records       = res.data.data.records
       today_stock   = res.data.data.today_record.today_stock
-      console.log(records,2323)
+      // console.log(records,2323)
       let tmoney = ((res.data.data.today_record.today_fund - res.data.data.today_record.init_fund)*10000).toFixed(0)
       this.getWeek(records)
       this.setData({
@@ -173,16 +173,26 @@ Page({
   getWeek(list){
     var days=list,weeks=[]
     days=days.reverse()
-    for(let i=0;i<55;i++){
+    for(let i=0;i<100;i++){
       weeks.push({
         name:'',
         data:[],
         total:0
       })
     }
+    var pre=0;
     days.forEach(item=>{
       var w=this.getWeekNumber(item.stock_date)
-      weeks[w-1].data.push(item)
+      if(w<pre){
+        if(w==1){
+          weeks[pre-1].data.push(item)
+        } else{
+          weeks[pre+w-2].data.push(item)
+        }
+      }else{
+        weeks[w-1].data.push(item)
+        pre=w
+      } 
     })
     weeks=weeks.filter(item=>item.data.length>0)
     var w_text=['一','二','三','四','五','六','七','八','九','十','十一','十二','十三','十四','十五']
@@ -232,7 +242,7 @@ Page({
   },
 
   preview(e){
-    console.log(e)
+    // console.log(e)
     wx.previewImage({
       urls: e.target.dataset.urls,
       current: e.target.dataset.src

+ 1 - 1
pages/stock/stock.wxml

@@ -33,7 +33,7 @@
         </view>
         <scroll-view wx:if='{{cur==1}}' bindscrolltolower='next1' scroll-y='{{true}}' style="height:calc(100vh - 90rpx);">
             <navigator hover-class="none" class="player" wx:for='{{list}}' bind:tap="pushToday" data-match_id="{{item.match_id}}" data-record_id="{{item.id}}" data-user_id = "{{item.user_id}}">
-              <view class="name">{{item.username}}  <text>{{item.badge}}</text> 
+              <view class="name">{{item.username}} 
               </view> 
               <view class="info">
                           资产:<view><label style="font-weight: 600;">{{item.today_fund}}w</label>(今日收益 <text  class="{{item.today_income[0]=='-' ?'down':'up'}}">{{item.today_income}}</text><text style="color:#F5F5F5;">  |  </text>总收益<text  class="{{item.total_income[0]=='-' ?'down':'up'}}">{{item.total_income}}</text>)</view>

+ 0 - 1
pages/upload/upload.js

@@ -281,7 +281,6 @@ Page({
 
   loadOcr(path,url){
     var _this = this
-    console.log(path,url)
     wx.getImageInfo({
       src:path,
       success:function(ires){

+ 5 - 0
pages/winlost/winlost.js

@@ -52,6 +52,11 @@ Page({
       curs:curs
     })
 },
+tapAvg(e){
+  wx.navigateTo({
+    url: '../avg/avg?index=0' + '&match_id=' + e.currentTarget.dataset.match_id + '&match_name=' + e.currentTarget.dataset.match_name
+  })
+},
   
   /**
    * 生命周期函数--监听页面初次渲染完成

+ 2 - 0
pages/winlost/winlost.wxml

@@ -3,7 +3,9 @@
 <view class="up-down-view" wx:for="{{winLost}}" wx:for-item="list">
   <view class="up-title">
         {{list.match_name}}
+        <navigator bind:tap="tapAvg" data-match_id='{{list.match_id}}' data-match_name='{{list.match_name}}'>指数<image class="more-image" mode="widthFix" src="../../images/right_icon.png"></image></navigator>
   </view>
+
   <view class="tab">
     <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>

+ 12 - 0
pages/winlost/winlost.wxss

@@ -108,4 +108,16 @@ image.number{
   font-size: 30rpx;
   margin-bottom: 10rpx;
   display: block;
+}
+
+.up-title navigator{
+  float: right;
+  font-size: 28rpx;
+  top:5rpx;
+}
+
+.more-image{
+  width: 32rpx;
+  position: relative;
+  top:8rpx;
 }

+ 2 - 0
utils/api.js

@@ -225,6 +225,8 @@ const API = {
   checkMark: (data) => request(GET, `/api/wx/v3/user/markscore/check`, data),
   getMark: (data) => request(GET, `/api/wx/v3/user/markscore/weekavg`, data),
   contentCheck: (data) => request(POST, `/api/wx/v3/msg/content/check`, data),
+  getMatchGroupList: (data) => request(GET, `/api/wx/v3/match/group/list`, data),
+  getCangweiList: (data) => request(GET, `/api/wx/v3/match/cangwei/avg/allday`, data),
   initUser:() => initUser(),
   checkUser:() => checkUser(),
   checkUserRole:() => checkUserRole(),