<template>
	<view class="supplier-container">
		<view class="supplier-info" v-for="(item, index) in dataList" :key="index" @click="gotoSupplierDetail(item)">
			<view class="supplier-title">
				<view class="supplier-title-text">
					{{item.name || '-'}}
				</view>
				<view class="supplier-title-contacts">
					{{item.contactName || '-'}}
				</view>
			</view>
			<view class="supplier-tel">
				{{item.contactPhone || '-'}}
			</view>
		</view>
	</view>
</template>

<script>
	export default {
	  data() {
	    return {
			//列表数据
			dataList: [],
			//查询条件
			param: {
				stationCode: null,
			}
	    }
	  },
		//第一次加载
		onLoad(e) {
			this.param.stationCode = e.stationCode  
		},
	   onReady() {
	        
	    },
		//页面显示
		onShow() {
	
		},
		mounted() {
			this.getSupplierListData();
		},
		methods: {
			//跳转详情页
			gotoSupplierDetail(item) {
				uni.navigateTo({
					url: '/pages/index/supplierDetail?dataInfo=' + encodeURIComponent(JSON.stringify(item)),
				})
			},
			//获取站点内供货商的列表
			getSupplierListData() {
				let _that = this;
				_that.dataList = [];
				uni.showLoading({
					title: '搜索中...',
				})
				_that.$http.getSupplierList(_that.param).then(res => {
					uni.hideLoading();
					if(res.code == 200) {
						_that.dataList = res.data.list || [];
					} else {
						_that.$utils.msg(res.msg);
					}
				})
			},
		}	
	}
</script>

<style lang="scss" scoped>
	.supplier-container {
		height: 100vh;
		position: relative;
		box-sizing: border-box;
		background: $uni-bg-color;
		padding-bottom: calc(20rpx + env(safe-area-inset-bottom));
		padding-top: 30rpx;
		.supplier-info {
			height: 160rpx;
			background: #FFFFFF;
			border-radius: 16rpx 16rpx 16rpx 16rpx;
			margin: 0 30rpx 30rpx;
			padding: 30rpx;
			.supplier-title {
				display: flex;
				.supplier-title-text {
					flex: 1;
					font-size: 30rpx;
					font-family: PingFang SC-Regular, PingFang SC;
					font-weight: 400;
					color: #1D2129;
					line-height: 44rpx;
				}
				.supplier-title-contacts {
					font-size: 30rpx;
					font-family: PingFang SC-Regular, PingFang SC;
					font-weight: 400;
					color: #1D2129;
					line-height: 44rpx;
					text-align: right;
				}
			}
			.supplier-tel {
				text-align: right;
				font-size: 26rpx;
				font-family: PingFang SC-Regular, PingFang SC;
				font-weight: 400;
				color: #86909C;
				line-height: 44rpx;
				margin-top: 20rpx;
			}
		}
	}
</style>