<template>
	<view class="page">
		<u-navbar title="客户服务" :border-bottom="false" :background="bgc" title-color='#fff' title-size='36'  back-icon-color='#fff'
			height='45'></u-navbar>
			<image class="backimg" src="https://lxnapi.ccttiot.com/bike/img/static/ukLK3qJWhi4m70KzlxAE" mode=""></image>
			<view class="tit">
				Hi 您好,我们为您提供更多帮助哦~
			</view>
			<view class="qscard">
				<view class="card_top">
					<view class="li"  v-for="(item,index) in classlist" :key="index" @click="changeitx(item,index)">
						<view class="txt">
							{{item.classifyName}}
						</view>
						<view class="bot_bor" v-if="tabindex==index"></view>
						<view class="bot_bor" v-if="tabindex!=index" style="background: #fff;"></view>
					</view>
					
				</view>
				<view class="qs_li" v-for="(item,index) in wordlist" :key="index" @click="topage(item)">
					<view class="qs_li_txt">
						{{item.title}}
					</view>
					<view class="iconfont icon-xiangyou1"></view>
				</view>
			</view>
		<view class="btn" @click="isbackcar=true">
			<image src="https://lxnapi.ccttiot.com/bike/img/static/uEM1RpP3J0K51qTjtnA5" mode=""></image>
			电话咨询
		</view>
		<u-mask :show="isbackcar" :z-index='100' duration='0'  @click="isbackcar = false" /> 
		<view class="pops" v-if="isbackcar">
			<view class="tits" style="font-weight: 600;text-align: center;display: flex;justify-content: center;">
				联系电话
			</view>
			<view class="cont_box" >
				<view class="pohone_li" v-if="areaInfo.serviceName1!=''&&areaInfo.serviceName1&&areaInfo.servicePhone1!=''&&areaInfo.servicePhone1" @click="callPhone(areaInfo.servicePhone1)">
					<view class="name">
						{{areaInfo.serviceName1}}
					</view>
					<view class="pohone">
							{{areaInfo.servicePhone1}}
					</view>
				</view>
				<view class="pohone_li" v-if="areaInfo.serviceName2!=''&&areaInfo.serviceName2&&areaInfo.servicePhone2!=''&&areaInfo.servicePhone2"  @click="callPhone(areaInfo.servicePhone2)">
					<view class="name">
						{{areaInfo.serviceName2}}
					</view>
					<view class="pohone">
							{{areaInfo.servicePhone2}}
					</view>
				</view>
				<view class="pohone_li" v-if="areaInfo.serviceName3!=''&&areaInfo.serviceName3&&areaInfo.servicePhone3!=''&&areaInfo.servicePhone3"  @click="callPhone(areaInfo.servicePhone3)">
					<view class="name">
						{{areaInfo.serviceName3}}
					</view>
					<view class="pohone">
						{{areaInfo.servicePhone3}}
					</view>
				</view>
			</view>
		
			<view class="btn_box">
				<view class="btn1" @click="isbackcar = false">
					取消
				</view>
				<!-- <view class="btn2" @click="backDevice()">
					确定
				</view> -->
			</view>
		
		</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				bgc: {
					backgroundColor: "#64B6A7",
				},
				areaInfo: {},
				tabindex:0,
				classlist:[],
				wordlist:[],
				isbackcar:false
			}
		},
		onShow() {
			this.getarea()
			this.getclass()
		},
		methods: {
			getuserInfo(){
				uni.showLoading({
					title:'加载中'
				})
				this.$u.get("/getAppInfo").then((res) => {
				
					if (res.code == 200) {
						uni.hideLoading()
						
						this.getarea()
						// if( res.user.role==2){
						// 	uni.navigateTo({
						// 		url:'/page_fix/fix_index'
						// 	})
						// }
					} else {
						
						let areaId=uni.getStorageSync('areaId'); 
						if(areaId){
							let that =this
							wx.login({
								success(res) {
									if (res.code) {
										console.log('登录!', res);
										let data = {
											wxOpenId: res.code,
							
										};
										let areaId = uni.getStorageSync('areaId');
										that.$u.post('/loginByopenid?jsCode=' + res.code + '&areaId=' + areaId).then(
											res => {
												uni.hideLoading();
												if (res.code == 200) {
													uni.setStorageSync('token', res.token);
													that.getuserInfo()
							
							
												} else if (res.code == 501) {
													uni.showToast({
														title: res.msg,
														icon: 'none',
														duration: 2000
													});
												} else {
													// console.log("老用户登录",res.data)
													uni.redirectTo({
														url: '/pages/login/login'
													})
												}
											});
									}
								},
							
							});
						}else{
							uni.showToast({
								title: '请授权位置信息后再尝试',
								icon: 'none',
								duration: 4000
							});
						}
						
					}
				});
			},
			getarea() {
				let id = uni.getStorageSync('areaId');
				this.$u.get("/app/area/" + id).then((res) => {

					if (res.code == 200) {
						this.areaInfo = res.data
						// this.areaInfo.serviceName1='陶旭旭'
						// this.areaInfo.servicePhone1='17795402553'
					} else {
						// uni.showToast({
						// 	title: res.msg,
						// 	icon: 'none',
						// 	duration: 2000
						// });
					}
				});
			},
			topage(item) {
			    // 编码 title 和 content
			    const encodedTitle = encodeURIComponent(item.title);
			    const encodedContent = encodeURIComponent(JSON.stringify(item.content));
			    // 跳转到新页面并传递编码后的 title 和 content
			    uni.navigateTo({
			        url: `/page_user/word?id=`+item.articleId
			    });
			},
			changeitx(itme,index){
				this.tabindex=index
				this.getword(itme.classifyId)
			},
			getclass() {
				
				this.$u.get("/app/classify/list?deptId=101&parentId=111" ).then((res) => {
			
					if (res.code == 200) {
						this.classlist = res.data
						let id =this.classlist[0].classifyId
						this.getword(id)
					} else {
						// uni.showToast({
						// 	title: res.msg,
						// 	icon: 'none',
						// 	duration: 2000
						// });
					}
				});
			},
			getword(id) {
				
				this.$u.get("/app/article/list?classifyId="+id ).then((res) => {
			
					if (res.code == 200) {
						this.wordlist = res.rows
			
					} else {
						// uni.showToast({
						// 	title: res.msg,
						// 	icon: 'none',
						// 	duration: 2000
						// });
					}
				});
			},
			callPhone(phone){
				this.isbackcar=false
				uni.makePhoneCall({
					phoneNumber:phone
				})
			}
		}
	}
