Skip to content

Commit

Permalink
测试图表
Browse files Browse the repository at this point in the history
  • Loading branch information
suvvm committed Dec 2, 2019
1 parent b72913f commit 93373c1
Showing 1 changed file with 30 additions and 59 deletions.
89 changes: 30 additions & 59 deletions pages/test/test.vue
Original file line number Diff line number Diff line change
@@ -1,72 +1,43 @@
<template>

<view>
<view v-for="item of 5">
{{testList[nowbg + item - 1]}}
</view>
<van-pagination
v-model="currentPage"
:total-items="testList.length"
:items-per-page="5"
@change="onPaginationChanged()"
/>
<view>66</view>
<div id="myChart" :style="{width: '100%', height: '300px'}"></div>

</view>
</template>

<script>
export default {
data() {
export default {
data () {
return {
value: 50,
imgfile: "",
nowbg: 0,
currentPage: 1,
testList: [{"name":"1"},{"name":"2"},{"name":"3"},{"name":"4"},
{"name":"5"},{"name":"6"},{"name":"7"},{"name":"8"},{"name":"9"},
{"name":"10"},{"name":"11"},{"name":"12"},{"name":"13"},{"name":"14"},
{"name":"15"},{"name":"16"},{"name":"17"},{"name":"18"},{"name":"19"}]
}
},
onLoad() {
if(this.$cookies.get("userInfo") != null){
this.userInfo = this.$cookies.get("userInfo");
}
var rp = require('request-promise');
var options = {
method: 'POST',
uri: 'http://localhost:8080/getUserById',
form: {
id: this.userInfo.id,
}
};
rp(options).then(res => {
this.$toast.clear();
if(res == "error") {
this.$toast.fail('获取用户信息识别');
} else {
var userInfo = JSON.parse(res);
console.log(userInfo);
// var base64Img = 'data:image/png;base64,' + userInfo.imgbase64;
// var imgFile = this.base64ImgtoFile(base64Img);
// console.log(base64Img);
// console.log(imgFile);
// this.imgfile = imgFile;
this.imgfile = userInfo.imgbase64;
this.$toast.success('获取用户信息识别成功');
}
// console.log(res)
}).catch(err => {
this.$toast.clear();
this.$toast.fail('获取用户信息识别');
console.log(err)
});
},
methods: {
onPaginationChanged(){
this.nowbg = this.currentPage * 5 - 5
}
},
mounted(){
this.drawLine();
},
methods: {
drawLine(){
// 基于准备好的dom,初始化echarts实例
let myChart = this.$echarts.init(document.getElementById('myChart'),null,{ renderer: 'svg' })
// 绘制图表
// myChart.init(document,null,{ renderer : 'svg' });
myChart.setOption({
title: { text: '在Vue中使用echarts' },
tooltip: {},
xAxis: {
data: ["zjp","hjt","jzm","ysk","lxn","lsq"]
},
yAxis: {},
series: [{
name: 'nb',
type: 'bar',
data: [5, 20, 36, 10, 10, 20]
}]
});
}
}
}
</script>

Expand Down

0 comments on commit 93373c1

Please sign in to comment.