<template>
	<view class="content">
		<!-- <view class="" style="height: 20rpx;"></view> -->
		<view class="list-top flex" v-if="list.length > 0">
			<view class="list-left">
				规格
			</view>
			<view class="list-mid">
				预估价格
			</view>
			<view class="list-right">
				操作
			</view>
		</view>
		<view class="jg">

		</view>
		<scroll-view scroll-y="true" class="scroll-wrap" :style="{'height': height}" @scrolltolower="getList">
			<view class="list-box" v-for="item in list">
				<view class="list-item flex list-top">
					<view class="list-left clamp">
						长:<text>{{item.long*1}}</text>宽:<text>{{item.wide*1}}</text>高:<text>{{item.high*1}}</text>
					</view>
					<view class="list-mid">
						<text>￥{{item.price*1}}</text>
					</view>
					<view class="list-right flex">
<!-- 						<view class="sc btn" @click="showSc(item)">
							删除
						</view> -->
						<view class="xq btn" @click="navto('/pages/user/jsxq?id=' + item.id + '&price=' + item.price + '&weight=' + item.weight + '&long=' + item.long + '&wide=' + item.wide + '&high=' + item.high)">
							详情
						</view>
					</view>
				</view>
			</view>
			<uni-load-more :status="loadingType"></uni-load-more>
		</scroll-view>

	</view>
</template>

<script>
	import { getJsList } from '@/api/user.js'
	export default {
		data() {
			return {
				height: '',
				loadingType: 'more',
				list: [],
				page: 1,
				limit: 20,
			}
		},
		onLoad() {

		},
		onShow() {
this.getList()
		},
		onReachBottom() {

		},
		onReady(res) {
			var obj = this;
			uni.getSystemInfo({
				success: resu => {
					const query = uni.createSelectorQuery();
					query.select('.scroll-wrap').boundingClientRect();
					query.exec(function(res) {
						obj.height = resu.windowHeight - res[0].top + 'px';
					});
				},
				fail: res => {}
			});
		},
		methods: {
			getList() {
				let obj = this
				if(obj.loadingType == 'noMore' || obj.loadingType == 'loading') {
					return
				}
				obj.loadingType = 'loading'
				getJsList().then(res => {
					let arr = res.data
					obj.list = obj.list.concat(arr)
					obj.page++
					if(arr.length == obj.limit) {
						obj.loadingType = 'more'
					}else {
						obj.loadingType = 'noMore'
					}
				})
			},
			showSc(item) {
				let obj = this
				uni.showModal({
					title: '提示',
					content: '确定删除该计算记录？',
					complete(e) {
						if(e.confirm) {
							// 确定删除
							// console.log()
							obj.$api.msg('已删除')
						}
					}
				})
			},
			navto(url) {
				uni.navigateTo({
					url
				})
			}
		}
	}
</script>

<style lang="scss">
	page {
		background: #fff;
	}

	.list-top {
		width: 708rpx;
		margin: auto;
		padding: 0 20rpx;
		text-align: center;
		font-size: 30rpx;
		font-weight: bold;
		color: #666666;
		background-color: #fff;
		line-height: 83rpx;

		.list-left {
			flex-shrink: 0;
			width: 55%;
		}

		.list-mid {
			flex-shrink: 0;
			width: 30%;
		}

		.list-right {
			flex-shrink: 0;
			width: 15%;
		}
	}

	.list-box {
		width: 708rpx;
		margin: auto;

		.list-item {
			border-bottom: 1px solid #EAEAEA;
		}

		.list-left {
			text {
				padding-right: 10rpx;
			}
		}

		text {
			color: #4261E3 !important;
		}

		.list-right {
			justify-content: center;

			.btn {
				width: 86rpx;
				height: 41rpx;
				border-radius: 21rpx;
				font-size: 24rpx;
				font-weight: 500;
				line-height: 41rpx;

			}

			.sc {
				border: 1px solid #D8D8D8;
				margin-right: 10rpx;
			}

			.xq {
				background: #ECEFFC;
				border: 1px solid #4261E3;
				color: #4261E3;
			}
		}
	}

	.jg {
		width: 750rpx;
		height: 1rpx;
		background: #EAEAEA;
	}
</style>
