Showing
6 changed files
with
358 additions
and
8 deletions
1 | +<template> | ||
2 | + <div class="progress-box"> | ||
3 | + <!-- 绘制圆环背景 --> | ||
4 | + <canvas class="progress-bg" id="canvasProgressbg" /> | ||
5 | + <!-- 绘制加载中圆弧 --> | ||
6 | + <canvas class="progress-canvas" id="canvasProgress" /> | ||
7 | + </div> | ||
8 | +</template> | ||
9 | + | ||
10 | +<script> | ||
11 | +import incomeItem from './incomeItem' | ||
12 | +export default { | ||
13 | + name: 'income-detail', | ||
14 | + props: { | ||
15 | + data: { | ||
16 | + type: Array, | ||
17 | + default: [] | ||
18 | + } | ||
19 | + }, | ||
20 | + data() { | ||
21 | + return { | ||
22 | + | ||
23 | + }; | ||
24 | + }, | ||
25 | + methods: { | ||
26 | + /** | ||
27 | + * 画progress底部背景 | ||
28 | + */ | ||
29 | + drawProgressbg: function (summary) { | ||
30 | + var c=document.getElementById("canvasProgressbg"); | ||
31 | + var cxt=c.getContext("2d"); | ||
32 | + // 设置圆环的宽度 | ||
33 | + ctx.setLineWidth(28 * radio); | ||
34 | + // 设置圆环的颜色 | ||
35 | + let strokeColor = '#E0E0E0' | ||
36 | + if (summary && summary.totalIncome > 0) { | ||
37 | + strokeColor = '#65AB85'; | ||
38 | + } | ||
39 | + ctx.setStrokeStyle(strokeColor); | ||
40 | + // 设置圆环端点的形状 | ||
41 | + ctx.setLineCap('round') | ||
42 | + //开始一个新的路径 | ||
43 | + ctx.beginPath(); | ||
44 | + //设置一个原点(110,110),半径为100的圆的路径到当前路径 | ||
45 | + console.log("起始点:" + Math.PI) | ||
46 | + ctx.arc(120 * radio, 120 * radio, 100 * radio, 0, 2 * Math.PI, false); | ||
47 | + //对当前路径进行描边 | ||
48 | + ctx.stroke(); | ||
49 | + //开始绘制 | ||
50 | + ctx.draw(); | ||
51 | + }, | ||
52 | + | ||
53 | + /** | ||
54 | + * 画progress进度 | ||
55 | + */ | ||
56 | + drawCircle: function (step) { | ||
57 | + // 使用 wx.createContext 获取绘图上下文 context | ||
58 | + var context = wx.createCanvasContext('canvasProgress'); | ||
59 | + // 设置圆环的宽度 | ||
60 | + context.setLineWidth(28 * radio); | ||
61 | + // 设置圆环的颜色 | ||
62 | + let strokeColor = '#002B47' | ||
63 | + // if (this.data.summary.totalIncome <= 0){ | ||
64 | + // strokeColor = '#E0E0E0'; | ||
65 | + // } | ||
66 | + context.setStrokeStyle(strokeColor); | ||
67 | + // 设置圆环端点的形状 | ||
68 | + context.setLineCap('round') | ||
69 | + //开始一个新的路径 | ||
70 | + context.beginPath(); | ||
71 | + //参数step 为绘制的圆环周长,从0到2为一周 。 -Math.PI / 2 将起始角设在12点钟位置 ,结束角 通过改变 step 的值确定 | ||
72 | + context.arc(120 * radio, 120 * radio, 100 * radio, -Math.PI / 2, step * Math.PI - Math.PI / 2, false); | ||
73 | + //对当前路径进行描边 | ||
74 | + context.stroke(); | ||
75 | + //开始绘制 | ||
76 | + context.draw() | ||
77 | + }, | ||
78 | + | ||
79 | + /** | ||
80 | + * 开始progress | ||
81 | + */ | ||
82 | + startProgress: function (summary) { | ||
83 | + | ||
84 | + // 设置倒计时 定时器 每100毫秒执行一次,计数器count+1 ,耗时6秒绘一圈 | ||
85 | + if (summary && summary.totalIncome > 0) { | ||
86 | + // this.countTimer = setInterval(() => { | ||
87 | + | ||
88 | + // if (this.data.count <= 60) { | ||
89 | + /* 绘制彩色圆环进度条 | ||
90 | + 注意此处 传参 step 取值范围是0到2, | ||
91 | + 所以 计数器 最大值 60 对应 2 做处理,计数器count=60的时候step=2 | ||
92 | + */ | ||
93 | + this.drawCircle(summary.goodsIncome / (summary.totalIncome / 2)) | ||
94 | + // if() | ||
95 | + // this.data.count++; | ||
96 | + // } | ||
97 | + // else { | ||
98 | + // clearInterval(this.countTimer); | ||
99 | + // this.startProgress(); | ||
100 | + // } | ||
101 | + // }, 100) | ||
102 | + } | ||
103 | + }, | ||
104 | + }, | ||
105 | + components: { | ||
106 | + incomeItem | ||
107 | + } | ||
108 | + | ||
109 | +}; | ||
110 | +</script> | ||
111 | + | ||
112 | +<style lang="scss" scoped> | ||
113 | +.total-income { | ||
114 | + font-size: 36px; | ||
115 | + padding: 15px; | ||
116 | + border-bottom: solid 1px #eee; | ||
117 | +} | ||
118 | +.no-data { | ||
119 | + color: #ccc; | ||
120 | + font-weight: bold; | ||
121 | + text-align: center; | ||
122 | + font-size: 42px; | ||
123 | + padding: 100px 0; | ||
124 | + } | ||
125 | +</style> |
1 | +<template> | ||
2 | + <div class="income-detail-header"> | ||
3 | + <p class="total-income">收入明细</p> | ||
4 | + <div v-if="data.length === 0" class="no-data">暂无收入明细</div> | ||
5 | + <div v-else> | ||
6 | + <incomeItem :data="data"></incomeItem> | ||
7 | + </div> | ||
8 | + </div> | ||
9 | +</template> | ||
10 | + | ||
11 | +<script> | ||
12 | +import incomeItem from './incomeItem' | ||
13 | +export default { | ||
14 | + name: 'income-detail', | ||
15 | + props: { | ||
16 | + data: { | ||
17 | + type: Array, | ||
18 | + default: [] | ||
19 | + } | ||
20 | + }, | ||
21 | + data() { | ||
22 | + return { | ||
23 | + | ||
24 | + }; | ||
25 | + }, | ||
26 | + components: { | ||
27 | + incomeItem | ||
28 | + } | ||
29 | + | ||
30 | +}; | ||
31 | +</script> | ||
32 | + | ||
33 | +<style lang="scss" scoped> | ||
34 | +.total-income { | ||
35 | + font-size: 36px; | ||
36 | + padding: 15px; | ||
37 | + border-bottom: solid 1px #eee; | ||
38 | +} | ||
39 | +.no-data { | ||
40 | + color: #ccc; | ||
41 | + font-weight: bold; | ||
42 | + text-align: center; | ||
43 | + font-size: 42px; | ||
44 | + padding: 100px 0; | ||
45 | + } | ||
46 | +</style> |
1 | +<template> | ||
2 | + <div class="income-header"> | ||
3 | + <p class="total-income">收入: {{data.totalIncome}}</p> | ||
4 | + <div class="income"> | ||
5 | + <span class="dot1"></span> | ||
6 | + <span class="income-name">货款收入</span> | ||
7 | + <span class="income-num">{{data.goodsIncome}}</span> | ||
8 | + </div> | ||
9 | + <div class="income"> | ||
10 | + <span class="dot2"></span> | ||
11 | + <span class="income-name">补偿收入</span> | ||
12 | + <span class="income-num">{{data.compensateIncome}}</span> | ||
13 | + </div> | ||
14 | + </div> | ||
15 | +</template> | ||
16 | + | ||
17 | +<script> | ||
18 | + | ||
19 | +export default { | ||
20 | + name: 'income-header', | ||
21 | + props: { | ||
22 | + data: { | ||
23 | + type: Object, | ||
24 | + default: {} | ||
25 | + } | ||
26 | + }, | ||
27 | + data() { | ||
28 | + return { | ||
29 | + | ||
30 | + }; | ||
31 | + }, | ||
32 | + | ||
33 | + | ||
34 | +}; | ||
35 | +</script> | ||
36 | + | ||
37 | +<style lang="scss" scoped> | ||
38 | +.income-header { | ||
39 | + margin: 50px 0; | ||
40 | +} | ||
41 | +.total-income { | ||
42 | + font-size: 36px; | ||
43 | + margin-bottom: 40px; | ||
44 | +} | ||
45 | +.income { | ||
46 | + margin-bottom: 15px; | ||
47 | + font-size: 24px; | ||
48 | + .dot1,.dot2 { | ||
49 | + display: inline-block; | ||
50 | + width: 16px; | ||
51 | + height: 16px; | ||
52 | + border-radius: 16px; | ||
53 | + } | ||
54 | + .dot1 { | ||
55 | + background-color: #002B47; | ||
56 | + } | ||
57 | + .dot2 { | ||
58 | + background-color: #65AB85; | ||
59 | + } | ||
60 | + .income-name { | ||
61 | + color: #999; | ||
62 | + } | ||
63 | +} | ||
64 | +</style> |
1 | +<template> | ||
2 | + <div class="assets-record-container"> | ||
3 | + <div class='assets-record-info-detail-view'> | ||
4 | + <div class='assets-record-left-view'> | ||
5 | + <img class='assets-record-image-style' :src='data.tradeType == 2 ?"" : ""' /> | ||
6 | + <div class='assets-record-middle-view'> | ||
7 | + <span class='assets-record-code-txt'>{{data.tradeTypeDesc}}(订单号:{{data.orderCode}})</span> | ||
8 | + <span class='assets-record-time-txt'>{{data.createTime}}</span> | ||
9 | + </div> | ||
10 | + </div> | ||
11 | + <div class='assets-record-right-view'> | ||
12 | + <span class='assets-record-income-txt'>+{{data.amount}}</span> | ||
13 | + <span class='assets-record-income-tip-txt' v-if="!data.normalFlag">打款失败</span> | ||
14 | + </div> | ||
15 | + </div> | ||
16 | + </div> | ||
17 | +</template> | ||
18 | + | ||
19 | +<script> | ||
20 | + | ||
21 | +export default { | ||
22 | + name: 'income-item', | ||
23 | + props: { | ||
24 | + data: { | ||
25 | + type: Object, | ||
26 | + default: {} | ||
27 | + } | ||
28 | + }, | ||
29 | + data() { | ||
30 | + return { | ||
31 | + | ||
32 | + }; | ||
33 | + }, | ||
34 | + | ||
35 | + | ||
36 | +}; | ||
37 | +</script> | ||
38 | + | ||
39 | +<style lang="scss" scoped> | ||
40 | + .assets-record-container { | ||
41 | + display: flex; | ||
42 | + flex-direction: column; | ||
43 | + justify-content: space-between; | ||
44 | + border-bottom: solid 1px #E0E0E0; | ||
45 | + /* background: #ee00dd; */ | ||
46 | + /* position: fixed; */ | ||
47 | +} | ||
48 | + | ||
49 | +.assets-record-info-detail-view { | ||
50 | + display: flex; | ||
51 | + flex-direction: row; | ||
52 | + justify-content: space-between; | ||
53 | + align-items: center; | ||
54 | + padding-top: 30px; | ||
55 | + padding-bottom: 30px; | ||
56 | +} | ||
57 | +.assets-record-left-view { | ||
58 | + display: flex; | ||
59 | + flex-direction: row; | ||
60 | + align-items: center; | ||
61 | + | ||
62 | +} | ||
63 | +.assets-record-middle-view { | ||
64 | + display: flex; | ||
65 | + flex-direction: column; | ||
66 | + margin-left: 20px; | ||
67 | +} | ||
68 | +.assets-record-right-view { | ||
69 | + display: flex; | ||
70 | + flex-direction: column; | ||
71 | + align-items: center; | ||
72 | +} | ||
73 | +.assets-record-image-style { | ||
74 | + width: 48px; | ||
75 | + height: 48px; | ||
76 | + /* background: #00ff */ | ||
77 | +} | ||
78 | +.assets-record-code-txt { | ||
79 | + font-family: PingFang-SC-Regular; | ||
80 | + font-size: 28px; | ||
81 | + color: #000000; | ||
82 | +} | ||
83 | +.assets-record-time-txt { | ||
84 | + font-family: SFProText-Regular; | ||
85 | + font-size: 24px; | ||
86 | + color: #999999; | ||
87 | + margin-top: 12px; | ||
88 | +} | ||
89 | +.assets-record-income-txt { | ||
90 | + font-family: SFProText-Medium; | ||
91 | + font-weight: bold; | ||
92 | + font-size: 28px; | ||
93 | + color: #000000; | ||
94 | +} | ||
95 | +.assets-record-income-tip-txt { | ||
96 | + font-family: PingFang-SC-Regular; | ||
97 | + font-size: 20px; | ||
98 | + color: #D0021B; | ||
99 | +} | ||
100 | +</style> |
1 | <template> | 1 | <template> |
2 | <LayoutApp :show-back="true"> | 2 | <LayoutApp :show-back="true"> |
3 | <div class="body" ref="body"> | 3 | <div class="body" ref="body"> |
4 | - <h2>trade</h2> | 4 | + <h1>我的收入</h1> |
5 | + <incomeHeader :data="incomeSum"></incomeHeader> | ||
6 | + <incomeDetail></incomeDetail> | ||
5 | </div> | 7 | </div> |
6 | </LayoutApp> | 8 | </LayoutApp> |
7 | </template> | 9 | </template> |
8 | 10 | ||
9 | <script> | 11 | <script> |
10 | -// import tabItem from './components/tabItem'; | ||
11 | - | 12 | +import incomeHeader from './components/incomeHeader'; |
13 | +import incomeDetail from './components/incomeDetail'; | ||
12 | import { createNamespacedHelpers } from 'vuex'; | 14 | import { createNamespacedHelpers } from 'vuex'; |
13 | 15 | ||
14 | -const {mapGetters, mapActions} = createNamespacedHelpers('home/mine'); | 16 | +const {mapState, mapActions} = createNamespacedHelpers('home/mine'); |
15 | export default { | 17 | export default { |
16 | data() { | 18 | data() { |
17 | return { | 19 | return { |
@@ -19,6 +21,16 @@ export default { | @@ -19,6 +21,16 @@ export default { | ||
19 | } | 21 | } |
20 | }, | 22 | }, |
21 | computed:{ | 23 | computed:{ |
24 | + ...mapState({ | ||
25 | + incomeSum:(state) => { | ||
26 | + return { | ||
27 | + goodsIncome: state.assetData.goodsIncome, | ||
28 | + totalIncome: state.assetData.totalIncome, | ||
29 | + compensateIncome: state.assetData.compensateIncome | ||
30 | + } | ||
31 | + }, | ||
32 | + incomeData: (state) => state.assetData | ||
33 | + }), | ||
22 | 34 | ||
23 | }, | 35 | }, |
24 | created() { | 36 | created() { |
@@ -30,7 +42,8 @@ export default { | @@ -30,7 +42,8 @@ export default { | ||
30 | ...mapActions(['fetchAssets']) | 42 | ...mapActions(['fetchAssets']) |
31 | }, | 43 | }, |
32 | components: { | 44 | components: { |
33 | - | 45 | + incomeHeader, |
46 | + incomeDetail | ||
34 | } | 47 | } |
35 | }; | 48 | }; |
36 | </script> | 49 | </script> |
@@ -25,9 +25,9 @@ export default function() { | @@ -25,9 +25,9 @@ export default function() { | ||
25 | list: [], | 25 | list: [], |
26 | currentPage: 1, | 26 | currentPage: 1, |
27 | endReached: false, | 27 | endReached: false, |
28 | - compensateIncome: 0, | ||
29 | - goodsIncome: 0, | ||
30 | - totalIncome: 0 | 28 | + compensateIncome: '¥0.00', |
29 | + goodsIncome: '¥0.00', | ||
30 | + totalIncome: '¥0.00' | ||
31 | }, | 31 | }, |
32 | resource1: {}, | 32 | resource1: {}, |
33 | resource2: {} | 33 | resource2: {} |
@@ -115,6 +115,8 @@ export default function() { | @@ -115,6 +115,8 @@ export default function() { | ||
115 | }, | 115 | }, |
116 | addAssets(state, assetData) { | 116 | addAssets(state, assetData) { |
117 | assetData.totalIncome = formatNumber(assetData.totalIncome); | 117 | assetData.totalIncome = formatNumber(assetData.totalIncome); |
118 | + assetData.compensateIncome = formatNumber(assetData.compensateIncome); | ||
119 | + assetData.goodsIncome = formatNumber(assetData.goodsIncome); | ||
118 | state.assetData = Object.assign({}, state.assetData, assetData); | 120 | state.assetData = Object.assign({}, state.assetData, assetData); |
119 | }, | 121 | }, |
120 | 122 |
-
Please register or login to post a comment