|
@@ -18,7 +18,7 @@ Page({
|
|
|
onInit: null
|
|
|
},
|
|
|
datas:[],
|
|
|
- date:'',
|
|
|
+ days:[],
|
|
|
},
|
|
|
|
|
|
/**
|
|
@@ -54,30 +54,44 @@ Page({
|
|
|
$api.getAllDay(param).then(res => {
|
|
|
// console.log(res.data.data.list)
|
|
|
if(res.data.code == 0){
|
|
|
+ var week=['一','二','三','四','五','六','七','八','九','十','十一','十二','十三','十四','十五']
|
|
|
+ var days=res.data.data.list,weeks=[[]]
|
|
|
+ days=days.reverse()
|
|
|
+ week.forEach((item,index)=>{
|
|
|
+ weeks[index]={
|
|
|
+ name:'第'+item+'周',
|
|
|
+ data:[],
|
|
|
+ total:0
|
|
|
+ }
|
|
|
+ })
|
|
|
+ var i=0
|
|
|
+ days.forEach(item=>{
|
|
|
+ var w=new Date(item.stock_date).getDay()
|
|
|
+ item.day=w
|
|
|
+ if(w==1){
|
|
|
+ i++
|
|
|
+ }
|
|
|
+ weeks[i].data.push(item)
|
|
|
+ })
|
|
|
+ weeks.forEach(item=>{
|
|
|
+ if(item.data.length>0){
|
|
|
+ var total=0
|
|
|
+ var money = 10000.0
|
|
|
+ item.data.forEach(i=>{
|
|
|
+ var incom=Number(i.today_income.replace('%',''))
|
|
|
+ money += money*incom/100.0
|
|
|
+ i.date=(new Date(i.stock_date).getMonth()+1)+'/'+(new Date(i.stock_date).getDate())
|
|
|
+ })
|
|
|
+ total = (money-10000)*100.0/10000.0
|
|
|
+ item.total=total.toFixed(2)
|
|
|
+ }
|
|
|
+ })
|
|
|
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,
|
|
|
+ days:weeks.reverse()
|
|
|
})
|
|
|
}
|
|
|
})
|
|
@@ -90,32 +104,47 @@ Page({
|
|
|
}
|
|
|
$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,
|
|
|
- })
|
|
|
- }
|
|
|
-
|
|
|
+ records = res.data.data.list.reverse()
|
|
|
+ var week=['一','二','三','四','五','六','七','八','九','十','十一','十二','十三','十四','十五']
|
|
|
+ var days=res.data.data.list.reverse(),weeks=[[]]
|
|
|
+ days=days.reverse()
|
|
|
+ week.forEach((item,index)=>{
|
|
|
+ weeks[index]={
|
|
|
+ name:'第'+item+'周',
|
|
|
+ data:[],
|
|
|
+ total:0
|
|
|
+ }
|
|
|
+ })
|
|
|
+ var i=0
|
|
|
+ days.forEach(item=>{
|
|
|
+ var w=new Date(item.stock_date).getDay()
|
|
|
+ item.day=w
|
|
|
+ if(w==1){
|
|
|
+ i++
|
|
|
+ }
|
|
|
+ weeks[i].data.push(item)
|
|
|
+ })
|
|
|
+ weeks.forEach(item=>{
|
|
|
+ if(item.data.length>0){
|
|
|
+ var total=0
|
|
|
+ var money = 10000.0
|
|
|
+ item.data.forEach(i=>{
|
|
|
+ var incom=Number(i.today_income.replace('%',''))
|
|
|
+ money += money*incom/100.0
|
|
|
+ i.date=(new Date(i.stock_date).getMonth()+1)+'/'+(new Date(i.stock_date).getDate())
|
|
|
+ })
|
|
|
+ total = (money-10000)*100.0/10000.0
|
|
|
+ item.total=total.toFixed(2)
|
|
|
+ }
|
|
|
+ })
|
|
|
this.setData({
|
|
|
ec: {
|
|
|
onInit: initChart
|
|
|
},
|
|
|
- days: days,
|
|
|
- date:date,
|
|
|
+ days:weeks.reverse()
|
|
|
})
|
|
|
}
|
|
|
+
|
|
|
})
|
|
|
},
|
|
|
|
|
@@ -187,6 +216,7 @@ Page({
|
|
|
/**折线图 */
|
|
|
function initChart(canvas, width, height, dpr) {
|
|
|
var xdata = [], ydata = [];
|
|
|
+ records = records.reverse()
|
|
|
for (let i = 0; i < records.length; i++) {
|
|
|
let date = records[i].stock_date.split('-');
|
|
|
xdata.push(date[1] + '/' + date[2])
|