<template>
	<view class="contactCustomerService">
		<u-navbar :title="$route.query.title">
			<view slot="left" class="back">
				<u-icon @click="toLogin()" name="arrow-left"></u-icon>
			</view>
		</u-navbar>
		<view class="img">
			<img width="200px" :src="kf.keyImage" alt="" />
		</view>
		<view class="text">
			{{ $t('page.contactCustomerService.text') }}
		</view>
		<view class="text">
			{{ kf.keyPhone }}
		</view>
		<button class="btn" @click="copy">
			{{ $t('page.contactCustomerService.copy') }}
		</button>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				kf: {}
			};
		},
		onShow() {
			this.getData()
		},
		methods: {
			getData() {
				this.request('getKeFu').then(res => {
					this.kf = res.result
				})
			},
			toLogin() {
				let query = this.$route.query;
				if (query.url && query.id) {
					return uni.navigateTo({
						url: query.url + '?id=' + query.id
					})
				}
				uni.navigateTo({
					url: '/pages/login/login'
				})
			},
			copy() {
				uni.setClipboardData({
					data: this.kf.keyPhone,
					success: () => {
						uni.showToast({
							title: this.$t('success-operation'),
							icon: 'none'
						})
					}
				})
			}
		}
	}
</script>

<style lang="scss" scoped>
	.contactCustomerService {
		height: 100vh;
		width: 100%;
		background-color: #fff;
		display: flex;
		flex-direction: column;
		justify-content: center;
		align-items: center;
		flex-wrap: wrap;

		.text {
			box-sizing: border-box;
			padding: 10px;
			text-align: center;
		}

		.btn {
			border-radius: 5px;
			height: 30px;
			font-size: 13px;
			line-height: 30px;
			background-color: #ED762F;
			color: #fff;
		}
	}
</style>