| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394 | <template>	<view class="top">		<view class="qiun-charts">			<view v-for="(item,index) in orderList" :key="index">				<view class="content">					<view class="qiun-charts-one">					</view>					<text class="qiun-charts-two">{{item.brand}}</text>					<view style="display: flex;justify-content: space-between;">						<view class="qiun-charts-three">							<view>							</view>							<view>								{{item.month}}							</view>						</view>						<view class="qiun-charts-four">							<view>							</view>							<view>								{{item.quarter}}							</view>						</view>					</view>					<view class="content-one">						<canvas :canvas-id="'mouthPie' + index" :id="'mouthPie' + index" class="charts" @touchstart="touchPie($event,'mouthPie' + index)"></canvas>						<canvas :canvas-id="'quarterPie' + index" :id="'quarterPie' + index" class="charts" @touchstart="touchPie($event,'quarterPie' + index)"></canvas>					</view>				</view>			</view>		</view>	</view></template><script>	var canvasObj = {};	import {		request	} from '../../../common/request/request'	require("promise.prototype.finally").shim()	import uCharts from '@/components/u-charts/u-charts.js';	import {		isJSON	} from '@/common/checker.js';	var _self;	var canvaPie = null;	export default {		data() {			return {				orderList: [],				cWidth: '',				cHeight: '',				pixelRatio: 1,				piearr: [],				textarea: '',				// name: '',				pieObj:{					series:[						{							data:60,							name:'已完成'						},						{							data:40,							name:'未完成'						},					]				},				pieObj2:{					series:[						{							data:60,							name:'已完成'						},						{							data:40,							name:'未完成'						},					]				}			}		},		onLoad() {			_self = this;			_self.cWidth = uni.upx2px(370);			_self.cHeight = uni.upx2px(320);			// this.showPie('canvasRing')		},		created() {			this.getDate()		},		methods: {			getDate() {				request({						url: '/myapp/storeBrandTask',						method: 'post',						data: {							"storeId":this.$store.state.storeInfo.storeId,							'userId':this.$store.state.storeInfo.userId						}					}).then(res => {						console.log(res)						this.orderList = res.data.data						for(var i=0;i<res.data.data.length;i++){							let  monthPie = {								series: []							};							let quarterPie = {								series: []							}														for(var j=0;j<res.data.data[i].storeMonthList.length;j++){								// var _this = this								this.name = res.data.data[i].storeMonthList[j].data								let name = ""								console.log(this.name)								let monthObj = {									data:null,									name:'',								}								let quarterObj = {									data:null,									name:'',								}								name= res.data.data[i].storeMonthList[j].data								console.log(name)								monthObj.data = res.data.data[i].storeMonthList[j].data								monthObj.name = res.data.data[i].storeMonthList[j].name								quarterObj.data = res.data.data[i].storeQuarterList[j].data								quarterObj.name = res.data.data[i].storeQuarterList[j].name																console.log('^^^^',monthObj)								console.log('9999999',quarterObj)																monthPie.series.push(monthObj)								quarterPie.series.push(quarterObj)															}														console.log(`mouthPie${i}`,monthPie,quarterPie)							 this.showPie(`mouthPie${i}`,monthPie);							 this.showPie(`quarterPie${i}`,quarterPie)							// this[`${this.refVal}`]						}																		// let HstoreMonthList = res.data.data[0].storeMonthList						// let SstoreMonthList = res.data.data[1].storeMonthList						// for(var i=0;i<HstoreMonthList.length;i++){						// 	let obj = {						// 		data:null,						// 		name:'',						// 	}						// 	obj.data = HstoreMonthList[i].data						// 	obj.name = HstoreMonthList[i].name						// 	console.log(obj)						// 	Pie.series[i] = obj						// }						// this.showPie("canvasPie", Pie);						//这里我后台返回的是数组,所以用等于,如果您后台返回的是单条数据,需要push进去						// for (let i = 0; i < res.data.data.length; i++) {						// 	for(let j=0;j<res.data.data[i].storeMonthList.length;j++){						// 		let obj = {						// 			data:null,						// 			name:'',						// 		}						// 		console.log(res.data.data[i].storeMonthList[j].data)						// 		console.log(res.data.data[i].storeMonthList[j].name)						// 		obj.data = res.data.data[i].storeMonthList[j].data						// 		obj.name = res.data.data[i].storeMonthList[j].name						// 		Pie.series[j] = obj						// 	}						// 	this.showPie("canvasPie", Pie);							// this.pieObj = res.data.data[i].storeMonthList							// for(let j =0;j<res.data.data[i].storeMonthList.length;j++){							// 	let obj = {							// 		name:'',							// 		data:null							// 	}							// 	obj.name = res.data.data[i].storeMonthList[j].name							// 	obj.data = res.data.data[i].storeMonthList[j].data							// 	Pie.series[j] = obj							// 	console.log('^^^^^',Pie)							// 	this.showPie("canvasPie",Pie);							// }							// let obj = {							// 	name:'',							// 	data:null							// }							// obj.name = res.data.data[i]						// Pie.series = res.data.data[i].storeMonthList;						// console.log(this.pieObj)						// console.log(Pie)																								// }											}).catch(err => {						console.log(err)					})					.finally(() => {						setTimeout(() => {							uni.hideLoading();							this.loading = false;						}, 300)					})			},			showPie(canvasId, chartData) {				console.log('8888888',canvasId,chartData)				canvasObj[canvasId]=new uCharts({					$this: _self,					canvasId: canvasId,					type: 'ring',					fontSize: 11,					padding: [5, 5, 5, 5],					legend: {						show: true,						position: 'bottom',						float: 'center',						itemGap: 10,						padding: 2,						lineHeight: 26,						margin: 1,						//backgroundColor:'rgba(41,198,90,0.2)',						//borderColor :'rgba(41,198,90,0.5)',						borderWidth: 1					},					background: '#fff',					pixelRatio: _self.pixelRatio,					series: chartData.series,					animation: false,					width: _self.cWidth,					height: _self.cHeight,					disablePieStroke: true,					dataLabel: true,					subtitle: {						// name: 40,1						color: '#7cb5ec',						fontSize: 12 * _self.pixelRatio,					},					title: {						name: '待完成',						color: '#666666',						fontSize: 13 * _self.pixelRatio,					},					extra: {						pie: {							offsetAngle: 0,							ringWidth: 15 * _self.pixelRatio,							labelWidth: 1						}					},				});				// this.piearr = canvaPie.opts.series;			},			// touchRing(e) {			// 	canvaRing.touchLegend(e, {			// 		animation: false			// 	});			// 	canvaRing.showToolTip(e, {			// 		format: function(item) {			// 			return item.name + ':' + item.data			// 		}			// 	});			// },			touchPie(e,id){				console.log(e,id)								// canvaPie.touchLegend(e, {				// 	animation: false				// });				canvasObj[id].showToolTip(e, {						format: function (item) {								return item.name + ':' + item.data 						}				});			},														}	}</script><style>	/*样式的width和height一定要与定义的cWidth和cHeight相对应*/	.qiun-charts {		width: 750rpx;		height: 331rpx;		background: url(../../../static/sailun/background.png) no-repeat;		background-size: 750rpx 331rpx;	}	.qiun-charts-one {		width: 6rpx;		height: 30rpx;		background: #0292FD;		position: relative;		top: 20rpx;		left: 30rpx;	}	.qiun-charts-two {		position: relative;		top: -18rpx;		left: 60rpx;		font-size: 26rpx;		font-weight: bold;	}	.content {		width: 702rpx;		height: 410rpx;		background: #FFFFFF;		box-shadow: 0px 10px 40px 0px rgba(223, 223, 223, 0.91);		border-radius: 18px;		margin: 0 auto;		position: relative;		top: 20rpx;		margin-bottom: 40rpx;	}	.content-one {		display: flex;		justify-content: space-between;	}	.charts {		width: 380rpx;		height: 450rpx;		position: relative;		top: -20rpx;	}	.qiun-charts-three>view:nth-child(1) {		width: 24rpx;		height: 24rpx;		border: 6rpx solid #0094FE;		transform: rotate(50deg);		position: relative;		top: 20rpx;		left: 30rpx;	}	.qiun-charts-three>view:nth-child(2) {		width: 150rpx;		height: 22rpx;		background-color: #000000;		color: #fff;		font-size: 15rpx;		opacity: 0.3;		text-align: center;		position: relative;		top: -2rpx;		left: 40rpx;		border-top-right-radius: 12rpx;	}	.qiun-charts-four {		position: relative;		right: 200rpx;	}	.qiun-charts-four>view:nth-child(1) {		width: 24rpx;		height: 24rpx;		border: 6rpx solid #0094FE;		transform: rotate(50deg);		position: relative;		top: 20rpx;		left: 30rpx;	}	.qiun-charts-four>view:nth-child(2) {		width: 150rpx;		height: 22rpx;		background-color: #000000;		color: #fff;		font-size: 15rpx;		opacity: 0.3;		text-align: center;		position: relative;		top: -2rpx;		left: 40rpx;		border-top-right-radius: 12rpx;	}</style>
 |