|
@@ -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 () {
|
|
|
|