<template style="background: #F6F6F6;">
	<view style="height: 100%;width: 100%;padding: 20rpx 28rpx;">
		<view class="" v-for="(itm,idx) in serviceList" :key="idx">
			<view class="list" @click="list(itm)">
				<!-- 左边 -->
				<view class="left">
					<view style="font-size: 30rpx;font-weight: bold;margin-bottom: 20rpx;">{{itm.order_pack.insurance_policy}}</view>
					<view style="font-size: 26rpx;color: #999999;">{{itm.order_pack.pack_name}}</view>
				</view>
				<!-- 右边 -->
				<view class="ringht">
					<u-icon name="arrow-right" color="#C0C0C0"></u-icon>
				</view>
			</view>
		</view>
		<u-empty text="暂无数据" :show="show" mode="order" margin-top="250"></u-empty>
		<view class="cu-tabbar-height"></view>
		<view class="cu-tabbar-height"></view>
	</view>
</template>

<script>
	export default {
		mounted() {
			this.getInsurance()
		},
		data() {
			return {
				pageindex: 1,
				serviceList: [],
				show: false
			}
		},
		methods: {
			//关注
			list(item) {
				uni.showLoading({
					title: "加载中，请等待"
				})
				uni.downloadFile({
					url: item.order_pack.insurance_img_url,
					success(res) {
						console.log(res)
						let data = res.tempFilePath;
						uni.openDocument({
							filePath: data,
							fileType: 'pdf',
							success: (res) => {
								uni.hideLoading()
							}
						})
					}
				})
				// uni.navigateTo({
				// 	url: "order_details?pdfurl=" + item.order_pack.insurance_img_url
				// })
				// uni.navigateTo({
				// 	url: '/pages/common_tools/me_order/order_details?data=' + JSON.stringify(item)
				// 	// url: '/pages/customer/customer-datails?n=' + n
				// })
			},
			getInsurance: async function() {
				let res = await this.$request.post("/api/v1/order/orderList", {
					page: this.pageindex,
					list_type: 1,
					product_type: 6,
				})
				console.log(res)
				if (res.status == 0) {
					if (this.pageindex > res.data.last_page) {
						uni.showToast({
							title: "没有更多了",
							icon: "none"
						})
					} else {
						this.serviceList = this.serviceList.concat(res.data.data)
						this.pageindex++
					}
				}
				if (this.serviceList.length == 0) {
					this.show = true
				} else {
					this.show = false
				}
			}
		}
	}
</script>

<style>
	.list {
		box-shadow: 0px 2px 12px 0px rgba(0, 0, 0, 0.04);
		border-radius: 12px;
		background: #FFFFFF;
		margin-bottom: 20rpx;
		display: flex;
		justify-content: center;
		align-items: center;
		padding: 48rpx 28rpx;
	}

	.left {
		width: 95%;
		display: initial;
	}

	.ringht {
		width: 5%;
	}
</style>
