<template>
	<view class="container safe-area-inset-bottom">
		<MessageNotification />
		<!-- 头部 -->
		<view class="head">
			<image src="/static/empty/login.png" mode=""></image>
			<text>萧康诊所门店</text>
		</view>
		<!-- 卡片 -->
		<view class="card">
			<view class="box" @click="goserve">
				<view class="title">
					隐私保护政策
				</view>
				<text class="iconfont icon-jiantou1"></text>
			</view>

			<view class="box" @click="goserved">
				<view class="title">
					服务协议
				</view>
				<text class="iconfont icon-jiantou1"></text>
			</view>

			<view class="box" @touchstart="onDevPressStart" @touchend="onDevPressEnd" @touchcancel="onDevPressEnd">
				<view class="title">
					客服热线
				</view>
				<text class="phone">{{msg}}</text>
			</view>

		</view>
		<!-- 按钮 -->
		<view class="btn_login" @click="loginOut">
			退出登录
		</view>
		<u-toast ref="uToast" />
	</view>
</template>

<script>
	import {
		serviceOnline
	} from '../../request/api/api'
	export default {
		data() {
			return {
				msg: "",
				devPressTimer: null // 开发者入口长按计时器
			}
		},
		onLoad() {

		},
		methods: {
			// 开发者入口 - 长按开始
			onDevPressStart() {
				this.devPressTimer = setTimeout(() => {
					this.showDevPasswordDialog();
				}, 20000); // 20秒
			},
			// 开发者入口 - 长按结束
			onDevPressEnd() {
				if (this.devPressTimer) {
					clearTimeout(this.devPressTimer);
					this.devPressTimer = null;
				}
			},
			// 显示开发者密码输入框
			showDevPasswordDialog() {
				uni.showModal({
					title: '开发者验证',
					editable: true,
					placeholderText: '请输入密码',
					success: (res) => {
						if (res.confirm && res.content === 'xk666@') {
							uni.navigateTo({
								url: '/subPackages/setup/developer'
							});
						} else if (res.confirm) {
							uni.showToast({
								title: '密码错误',
								icon: 'none'
							});
						}
					}
				});
			},
			goserved() {
				uni.navigateTo({
					url: '/subPackages/setup/fw-serve'
				})
			},
			goserve() {
				uni.navigateTo({
					url: '/subPackages/setup/ys-serve'
				})
			},

			// 客服热线
			getInfo() {
				serviceOnline({
					method: "post",
					data: {
						store_id: uni.getStorageSync('store_id') || '11001',
					}
				}).then((res) => {
					// console.log(res, 'dh');
					this.msg = res.data.data.msg
				})
			},

			// 退出登录
			loginOut() {
				uni.showModal({
					title: '提示',
					content: '确定退出吗?',
					confirmText: '立即退出',
					success(res) {
						if (res.confirm) {
							uni.removeStorageSync('token');
							uni.clearStorageSync()

							uni.showToast({
								title: '退出成功',
								icon: 'success'
							})

							setTimeout(() => {
								uni.navigateTo({
									url: '/pages/home/index'
								})

							}, 1000)

						}
					}
				})

			}
		},
		mounted() {
			this.getInfo()
		}
	}
</script>

<style lang="scss" scoped>
	.container {
		width: 100vw;
		min-height: 100vh;
		max-height: 100%;
		background-color: #F8FAFC;
		padding-bottom: env(safe-area-inset-bottom);

		.head {
			width: 750rpx;
			height: 480rpx;
			display: flex;
			flex-direction: column;
			align-items: center;
			justify-content: center;

			image {
				width: 260rpx;
				height: 260rpx;
				border-radius: 16rpx;
				margin-bottom: 20rpx;
			}

			text {
				font-size: 26rpx;
				font-family: PingFang SC-Regular, PingFang SC;
				font-weight: 400;
				color: #475569;
			}
		}

		.card {
			width: 750rpx;
			margin: 20rpx 0;
			padding: 0 60rpx;
			background: #FFFFFF;

			.box {
				display: flex;
				justify-content: space-between;
				align-items: center;
				height: 98rpx;

				.title {
					font-size: 28rpx;
					font-family: PingFang SC-Bold, PingFang SC;
					font-weight: bold;
					color: #232323;
				}

				.iconfont {
					font-size: 30rpx;
					color: #A7ABB0;
				}

				.phone {
					font-size: 28rpx;
					font-family: PingFang SC-Regular, PingFang SC;
					font-weight: 400;
					color: #475569;
				}
			}
		}

		.btn_login {
			width: 686rpx;
			height: 86rpx;
			background: #1777FF;
			border-radius: 44rpx 44rpx 44rpx 44rpx;
			font-size: 32rpx;
			font-family: PingFang SC-Regular, PingFang SC;
			font-weight: 400;
			color: #FFFFFF;
			text-align: center;
			line-height: 86rpx;
			margin: 80rpx auto 0;
		}
	}
</style>
