<script>
	import Vue from 'vue';
	//app.js
	var config = require("./config");
	export default {
		onLaunch(options) {
			uni.getSystemInfo({
				success: function(e) {
					console.log(e, 'adjsakljdklasjdklsakjdslakjd')
					// #ifdef MP-WEIXIN
					Vue.prototype.StatusBar = e.statusBarHeight;
					let custom = wx.getMenuButtonBoundingClientRect();
					Vue.prototype.Custom = custom;
					Vue.prototype.CustomBar = custom.bottom + custom.top - e.statusBarHeight;
					Vue.prototype.windowHeight = e.safeArea.height
					// #endif
					Vue.mixin({
						data() {
							return {
								StatusBar: Vue.prototype.StatusBar,
								CustomBar: Vue.prototype.CustomBar,
								windowHeight: Vue.prototype.windowHeight
							};
						},

						methods: {
							// 时分秒转换为秒
							TIMEEVENT(e) {
								var time = e;
								var len = time.split(':')
								if (len.length == 3) {
									var hour = time.split(':')[0];
									var min = time.split(':')[1];
									var sec = time.split(':')[2];
									return Number(hour * 3600) + Number(min * 60) + Number(sec);
								}
								if (len.length == 2) {
									var min = time.split(':')[0];
									var sec = time.split(':')[1];
									return Number(min * 60) + Number(sec);
								}
								if (len.length == 1) {
									var sec = time.split(':')[0];
									return Number(sec);
								}
							},

							// 目前使用页面为录音页面
							SPEAKERSTYLE(index) {
								let obj = {
									color: '',
								}
								switch (index) {
									case 1:
										obj.color = '#60CBEC';
										break;
									case 2:
										obj.color = '#EC8B47';
										break;
									case 3:
										obj.color = '#4F861E';
										break;
									case 5:
										obj.color = '#4980C8';
										break;
									case 6:
										obj.color = '#60CBEC';
										break;
									case 7:
										obj.color = '#EC8B47';
										break;
									case 8:
										obj.color = '#4F861E';
										break;
									default:
										obj.color = '#9F61C8';
										break;
								}
								return obj
							},
						},

						filters: {
							// ASCII码转换 大写字母A是65 演讲人是从1开始所以num+64
							toCapital(num) {
								let str = ''
								if (num) {
									str = String.fromCharCode(num + 64)
								}
								return str
							}
						}
					});
				}
			});

			if (wx.canIUse('getUpdateManager')) {
				const updateManager = wx.getUpdateManager()
				updateManager.onCheckForUpdate(function(res) {
					if (res.hasUpdate) {
						updateManager.onUpdateReady(function() {
							uni.showModal({
								title: '更新提示',
								cancelColor: "#999999",
								content: '新版本已经准备好，是否重启应用？',
								success: function(res) {
									if (res.confirm) {
										updateManager.applyUpdate()
									}
								}
							})
						})
						updateManager.onUpdateFailed(function() {
							uni.showModal({
								title: '已经有新版本了哟~',
								cancelColor: "#999999",
								content: '新版本已经上线啦~，请您删除当前小程序，重新搜索打开哟~'
							})
						})
					}
				})
			} else {
				uni.showModal({
					title: '提示',
					cancelColor: "#999999",
					content: '当前微信版本过低，无法使用该功能，请升级到最新微信版本后重试。'
				})
			}
			const token = uni.getStorageSync("weapp_session_login_data")
			if (typeof token.token != "string") {
				return
			}
			uni.request({
				url: config.service.getUser,
				method: "GET",
				header: {
					'content-type': 'application/json',
					'Authorization': 'Bearer ' + uni.getStorageSync('weapp_session_login_data').token
				},
				success: (res) => {
					let rescor = res.data.data;
					console.log(res, '数据', rescor)
					// return
					if (res.statusCode == 401) {
						uni.showToast({
							title: '登录过期请重新登录',
							icon: "none",
							duration: 2000,
						})
						uni.navigateTo({
							url: `/pages/login/index`
						})
						return
					}
					if (rescor.user.total == 0) {
						uni.showToast({
							title: '暂无绑定项目',
							duration: 2000,
							icon: "none"
						});
						return
					} else {
						let lopan = {
							id: rescor.houseList[0].id,
							name: rescor.houseList[0].propertyName
						}
						let users = rescor.user
						users.zkProperties = rescor.houseList
						console.log(users, '角色数据')
						uni.setStorageSync("weapp_session_userInfo_data", users); //写入缓存
					}
				}
			})
			// this.$u.get("/user/getUser")
			// .then(data => {
			// 	if (data.user.total==0) {
			// 		uni.showToast({
			// 		    title: '暂无绑定项目',
			// 		    duration: 2000,
			// 			icon:"none"
			// 		});
			// 		return
			// 	} else {
			// 			let lopan = {
			// 				id: data.houseList[0].id,
			// 				name: data.houseList[0].propertyName
			// 			}
			// 			let users=data.user
			// 			users.zkProperties=data.houseList
			// 			uni.setStorageSync("weapp_session_userInfo_data",users); //写入缓存
			// 	}	
			// })
			wx.setInnerAudioOption({
				obeyMuteSwitch: false
			});
		},


		onShow(options) {
			const token = uni.getStorageSync("weapp_session_login_data")
			if (typeof token.token != "string") {
				console.log("没有")
				return
			} else {}
		}
	};
</script>

<style>
	@import "./app.css";
