tanyanfei 4 ヶ月 前
コミット
4971778542
4 ファイル変更124 行追加4 行削除
  1. 76 0
      pages/index/index.js
  2. 28 0
      pages/index/index.wxml
  3. 17 3
      pages/index/index.wxss
  4. 3 1
      utils/api.js

+ 76 - 0
pages/index/index.js

@@ -29,8 +29,18 @@ Page({
     groups:{},
     role:0,
     match_day:0,
+    socore:[10,9,8,7,6,5,4,3,2,1],
+    isScore:0,
+    isWeek:0,
+    scoredays:[]
   },
   onLoad() {
+    var w=new Date().getDay()
+    if(w == 0 || w == 6){
+      this.setData({
+        isWeek:1
+      })
+    }
     wx.showNavigationBarLoading()
     wx.getStorage({
       key: 'user',
@@ -50,10 +60,76 @@ Page({
           notices:res.data.data
         })
       })
+      // 是否打分
+      if(!this.data.isWeek){
+        $api.checkMark({stock_date:this.data.date}).then(res=>{
+          if(res.data.data){
+            this.setData({
+              isScore:1
+            })
+          }
+        })
+      }
+      
     })
     this.getFollow()
     this.getIndexData()
     this.getExp()
+    this.getWeekAvg()
+   
+  },
+  getWeekAvg:function(){
+    $api.getMark().then(res=>{
+      var days=res.data.data,weeks={}
+        days.forEach(item=>{
+          item.week=getYearWeek(item.stock_date)
+          item.date=(new Date(item.stock_date).getMonth()+1)+'/'+(new Date(item.stock_date).getDate())
+          weeks[item.week]=[]
+        })
+        days.forEach(item=>{
+          weeks[item.week].push(item)
+        })
+        var scoredays=[]
+        for (let key in weeks) {
+          scoredays.push({
+            name:key,
+            data:weeks[key]
+          })
+        }
+        this.setData({
+          scoredays:scoredays.reverse()
+        })
+    })
+    
+
+    function getYearWeek(endDate) {
+        //本年的第一天
+        endDate=new Date(endDate)
+        var beginDate = new Date(endDate.getFullYear(), 0, 1);
+        //星期从0-6,0代表星期天,6代表星期六
+        var endWeek = endDate.getDay();
+        if (endWeek == 0) endWeek = 7;
+        var beginWeek = beginDate.getDay();
+        if (beginWeek == 0) beginWeek = 7;
+        //计算两个日期的天数差
+        var millisDiff = endDate.getTime() - beginDate.getTime();
+        var dayDiff = Math.floor(( millisDiff + (beginWeek - endWeek) * (24 * 60 * 60 * 1000)) / 86400000);
+        return Math.ceil(dayDiff / 7) + 1;
+    } 
+
+  },
+  radioChange:function(e){
+    this.setData({
+      s:e.detail.value
+    })
+    $api.markScore({stock_date:this.data.date,score:e.detail.value}).then(res=>{
+      console.log(res)
+      if(res.data.code == 0){
+          wx.showToast({
+            title: '打分成功',
+          })
+      }
+    })
   },
   fresh: function () {
 

+ 28 - 0
pages/index/index.wxml

@@ -124,6 +124,34 @@
   </view>
 </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=" ">
+      <view wx:for='{{scoredays}}' 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.avg_score < 5 ?'down':'up'}}">
+            {{week.date}}
+            <text>{{week.avg_score}}</text>
+        </view>
+        </view>
+       
+      </view>
+  </view>
+</view>
+<view wx:else class="up-down-view" style="padding: 25rpx;">
+  <view class="article-title" > 请给今日市场打分</view>
+  <radio-group bindchange="radioChange">
+    <view  class="score" wx:for="{{socore}}">
+      <text>{{item}}分</text>
+      <view>
+        <view style="background-color: {{filters.getColor()}};width:{{item/10*100}}%"></view>
+      </view>
+      <radio value="{{item}}"></radio>
+    </view>
+  </radio-group>
+</view>
+
 <view class="up-down-view">
   <view class="up-title">
         {{winLost.match_name}}<label wx:if="{{match_day >= 0}}">开赛第{{match_day}}天</label>

+ 17 - 3
pages/index/index.wxss

@@ -666,7 +666,7 @@ scroll-view{
 
 .yk{
   display: flex;
-  justify-content: space-between;
+  /* justify-content: space-between; */
   font-size: 24rpx;
 }
 .week_name{
@@ -684,8 +684,8 @@ scroll-view{
   display: flex;
 }
 .week_incom>view{
-  padding: 10rpx 0;
-  width: 100rpx;
+  padding: 5px 0;
+  width: 20%;
   text-align: center;
   /* border: 1px solid red; */
 }
@@ -704,4 +704,18 @@ scroll-view{
 .week_incom .none{
   background-color: #a3a3a3;
   /* color: #fff !important; */
+}
+
+.score{
+  display: flex;
+  justify-content: space-between;
+  align-items: center;
+  margin-bottom: 10rpx;
+}
+
+.score>view{
+  width: 75%;
+}
+.score view view{
+  height: 15rpx;
 }

+ 3 - 1
utils/api.js

@@ -217,7 +217,9 @@ const API = {
   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),
   getWinlossRank: (data) => request(GET, `/api/wx/v3/user/match/stock/winlossrank/list`, data),
-  
+  markScore: (data) => request(POST, `/api/wx/v3/user/markscore`, data),
+  checkMark: (data) => request(GET, `/api/wx/v3/user/markscore/check`, data),
+  getMark: (data) => request(GET, `/api/wx/v3/user/markscore/weekavg`, data),
   initUser:() => initUser(),
 
 };