ソースを参照

优化uchart兼容小程序

吴洪双 6 年 前
コミット
c4f39d08cb

+ 0 - 270
components/Charts/MyChartsColumn.vue

@@ -1,270 +0,0 @@
-<template>
-	<view class="qiun-columns">
-		<view class="qiun-bg-white qiun-title-bar qiun-common-mt">
-			<view class="qiun-title-dot-light">{{chartTitle}}</view>
-			<view style="text-align: center;position: relative;">
-				<image @click="pre()" style="position: absolute;left: 40upx; width: 40upx;height: 40upx;" src="/static/img/leftTriangle.png"></image>
-				<span v-if="this.chartType==='day'">{{startDate}}</span>
-				<span v-if="this.chartType!=='day'">{{startDate}} 至 {{endDate}}</span>
-				<image @click="next()" style="position: absolute;right: 40upx; width: 40upx;height: 40upx;" src="/static/img/rightTriangle.png"></image>
-			</view>
-		</view>
-		<view class="qiun-charts" style="background-color: #E5FDC3;">
-			<canvas :canvas-id="canvasId" :id="canvasId" class="charts" disable-scroll=true @touchstart="touchLineA" @touchmove="moveLineA"
-			 @touchend="touchEndLineA" style="background-color: #E5FDC3;"></canvas>
-		</view>
-	</view>
-</template>
-
-<script>
-	import {
-		mapState,
-		mapActions,
-		mapMutations
-	} from 'vuex';
-	import {
-		dateUtils
-	} from '@/common/util.js';
-	import uCharts from '@/components/u-charts/u-charts.js';
-	var _self;
-	var canvaColumn = null;
-	export default {
-		name: 'MyChartsColumn',
-		props: {
-			canvasId: String,
-			chartTitle: String,
-			chartType: String,
-			equipmentId: '',
-			adminId: '',
-		},
-		data() {
-			return {
-				cWidth: '',
-				cHeight: '',
-				pixelRatio: 1,
-				serverData: '',
-				canvaColumn: Object,
-				startDate: String,
-				endDate: String,
-			}
-		},
-		computed: {
-			...mapState(['loginUser']),
-		},
-		mounted() {
-			_self = this;
-			this.$data.type = this.chartType;
-			this.cWidth = uni.upx2px(750);
-			this.cHeight = uni.upx2px(500);
-			this.init();
-		},
-		methods: {
-			...mapActions('chart', ['getStatistics','getMainStatistics']),
-			init() {
-				this.initDateRang(new Date());
-				this.getStatisticsData();
-			},
-			initDateRang(day) {
-				const daystr = dateUtils.formateDate(day, 'yyyy/MM/dd');
-				let startDate = daystr;
-				let endDate = daystr;
-				if (this.chartType === 'week') {
-					startDate = dateUtils.formateDate(dateUtils.getFirstDayOfWeek(day), 'yyyy/MM/dd');
-					endDate = dateUtils.formateDate(dateUtils.getLastDayOfWeek(day), 'yyyy/MM/dd');
-				}
-				if (this.chartType === 'month') {
-					startDate = dateUtils.formateDate(dateUtils.getCurrentMonFirstDate(day), 'yyyy/MM/dd');
-					endDate = dateUtils.formateDate(dateUtils.getCurrentMonLastDate(day), 'yyyy/MM/dd');
-				}
-				if (this.chartType === 'year') {
-					startDate = dateUtils.formateDate(dateUtils.getCurrentYearFirstDate(day), 'yyyy/MM/dd');
-					endDate = dateUtils.formateDate(dateUtils.getCurrentYearLastDate(day), 'yyyy/MM/dd');
-				}
-				this.$data.startDate = startDate;
-				this.$data.endDate = endDate;
-			},
-			/**上一个 */
-			pre() {
-				const day = new Date(this.$data.startDate);
-				if (this.chartType === 'day') { // 日
-					day.setDate(day.getDate() - 1);
-				}
-				if(this.chartType === 'week'){ // 周
-					day.setDate(day.getDate() - 7);
-				}
-				if (this.chartType === 'month') { // 月
-					day.setMonth(day.getMonth() - 1);
-				}
-				if (this.chartType === 'year') { // 年
-					day.setFullYear(day.getFullYear() - 1);
-				}
-				this.initDateRang(day);
-				this.getStatisticsData();
-			},
-			/**下一个 */
-			next() {
-				const day = new Date(this.$data.startDate);
-				if (this.chartType === 'day') { // 日
-					day.setDate(day.getDate() + 1);
-				}
-				if(this.chartType === 'week'){ // 周
-					day.setDate(day.getDate() + 7);
-				}
-				if (this.chartType === 'month') { // 月
-					day.setMonth(day.getMonth() + 1);
-				}
-				if (this.chartType === 'year') { // 年
-					day.setFullYear(day.getFullYear() + 1);
-				}
-				this.initDateRang(day);
-				this.getStatisticsData();
-			},
-			getStatisticsData() {
-				const param = {
-					'startDate': this.$data.startDate,
-					'endDate': this.$data.endDate,
-					'chartType': this.chartType
-				};
-				// console.log('chartType:' + param.chartType)
-				if(this.adminId){ // 子组件,则拿传过来的参
-					param['adminId'] = this.adminId;
-				}else if ('admin' !== this.loginUser['username']) { //否则为主页,拿登录用户
-					param['adminId'] = this.loginUser['id'];
-				}
-				if (this.equipmentId) {
-					param['equipmentId'] = this.equipmentId;
-				}
-				setTimeout(() => {
-					this.getStatistics(param)
-						.then(data => [uni.stopPullDownRefresh(), this.showColumn(this.canvasId, data)]
-						, _ => void [uni.stopPullDownRefresh(),this.showColumn(this.canvasId, {categories:[],series:[]})]);
-				}, 0);
-			},
-			showColumn(canvasId, chartData) {
-				this.canvaColumn = new uCharts({
-					$this: _self,
-					canvasId: canvasId,
-					enableScroll: true,
-					type: 'column',
-					legend: true,
-					fontSize: 11,
-					background: '#E5FDC3',
-					pixelRatio: _self.pixelRatio,
-					animation: true,
-					categories: chartData.categories,
-					series: chartData.series,
-					xAxis: {
-						type: 'grid',
-						gridType: 'dash',
-						itemCount: 5, //x轴单屏显示数据的数量,默认为5个
-						scrollShow: true, //新增是否显示滚动条,默认false
-						scrollAlign: 'left', //滚动条初始位置
-						scrollBackgroundColor: '#F7F7FF', //默认为 #EFEBEF
-						scrollColor: '#DEE7F7', //默认为 #A6A6A6
-						// disableGrid:true,
-					},
-					yAxis: {
-						//disabled:true
-					},
-					dataLabel: true,
-					width: _self.cWidth * _self.pixelRatio,
-					height: _self.cHeight * _self.pixelRatio,
-					extra: {
-						column: {
-							// width: _self.cWidth*_self.pixelRatio*0.45/chartData.categories.length
-							width: 30
-						}
-					}
-				});
-			},
-			touchColumn(e) {
-				this.canvaColumn.showToolTip(e, {
-					format: function(item, category) {
-						if (typeof item.data === 'object') {
-							return category + ' ' + item.name + ':' + item.data.value
-						} else {
-							return category + ' ' + item.name + ':' + item.data
-						}
-					}
-				});
-			},
-			touchLineA(e) {
-				this.canvaColumn.scrollStart(e);
-			},
-			moveLineA(e) {
-				this.canvaColumn.scroll(e);
-			},
-			touchEndLineA(e) {
-				this.canvaColumn.scrollEnd(e);
-				//下面是toolTip事件,如果滚动后不需要显示,可不填写
-				this.canvaColumn.showToolTip(e, {
-					format: function(item, category) {
-						return category + ' ' + item.name + ':' + item.data
-					}
-				});
-			},
-
-		}
-	}
-</script>
-
-<style>
-	page {
-		background: #F2F2F2;
-		width: 750upx;
-		overflow-x: hidden;
-	}
-
-	.qiun-padding {
-		padding: 2%;
-		width: 96%;
-	}
-
-	.qiun-wrap {
-		display: flex;
-		flex-wrap: wrap;
-	}
-
-	.qiun-rows {
-		display: flex;
-		flex-direction: row !important;
-	}
-
-	.qiun-columns {
-		display: flex;
-		flex-direction: column !important;
-	}
-
-	.qiun-common-mt {
-		margin-top: 10upx;
-	}
-
-	.qiun-bg-white {
-		background: #FFFFFF;
-	}
-
-	.qiun-title-bar {
-		width: 96%;
-		padding: 10upx 2%;
-		flex-wrap: nowrap;
-	}
-
-	.qiun-title-dot-light {
-		border-left: 10upx solid #0ea391;
-		padding-left: 10upx;
-		font-size: 32upx;
-		color: #000000
-	}
-
-	.qiun-charts {
-		width: 750upx;
-		height: 500upx;
-		background-color: #FFFFFF;
-	}
-
-	.charts {
-		width: 750upx;
-		height: 500upx;
-		background-color: #FFFFFF;
-	}
-</style>

