<template>
	<view class="container">
		<navBar title="客服中心" :back="true" color="#333333" background="#FFFFFF" />


		<view class="server">
			<image :src="picBase+'kefuAvatar.png'" mode=""></image>
		</view>
		<view v-if="phone" class="kefu">
			<view class="dian"></view>
			<view class="">客服手机号：{{phone}}</view>
			<view class="yijian"><u-button @click="call(phone)" color="#207CF7" size="mini" type="primary"
					shape="circle" text="一键拨号"></u-button></view>
		</view>
		<view v-if="weiChat" class="kefu">
			<view class="dian"></view>
			<view>客服微信号：{{weiChat}}</view>
			<view class="yijian"><u-button @click="fhuzhi" color="#207CF7" size="mini" type="primary" shape="circle"
					text="一键复制"></u-button></view>

		</view>
		<!-- <view class="sds">dfhsfsdh25</view> -->
		<block v-if="code">
			<view class="kefu">
				<view class="dian"></view>
				<view class="">客服二维码</view>
			</view>
			<view class="qrcode_path">
				<image @click="viewsave(code)" :src="code" mode="widthFix"></image>
				<!-- <image src="@/static/images/head.jpg" mode="widthFix"></image> -->
			</view>
		</block>

	</view>
</template>

<script>
	// import navBar from '@/components/navBar/index.vue'

	import {
		getKefu,
	} from '@/api/index/index.js'
	export default {
		// components: {
		// 	navBar
		// },
		data() {
			return {
				picBase: this.$picBase2,


				phone: '',
				weiChat: '',
				code: ''
			}

			info: null
		},
		onLoad() {
			this.getKefu()
		},
		methods: {
			async getKefu() {
				let res1 = await getKefu()
				console.log('客服信息返回值--------', res1);
				if (res1.code == 0) {
					this.phone = res1.data.service_phone.value
					this.weiChat = res1.data.service_wx.value
					this.code = this.$ossBaseUrl + res1.data.service_qrcode.value

					console.log(this.phone, this.weiChat, this.code);
				} else {
					this.$toast(res1.message)
				}
			},

			viewsave(e) {
				uni.previewImage({
					urls: [e],
					current: 0
				})
			},
			fhuzhi() {
				var that = this;
				uni.setClipboardData({
					data: that.weiChat,
					success: function() {
						uni.showToast({
							title: '微信号已复制'
						})
					}
				});
			},
			call(e) {
				wx.makePhoneCall({
					phoneNumber: e //仅为示例，并非真实的电话号码
				})
			},
		}
	}
</script>

<style lang="scss" scoped>
	@import "./index.scss";
</style>