<template>
	<div class="app-container">
		<div class="top">
			<div class="tysx">
				<div class="tybq"></div>
				<div>交易大数据</div>
			</div>
			<div class="father">
				<div class="son">
					<img src="../../../assets/images/ddzs.png" alt="">
					<div>
						<p style="font-weight: 600;">123</p>
						<p style="color: #c2c2c2;">订单总数</p>
					</div>
				</div>
				<div class="son">
					<img src="../../../assets/images/xsl.png" alt="">
					<div>
						<p style="font-weight: 600;">33</p>
						<p style="color: #c2c2c2;">销售单量</p>
					</div>
				</div>
				<div class="son">
					<img src="../../../assets/images/xsje.png" alt="">
					<div>
						<p style="font-weight: 600;">12345.01</p>
						<p style="color: #c2c2c2;">销售金额</p>
					</div>
				</div>
				<div class="son">
					<img src="../../../assets/images/hsl.png" alt="">
					<div>
						<p style="font-weight: 600;">23</p>
						<p style="color: #c2c2c2;">回收单量</p>
					</div>
				</div>
				<div class="son">
					<img src="../../../assets/images/hsje.png" alt="">
					<div>
						<p style="font-weight: 600;">12345.00</p>
						<p style="color: #c2c2c2;">回收金额</p>
					</div>
				</div>
			</div>
		</div>
		<div class="banner">
			<div class="banner-left">
				<div class="tysx">
					<div class="tybq"></div>
					<div>交易游戏品类回收</div>
				</div>
				<div ref="chart6" style="width: 50%;height: 400px;"></div>
			</div>
			<div class="banner-right">
				<div class="tysx">
					<div class="tybq"></div>
					<div>交易游戏品类销售</div>
				</div>
			</div>
		</div>
		<div class="bottom">
			<div class="bottom-left">
				<div class="tysx">
					<div class="tybq"></div>
					<div>今日交易订单</div>
				</div>
			</div>
		</div>
	</div>
</template>

