<template>
	<view class="view">
		<div class="card">
			<div class="row" @tap="goPage()">
				<div class="left">
					<image :src="$util.img('/upload/weapp/user/kefu.png')" mode=""></image>
					<span class="text">在线客服</span>
				</div>
				<div class="right">
					<image :src="$util.img('/upload/weapp/user/arrow-right.png')" mode=""></image>
				</div>
			</div>
			<u-line></u-line>

			<div class="row">
				<div class="left">
					<image :src="$util.img('/upload/weapp/user/contact.png')" mode=""></image>
					<span class="text">专属业务员</span>
				</div>
				<div class="right" @click="professer = !professer">
					<image :src="$util.img('/upload/weapp/user/arrow-bottom.png')" v-if="professer" mode=""></image>
					<image :src="$util.img('/upload/weapp/user/arrow-right.png')" mode="" v-else></image>
				</div>
			</div>
			<!-- <u-line></u-line> -->


			<div class="open" v-if="professer">
				<!--  #ifndef  MP-WEIXIN -->
				<a :href="`tel:${my_salasman_info.tel}`" style="text-decoration:none">
					<div class="open_row">
						<div class="name">{{ my_salasman_info.salasman_name }}</div>
						<div class="phone">{{ my_salasman_info.tel }}</div>
					</div>
				</a>
				<!-- #endif -->
				<!--  #ifdef  MP-WEIXIN -->
				<div class="open_row" @click="() => makePhoneCall(my_salasman_info.tel)">
					<div class="name">{{ my_salasman_info.salasman_name }}</div>
					<div class="phone">{{ my_salasman_info.tel }}</div>
				</div>
				<!-- #endif -->
				<!-- <u-line></u-line> -->
			</div>



			<!-- <div class="row" style="padding-bottom: 25rpx;">
				<div class="left">
					<image :src="$util.img('/upload/weapp/user/contact1.png')" mode=""></image>
					<span class="text">其他联系方式</span>
				</div>
				<div class="right" @click="elseContact = !elseContact">
					<image :src="$util.img('/upload/weapp/user/arrow-bottom.png')" v-if="elseContact" mode=""></image>
					<image :src="$util.img('/upload/weapp/user/arrow-right.png')" mode="" v-else></image>
				</div>
			</div>


			<u-line v-if="elseContact"></u-line>
			<div class="open" v-if="elseContact">
				<div v-for="(item, index) in salas_list" :key="index"> -->
					<!--  #ifndef  MP-WEIXIN -->
				<!-- 	<a :href="`tel:${item.tel}`" style="text-decoration:none">
						<div class="open_row">
							<div class="name">{{ item.salasman_name }}</div>
							<div class="phone">{{ item.tel }}</div>
						</div>
					</a> -->
					<!-- #endif -->
					<!--  #ifdef  MP-WEIXIN -->
					<!-- <div class="open_row" @click="() => makePhoneCall(item.tel)">
						<div class="name">{{ item.salasman_name }}</div>
						<div class="phone">{{ item.tel }}</div>
					</div> -->
					<!-- #endif -->
					<!-- <u-line></u-line> -->
				<!-- </div> -->
			<!-- </div> -->
		</div>
	</view>
</template>

<script>
export default {
	data() {
		return {
			professer: false,
			elseContact: true,
			my_salasman_info: {}, // 我的业务员
			parent_info: {}, // 上级业务员
			salas_list: [] // 同一个业务经理下的其他业务员
		}
	},
	onShow() {
		this.getSalasmanInfo()
	},
	methods: {
		goPage() {
			const _floatData = uni.getStorageSync('floatData')
			this.$util.diyRedirectTo(_floatData.list[0].link)
		},
		getSalasmanInfo() {
			this.$api.sendRequest({
				url: '/api/member/salasmanInfo',
				data: {},
				success: res => {
					this.my_salasman_info = res.data.my_salasman_info
					this.parent_info = res.data.parent_info
					this.salas_list = res.data.salas_list

				}
			})
		},
		makePhoneCall(phoneNumber) {
			try {
				console.log(phoneNumber, 'phoneNumber');
				uni.makePhoneCall({ phoneNumber })
			} catch (e) {
				//TODO handle the exception
			}
		}
	}
}
</script>

<style lang="scss" scoped>
.view {
	padding: 32rpx;

	.card {
		background: #FFFFFF;
		border-radius: 16rpx;
		padding: 0 32rpx 0 32rpx;

		.row {
			display: flex;
			padding: 32rpx 0;

			.left {
				image {
					width: 32rpx;
					height: 32rpx;
					position: relative;
					top: 6rpx;
				}

				.text {

					margin-left: 16rpx;
					font-size: 28rpx;
					font-family: PingFangSC-Medium, PingFang SC;
					font-weight: 600;
					color: #222222;
				}
			}

			.right {
				text-align: right;
				flex: 1;

				image {
					width: 32rpx;
					height: 32rpx;
				}
			}
		}

		.open {
			padding: 0 8rpx 0 48rpx;

			.open_row {
				padding: 30rpx 0;
				width: 100%;
				display: flex;

				.name {
					flex-grow: 1;
					font-size: 28rpx;
					font-family: PingFangSC-Regular, PingFang SC;
					color: #585858;
				}

				.phone {
					font-size: 28rpx;
					font-family: PingFangSC-Regular, PingFang SC;
					color: #585858;
				}
			}
		}
	}
}
</style>
