<template>
	<view class="wrap">
		<uni-nav-bar dark :fixed="true" backgroundColor="#3F9EFF" statusBar="false" left-icon="left" left-text="返回"
			@clickLeft="toBack">
			<view class="nav-title">
				<text>{{title}}</text>
			</view>
		</uni-nav-bar>
		<view class="container">
			<view v-for="(item,index) in list" :key="item.id">
				<uni-group :title="item.orgName" margin-top="20">
					<uni-table ref="order_table" border stripe type="" emptyText="暂无更多数据">
						<uni-tr>
							<uni-th width="180" align="center">
								<view style="text-align: center;color: black;">姓名</view>
							</uni-th>
							<uni-th align="center">
								<view style="text-align: center;color: black;">联系电话</view>
							</uni-th>
						</uni-tr>
						<uni-tr v-for="person in item.servicePersonVOList" :key="person.id">
							<uni-td>
								<view style="text-align: center;">{{ person.personName }}</view>
							</uni-td>
							<uni-td align="center">
								<view style="text-align: center;color: cornflowerblue;text-decoration:underline;"
									@click="call(person.contactPhone)">{{ person.contactPhone }}</view>
							</uni-td>
						</uni-tr>
					</uni-table>
				</uni-group>
			</view>
		</view>
	</view>
	</view>
</template>

<script>
	import http from '@/http/api.js';

	export default {
		components: {},
		onLoad(option) {
			this.getContact();
		},
		data() {
			return {
				list: [],
				title: '人员通讯录',
				desc: '',
				tableData: [],
				equipmentInspectionTableData: [],
				pageSize: 10,
				// 当前页
				pageCurrent: 1,
				// 数据总量
				total: 0,
				orgId: '',
				projectId: '',
				projectTree: [],
				selectedTreeNode: '',
				searchVal: '',
			}
		},
		computed: {},
		onShow() {},
		methods: {
			toBack() {
				uni.navigateBack({
					delta: 1
				})
			},
			getContact() {
				var that = this;
				http.request({
					url: '/galaxy-business/serviceperson/contact',
					method: 'GET',
				}).then(res => {
					if (res.data != null) {
						console.log(JSON.stringify(res.data))
						that.list = res.data;
					}
				}).catch(err => {
					console.log(err)
				})
			},
			call(phone) {
				console.log(phone)
				uni.showModal({
					content: '是否需要拨打[' + phone + ']?',
					showCancel: true,
					success(res) {
						if (res.confirm) {
							uni.makePhoneCall({
								phoneNumber: phone
							});
						}
					}
				});
			}
		}
	}
</script>

<style>

</style>

<style lang="scss" scoped>

</style>
