<template>
	<view class="topcon" @click="goservice">
		<image class="topimg" src="/static/image/kf.png" mode="aspectFill" lazy-load></image>
	</view>
</template>

<script> 
import { myCache } from '../../utils/utils.js';
export default {
	data() {
		return {
		};
	}, 
	methods: {
		goservice(){
			console.log('linemobile',myCache('linemobile'))
			myCache('linemobile','18900000001')
			// 在线客服
			if(myCache('linemobile')){
				// 在线客服
				uni.makePhoneCall({
					phoneNumber: String(myCache('linemobile')),
					success:function(){
						console.log('拨打电话成功');
					},
					fail() {
						console.log('打电话失败了');
					}
				}); 
			}
			else{
				// this.getlinemobile();
			}
			this.$emit("goservice", "goservice");
		},
		async getlinemobile(){
			const {data: res} = await uni.$http.get('/platform/getHotline');
			console.log(res)
			if (res) {
				myCache('linemobile',res);
				uni.makePhoneCall({
					phoneNumber: String(myCache('linemobile')),
					success:function(){
						console.log('拨打电话成功');
					},
					fail() {
						console.log('打电话失败了');
					}
				});
			}
			else{
				uni.showModal({
					title: '提示',
					content: '在线电话获取失败！请稍后再试！',
					cancelText: '取消',
					confirmText: '确定',
					success: ress => {
						if (ress.confirm) {
						}
					}
				});
			}
		}
	}
}
</script>

<style lang="scss" scoped>
	.topcon{
		position: fixed;
		right: 20rpx;
		bottom: 280rpx;
		width: 66rpx;
		height: 66rpx;
		display: flex;
		align-items: center;
		justify-content: center;
		background-color: rgba(243, 244, 239, 0.8);
		border-radius: 100% 100%;
		border: 1rpx solid #89965f;
		z-index: 998;
		.topimg{
			width: 40rpx;
			height: 40rpx;
			opacity: 1;
		}
	}
</style>
 