<template>
	<view class="container">
		<Navbar title="订气列表" canBack></Navbar>
		<view class="usuallyCard margin padding" v-for="(item,index) in phoneList" :key="index">
			<view class="flex flex-direction">
				<view class="flex">
					<view class="">
						<u-tag size="mini" bgColor="#5875EB" color="#fff" borderColor="#fff" :text="item.qzlx || ''"></u-tag>
					</view>
					<view class="text-lg margin-left-sm">
						{{item.qzmc || ""}}
					</view>
				</view>
				<view class="flex justify-between align-center margin-top-sm">
					<view class="flex" >
						<u-tag class="margin-right-xs" v-for="(i,n) in item.psfs" :key="n" bgColor="#FFF6E6" color="#ffa500" borderColor="#fff" :text="i"></u-tag>
					</view>
					<view class="" @click="callPhone(item.qzdh)">
						<u-button shape="circle" color="#EE651F" iconColor="#fff" icon="phone-fill"
							:customStyle="{height:'30px'}">电话订气</u-button>
					</view>
				</view>
				<view class="flex margin-top-sm">
					<u-icon name="map" class="margin-right-xs"></u-icon>
					<view class="text-gray">
						{{item.qzdz || ""}}
					</view>
				</view>
			</view>
		</view>
	</view>
</template>

<script>
	export default {
		components: {

		},
		data() {
			return {
				phoneList: [],
				queryParams:{
					page: 1,
					size: 10,
					jd:"",
					wd:""
				}
			};
		},
		onLoad() {
			this.getCzPage();
		},
		mounted() {

		},
		onPullDownRefresh() {
			this.phoneList = [];
			this.queryParams.page = 1;
			this.getCzPage()
			setTimeout(() => {
				//结束下拉刷新
				uni.stopPullDownRefresh();
			}, 500);
		},
		onReachBottom() {
			// let allTotal = this.pageParams.currentPage * this.pageParams.size
			// if (allTotal < this.total) {
			// 	//当前条数小于总条数 则增加请求页数
			// 	this.pageParams.currentPage++;
			// 	this.status = 'loading';
			// 	setTimeout(() => {
			// 		this.getOrderList()
			// 	}, 500)
			// } else {
			// 	this.status = 'nomore'
			// 	// console.log('已加载全部数据')
			// }
		},
		methods: {
			async getCzPage() {
				let fJd = this.$store.state.user.adsJd;
				let fWd = this.$store.state.user.adsWd;
				if (!fJd || !fWd) {
					uni.$u.toast('定位出错');
					return;
				}
				this.queryParams.jd = fJd;
				this.queryParams.wd = fWd;
				// let query = {
				// 	page: 1,
				// 	size: 10,
				// 	jd: fJd,
				// 	wd: fWd
				// }
				let result = await this.$api.memberApi.getCzPage(this.queryParams);
				let {
					code,
					value
				} = result;
				if (code === 200) {
					let records = value.records;
					if (!records.length) {
						uni.$u.toast('未查询到相关气站');
						return;
					}
					this.phoneList = records;
					console.log("气站电话列表", this.phoneList);
				}
			},
			callPhone(phone) {
				if (!phone) {
					uni.$u.toast('未查询到电话')
					return
				}
				uni.makePhoneCall({
					phoneNumber: phone, // 电话号码
					success: function() {
						console.log('拨号成功');
					},
					fail: function(err) {
						console.log('拨号失败：', err);
					}
				});
			}
		}
	}
</script>

<style lang="scss" scoped>

</style>