<template>
	<view class="ad flex-col align-end">
		<view class="adIcon flex-col align-center" v-if="barName == 'repair'" @click="appiontment()">
			<image class="icon_1" :src="imagesUrl+'appointment.png'" />
			<text style="font-size: 20rpx;">预约</text>
		</view>
		<view class="adIcon flex-col align-center" v-if="barName == 'index'" @click="getkefu">
			<image class="icon_2" :src="imagesUrl+'service.png'" />
		</view>
		<view class="adIcon flex-col align-center" v-if="barName == 'index'" @click="call">
			<image class="icon_3" :src="imagesUrl+'phone.png'" />
		</view>
	</view>
</template>

<script>
	export default {
		name: "contactBar",
		props: {
			barName: String
		},
		data() {
			return {
				imagesUrl: getApp().globalData.config.imagesUrl,
				groupTel: null
			};
		},
		mounted() {
			this.getConfig()
		},
		methods: {
			getkefu() {
				console.log('执行');
				wx.openCustomerServiceChat({
					extInfo: {
						url: 'https://work.weixin.qq.com/kfid/kfc7eb80993bc0ecd32'
					},
					corpId: 'ww2a4d01f86ea7ad90',
					success(res) {
						console.log(res);
					}
				})
			},
			// 获取配置:电话与位置、坐标
			async getConfig() {
				const res = await this.$request({
					url: '/system/shopconfig/listWx'
				})
				this.groupTel = res.rows[0].groupTel;
			},
			call() {
				uni.makePhoneCall({
					phoneNumber: this.groupTel.toString(), //电话号码
					success: function(e) {
						console.log(e);
					},
					fail: function(e) {
						console.log(e);

					}
				})
			},
			appiontment() {
				this.$emit("appiontment")
			}
		},

	}
</script>

<style scoped>
	.ad {
		width: 150rpx;
		height: 300rpx;
		position: fixed;
		right: 30rpx;
		bottom: 60px;
		z-index: 9999;
		padding-right: 30rpx;
	}

	.adIcon {
		box-shadow: 0px 0px 13px 4px rgba(216, 216, 216, 0.61);
		background-color: rgba(255, 255, 255, 1);
		border-radius: 50%;
		height: 102rpx;
		width: 102rpx;
		margin-bottom: 30rpx;
	}

	.icon_1 {
		width: 50rpx;
		height: 50rpx;
		margin: 10rpx auto;
	}

	.icon_2 {
		width: 54rpx;
		height: 66rpx;
		margin: 22rpx 18rpx 0 18rpx;
	}

	.icon_3 {
		width: 53rpx;
		height: 53rpx;
		margin: 25rpx 0 0 5rpx;
	}
</style>