+ 1 - 0
components/uni-collapse-item/uni-collapse-item.vue

@@ -116,6 +116,7 @@
 				}
 				this.isOpen = !this.isOpen
 				this.collapse.onChange && this.collapse.onChange()
+				this.$emit('open',this)
 			}
 		}
 	}

+ 1 - 0
components/uni-collapse/uni-collapse.vue

@@ -29,6 +29,7 @@
 				this.childrens.forEach((vm, index) => {
 					if (vm.isOpen) {
 						activeItem.push(vm.nameSync)
+						this.$emit('change2', vm)
 					}
 				})
 				this.$emit('change', activeItem)

+ 0 - 2
main.js

@@ -3,7 +3,6 @@ import App from './App'
 import apis from './configs/http';
 import store from './store';
 import env from '@/configs/env';
-import MyChartsColumn from '@/components/Charts/MyChartsColumn';
 import mainStatistics from '@/pages/Charts/mainStatistics';
 
 
@@ -24,5 +23,4 @@ Object.keys(apis).forEach(key => {
 	Vue.prototype[`$${key}`] = apis[key];
 });
 
-Vue.component('MyChartsColumn', MyChartsColumn);
 Vue.component('mainStatistics', mainStatistics);

+ 7 - 7
pages.json

@@ -11,24 +11,24 @@
 		    "path" : "pages/Charts/mainStatistics",
 		    "style" : {
 				"navigationBarTitleText":"统计图表"
-				// "disableScroll": true,
+				// "disableScroll": true
 				// "enablePullDownRefresh": true
 			}
 		},
 		{
 		    "path" : "pages/User/merchantList",
 		    "style" : {
-				"navigationBarTitleText":"机器销售"
+				"navigationBarTitleText":"机器销售",
 				// "disableScroll": true,
-				// "enablePullDownRefresh": true
+				"enablePullDownRefresh": true
 			}
 		},
 		{
-		    "path" : "pages/User/merchantList2",
+		    "path" : "pages/User/equipmentStatusList",
 		    "style" : {
-				"navigationBarTitleText":"机器状态"
+				"navigationBarTitleText":"机器状态",
 				// "disableScroll": true,
-				// "enablePullDownRefresh": true
+				"enablePullDownRefresh": true
 			}
 		},
 		{
@@ -64,7 +64,7 @@
 				"text": "机器销售"
 			},
 			{
-				"pagePath": "pages/User/merchantList2",
+				"pagePath": "pages/User/equipmentStatusList",
 				"iconPath": "static/img/equipment.png",
 				"selectedIconPath": "static/img/equipmentHL.png",
 				"text": "机器状态"

+ 368 - 13
pages/Charts/mainStatistics.vue

@@ -6,16 +6,74 @@
 			<view class="qiun-title-dot-light">本月收入总额: {{monthTotalMoney}}</view>
 			<view class="qiun-title-dot-light">本年度收入总额: {{yearTotalMoney}}</view>
 		</view>
-		
-		<MyChartsColumn canvasId="column1" chartTitle="今日销售情况" chartType='day' :adminId="this.adminId" :equipmentId="this.equipmentId"></MyChartsColumn>
-		<MyChartsColumn canvasId="column2" chartTitle="本周销售情况" chartType='week' :adminId="this.adminId" :equipmentId="this.equipmentId"></MyChartsColumn>
-		<MyChartsColumn canvasId="column3" chartTitle="本月销售情况" chartType='month' :adminId="this.adminId" :equipmentId="this.equipmentId"></MyChartsColumn>
-		<MyChartsColumn canvasId="column4" chartTitle="本年销售情况" chartType='year' :adminId="this.adminId" :equipmentId="this.equipmentId"></MyChartsColumn>
+		<view class="qiun-columns">
+			<view class="qiun-bg-white qiun-title-bar qiun-common-mt">
+				<view class="qiun-title-dot-light">今日销售情况</view>
+				<view style="text-align: center;position: relative;">
+					<image @click="pre('day')" class="preImg" src="/static/img/leftTriangle.png"></image>
+					<span>{{startDate1}}</span>
+					<image @click="next('day')" class="nextImg" src="/static/img/rightTriangle.png"></image>
+				</view>
+			</view>
+			<view class="qiun-charts" style="background-color: #E5FDC3;">
+				<canvas canvas-id="canvaColumn1" id="canvaColumn1" class="charts" disable-scroll=true @touchstart="touchLine1" @touchmove="moveLine1"
+				 @touchend="touchEndLine1" style="background-color: #E5FDC3;"></canvas>
+			</view>
+		</view>
+		<view class="qiun-columns">
+			<view class="qiun-bg-white qiun-title-bar qiun-common-mt">
+				<view class="qiun-title-dot-light">本周销售情况</view>
+				<view style="text-align: center;position: relative;">
+					<image @click="pre('week')" class="preImg" src="/static/img/leftTriangle.png"></image>
+					<span>{{startDate2}} 至 {{endDate2}}</span>
+					<image @click="next('week')" class="nextImg" src="/static/img/rightTriangle.png"></image>
+				</view>
+			</view>
+			<view class="qiun-charts" style="background-color: #E5FDC3;">
+				<canvas canvas-id="canvaColumn2" id="canvaColumn2" class="charts" disable-scroll=true @touchstart="touchLine2" @touchmove="moveLine2"
+				 @touchend="touchEndLine2" style="background-color: #E5FDC3;"></canvas>
+			</view>
+		</view>
+		<view class="qiun-columns">
+			<view class="qiun-bg-white qiun-title-bar qiun-common-mt">
+				<view class="qiun-title-dot-light">本月销售情况</view>
+				<view style="text-align: center;position: relative;">
+					<image @click="pre('month')" class="preImg" src="/static/img/leftTriangle.png"></image>
+					<span>{{startDate3}} 至 {{endDate3}}</span>
+					<image @click="next('month')" class="nextImg" src="/static/img/rightTriangle.png"></image>
+				</view>
+			</view>
+			<view class="qiun-charts" style="background-color: #E5FDC3;">
+				<canvas canvas-id="canvaColumn3" id="canvaColumn3" class="charts" disable-scroll=true @touchstart="touchLine3" @touchmove="moveLine3"
+				 @touchend="touchEndLine3" style="background-color: #E5FDC3;"></canvas>
+			</view>
+		</view>
+		<view class="qiun-columns">
+			<view class="qiun-bg-white qiun-title-bar qiun-common-mt">
+				<view class="qiun-title-dot-light">本年销售情况</view>
+				<view style="text-align: center;position: relative;">
+					<image @click="pre('year')" class="preImg" src="/static/img/leftTriangle.png"></image>
+					<span>{{startDate4}} 至 {{endDate4}}</span>
+					<image @click="next('year')" class="nextImg" src="/static/img/rightTriangle.png"></image>
+				</view>
+			</view>
+			<view class="qiun-charts" style="background-color: #E5FDC3;">
+				<canvas canvas-id="canvaColumn4" id="canvaColumn4" class="charts" disable-scroll=true @touchstart="touchLine4" @touchmove="moveLine4"
+				 @touchend="touchEndLine4" style="background-color: #E5FDC3;"></canvas>
+			</view>
+		</view>
 	</view>
 </template>
 
 <script>
 	import { mapState, mapActions, mapMutations } from 'vuex';
+	import uCharts from '@/components/u-charts/u-charts.js';
+	import {dateUtils} from '@/common/util.js';
+	var _self;
+	var canvaColumn1=null;
+	var canvaColumn2=null;
+	var canvaColumn3=null;
+	var canvaColumn4=null;
 	export default {
 		name: 'mainStatistics',
 		props: {
@@ -28,19 +86,203 @@
 				weekTotalMoney:0,
 				monthTotalMoney:0,
 				yearTotalMoney:0,
+				cWidth: '',
+				cHeight: '',
+				pixelRatio: 1,
+				startDate1: '',
+				startDate2: '',
+				endDate2: '',
+				startDate3: '',
+				endDate3: '',
+				startDate4: '',
+				endDate4: '',
 			}
 		},
 		computed: {
 			...mapState(['loginUser']),
 		},
 		onLoad(state){
-			this.getMainStatisticsData();
+			this.init();
 		},
 		mounted() {
-			this.getMainStatisticsData();
 		},
 		methods: {
 			...mapActions('chart', ['getStatistics','getMainStatistics']),
+			init(){
+				_self = this;
+				this.cWidth = uni.upx2px(750);
+				this.cHeight = uni.upx2px(500);
+				
+				this.getMainStatisticsData();
+				
+				this.initDateRang(new Date(),'day');
+				this.initDateRang(new Date(),'week');
+				this.initDateRang(new Date(),'month');
+				this.initDateRang(new Date(),'year');
+			},
+			initDateRang(day,chartType) {
+				const daystr = dateUtils.formateDate(day, 'yyyy/MM/dd');
+				if(chartType === 'day'){
+					this.startDate1 = dateUtils.formateDate(day, 'yyyy/MM/dd');
+				}
+				if (chartType === 'week') {
+					this.startDate2 = dateUtils.formateDate(dateUtils.getFirstDayOfWeek(day), 'yyyy/MM/dd');
+					this.endDate2 = dateUtils.formateDate(dateUtils.getLastDayOfWeek(day), 'yyyy/MM/dd');
+				}
+				if (chartType === 'month') {
+					this.startDate3 = dateUtils.formateDate(dateUtils.getCurrentMonFirstDate(day), 'yyyy/MM/dd');
+					this.endDate3 = dateUtils.formateDate(dateUtils.getCurrentMonLastDate(day), 'yyyy/MM/dd');
+				}
+				if (chartType === 'year') {
+					this.startDate4 = dateUtils.formateDate(dateUtils.getCurrentYearFirstDate(day), 'yyyy/MM/dd');
+					this.endDate4 = dateUtils.formateDate(dateUtils.getCurrentYearLastDate(day), 'yyyy/MM/dd');
+				}
+				
+				this.getStatisticsData(chartType);
+			},
+			/**上一个 */
+			pre(chartType) {
+				let day;
+				if (chartType === 'day') { // 日
+					day = new Date(this.startDate1);
+					day.setDate(day.getDate() - 1);
+				}
+				if(chartType === 'week'){ // 周
+					day = new Date(this.startDate2);
+					day.setDate(day.getDate() - 7);
+				}
+				if (chartType === 'month') { // 月
+					day = new Date(this.startDate3);
+					day.setMonth(day.getMonth() - 1);
+				}
+				if (chartType === 'year') { // 年
+					day = new Date(this.startDate4);
+					day.setFullYear(day.getFullYear() - 1);
+				}
+				this.initDateRang(day,chartType);				
+			},
+			/**下一个 */
+			next(chartType) {
+				let day;
+				if (chartType === 'day') { // 日
+					day = new Date(this.startDate1);
+					day.setDate(day.getDate() + 1);
+				}
+				if(chartType === 'week'){ // 周
+					day = new Date(this.startDate2);
+					day.setDate(day.getDate() + 7);
+				}
+				if (chartType === 'month') { // 月
+					day = new Date(this.startDate3);
+					day.setMonth(day.getMonth() + 1);
+				}
+				if (chartType === 'year') { // 年
+					day = new Date(this.startDate4);
+					day.setFullYear(day.getFullYear() + 1);
+				}
+				
+				this.initDateRang(day,chartType);
+			},
+			getStatisticsData(chartType) {
+				const param = {
+					'chartType': chartType
+				};
+				if(chartType=='day'){
+					param['startDate'] = this.startDate1;
+					param['endDate'] = this.startDate1;
+				}
+				if(chartType=='week'){
+					param['startDate'] = this.startDate2;
+					param['endDate'] = this.endDate2;
+				}
+				if(chartType=='month'){
+					param['startDate'] = this.startDate3;
+					param['endDate'] = this.endDate3;
+				}
+				if(chartType=='year'){
+					param['startDate'] = this.startDate4;
+					param['endDate'] = this.endDate4;
+				}
+				if(this.adminId){ // 子组件,则拿传过来的参
+					param['adminId'] = this.adminId;
+				}else if ('admin' !== this.loginUser['username']) { //否则为主页,拿登录用户
+					param['adminId'] = this.loginUser['id'];
+				}
+				if (this.equipmentId) {
+					param['equipmentId'] = this.equipmentId;
+				}
+				setTimeout(() => {
+					this.getStatistics(param)
+						.then(data => {
+								uni.stopPullDownRefresh();
+								if(param['chartType']=='day'){
+									canvaColumn1 = this.initChart('canvaColumn1',data);
+								}
+								if(param['chartType']=='week'){
+									canvaColumn2 = this.initChart('canvaColumn2',data);
+								}
+								if(param['chartType']=='month'){
+									canvaColumn3 = this.initChart('canvaColumn3',data);
+								}
+								if(param['chartType']=='year'){
+									canvaColumn4 = this.initChart('canvaColumn4',data);
+								}
+							}
+						, _ => {
+								uni.stopPullDownRefresh();
+								if(param['chartType']=='day'){
+									canvaColumn1 = this.initChart('canvaColumn1',{categories:['暂无数据'],series:[{name: '销售个数',data:[0]}]});
+								}
+								if(param['chartType']=='week'){
+									canvaColumn2 = this.initChart('canvaColumn2',{categories:['暂无数据'],series:[{name: '销售个数',data:[0]}]});
+								}
+								if(param['chartType']=='month'){
+									canvaColumn3 = this.initChart('canvaColumn3',{categories:['暂无数据'],series:[{name: '销售个数',data:[0]}]});
+								}
+								if(param['chartType']=='year'){
+									canvaColumn4 = this.initChart('canvaColumn4',{categories:['暂无数据'],series:[{name: '销售个数',data:[0]}]});
+								}
+							}
+						);
+				}, 0);
+			},
+			initChart(canvasId, chartData){
+				return new uCharts({
+					$this: _self,
+					canvasId: canvasId,
+					enableScroll: true,
+					type: 'column',
+					legend: true,
+					fontSize: 11,
+					background: '#E5FDC3',
+					pixelRatio: 1,
+					animation: true,
+					categories: chartData.categories,
+					series: chartData.series,
+					xAxis: {
+						type: 'grid',
+						gridType: 'dash',
+						itemCount: 5, //x轴单屏显示数据的数量,默认为5个
+						scrollShow: true, //新增是否显示滚动条,默认false
+						scrollAlign: 'left', //滚动条初始位置
+						scrollBackgroundColor: '#F7F7FF', //默认为 #EFEBEF
+						scrollColor: '#DEE7F7', //默认为 #A6A6A6
+						// disableGrid:true,
+					},
+					yAxis: {
+						//disabled:true
+					},
+					dataLabel: true,
+					width: _self.cWidth * _self.pixelRatio,
+					height: _self.cHeight * _self.pixelRatio,
+					extra: {
+						column: {
+							// width: _self.cWidth*_self.pixelRatio*0.45/chartData.categories.length
+							width: 30
+						}
+					}
+				});
+			},
 			getMainStatisticsData(){
 				setTimeout(() => {
 					const param = {};
@@ -73,20 +315,133 @@
 						}
 						, _ => void uni.stopPullDownRefresh());
 				}, 0);
-			}
+			},
+			touchLine1(e) {
+				canvaColumn1.scrollStart(e);
+			},
+			moveLine1(e) {
+				canvaColumn1.scroll(e);
+			},
+			touchEndLine1(e) {
+				canvaColumn1.scrollEnd(e);
+				//下面是toolTip事件,如果滚动后不需要显示,可不填写
+				canvaColumn1.showToolTip(e, {
+					format: function(item, category) {
+						return category + ' ' + item.name + ':' + item.data
+					}
+				});
+			},
+			touchLine2(e) {
+				canvaColumn2.scrollStart(e);
+			},
+			moveLine2(e) {
+				canvaColumn2.scroll(e);
+			},
+			touchEndLine2(e) {
+				canvaColumn2.scrollEnd(e);
+				//下面是toolTip事件,如果滚动后不需要显示,可不填写
+				canvaColumn2.showToolTip(e, {
+					format: function(item, category) {
+						return category + ' ' + item.name + ':' + item.data
+					}
+				});
+			},
+			touchLine3(e) {
+				canvaColumn3.scrollStart(e);
+			},
+			moveLine3(e) {
+				canvaColumn3.scroll(e);
+			},
+			touchEndLine3(e) {
+				canvaColumn3.scrollEnd(e);
+				//下面是toolTip事件,如果滚动后不需要显示,可不填写
+				canvaColumn3.showToolTip(e, {
+					format: function(item, category) {
+						return category + ' ' + item.name + ':' + item.data
+					}
+				});
+			},
+			touchLine4(e) {
+				canvaColumn4.scrollStart(e);
+			},
+			moveLine4(e) {
+				canvaColumn4.scroll(e);
+			},
+			touchEndLine4(e) {
+				canvaColumn4.scrollEnd(e);
+				//下面是toolTip事件,如果滚动后不需要显示,可不填写
+				canvaColumn4.showToolTip(e, {
+					format: function(item, category) {
+						return category + ' ' + item.name + ':' + item.data
+					}
+				});
+			},
 		}
 	}
 </script>
 <style>