<script>
	import {
		getSysDeptInfo,
		getDeptInfo,
		accountMonitoring,
		add,
		upData,
		getPhone,
		view,
		deletePhone,
		getInitGoodsManager,
		getPaymentInfo,
		updateOriginalPrice,
		getTBusGoodsPaymentSum,
		updatePaymentStatus
	} from "@/api/data/bindingPhone";
	import {
		queryTBusShop,
	} from "@/api/data/goodsPayment";
	import {
		getShopInfo,
		shopEdit
	} from "@/api/data/numberLibrary";
	import {
		getTBusShopInfo,
	} from "@/api/data/goodsPayment";
	import Cookies from 'js-cookie';
	import {
		getToken
	} from "@/utils/auth";
	export default {

		dicts: ['pallet_type', 'service_name'],
		data() {
			return {
				disabled3: false,
				deptOptions: [],
				dialogVisible1: false,
				form5: {},
				// 统计
				originalprice: 0,
				salesprice: 0,
				paidinprice: 0,
				lr: 0,
				bplr: 0,
				allPrice: 0,
				// 筛选
				// activeNames: ['1'],
				cs: 0,
				cs1: 0,
				cs2: 0,
				cs3: 0,
				input: '',
				ck: false,
				yxbh: false,
				yxdq: false,
				spbh: false,
				sjbh: false,
				disabled: true,
				block: false,
				originalPrice1open: false,
				originalPriceopen: false,
				xz: false,
				open1: false,
				openPicture: false,
				cbj: false,
				cbj1: false,
				cbj2: true,
				fl: false,
				openFkpz1: false,
				bp: false,
				zybd: true,
				sjbd: false,
				bpLr: false,
				// 付款凭证
				attach_list: [],
				carouselImg: [],
				rules: {
					phone: [{
						required: true,
						message: '请输入手机号',
						trigger: 'blur'
					}],
					code: [{
						required: true,
						message: '请输入卡编号',
						trigger: 'blur'
					}],
					serviceName: [{
						required: true,
						message: '请输入运营商',
						trigger: 'blur'
					}],
					sites: [{
						required: true,
						message: '请输入卡位',
						trigger: 'blur'
					}],
					palletType: [{
						required: true,
						message: '请选择卡板类型',
						trigger: 'blur'
					}],
					placement: [{
						required: true,
						message: '请输入机位',
						trigger: 'blur'
					}],
					statuses: [{
						required: true,
						message: '请选择状态',
						trigger: 'blur'
					}],
					anomalies: [{
						required: true,
						message: '请输入异常原因',
						trigger: 'blur'
					}],
					remark1: [{
						required: true,
						message: '请输入备注',
						trigger: 'blur'
					}],
				},
				gameList: [],
				tableData: [],
				// 遮罩层
				loading: true,
				yzoptions: [{
					value: 'Y',
					label: '已缴'
				}, {
					value: 'N',
					label: '未缴'
				}],
				stoptions: [{
					value: '0',
					label: '正常'
				}, {
					value: '1',
					label: '异常'
				}],
				// open:false

				// 总条数
				total: 0,
				// 弹出层标题
				title: "",
				// 显示搜索条件
				showSearch: true,
				// 是否显示弹出层
				open: false,
				// 查询参数
				queryParams: {
					pageNum: 1,
					pageSize: 10,
					realName: null,
					phone: null,
				},
				ppOptions: [],

				// 表单参数
				form1: {

				},
				// 表单参数
				form3: {

				},
				option6: {
					tooltip: {
						trigger: 'item'
					},
					legend: {
						top: '5%',
						left: 'center'
					},
					series: [{
						name: 'Access From',
						type: 'pie',
						radius: ['40%', '70%'],
						avoidLabelOverlap: false,
						label: {
							show: false,
							position: 'center'
						},
						emphasis: {
							label: {
								show: true,
								fontSize: 40,
								fontWeight: 'bold'
							}
						},
						labelLine: {
							show: false
						},
						data: [{
								value: 1048,
								name: 'Search Engine'
							},
							{
								value: 735,
								name: 'Direct'
							},
							{
								value: 580,
								name: 'Email'
							},
							{
								value: 484,
								name: 'Union Ads'
							},
							{
								value: 300,
								name: 'Video Ads'
							}
						],
					}],
				},
				myChart: {},
			}
		},
		created() {
			this.user1();
			this.getList();
			this.getEchartData6();
		},
		methods: {
			getEchartData6() {
				const chart1 = this.$refs.chart6
				console.log(this.$refs.chart6)
				if (chart1) {
					const myChart = this.$echarts.init(chart1)
					myChart.setOption(this.option6)
					window.addEventListener("resize", function() {
						myChart.resize()
					})
				}
				this.$on('hook:destroyed', () => {
					window.removeEventListener("resize", function() {
						myChart.resize();
					});
				})
			},
			user1() {
				getTBusShopInfo().then(res => {
					if (res.data) {
						this.disabled3 = false;
					} else {
						this.disabled3 = true;
					}
				})
				queryTBusShop().then(response => {
					response.data.forEach((item) => {
						this.deptOptions.push({
							label: item.name,
							value: item.id,
						});
					});
				});
				return this.deptOptions;
			},
			handleUpdateAll() {
				shopEdit(this.form5).then(res => {
					if (res.code == 200) {
						this.ppOptions = [];
						this.$message({
							type: 'success',
							message: '修改成功'
						})
						this.dialogVisible1 = false;
						let pplist = this.form5.phonePlace.split(/[/]/)
						pplist.forEach(item => {
							this.ppOptions.push({
								label: item,
								value: item,
							});
						})
					}
				})
			},
			handleClose() {},
			user() {
				this.ppOptions = [];
				this.xz = true;
				this.title = "添加手机号信息";
				getTBusShopInfo().then(res => {
					if (res.data) {
						this.form3.shopId = res.data.id;
						if (res.data.phonePlace) {
							let pplist = res.data.phonePlace.split(/[/]/)
							pplist.forEach(item => {
								this.ppOptions.push({
									label: item,
									value: item,
								});
							})
						}
					}
				})
			},
			handleAddpp() {
				this.form5 = {};
				this.getgetShopInfo();
				this.dialogVisible1 = true;
			},
			getgetShopInfo() {
				if (this.form3.shopId) {
					getShopInfo(this.form3.shopId).then(res => {
						if (res.data) {
							if (this.dialogVisible1 == true) {
								this.form5 = res.data
							}
						} else {
							alert('请联系管理员!')
						}
					})
				}

			},
			/** 新增按钮操作 */
			handleAdd() {
				this.form1 = {};
				this.resetQuery();
				this.user();
			},
			/** 删除按钮操作 */
			handleDelete(row) {
				const id = row.id
				const names = row.phone
				this.$modal.confirm('是否确认删除手机号["' + names + '"]的数据项？').then(function() {
					return deletePhone(id);
				}).then(() => {
					this.getList();
					this.$modal.msgSuccess("删除成功");
				}).catch(() => {});
			},

			/** 查询账号信息列表 */
			getList() {
				this.loading = true;
				accountMonitoring(this.queryParams).then(response => {
					this.tableData = response.rows;
					this.total = response.total
					this.loading = false;
				});
			},
			//已交按钮
			handleYupdate(row) {
				const names = row.phone
				this.$modal.confirm('是否确认手机号["' + names + '"]的月租已缴费？').then(function() {
					row.monthly = 'Y';
					return upData(row);
				}).then(() => {
					this.getList();
					this.$modal.msgSuccess("确认成功");
				}).catch(() => {});
			},
			//修改按钮
			handleUpdate(row) {
				this.user();
				this.form1 = [];
				this.ppOptions = [];
				getTBusShopInfo().then(res => {
					if (res.data) {
						if (res.data.phonePlace) {
							let kflist = res.data.phonePlace.split(/[/]/)
							kflist.forEach(item => {
								this.ppOptions.push({
									label: item,
									value: item,
								});
							})
						}
					}
				})
				getPhone(row.id).then(res => {
					this.form1 = res.data
					this.form1.remark1 = this.form1.remark
					this.xz = true;
					this.title = "修改手机号信息";
				})
			},


			/** 搜索按钮操作 */
			handleQuery() {
				this.disabled = true;
				this.block = false;
				this.queryParams.pageNum = 1;
				this.getList();
			},

			/** 重置按钮操作 */
			resetQuery() {
				this.block = false;
				this.disabled = true;
				this.resetForm("queryForm");
				this.handleQuery();
			},
			// 新增确定按钮
			submitForm() {
				this.$refs["form"].validate(valid => {
					if (valid) {
						if (this.form1.palletType == '其他') {
							this.form1.remark = this.form1.remark1
						}
						if (this.form1.statuses == '0') {
							this.form1.anomalies = ''
						} //异常原因置空
						if (this.title == '添加手机号信息') {
							add(this.form1).then(res => {
								if (res.code == 200) {
									this.getList();
									this.xz = false;
									this.$modal.msgSuccess("添加成功");
								} else {
									alert(res.msg)
								}
							})
						} else {
							if (this.form1.palletType == '其他') {
								this.form1.remark = this.form1.remark1
							}
							if (this.form1.statuses == '0') {
								this.form1.anomalies = ''
							} //异常原因置空
							upData(this.form1).then(res => {
								if (res.code == 200) {
									this.getList();
									this.xz = false;
									this.$modal.msgSuccess("修改成功");
								} else {
									alert(res.msg)
								}
							})
						}
					}
				})
			},


			cancel() {
				this.xz = false;
				this.open1 = false;
				this.resetForm("form");
			},



		}
	};
