Showing
1 changed file
with
30 additions
and
15 deletions
@@ -23,16 +23,13 @@ Page({ | @@ -23,16 +23,13 @@ Page({ | ||
23 | let api = new MyAssetsService(); | 23 | let api = new MyAssetsService(); |
24 | this.setData({ api: api }); | 24 | this.setData({ api: api }); |
25 | this.fetchIncomeList(); | 25 | this.fetchIncomeList(); |
26 | - //绘制背景 | ||
27 | - this.drawProgressbg(); | ||
28 | - //开始progress | ||
29 | - this.startProgress(); | 26 | + |
30 | // this.setData({api: new MyAssetsService()}); | 27 | // this.setData({api: new MyAssetsService()}); |
31 | }, | 28 | }, |
32 | /** | 29 | /** |
33 | * 画progress底部背景 | 30 | * 画progress底部背景 |
34 | */ | 31 | */ |
35 | - drawProgressbg: function () { | 32 | + drawProgressbg: function (summary) { |
36 | // let summary = { | 33 | // let summary = { |
37 | // totalIncome: '130.98', | 34 | // totalIncome: '130.98', |
38 | // goodsIncome: '30.98', | 35 | // goodsIncome: '30.98', |
@@ -47,7 +44,7 @@ Page({ | @@ -47,7 +44,7 @@ Page({ | ||
47 | ctx.setLineWidth(10); | 44 | ctx.setLineWidth(10); |
48 | // 设置圆环的颜色 | 45 | // 设置圆环的颜色 |
49 | let strokeColor = '#E0E0E0' | 46 | let strokeColor = '#E0E0E0' |
50 | - if (this.data.summary.totalIncome >= 0) { | 47 | + if (summary && summary.totalIncome >= 0) { |
51 | strokeColor = '#65AB85'; | 48 | strokeColor = '#65AB85'; |
52 | } | 49 | } |
53 | ctx.setStrokeStyle(strokeColor); | 50 | ctx.setStrokeStyle(strokeColor); |
@@ -93,10 +90,10 @@ Page({ | @@ -93,10 +90,10 @@ Page({ | ||
93 | /** | 90 | /** |
94 | * 开始progress | 91 | * 开始progress |
95 | */ | 92 | */ |
96 | - startProgress: function () { | 93 | + startProgress: function (summary) { |
97 | 94 | ||
98 | // 设置倒计时 定时器 每100毫秒执行一次,计数器count+1 ,耗时6秒绘一圈 | 95 | // 设置倒计时 定时器 每100毫秒执行一次,计数器count+1 ,耗时6秒绘一圈 |
99 | - if (this.data.summary.totalIncome > 0) { | 96 | + if (summary && summary.totalIncome > 0) { |
100 | // this.countTimer = setInterval(() => { | 97 | // this.countTimer = setInterval(() => { |
101 | 98 | ||
102 | // if (this.data.count <= 60) { | 99 | // if (this.data.count <= 60) { |
@@ -126,14 +123,32 @@ Page({ | @@ -126,14 +123,32 @@ Page({ | ||
126 | that.data.api.getAssetsList(params, () => { | 123 | that.data.api.getAssetsList(params, () => { |
127 | wx.hideLoading(); | 124 | wx.hideLoading(); |
128 | }).then(data => { | 125 | }).then(data => { |
129 | - // let detail = data.data; | ||
130 | - that.setData(data); | ||
131 | - if (that.data.currentPage <= data.pagetotal){ | ||
132 | - let cPage = data.page+1; | ||
133 | - that.setData({ currentPage: cPage}); | ||
134 | - }else{ | ||
135 | - that.setData({ isLast: true }); | 126 | + if(data){ |
127 | + let detail = data.data; | ||
128 | + let summary = data.summary; | ||
129 | + let cPage = data.page; | ||
130 | + if (cPage == 1){ | ||
131 | + //绘制背景 | ||
132 | + that.drawProgressbg(summary); | ||
133 | + //开始progress | ||
134 | + that.startProgress(summary); | ||
135 | + } | ||
136 | + | ||
137 | + let isLast = false; | ||
138 | + // that.setData(data); | ||
139 | + if (that.data.currentPage <= data.pagetotal) { | ||
140 | + cPage = data.page + 1; | ||
141 | + } else { | ||
142 | + isLast = true; | ||
143 | + } | ||
144 | + that.setData({ | ||
145 | + data: detail, | ||
146 | + currentPage: cPage, | ||
147 | + isLast: isLast, | ||
148 | + summary: summary | ||
149 | + }); | ||
136 | } | 150 | } |
151 | + | ||
137 | // console.log(data); | 152 | // console.log(data); |
138 | }) | 153 | }) |
139 | }, | 154 | }, |
-
Please register or login to post a comment