<template>
	<div class="content">
		<!-- 收件人 -->
		 <!-- 搜索列表 -->
		 <van-search
			v-model="parmas.storeName"
			placeholder="请输入门店名称"
			@search="getData"
		/>
		<div class="list">
			<div class="jjinfo" v-for="item in addressList" :key="item.id">
				<div>
					<div class="jj">
						<div class="jjaddress" @click="transmitMessage(item)">
							<p style="background: #0c2469;">收</p>
							<div :id="'copytkl' + item.id">
								<p>{{ item.storeName }} {{ item.storeCode }}</p>
								<p>
									{{ item.storeProvince }}{{ item.storeCity
									}}{{ item.storeCounty }}{{ item.storeAddrInfo }}
								</p>
							</div>
						</div>
					</div>
				</div>
			</div>
		</div>
		<!-- 寄件 -->
		<!-- <div class="btn">
			<van-button type="info" @click="link">添加收件人</van-button>
		</div> -->
	</div>
</template>

<script>
import { Toast, Dialog } from "vant";
import { deleteUserAddressById, getStoreAddressList } from "@/api/addressBoook";
export default {
	data() {
		return {
			titlename: "收件人地址簿",
			userId: "",
			addressList: [],
			parmas: {
				storeName:''
			}
		};
	},
	created: function () {
		this.isLogin();
		this.userId = localStorage.getItem("userId");
		//获取参数
		this.getData();
	},
	methods: {
		// //复制
		// copyLink(id) {
		// 	let _this = this;
		// 	let clipboard = new this.clipboard("#fz" + id);
		// 	clipboard.on("success", function () {
		// 		//window.console.log('00')
		// 		_this.$toast("复制成功");
		// 	});
		// 	clipboard.on("error", function () {
		// 		_this.$toast("复制失败");
		// 	});
		// },
		// tab(obj) {
		// 	this.index = obj;
		// 	this.getData();
		// },
		// link(obj) {
		// 	this.$router.push({ path: "/transferGoods", query: { type: obj } });
		// },
		// 获取数据
		async getData() {
			Toast.loading({
				message: "加载中...",
				forbidClick: true,
				duration: 0
			});
			try {
				const res = await getStoreAddressList({ ...this.parmas });
				console.log(res, "res");
				if (res.code.toString() === '200') {
					this.addressList = res.storeList;
				} else {
					Toast("网络错误!");
				}
			} catch (error) {
				Toast("网络错误!");
			}
			Toast.clear();
		},

		//   // 删除
		//   del(id) {
		// 	Dialog.confirm({ title: "", message: "确定删除吗" })
		// 	  .then(async () => {
		// 		Toast.loading({
		// 		  message: "删除中...",
		// 		  forbidClick: true,
		// 		  duration: 0
		// 		});
		// 		const res = await deleteUserAddressById({ id: id });
		// 		if (res.msg == "success") {
		// 		  this.getData();
		// 		  Toast("删除成功!");
		// 		} else {
		// 		  Toast("删除失败!");
		// 		}
		// 		Toast.clear();
		// 	  })
		// 	  .catch(() => {
		// 		//  on cancel
		// 	  });
		//   },
		//   //跳去编辑页
		//   linkEdit(id) {
		// 	this.$router.push({ path: "/Editaddress", query: { id: id } });
		//   },
		transmitMessage(item) {
			let transmitMessageVlaue = {};
			transmitMessageVlaue.storeName = item.storeName;
			transmitMessageVlaue.addresseeName = item.storeName;
			transmitMessageVlaue.addresseeAddress = item.storeAddress;
			// transmitMessageVlaue.addresseePhone = item.addresseePhone;
			transmitMessageVlaue.createTime = item.createTime;
			transmitMessageVlaue.id = item.id;
			transmitMessageVlaue.storeCode = item.storeCode;
			transmitMessageVlaue.addresseeAddrInfo = item.storeAddrInfo;
			transmitMessageVlaue.addresseeCity = item.storeCity;
			transmitMessageVlaue.addresseeCounty = item.storeCounty;
			transmitMessageVlaue.addresseeProvince = item.storeProvince;
			transmitMessageVlaue.addresseeTown = item.storeTown;
			// transmitMessageVlaue.sendNum = item.sendNum;
			transmitMessageVlaue.isAddressIdTransfer = true;
			this.$store.commit("getTransmitMessageVlaue", transmitMessageVlaue);
			this.$router.push({ path: "/transferGoods", params: { addressee: transmitMessageVlaue } });
		}
	},
	computed: {}
};
</script>

<style scoped lang="less">
.van-button--info {
	background-color: #0c2469;
	color: #fff;
	background-color: #0c2469;
	border: 1px solid #0c2469;
}

.content {
	height: 100vh;
	width: 100vw;
	display: flex;
	flex-direction: column;
	overflow: hidden;

	.list {
		flex: auto;
		overflow: hidden;
		overflow-y: auto;
		padding: 15px 0.33rem 0px;
	}

	.btn {
		// height: 100vh;
		width: 100vw;
		display: flex;

		// padding: .0rem .33rem 0.33rem;

		button {
			width: 100%;
			margin: 0.33rem;
		}
	}

	.tab {
		font-size: 0.36rem;
		color: #0c2469;

		div {
			display: flex;
			border: 0.01rem solid #0c2469;
			text-align: center;
			border-radius: 0.05rem;

			p {
				flex: 1;
				padding: 0.1rem 0rem;
			}

			p.active {
				background: #0c2469;
				color: white;
			}
		}
	}

	.jjinfo {
		font-size: 0.36rem;
		color: #999999;
		padding: 0rem 0rem 0.33rem;
		word-break: break-word;

		>div {
			background: white;
			border-radius: 0.05rem;
			padding: 0.1rem 0.3rem;

			.jj {
				display: flex;
				justify-content: space-between;
				padding: 0.2rem 0rem;
				flex-wrap: wrap;

				.jjaddress {
					display: flex;
					padding: 0.1rem 0rem 0.2rem;

					>p {
						font-size: 0.24rem;
						font-weight: bold;
						display: inline-block;
						width: 0.5rem;
						height: 0.5rem;
						background: #0c2469;
						text-align: center;
						line-height: 0.5rem;
						color: white;
						border-radius: 50%;
						margin-right: 0.3rem;
					}

					div {
						//font-weight: bold;
						max-width: 5.2rem;

						p:nth-of-type(1) {
							font-size: 0.3rem;
							color: #333;
							margin-bottom: 0.2rem;
						}

						p:nth-of-type(2) {
							font-size: 0.3rem;
						}
					}
				}

				.cz {
					border-top: 0.01rem solid #ededed;
					width: 100%;
					display: flex;
					flex-direction: row-reverse;
					font-size: 0.24rem;
					color: #999999;
					padding-top: 0.2rem;

					p {
						margin-left: 0.2rem;

						img {
							width: 0.22rem;
							height: 0.24rem;
						}

						span {
							position: relative;
							top: -0.01rem;
						}
					}
				}
			}
		}
	}
}
</style>