Authored by baoss

交易收入页面完善

<template>
<div class="progress-box">
<!-- 绘制圆环背景 -->
<canvas class="progress-bg" id="canvasProgressbg" />
<!-- 绘制加载中圆弧 -->
<canvas class="progress-canvas" id="canvasProgress" />
</div>
</template>
<script>
import incomeItem from './incomeItem'
export default {
name: 'income-detail',
props: {
data: {
type: Array,
default: []
}
},
data() {
return {
};
},
methods: {
/**
* 画progress底部背景
*/
drawProgressbg: function (summary) {
var c=document.getElementById("canvasProgressbg");
var cxt=c.getContext("2d");
// 设置圆环的宽度
ctx.setLineWidth(28 * radio);
// 设置圆环的颜色
let strokeColor = '#E0E0E0'
if (summary && summary.totalIncome > 0) {
strokeColor = '#65AB85';
}
ctx.setStrokeStyle(strokeColor);
// 设置圆环端点的形状
ctx.setLineCap('round')
//开始一个新的路径
ctx.beginPath();
//设置一个原点(110,110),半径为100的圆的路径到当前路径
console.log("起始点:" + Math.PI)
ctx.arc(120 * radio, 120 * radio, 100 * radio, 0, 2 * Math.PI, false);
//对当前路径进行描边
ctx.stroke();
//开始绘制
ctx.draw();
},
/**
* 画progress进度
*/
drawCircle: function (step) {
// 使用 wx.createContext 获取绘图上下文 context
var context = wx.createCanvasContext('canvasProgress');
// 设置圆环的宽度
context.setLineWidth(28 * radio);
// 设置圆环的颜色
let strokeColor = '#002B47'
// if (this.data.summary.totalIncome <= 0){
// strokeColor = '#E0E0E0';
// }
context.setStrokeStyle(strokeColor);
// 设置圆环端点的形状
context.setLineCap('round')
//开始一个新的路径
context.beginPath();
//参数step 为绘制的圆环周长,从0到2为一周 。 -Math.PI / 2 将起始角设在12点钟位置 ,结束角 通过改变 step 的值确定
context.arc(120 * radio, 120 * radio, 100 * radio, -Math.PI / 2, step * Math.PI - Math.PI / 2, false);
//对当前路径进行描边
context.stroke();
//开始绘制
context.draw()
},
/**
* 开始progress
*/
startProgress: function (summary) {
// 设置倒计时 定时器 每100毫秒执行一次,计数器count+1 ,耗时6秒绘一圈
if (summary && summary.totalIncome > 0) {
// this.countTimer = setInterval(() => {
// if (this.data.count <= 60) {
/* 绘制彩色圆环进度条
注意此处 传参 step 取值范围是0到2,
所以 计数器 最大值 60 对应 2 做处理,计数器count=60的时候step=2
*/
this.drawCircle(summary.goodsIncome / (summary.totalIncome / 2))
// if()
// this.data.count++;
// }
// else {
// clearInterval(this.countTimer);
// this.startProgress();
// }
// }, 100)
}
},
},
components: {
incomeItem
}
};
</script>
<style lang="scss" scoped>
.total-income {
font-size: 36px;
padding: 15px;
border-bottom: solid 1px #eee;
}
.no-data {
color: #ccc;
font-weight: bold;
text-align: center;
font-size: 42px;
padding: 100px 0;
}
</style>
<template>
<div class="progress-box">
<!-- 绘制圆环背景 -->
<canvas ref="canvasProgressbg" class="progress-bg" id="canvasProgressbg" width="280" height="280" />
<!-- 绘制加载中圆弧 -->
<canvas ref ="canvasProgress" class="progress-canvas" id="canvasProgress" width="280" height="280" />
</div>
</template>
<script>
import {mapState} from 'vuex';
export default {
name: 'income-circle',
props: {
data: {
type: Object,
default: {}
}
},
data() {
return {
};
},
computed: {
...mapState({
radio: (state) => {
return (state.yoho.window.clientWidth/750).toFixed(2);
},
// summary:(state) => {
// return {
// goodsIncome: state.home.mine.assetData.goodsIncome,
// totalIncome: state.home.mine.assetData.totalIncome,
// compensateIncome: state.home.mine.assetData.compensateIncome
// }
// },
})
},
mounted() {
// console.log(typeof this.data.compensateIncome)
let summary = {}
// console.log(this.goodsIncome)
// console.log(summary)
// console.log('---------')
// console.log(this.data)
summary.compensateIncome = '299.26';
summary.goodsIncome = '955.78';
summary.totalIncome = '1255.04';
this.drawProgressbg(summary);
this.startProgress(summary);
},
methods: {
// 画progress底部背景
drawProgressbg: function (summary) {
var c=document.getElementById("canvasProgressbg");
var ctx=c.getContext("2d");
ctx.lineWidth= 28 ;
let strokeStyle = '#E0E0E0'
if (summary && summary.totalIncome > 0) {
strokeStyle = '#65AB85';
}
ctx.strokeStyle=strokeStyle;
ctx.lineCap='round'
ctx.beginPath();
//设置一个原点(110,110),半径为100的圆的路径到当前路径
console.log("起始点:" + Math.PI)
ctx.arc(120, 120, 100, 0, 2 * Math.PI, false);
ctx.stroke();
//开始绘制
// ctx.draw();
},
// 画progress进度
drawCircle: function (step) {
var c=document.getElementById("canvasProgress");
var context=c.getContext("2d");
context.lineWidth=28;
let strokeColor = '#002B47'
context.strokeStyle=strokeColor;
context.lineCap='round';
context.beginPath();
//参数step 为绘制的圆环周长,从0到2为一周 。 -Math.PI / 2 将起始角设在12点钟位置 ,结束角 通过改变 step 的值确定
context.arc(120, 120, 100, -Math.PI / 2, step * Math.PI - Math.PI / 2, false);
context.stroke();
//开始绘制
// context.draw()
},
// 开始progress
startProgress: function (summary) {
if (summary && summary.totalIncome > 0) {
this.drawCircle(summary.goodsIncome / (summary.totalIncome / 2))
}
},
}
};
</script>
<style lang="scss" scoped>
.progress-box {
position: absolute;
top: 50px;
right: 50px;
width: 280px;
height: 280px;
}
.progress-bg {
position: absolute;
width: 100%;
height: 100%;
}
.progress-canvas {
position: absolute;
width: 100%;
height: 100%;
}
</style>
... ...
... ... @@ -15,8 +15,6 @@ export default {
methods: {
},
};
</script>
... ...
<template>
<div>
<p class="income-title">我的收入</p>
<div class="income-header">
<p class="total-income">收入: {{data.totalIncome}}</p>
<div class="income">
... ... @@ -12,10 +14,12 @@
<span class="income-num">{{data.compensateIncome}}</span>
</div>
</div>
<incomeCircle :data="data"></incomeCircle>
</div>
</template>
<script>
import incomeCircle from './incomeCircle';
export default {
name: 'income-header',
props: {
... ... @@ -29,12 +33,21 @@ export default {
};
},
components: {
incomeCircle
}
};
</script>
<style lang="scss" scoped>
.income-header-wrapper {
position: relative;
}
.income-title {
font-size: 60px;
color: #000;
margin-top: 20px;
}
.income-header {
margin: 50px 0;
}
... ...
... ... @@ -31,8 +31,6 @@ export default {
};
},
};
</script>
... ... @@ -42,8 +40,6 @@ export default {
flex-direction: column;
justify-content: space-between;
border-bottom: solid 1px #E0E0E0;
/* background: #ee00dd; */
/* position: fixed; */
}
.assets-record-info-detail-view {
... ... @@ -74,7 +70,6 @@ export default {
.assets-record-image-style {
width: 48px;
height: 48px;
/* background: #00ff */
}
.assets-record-code-txt {
font-family: PingFang-SC-Regular;
... ...
... ... @@ -32,15 +32,10 @@ export default {
default: 0
}
},
methods: {
},
components: {
Style,
Loading
}
};
</script>
... ...
... ... @@ -7,7 +7,7 @@
:options="options"
@pulling-down="onPullingDown"
@pulling-up="onPullingUp">
<h1>我的收入</h1>
<incomeHeader :data="incomeSum"></incomeHeader>
<incomeDetail :data="incomeData">
<template v-for="(item,index) in incomeData.list">
... ... @@ -52,26 +52,19 @@ export default {
},
mounted() {
this.fetchAssets(true).then(data => {
console.log(data)
})
this.fetchAssets(true)
},
methods: {
...mapActions(['fetchAssets']),
onPullingDown() {
this.fetchAssets(true).then(data => {
console.log(data)
})
this.fetchAssets(true)
},
onPullingUp() {
if(!this.incomeData.endReached) {
this.fetchAssets(false).then(data => {
console.log(data)
})
this.fetchAssets(false)
} else {
this.$refs.scroll.forceUpdate()
}
}
},
components: {
... ... @@ -92,8 +85,5 @@ export default {
background-color: white;
padding: 0 40px;
color: #999;
h1 {
color: #000;
}
}
</style>
... ...
... ... @@ -122,7 +122,6 @@ export default function() {
state.assetData = Object.assign({}, state.assetData, assetData);
},
assetFetching(state, {isFetching}) {
console.log(isFetching)
state.assetData.isFetching = isFetching;
},
... ... @@ -193,8 +192,6 @@ export default function() {
},
async fetchAssets({ commit, state }, isRefresh) {
console.log('----------------');
console.log(isRefresh);
let {isFetching, endReached, currentPage, list, pageSize} = state.assetData;
if (isFetching || (!isRefresh && endReached)) {
... ... @@ -212,11 +209,12 @@ export default function() {
let newList = [...oldList, ...assetData.list];
assetData.list = newList;
console.log(assetData)
if (typeof assetData.totalIncome !== 'undefined') {
commit('addAssets', assetData);
}
}
return result.data.page;
return result.data;
},
},
};
... ...