|
@@ -17,7 +17,7 @@
|
|
|
</view>
|
|
|
<view class="header-bar header-center">首页</view>
|
|
|
<view class="header-right">
|
|
|
- <image src="../../static/images/seticon.png" mode="" class="icon"></image>
|
|
|
+ <image src="../../static/images/seticon.png" mode="" class="icon" @tap="tosetting"></image>
|
|
|
</view>
|
|
|
</view>
|
|
|
<view class="user">
|
|
@@ -200,164 +200,168 @@
|
|
|
</view>
|
|
|
</template>
|
|
|
<script>
|
|
|
- import uCharts from '../../js_sdk/u-charts/u-charts/u-charts';
|
|
|
- let _self;
|
|
|
- let canvaLineA = null;
|
|
|
- let canvaPie = null;
|
|
|
- export default {
|
|
|
- name: 'Header',
|
|
|
- data() {
|
|
|
- return {
|
|
|
- array: ['中国', '美国', '巴西', '日本'],
|
|
|
- index: 0,
|
|
|
- cWidth: '',
|
|
|
- cHeight: '',
|
|
|
- pixelRatio: 1, // 像素比
|
|
|
-
|
|
|
- // 饼图数据
|
|
|
- bWidth: '',
|
|
|
- bHeight: ''
|
|
|
- };
|
|
|
- },
|
|
|
- // 此处定义传入的数据
|
|
|
- props: {
|
|
|
- shoplist: {
|
|
|
- type: Object,
|
|
|
- value: null,
|
|
|
- },
|
|
|
- },
|
|
|
- // 页面生命周期 监听页面加载
|
|
|
- onLoad() {
|
|
|
- _self = this;
|
|
|
- this.cWidth = uni.upx2px(690); // upx2px 转换为px
|
|
|
- this.cHeight = uni.upx2px(300);
|
|
|
- this.bWidth = uni.upx2px(690);
|
|
|
- this.bHeight = uni.upx2px(300);
|
|
|
- this.getServerData();
|
|
|
- },
|
|
|
- methods: {
|
|
|
- bindPickerChange: function(e) {
|
|
|
- console.log('picker发送选择改变,携带值为', e.target.value);
|
|
|
- this.index = e.target.value;
|
|
|
- },
|
|
|
- getList() {
|
|
|
- console.log(1);
|
|
|
- },
|
|
|
-
|
|
|
- seting() {
|
|
|
- console.log('设置');
|
|
|
- },
|
|
|
- // 数据处理
|
|
|
- getServerData() {
|
|
|
- uni.request({
|
|
|
- url: 'https://www.ucharts.cn/data.json',
|
|
|
- data: {},
|
|
|
- success: function(res) {
|
|
|
- console.log(res);
|
|
|
- let LineA = {
|
|
|
- categories: [],
|
|
|
- series: [],
|
|
|
- };
|
|
|
- //这里我后台返回的是数组,所以用等于,如果您后台返回的是单条数据,需要push进去
|
|
|
- LineA.categories = res.data.data.LineA.categories;
|
|
|
- LineA.series = res.data.data.LineA.series;
|
|
|
- _self.showLineA('canvasLineA', LineA);
|
|
|
-
|
|
|
- let pie = {
|
|
|
- series: [],
|
|
|
- };
|
|
|
- pie.series = res.data.data.Pie.series;
|
|
|
- _self.showPie('shopecharts', pie);
|
|
|
- },
|
|
|
- fail: () => {
|
|
|
- _self.tips = '网络错误,小程序端请检查合法域名';
|
|
|
- },
|
|
|
- });
|
|
|
- },
|
|
|
- // 图表
|
|
|
- showLineA(canvasId, chartData) {
|
|
|
- canvaLineA = new uCharts({
|
|
|
- $this: _self,
|
|
|
- canvasId: canvasId,
|
|
|
- type: 'line',
|
|
|
- fontSize: 12,
|
|
|
- legend: {
|
|
|
- show: false,
|
|
|
- },
|
|
|
- dataLabel: false, // 图表中是否显示数据
|
|
|
- duration: 500,
|
|
|
- dataPointShape: false, // 折点
|
|
|
- background: '#FFFFFF',
|
|
|
- pixelRatio: _self.pixelRatio,
|
|
|
- categories: chartData.categories, // x轴数据
|
|
|
- series: chartData.series, // 值
|
|
|
- animation: true,
|
|
|
- xAxis: {
|
|
|
- type: 'grid',
|
|
|
- disableGrid: true,
|
|
|
- },
|
|
|
- yAxis: {
|
|
|
- gridType: 'solid',
|
|
|
- gridColor: '#CCCCCC',
|
|
|
- min: 0,
|
|
|
- max: 180,
|
|
|
- format: (val) => {
|
|
|
- return val.toFixed(0) + '元';
|
|
|
- },
|
|
|
- },
|
|
|
- width: _self.cWidth * _self.pixelRatio,
|
|
|
- height: _self.cHeight * _self.pixelRatio,
|
|
|
- extra: {
|
|
|
- line: {
|
|
|
- type: 'curve', // 平滑曲线; straight直线
|
|
|
- },
|
|
|
- },
|
|
|
- });
|
|
|
- },
|
|
|
- touchLineA(e) {
|
|
|
- canvaLineA.showToolTip(e, {
|
|
|
- format: function(item, category) {
|
|
|
- return category + ' ' + item.name + ':' + item.data;
|
|
|
- },
|
|
|
- });
|
|
|
- },
|
|
|
-
|
|
|
- // 饼图
|
|
|
- showPie(canvasId, chartData) {
|
|
|
- canvaPie = new uCharts({
|
|
|
- $this: _self,
|
|
|
- canvasId: canvasId,
|
|
|
- type: 'pie',
|
|
|
- fontSize: 11,
|
|
|
- legend: {
|
|
|
- show: true,
|
|
|
- position: 'left',
|
|
|
- margin: 10,
|
|
|
- itemGap: 20,
|
|
|
- },
|
|
|
- background: '#FFFFFF',
|
|
|
- pixelRatio: _self.pixelRatio,
|
|
|
- series: chartData.series,
|
|
|
- animation: true,
|
|
|
- width: _self.cWidth * _self.pixelRatio,
|
|
|
- height: _self.cHeight * _self.pixelRatio,
|
|
|
- dataLabel: true,
|
|
|
- extra: {
|
|
|
- pie: {
|
|
|
- lableWidth: 15,
|
|
|
- },
|
|
|
- },
|
|
|
- });
|
|
|
- },
|
|
|
- touchPie(e) {
|
|
|
- canvaPie.showToolTip(e, {
|
|
|
- format: function(item) {
|
|
|
- return item.name + ':' + item.data;
|
|
|
- },
|
|
|
- });
|
|
|
- },
|
|
|
- },
|
|
|
- };
|
|
|
+import uCharts from '../../js_sdk/u-charts/u-charts/u-charts';
|
|
|
+let _self;
|
|
|
+let canvaLineA = null;
|
|
|
+let canvaPie = null;
|
|
|
+export default {
|
|
|
+ name: 'Header',
|
|
|
+ data() {
|
|
|
+ return {
|
|
|
+ array: ['中国', '美国', '巴西', '日本'],
|
|
|
+ index: 0,
|
|
|
+ cWidth: '',
|
|
|
+ cHeight: '',
|
|
|
+ pixelRatio: 1, // 像素比
|
|
|
+
|
|
|
+ // 饼图数据
|
|
|
+ bWidth: '',
|
|
|
+ bHeight: '',
|
|
|
+ };
|
|
|
+ },
|
|
|
+ // 此处定义传入的数据
|
|
|
+ props: {
|
|
|
+ shoplist: {
|
|
|
+ type: Object,
|
|
|
+ value: null,
|
|
|
+ },
|
|
|
+ },
|
|
|
+ // 页面生命周期 监听页面加载
|
|
|
+ onLoad() {
|
|
|
+ _self = this;
|
|
|
+ this.cWidth = uni.upx2px(690); // upx2px 转换为px
|
|
|
+ this.cHeight = uni.upx2px(300);
|
|
|
+ this.bWidth = uni.upx2px(690);
|
|
|
+ this.bHeight = uni.upx2px(300);
|
|
|
+ this.getServerData();
|
|
|
+ },
|
|
|
+ methods: {
|
|
|
+ bindPickerChange: function (e) {
|
|
|
+ console.log('picker发送选择改变,携带值为', e.target.value);
|
|
|
+ this.index = e.target.value;
|
|
|
+ },
|
|
|
+ // 设置页
|
|
|
+ tosetting() {
|
|
|
+ this.$mRouter.redirectTo({ route: '/pages/index/setting/setting' });
|
|
|
+ },
|
|
|
+ getList() {
|
|
|
+ console.log(1);
|
|
|
+ },
|
|
|
+
|
|
|
+ seting() {
|
|
|
+ console.log('设置');
|
|
|
+ },
|
|
|
+ // 数据处理
|
|
|
+ getServerData() {
|
|
|
+ uni.request({
|
|
|
+ url: 'https://www.ucharts.cn/data.json',
|
|
|
+ data: {},
|
|
|
+ success: function (res) {
|
|
|
+ console.log(res);
|
|
|
+ let LineA = {
|
|
|
+ categories: [],
|
|
|
+ series: [],
|
|
|
+ };
|
|
|
+ //这里我后台返回的是数组,所以用等于,如果您后台返回的是单条数据,需要push进去
|
|
|
+ LineA.categories = res.data.data.LineA.categories;
|
|
|
+ LineA.series = res.data.data.LineA.series;
|
|
|
+ _self.showLineA('canvasLineA', LineA);
|
|
|
+
|
|
|
+ let pie = {
|
|
|
+ series: [],
|
|
|
+ };
|
|
|
+ pie.series = res.data.data.Pie.series;
|
|
|
+ _self.showPie('shopecharts', pie);
|
|
|
+ },
|
|
|
+ fail: () => {
|
|
|
+ _self.tips = '网络错误,小程序端请检查合法域名';
|
|
|
+ },
|
|
|
+ });
|
|
|
+ },
|
|
|
+ // 图表
|
|
|
+ showLineA(canvasId, chartData) {
|
|
|
+ canvaLineA = new uCharts({
|
|
|
+ $this: _self,
|
|
|
+ canvasId: canvasId,
|
|
|
+ type: 'line',
|
|
|
+ fontSize: 12,
|
|
|
+ legend: {
|
|
|
+ show: false,
|
|
|
+ },
|
|
|
+ dataLabel: false, // 图表中是否显示数据
|
|
|
+ duration: 500,
|
|
|
+ dataPointShape: false, // 折点
|
|
|
+ background: '#FFFFFF',
|
|
|
+ pixelRatio: _self.pixelRatio,
|
|
|
+ categories: chartData.categories, // x轴数据
|
|
|
+ series: chartData.series, // 值
|
|
|
+ animation: true,
|
|
|
+ xAxis: {
|
|
|
+ type: 'grid',
|
|
|
+ disableGrid: true,
|
|
|
+ },
|
|
|
+ yAxis: {
|
|
|
+ gridType: 'solid',
|
|
|
+ gridColor: '#CCCCCC',
|
|
|
+ min: 0,
|
|
|
+ max: 180,
|
|
|
+ format: (val) => {
|
|
|
+ return val.toFixed(0) + '元';
|
|
|
+ },
|
|
|
+ },
|
|
|
+ width: _self.cWidth * _self.pixelRatio,
|
|
|
+ height: _self.cHeight * _self.pixelRatio,
|
|
|
+ extra: {
|
|
|
+ line: {
|
|
|
+ type: 'curve', // 平滑曲线; straight直线
|
|
|
+ },
|
|
|
+ },
|
|
|
+ });
|
|
|
+ },
|
|
|
+ touchLineA(e) {
|
|
|
+ canvaLineA.showToolTip(e, {
|
|
|
+ format: function (item, category) {
|
|
|
+ return category + ' ' + item.name + ':' + item.data;
|
|
|
+ },
|
|
|
+ });
|
|
|
+ },
|
|
|
+
|
|
|
+ // 饼图
|
|
|
+ showPie(canvasId, chartData) {
|
|
|
+ canvaPie = new uCharts({
|
|
|
+ $this: _self,
|
|
|
+ canvasId: canvasId,
|
|
|
+ type: 'pie',
|
|
|
+ fontSize: 11,
|
|
|
+ legend: {
|
|
|
+ show: true,
|
|
|
+ position: 'left',
|
|
|
+ margin: 10,
|
|
|
+ itemGap: 20,
|
|
|
+ },
|
|
|
+ background: '#FFFFFF',
|
|
|
+ pixelRatio: _self.pixelRatio,
|
|
|
+ series: chartData.series,
|
|
|
+ animation: true,
|
|
|
+ width: _self.cWidth * _self.pixelRatio,
|
|
|
+ height: _self.cHeight * _self.pixelRatio,
|
|
|
+ dataLabel: true,
|
|
|
+ extra: {
|
|
|
+ pie: {
|
|
|
+ lableWidth: 15,
|
|
|
+ },
|
|
|
+ },
|
|
|
+ });
|
|
|
+ },
|
|
|
+ touchPie(e) {
|
|
|
+ canvaPie.showToolTip(e, {
|
|
|
+ format: function (item) {
|
|
|
+ return item.name + ':' + item.data;
|
|
|
+ },
|
|
|
+ });
|
|
|
+ },
|
|
|
+ },
|
|
|
+};
|
|
|
</script>
|
|
|
<style lang="scss" scoped>
|
|
|
.header {
|
|
@@ -378,6 +382,9 @@
|
|
|
.header-left {
|
|
|
font-size: 28rpx;
|
|
|
|
|
|
+ .uni-list:after {
|
|
|
+ border-color: transparent;
|
|
|
+ }
|
|
|
.uni-list-cell-db {
|
|
|
height: 80rpx;
|
|
|
font-size: 28rpx;
|
|
@@ -385,7 +392,6 @@
|
|
|
justify-content: center;
|
|
|
align-items: center;
|
|
|
background-color: $barColor;
|
|
|
- border-bottom: transparent;
|
|
|
|
|
|
.icon {
|
|
|
width: 17rpx;
|