-	.qiun-title-dot-light {
-		border-left: 10upx solid #ca8019;
-		padding-left: 10upx;
-		font-size: 32upx;
-		color: #000000
+	page {
+		background: #F2F2F2;
+		width: 750upx;
+		overflow-x: hidden;
+	}
+	
+	.qiun-padding {
+		padding: 2%;
+		width: 96%;
+	}
+	
+	.qiun-wrap {
+		display: flex;
+		flex-wrap: wrap;
+	}
+	
+	.qiun-rows {
+		display: flex;
+		flex-direction: row !important;
+	}
+	
+	.qiun-columns {
+		display: flex;
+		flex-direction: column !important;
 	}
+	
+	.qiun-common-mt {
+		margin-top: 10upx;
+	}
+	
+	.qiun-bg-white {
+		background: #FFFFFF;
+	}
+	
 	.qiun-title-bar {
 		width: 96%;
 		padding: 10upx 2%;
 		flex-wrap: nowrap;
 	}
+	
+	.qiun-title-dot-light {
+		border-left: 10upx solid #0ea391;
+		padding-left: 10upx;
+		font-size: 32upx;
+		color: #000000
+	}
+	
+	.qiun-charts {
+		width: 750upx;
+		height: 500upx;
+		background-color: #FFFFFF;
+	}
+	
+	.charts {
+		width: 750upx;
+		height: 500upx;
+		background-color: #FFFFFF;
+	}
+	.preImg {
+		position: absolute;left: 40upx; width: 40upx;height: 40upx;
+	}
+	.nextImg {
+		position: absolute;right: 40upx; width: 40upx;height: 40upx;
+	}
 </style>

+ 13 - 19
pages/User/merchantList2.vue

@@ -12,11 +12,11 @@
 									<uni-collapse-item :title="getEquipmentTitle(equipment)">
 										<view style="padding: 20upx;background-color: antiquewhite;">
 											<view><span>机器唯一码:</span><span>{{equipment.clientId}}</span></view>
-											<view><span>所在地:</span><span>{{equipment.fullName}}</span></view>
-											<view><span>温度:</span><span>{{equipment.cabinetTm}}</span></view>
-											<view><span>湿度:</span><span>{{equipment.cabinetHd}}</span></view>
-											<view><span>转速:</span><span>{{equipment.furnaceSp}}</span></view>
-											<view><span>报警内容:</span><span>{{equipment.occurrenceTime}}  {{equipment.alarmContent}}</span></view>
+											<view><span>所在地:</span><span>{{equipment.fullName?equipment.fullName:''}}</span></view>
+											<view><span>温度:</span><span>{{equipment.cabinetTm?equipment.cabinetTm:''}}</span></view>
+											<view><span>湿度:</span><span>{{equipment.cabinetHd?equipment.cabinetHd:''}}</span></view>
+											<view><span>转速:</span><span>{{equipment.furnaceSp?equipment.furnaceSp:''}}</span></view>
+											<view><span>报警内容:</span><span>{{equipment.occurrenceTime?equipment.occurrenceTime:''}}  {{equipment.alarmContent}}</span></view>
 										</view>
 									</uni-collapse-item>
 								</view>
@@ -34,11 +34,11 @@
 				<uni-collapse-item :title="getEquipmentTitle(equipment)">
 					<view style="padding: 20upx;background-color: antiquewhite;">
 						<view><span>机器唯一码:</span><span>{{equipment.clientId}}</span></view>
-						<view><span>所在地:</span><span>{{equipment.fullName}}</span></view>
-						<view><span>温度:</span><span>{{equipment.cabinetTm}}</span></view>
-						<view><span>湿度:</span><span>{{equipment.cabinetHd}}</span></view>
-						<view><span>转速:</span><span>{{equipment.furnaceSp}}</span></view>
-						<view><span>报警内容:</span><span>{{equipment.occurrenceTime}}  {{equipment.alarmContent}}</span></view>
+						<view><span>所在地:</span><span>{{equipment.fullName?equipment.fullName:''}}</span></view>
+						<view><span>温度:</span><span>{{equipment.cabinetTm?equipment.cabinetTm:''}}</span></view>
+						<view><span>湿度:</span><span>{{equipment.cabinetHd?equipment.cabinetHd:''}}</span></view>
+						<view><span>转速:</span><span>{{equipment.furnaceSp?equipment.furnaceSp:''}}</span></view>
+						<view><span>报警内容:</span><span>{{equipment.occurrenceTime?equipment.occurrenceTime:''}}  {{equipment.alarmContent}}</span></view>
 					</view>
 				</uni-collapse-item>
 			</view>
@@ -80,17 +80,11 @@
 		onLoad(state){
 			this.getEquipmentListData();
 		},
+		onPullDownRefresh() {
+			this.getEquipmentListData();
+		},
 		methods: {
 			...mapActions('chart', ['getEquipmentListByUser']),
-			change(e) {
-				// console.log(e)
-			},
-			showEquipment(merchant){
-				 merchant['ifShow']=!merchant['ifShow'];
-			},
-			showLabel(merchant){
-				return merchant['ifShow']?'收起':'展开';
-			},
 			getMerchantTitle(merchant){
 				return merchant.name?merchant.name:merchant.username;
 			},

+ 19 - 25
pages/User/merchantList.vue

@@ -1,22 +1,18 @@
 <template>
 	<view v-if="merchantList.length>1">
-		<uni-collapse :accordion="true">
+		<uni-collapse :accordion="true" >
 			<view v-for="(merchant,index) in merchantList" :key="merchant.id" >
 				<uni-collapse-item :title="getMerchantTitle(merchant)" :open="index===0">
 					<view style="padding: 20upx;background-color: aliceblue;">
 						<view v-if="merchant.equipmentList.length==0" style="text-align: center;">暂无数据</view>
 						<view v-if="merchant.equipmentList.length>0">
 							<uni-collapse :accordion="true">
-								<uni-collapse-item title="总销售情况">
-									<view style="padding: 20upx;">
-										<mainStatistics :adminId="merchant.id"></mainStatistics>
-									</view>
+								<uni-collapse-item title="总销售情况" @open="open">
+									<mainStatistics :adminId="merchant.id" style="padding: 20upx;"></mainStatistics>
 								</uni-collapse-item>
 								<view v-for="equipment in merchant.equipmentList" :key="equipment.id">
-									<uni-collapse-item :title="getEquipmentTitle(equipment)">
-										<view style="padding: 20upx;">
-											<mainStatistics :equipmentId="equipment.id"></mainStatistics>
-										</view>
+									<uni-collapse-item :title="getEquipmentTitle(equipment)" @open="open">
+										<mainStatistics :equipmentId="equipment.id" style="padding: 20upx;"></mainStatistics>
 									</uni-collapse-item>
 								</view>
 							</uni-collapse>	
@@ -29,16 +25,12 @@
 	<view v-else>
 		<view v-if="merchantList[0].equipmentList.length>1">
 			<uni-collapse :accordion="true">
-				<uni-collapse-item title="总销售情况">
-					<view style="padding: 20upx;">
-						<mainStatistics :adminId="merchantList[0].id"></mainStatistics>
-					</view>
+				<uni-collapse-item title="总销售情况" @open="open">
+					<mainStatistics :adminId="merchantList[0].id" style="padding: 20upx;"></mainStatistics>
 				</uni-collapse-item>
 				<view v-for="equipment in merchantList[0].equipmentList" :key="equipment.id">
-					<uni-collapse-item :title="getEquipmentTitle(equipment)">
-						<view style="padding: 20upx;">
-							<mainStatistics :equipmentId="equipment.id"></mainStatistics>
-						</view>
+					<uni-collapse-item :title="getEquipmentTitle(equipment)" @open="open">
+						<mainStatistics :equipmentId="equipment.id" style="padding: 20upx;"></mainStatistics>
 					</uni-collapse-item>
 				</view>
 			</uni-collapse>	
@@ -77,16 +69,18 @@
 		onLoad(state){
 			this.getEquipmentListData();
 		},
+		onPullDownRefresh() {
+			this.getEquipmentListData();
+		},
 		methods: {
 			...mapActions('chart', ['getEquipmentListByUser']),
-			change(e) {
-				// console.log(e)
-			},
-			showEquipment(merchant){
-				 merchant['ifShow']=!merchant['ifShow'];
-			},
-			showLabel(merchant){
-				return merchant['ifShow']?'收起':'展开';
+			open(e){
+				for (let component of e.$children) {
+					if(component.$options.name=='mainStatistics'){
+						component.init();
+						return;
+					}
+				}
 			},
 			getMerchantTitle(merchant){
 				return merchant.name?merchant.name:merchant.username;