</script>

<style lang="scss">
	page {
		background-color: #fff;
	}

	.page {
		width: 750rpx;
		padding-bottom: 300rpx;
		.pops {
			padding: 46rpx 36rpx;
			position: fixed;
			top: 400rpx;
			left: 74rpx;
			width: 604rpx;
			// height: 606rpx;
			background: #fff;
			border-radius: 20rpx 20rpx 20rpx 20rpx;
			z-index: 110;
		
			.close {
				position: absolute;
				left: 266rpx;
				bottom: -100rpx;
		
				image {
					width: 80rpx;
					height: 80rpx;
				}
			}
		
			.loading_box {
				width: 100%;
				// height: 200rpx;
				display: flex;
				align-items: center;
				justify-content: center;
		
				image {
					width: 336rpx;
					height: 154rpx;
				}
		
				// .loader {
				//   width: 120rpx;
				//   aspect-ratio: 1;
				//   border-radius: 50%;
				//   clip-path: inset(-360rpx); /* 4倍的比例调整 */
				//   box-shadow: -240rpx 60rpx, -240rpx 60rpx, -240rpx 60rpx; /* 4倍的比例调整 */
				//   transform: translateY(-60rpx); /* 4倍的比例调整 */
				//   animation: l19 1s infinite linear;
				// }
		
				// @keyframes l19 {
				//   16.67% {box-shadow:-240rpx 60rpx,-240rpx 60rpx,  76rpx 60rpx} /* 4倍的比例调整 */
				//   33.33% {box-shadow:-240rpx 60rpx,    0px 60rpx,  76rpx 60rpx} /* 4倍的比例调整 */
				//   40%,60%{box-shadow: -76rpx 60rpx,    0px 60rpx,  76rpx 60rpx} /* 4倍的比例调整 */
				//   66.67% {box-shadow: -76rpx 60rpx,    0px 60rpx, 240rpx 60rpx} /* 4倍的比例调整 */
				//   83.33% {box-shadow: -76rpx 60rpx, 240rpx 60rpx,240rpx 60rpx} /* 4倍的比例调整 */
				//   100%   {box-shadow: 240rpx 60rpx, 240rpx 60rpx,240rpx 60rpx} /* 4倍的比例调整 */
				// }
		
			}
		
			.btn_box {
				margin-top: 80rpx;
				display: flex;
				align-items: center;
				justify-content: center;
		
				.btn1 {
					display: flex;
					align-items: center;
					justify-content: center;
					width: 216rpx;
					height: 90rpx;
					background: #989898;
					border-radius: 54rpx 54rpx 54rpx 54rpx;
		
					font-weight: 500;
					font-size: 40rpx;
					color: #FFFFFF;
				}
		
				.btn2 {
					display: flex;
					align-items: center;
					justify-content: center;
					width: 268rpx;
					height: 90rpx;
					background: #4C97E7;
					border-radius: 54rpx 54rpx 54rpx 54rpx;
		
					font-weight: 500;
					font-size: 40rpx;
					color: #FFFFFF;
				}
			}
		
			.time {
				margin-top: 20rpx;
				text-align: center;
				font-weight: 500;
				font-size: 48rpx;
				color: #4C97E7;
			}
		
			.cont {
				height: 500rpx;
				overflow-x: hidden;
				overflow-y: auto;
			}
		
			.tits {
				// width: 604rpx;
				text-align: center;
				font-weight: 500;
				font-size: 36rpx;
				color: #3D3D3D;
				margin-bottom: 54rpx;
			}
		
			.cont_box {
				margin-top: 36rpx;
				display: flex;
				flex-wrap: wrap;
				align-items: center;
				justify-content: center;
				.pohone_li{
					margin-top: 10rpx;
					display: flex;
					flex-wrap: nowrap;
					.name{
						font-weight: 500;
						font-size: 36rpx;
						color: #3D3D3D;
						margin-bottom: 54rpx;
					}
					.pohone{
						margin-left: 20rpx;
						font-weight: 500;
						font-size: 36rpx;
						color: #3D3D3D;
						margin-bottom: 54rpx;
					}
				}
				
			}
		
			.text {
				margin-top: 36rpx;
				display: flex;
				flex-wrap: wrap;
				// align-items: center;
		
				.yuan {
					margin-top: 10rpx;
					margin-right: 12rpx;
					width: 20rpx;
					height: 20rpx;
					background: #000;
					border-radius: 50%;
				}
		
				span {
					width: 90%;
					font-weight: 400;
					font-size: 28rpx;
					color: #3D3D3D;
				}
			}
		
			.btn {
				margin-left: 40rpx;
				margin-top: 50rpx;
				display: flex;
				align-items: center;
				justify-content: center;
				width: 470rpx;
				height: 90rpx;
				background: #4C97E7;
				border-radius: 54rpx 54rpx 54rpx 54rpx;
				font-weight: 500;
				font-size: 40rpx;
				color: #FFFFFF;
			}
		
			.act1 {
				background-color: #ccc;
			}
		}
		
		
		.backimg{
			position: fixed;
			width: 750rpx;
			height: 384rpx;
			z-index: -1;
		}
		.tit{
			margin-top: 56rpx;
			margin-left: 56rpx;
			font-weight: 400;
			font-size: 30rpx;
			color: #FFFFFF;
		}
		.qscard{
			width: 680rpx;
			margin: 40rpx auto ;
			background: #FFFFFF;
			border-radius: 40rpx;
			padding: 28rpx 30rpx;
			box-shadow: 0rpx 16rpx 40rpx 0rpx rgba(42,130,228,0.1);
			.card_top{
				display: flex;
				align-items: center;
				flex-wrap: nowrap;
				justify-content: space-around;
				.li{
					width: 112rpx;
					display: flex;
					flex-wrap: wrap;
					justify-content: center;
					.txt{
						font-weight: 500;
						font-size: 28rpx;
						color: #3D3D3D;
					}
					.bot_bor{
						margin-top: 16rpx;
						width: 66rpx;
						height: 6rpx;
						background: #64B6A7;
						border-radius: 3rpx 3rpx 3rpx 3rpx;
					}
				}
			}
			.qs_li:first-child{
				margin-top: 40rpx;
			}
			.qs_li:last-child{
				border-bottom: 2rpx solid #fff;
			}
			.qs_li{
					// margin-top: 10rpx;
				display: flex;
				flex-wrap: nowrap;
				align-items: center;
				justify-content: space-between;
				border-bottom: 2rpx solid #D8D8D870;
				padding-top: 26rpx;
				padding-bottom: 26rpx;
				.qs_li_txt{
				
					font-weight: 400;
					font-size: 28rpx;
					color: #3D3D3D;
				}
				.icon-xiangyou1{
					font-size: 32rpx;
					color: #3D3D3D;
				}
			}
		}
		.btn {
			position: fixed;
			left: 36rpx;
			bottom: 44rpx;
			display: flex;
			align-items: center;
			justify-content: center;


			width: 680rpx;
			height: 118rpx;
			background: #1E807A;
			border-radius:20rpx;

			image {
				margin-right: 18rpx;
				width: 34.5rpx;
				height: 33rpx;
			}
			font-weight: 600;
			font-size: 40rpx;
			color: #FFFFFF;
		}
	}
</style>