tanyanfei hace 3 años
padre
commit
06b7a01adb
Se han modificado 8 ficheros con 166 adiciones y 10 borrados
  1. 5 3
      app.json
  2. BIN
      images/left.png
  3. BIN
      images/right.png
  4. 12 7
      pages/rank/rank.js
  5. 68 0
      pages/today/today.js
  6. 23 0
      pages/today/today.wxml
  7. 56 0
      pages/today/today.wxss
  8. 2 0
      utils/api.js

+ 5 - 3
app.json

@@ -1,7 +1,9 @@
 {
   "pages": [
-    
     "pages/index/index",
+    "pages/rank/rank",
+    "pages/today/today",
+    
     "pages/stock/stock",
     "pages/upload/upload",
     "pages/user/user",
@@ -13,13 +15,13 @@
     "pages/day/day",
     "pages/games/games",
     "pages/search/search",
-    "pages/rank/rank",
+    
     "pages/style/style",
     "pages/detail/detail",
     
     
     "pages/list/list",
-    "pages/today/today",
+    
     "pages/comment/comment"
     
     

BIN
images/left.png


BIN
images/right.png


+ 12 - 7
pages/rank/rank.js

@@ -14,12 +14,12 @@ Page({
    * 生命周期函数--监听页面加载
    */
   onLoad: function (options) {
-    var y = new Date().getFullYear(), m = (new Date().getMonth() + 1), d = new Date().getDate();
-    m = m > 9 ? m : '0' + m;
-    d = d > 9 ? d : '0' + d;
-    this.setData({
-      date: y + '-' + m + '-' + d
-    })
+    // var y = new Date().getFullYear(), m = (new Date().getMonth() + 1), d = new Date().getDate();
+    // m = m > 9 ? m : '0' + m;
+    // d = d > 9 ? d : '0' + d;
+    // this.setData({
+    //   date: y + '-' + m + '-' + d
+    // })
     
     $api.getDate().then(res => {
       this.setData({
@@ -62,7 +62,12 @@ Page({
   onShow: function () {
     wx.hideNavigationBarLoading()
     if (!this.data.datas.groups){
-      this.getData()
+      $api.getDate().then(res => {
+        this.setData({
+          date: res.data.data
+        })
+        this.getData()
+      })
     }
     
   },

+ 68 - 0
pages/today/today.js

@@ -8,6 +8,8 @@ Page({
    * 页面的初始数据
    */
   data: {
+    date:'2021-11',
+    days:[],
     ec: {
       onInit: null
     },
@@ -20,6 +22,8 @@ Page({
    * 生命周期函数--监听页面加载
    */
   onLoad: function (options) {
+    
+
     // options.id = 7, options.record_id = 29014
     id = options.id, record_id = options.record_id
     this.setData({
@@ -28,6 +32,33 @@ Page({
       player_id: options.player_id ? options.player_id:''
     })
     this.getData();
+    
+  },
+  getDays(){
+    // match_id   player_id  month: "2021-12"
+    $api.getCalendar({
+      player_id: this.data.player_id,
+      match_id:this.data.id,
+      month: this.data.date
+    }).then(res=>{
+      console.log(res.data.data)
+      var days = [], w = new Date(this.data.date + '-01').getDay();
+      for (let i = 0; i < w; i++) {
+        days.push({
+          day: '',
+          income: ''
+        })
+      }
+      for (let i = 0; i < res.data.data.length; i++) {
+        days.push({
+          day: i+1,
+          income: res.data.data[i].today_income
+        })
+      }
+      this.setData({
+        days: days
+      })
+    })
   },
   getData(){
     wx.showNavigationBarLoading();
@@ -42,8 +73,10 @@ Page({
       data.record_id = this.data.record_id
     }
     $api.getPlayerMatch(data).then(res=>{
+      let stock_date=res.data.data.today_record.stock_date.split('-')
       this.setData({
         datas: res.data.data,
+        date: stock_date[0] + '-' + stock_date[1],
         is_follow: res.data.data.is_follow,
         ec: {
           onInit: initChart
@@ -54,6 +87,7 @@ Page({
       })
       records = res.data.data.records
       today_stock = res.data.data.today_record.today_stock
+      this.getDays()
       wx.hideNavigationBarLoading()
     })
     .catch(err=>{
@@ -69,6 +103,40 @@ Page({
         })
     })
   },
+  bindDateChange(e){
+    this.setData({
+      date: e.detail.value
+    })
+    this.getDays()
+  },
+  prev(){
+    var date=this.data.date.split('-'),y=date[0],m=date[1];
+    if(m>1){
+      m--
+    }else{
+      m=12
+      y--
+    }
+    m=(m>9)?m:'0'+m
+    this.setData({
+      date: y+'-'+m
+    })
+    this.getDays()
+  },
+  next() {
+    var date = this.data.date.split('-'), y = date[0], m = date[1];
+    if (m < 12) {
+      m++
+    } else {
+      m = 1
+      y++
+    }
+    m = (m > 9) ? m : '0' + m
+    this.setData({
+      date: y + '-' + m
+    })
+    this.getDays()
+  },
   //预览
   preview(e) {
     wx.previewImage({

+ 23 - 0
pages/today/today.wxml

@@ -69,6 +69,29 @@
           </ec-canvas>
     </view>
 </view>
+<view class="content">
+  <view class="title">每月盈亏</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}}'>
+      {{item.day}}
+      <text>{{item.income}}</text>
+    </view>
+  </view>
+</view>
 
 <view class="days_stock">
   <view class="title">每日持股

+ 56 - 0
pages/today/today.wxss

@@ -120,6 +120,7 @@ ec-canvas {
   margin-bottom: 20rpx;
   background: #fff;
   padding: 30rpx;
+  position: relative;
 }
 .img{
   display: inline-block;
@@ -164,4 +165,59 @@ ec-canvas {
   width: 32rpx;
   position: relative;
   top: 7rpx;
+}
+
+.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;
+  margin-bottom: 10rpx;
+}
+.days text{
+  display: block;
+  color: #666;
+  font-size: 20rpx;
+  position: relative;
+  top: -5rpx;
+  font-weight: 400;
 }

+ 2 - 0
utils/api.js

@@ -129,6 +129,8 @@ const API = {
   getNotoice: (data) => request(GET, `/api/wx/v2/notices/list`, data),
   getDate: (data) => request(GET, `/api/wx/v2/default/date`, data),
   getHotFollow: (data) => request(GET, `/api/wx/v2/hot/follow/list`, data),
+  getCalendar: (data) => request(GET, `/api/wx/v2/player/match/calendar`, data),
+  
 }; 
 module.exports = {
   API: API