<template>
	<view>
		<view class="top-tabbar">
			<view v-for="(item, index) in tabs" :key="index" :class="state_active === index ? 'tab-item active' : 'tab-item'" @click="stateFunc(index)">{{ item.regionName }}</view>
		</view>
		<view class="order-list">
			<view class="order-item" v-for="(item, index) in belowList" :key="index">
				<view class="item-top">
					<view class="item-t-center">
						<view>
							<view class="f33 gray1 text-ellipsis fb">{{ item.shortName }}.{{ item.provinceName }}{{ item.cityName }}</view>
						</view>
						<span></span>
						<view class="f24 gray9">{{ $t('S_C_86') }}:{{ item.contacts }}</view>
						<view class="f24 gray9">
							{{ $t('S_C_87') }}:
							<a :href="'tel:' + item.phone" class="phone-link">{{ item.phone }}</a>
						</view>
						<view class="f24 gray9">{{ $t('S_C_88') }}:{{ item.shortName }}{{ item.provinceName }}{{ item.cityName }}{{ item.address }}</view>
					</view>
				</view>
			</view>
			<view class="">
				<!-- 没有记录 -->
				<view class="d-c-c p30" v-if="belowList.length == 0 && !loading">
					<text class="iconfont icon-wushuju"></text>
					<text class="cont">{{ $t('w_0405') }}</text>
				</view>
			</view>
		</view>
	</view>
</template>

<script>
export default {
	data() {
		return {
			belowList: [],
			state_active: 0,
			loading: false,
			regionName: '',
			region: '',
			tabs: []
		};
	},
	onLoad() {
		this.getData();
	},
	methods: {
		/*状态切换*/
		stateFunc(index) {
			if (this.state_active !== index) {
				this.belowList = [];
				this.loading = true;
				this.state_active = index;
				this.regionName = this.tabs[index].regionName;
				this.getData();
			}
		},
		getData() {
			let self = this;
			self.loading = true;
			uni.showLoading({
				title: self.$t('MN_F_6')
			});

			self._get(
				'home/api/ho-global-company/list',
				{
					regionName: self.regionName,
					region: self.region
				},
				res => {
					self.tabs = res.rows;
					self.belowList = res.rows[self.state_active].belowList;
					self.loading = false;
					uni.hideLoading();
				}
			);
		}
	}
};
</script>

<style lang="scss">
.top-tabbar {
	height: 94rpx;
	justify-content: flex-start;
	flex-wrap: nowrap;
	overflow-x: auto;
}
.phone-link {
	color: blue;
	text-decoration: underline;
}
.order-list {
	padding: 24rpx;

	.order-item {
		padding: 25rpx 20rpx;
		margin-bottom: 24rpx;
		background: #ffffff;
		border-radius: 25rpx;

		.item-top {
			display: flex;
			justify-content: center;
			align-items: center;
			.item-t-center {
				height: 180rpx;
				flex: 1;
				display: flex;
				justify-content: space-between;
				align-items: flex-start;
				flex-direction: column;
			}
		}

		.item-bottom {
			padding-top: 20rpx;

			.order-btn {
				height: 44rpx;
				line-height: 44rpx;
				background: #ffffff;
				border: 1rpx solid #eeeeee;
				border-radius: 22rpx;
				padding: 0 22rpx;
				font-size: 22rpx;
				color: #333333;
				margin-left: 20rpx;
			}

			.order-btn.full {
				color: #f2473f;
				background-color: rgba($color: #f89c31, $alpha: 0.15);
				border-color: rgba($color: #f89c31, $alpha: 0.15);
			}
		}
	}
}
</style>