</style>
<style lang="scss">
	@import "uview-ui/index.scss";

	/*每个页面公共css */
	//图表样式等
	.single {
		width: 100%;
		background: #FFFFFF;

		.title {
			width: 100%;
			height: 90rpx;
			display: flex;
			align-items: center;

			.title1 {
				flex: 2;
				font-size: 32rpx;
				font-weight: 500;
				color: #333333;
				line-height: 90rpx;
				text-indent: 30rpx;
			}

			.title3 {
				flex: 3;
				height: 90rpx;
				display: flex;
				align-items: center;
				justify-content: flex-end;
				padding-right: 30rpx;

				.title3-box {
					display: flex;
					align-items: center;
					width: 25%;
					justify-content: center;

					.activecltab {
						color: #2671E2;
						border-bottom: 4rpx solid #2671E2;
					}
				}
			}

			.title2 {
				flex: 2;
				display: flex;
				justify-content: flex-end;
				align-items: center;
				height: 42rpx;
				font-size: 30rpx;
				font-family: PingFangSC-Regular, PingFang SC;
				font-weight: 400;
				color: #333333;
				line-height: 42rpx;
				margin-right: 30rpx;
				.righttochoose {
						width: 24rpx;
						height: 12rpx;
						margin-left: 12rpx;
					}
			}
		}

		.swiper-box {
			width: 97%;
			margin: 0 auto 38rpx;
		}

		.hejibox {
			width: 100%;
			height: 80rpx;
			display: flex;

			.heji {
				width: 50%;
				height: 100%;
				font-size: 28rpx;
				font-weight: 400;
				color: #666666;
				line-height: 80rpx;
				text-indent: 30rpx;
			}
		}

		.danwei {
			width: 100%;
			height: 40rpx;
			font-size: 24rpx;
			font-weight: 400;
			color: #999999;
			line-height: 40rpx;
			text-indent: 30rpx;
		}

		.uchaserbox {
			width: 95%;
			height: 470rpx;
		}

		.jindu {
			width: 100%;
			height: 300rpx;

			.jindu-box {
				width: 100%;
				padding: 0 30rpx;

				.jindu-boxche {
					width: 100%;
					height: 40rpx;
					display: flex;
					align-items: center;
					margin-bottom: 38rpx;
					.jindu-name {
						width: 120rpx;
						font-size: 28rpx;
						font-family: PingFangSC-Regular, PingFang SC;
						font-weight: 400;
						color: #333333;
						line-height: 40rpx;
					}

					.progress-cus{
						flex: 1;
						height: 30rpx;
						margin-left: 10rpx;
						background: #F0F1F2;
						.color{
							height: 30rpx;
							background: linear-gradient(90deg, #3A82EF 0%, #7EB2FF 100%);
						}
						.color4{
							height: 30rpx;
							background: linear-gradient(270deg, #6DC5B8 0%, #07B79D 100%);
						}
						.color1{
							height: 30rpx;
							background: linear-gradient(270deg, #F88881 0%, #E6625B 100%);//1
						}
						.color2{
							height: 30rpx;
							background: linear-gradient(270deg, #FFC940 0%, #FF981E 100%);//2
						}
						.color3{
							height: 30rpx;
							background: linear-gradient(270deg, #FFE800 0%, #FFCC00 100%); //3
						}
					}

					.jindu-zxl {
						width: 120rpx;
						font-size: 28rpx;
						margin-left: 12rpx;
						color: #333;
						text-align: left;
						line-height: 40rpx;
					}
				}
			}
		}
	}

	//时间切换的样式
	.boxtittab {
		width: 100;
		height: 92rpx;
		background: #FFFFFF;
		display: flex;
		align-items: center;

		.tabbox {
			flex: 1;
			height: 100%;
			text-align: center;
			line-height: 92rpx;
			color: #666666;
			font-size: 28rpx;
			display: flex;
			justify-content: center;

			.activecllasscet {
				width: 96rpx;
				color: #2671E2;
				border-bottom: 4rpx solid #2671E2;
			}
		}
	}

	//多个格子的样式
	.boxzonglan {
		width: 100%;
		min-height: 496rpx;
		background: #FFFFFF;
		padding: 30rpx 30rpx 30rpx 30rpx;

		.zonglantit {
			font-size: 30rpx;
			color: #333333;
			font-family: PingFangSC-Semibold, PingFang SC;
			font-weight: 500;
		}

		.zonglanbox {
			width: 100%;
			display: flex;
			flex-wrap: wrap;
			margin-top: 24rpx;
			box-shadow: 0px 0px 12rpx 0px rgba(38, 113, 226, 0.1);
			border-radius: 12rpx;

			.grid {
				width: 50%;
				// height: 128rpx;
				padding-bottom: 24rpx;
				// border: 1rpx solid #E0E0E0;

				.audonum {
					color: #666666;
					text-indent: 40rpx;
					font-size: 28rpx;
					margin-top: 20rpx;
					line-height: 40rpx;
					display: flex;
					align-items: center;
					.circle{
						width: 20rpx;
						height: 20rpx;
						background: #FFFFFF;
						border: 6rpx solid #2671E2;
						margin-right: 12rpx;
						margin-left: 30rpx;
						border-radius: 50%;
					}
				}

				.num {
					color: #333333;
					text-indent: 40rpx;
					font-size: 44rpx;
					font-weight: 600;
					line-height: 50rpx;
					margin-top: 18rpx;
				}
			}
		}
	}
</style>