</script>
<style scoped lang="scss">
	.app-container {
		background-color: #ebedf9;
	}

	.top {
		width: 96%;
		margin: auto;
		padding: 0.625rem;
		background-color: #f6f7f9;

		.father {
			width: 100%;
			margin-top: 0.625rem;
			display: flex;
			justify-content: space-around;

			.son {
				width: 16%;
				height: 6rem;
				background-color: white;
				border-radius: 0.625rem;
				display: flex;
				justify-content: space-around;
				justify-items: center;

				img {
					height: 4rem;
					margin-top: 1rem;
				}
			}
		}
	}

	.tysx {
		display: flex;
		justify-items: center;
	}

	.tybq {
		width: 3px;
		height: 20px;
		margin-right: 0.425rem;
		background-color: #2869d1;
	}

	.banner {
		width: 96%;
		margin: auto;
		margin-top: 1rem;
		display: flex;
		justify-content: space-around;

		.banner-left {
			width: 49%;
			padding: 0.625rem;
			margin-right: 2%;
			height: 12rem;
			border-radius: 0.625rem;
			background-color: white;
		}

		.banner-right {
			width: 49%;
			padding: 0.625rem;
			height: 12rem;
			border-radius: 0.625rem;
			background-color: white;
		}
	}

	.bottom {
		width: 96%;
		margin: auto;
		margin-top: 1rem;
		display: flex;
		justify-content: left;

		.bottom-left {
			width: 70%;
			padding: 0.625rem;
			height: 12rem;
			border-radius: 0.625rem;
			background-color: white;
		}
	}

	.el-icon-loading {
		color: green;
		margin-right: 5px;
	}

	.el-icon-message-solid {
		color: green;
		margin-right: 5px;
	}

	.el-icon-check {
		color: green;
		margin-right: 5px;
	}

	.el-icon-coin {
		color: green;
		margin-right: 5px;
	}
</style>