<template>
	<view class="unclear-container">
		<uni-navbar pageName="待清运" :isBack="false" :isMap="true"></uni-navbar>
		<scroll-view class="scroll-con" scroll-y :scroll-top="scrollTop" @scrolltolower="onreachBottom">
			<!-- 列表数据 -->
			<view class="cell-item-con">
				<view class="cell-item" v-for="(item, index) in listdata" :key="index">
					<u-image class="cell-item-pic" src="/static/logo.jpg" width="140rpx" height="140rpx"></u-image>
					<view class="cell-item-c" @tap="goPage(item)">
						<view class="cell-item-info">
							<view class="cell-item-info-network">
								咸阳市秦都区文彩舫东区
								<u-badge type="success" bgColor="#c90101" :count="8" :offset="[-10,-32]" size="mini"></u-badge>
							</view>
							<view class="cell-item-info-weight">
								<view class="cell-item-weight-bar">
									15.25kg
									<u-badge class="badge" type="primary" bgColor="#01c9b2" count="总" :offset="[0,0]"></u-badge>
								</view>
								<view class="cell-item-weight-bar">
									15.25kg
									<u-badge class="badge" type="warning" bgColor="#05695d" count="最大" :offset="[0,0]"></u-badge>
								</view>
							</view>
						</view>
						<u-icon name="arrow-right" class="arrow-right" :size="28" color="#999"></u-icon>
					</view>
					<u-button size="mini" class="handle-btn" hover-class="none" :custom-style="customBtnStyle" @click="removeFun(item)">移除</u-button>
				</view>
			</view>
			<u-empty class="nodata" :text="noDataText" v-if="listdata.length==0 && status!='loading'" mode="list"></u-empty>
			<view class="loadmore">
				<u-loadmore v-if="total>pageSize || status=='loading'" :status="status" />
			</view>
		</scroll-view>
		
		<view class="footer-bar">
			<u-button class="footer-handle-btn scan-btn" hover-class="none" :custom-style="scanBtnStyle" shape="circle" @click="clearingOutlets" size="medium" type="primary">
				<u-icon name="scan" class="btn-icon" :size="28" color="#fff"></u-icon>
				<text>扫码清运</text>
			</u-button>
			<u-button class="footer-handle-btn" hover-class="none" :custom-style="btnStyle" shape="circle" @click="openQuery" size="medium">
				<u-icon name="plus" class="btn-icon" :size="28" color="#606266"></u-icon>
				<text>增加清运网点</text>
			</u-button>
		</view>
	</view>
</template>
<script>
	// import { getGoldLogList, GoldLogCancel, GoldLogTotal } from '@/api/officialPartnerGoldLog.js'
	import { scanCode } from '@/libs/tools.js'
	export default {
		data() {
			return {
				listdata: [{},{}],
				pageNo: 1,  //  当前页码
				pageSize: 40,  //  每页条数
				total: 0,  //  数据总条数
				noDataText: '暂无数据',  //  列表请求状态提示语
				status: 'loadmore',  //  加载中状态
				customBtnStyle: {  //  自定义按钮样式
					borderColor: '#01c9b2',
					backgroundColor: '#01c9b2',
					color: '#fff'
				},
				scrollTop: 0,  //  滚动条位置
				scanBtnStyle: {  //  自定义按钮样式
					borderColor: '#07c160',
					backgroundColor: '#07c160',
					width: '100%'
				},
				btnStyle: {  //  自定义按钮样式
					width: '100%'
				}
			}
		},
		onShow() {
			// this.refresh({})
		},
		methods:{
			clearingOutlets(){
				if(this.listdata.length==0){
					uni.showToast({ title: '请先选择待清运网点，再进行扫码清运', icon: 'none' })
				}else{
					this.openScan()
				}
			},
			//  扫码清运
			openScan(){
				//  调起微信扫码
				scanCode().then(res => {
				  this.code = res.result
				  //  请求接口
				  // return verShow(res.result)
				}).then(res => {
				  if (res.status == 200) {
				    this.info = res.data
				    this.showInfo = true
				    this.carNum = ''
				  } else {
				    wx.showToast({
				      title: res.message,
				      icon: 'none',
				      duration: 2500
				    })
				  }
				})
			},
			//  增加清运网点
			openQuery(){
				uni.navigateTo({
				    url: '/pages/cleared/chooseNetwork'
				})
			},
			// 获取查询参数 刷新列表
			refresh(params){
				this.listdata = []
				this.total = 0
				this.searchHandle(1)
			},
			// 搜索查询
			searchHandle (pageNo) {
				this.status = "loading"
				pageNo ? this.pageNo = pageNo : null
				// getGoldLogList({
				// 	pageNo: this.pageNo,
				// 	pageSize: this.pageSize
				// }).then(res => {
				// 	if (res.status == 200) {
				// 		if(this.pageNo>1){
				// 			this.listdata = this.listdata.concat(res.data.list || [])
				// 		}else{
				// 			this.listdata = res.data.list || []
				// 			this.scrollTop = 0
				// 		}
				// 		this.total = res.data.count || 0
				// 		this.noDataText = '暂无数据'
				// 	} else {
				// 		this.noDataText = res.message
				// 		this.listdata = []
				// 		this.total = 0
				// 	}
				// 	this.status = "loadmore"
				// })
			},
			//  移除
			removeFun(row){
				const _this = this
				uni.showModal({
				  title: '提示',
				  content: '确认移除该网点的清运单？',
				  success(res) {
				    if (res.confirm) {
				   //    GoldLogCancel({ id: row.id }).then(ret => {
						 //  if(ret.status == 200){
							//   uni.showToast({ title: ret.message, icon: 'none' })
							//   _this.searchHandle(1)
						 //  }
					  // })
				    }
				  }
				})
			},
			//  查看详情
			goPage(row){
				uni.navigateTo({
				    url: '/pages/cleared/details'
				})
			},
			// scroll-view到底部加载更多
			onreachBottom() {
				if(this.listdata.length < this.total){
					this.pageNo += 1
					this.searchHandle()
				}else{
					uni.showToast({ title: '已经到底了', icon: 'none' })
					this.status = "nomore"
				}
			}
		}
	}
</script>

<style lang="scss">
	page{
		height: 100%;
	}
	.unclear-container {
		width: 100%;
		height: 100%;
		display: flex;
		flex-direction: column;
		padding-bottom: 204rpx;
		//  列表
		.scroll-con{
			flex: 1;
			overflow: auto;
		}
		//  列表样式
		.cell-item-con{
			.cell-item{
				margin: $uni-spacing-col-base $uni-spacing-row-base;
				background-color: #fff;
				border-radius: $uni-border-radius-base;
				color: $uni-text-color;
				font-size: $uni-font-size-base;
				box-shadow: 3rpx 3rpx 5rpx #eee;
				display: flex;
				justify-content: space-between;
				align-items: center;
				padding: $uni-spacing-col-base $uni-spacing-row-base;
				position: relative;
				.cell-item-pic{
					flex-shrink: 0;
					margin-right: 10rpx;
				}
				.cell-item-c{
					flex-grow: 1;
					display: flex;
					justify-content: space-around;
					align-items: center;
					.cell-item-info{
						flex-grow: 1;
						.cell-item-info-network{
							word-break: break-all;
							margin-bottom: $uni-spacing-col-base;
							display: inline-block;
							position: relative;
						}
						.cell-item-info-weight{
							font-size: 24rpx;
							display: flex;
							align-items: center;
							justify-content: space-between;
							.cell-item-weight-bar{
								position: relative;
								display: inline-block;
								padding-right: 50rpx;
								&:nth-child(2){
									padding-right: 76rpx;
								}
							}
						}
					}
					.arrow-right{
						flex-shrink: 0;
						margin-left: 64rpx;
					}
				}
				.handle-btn{
					position: absolute;
					right: $uni-spacing-row-sm;
					top: $uni-spacing-col-sm;
				}
			}
		}
		.footer-bar{
			width: 100%;
			height: 204rpx;
			padding: 0 10%;
			position: fixed;
			bottom: 0;
			left: 0;
			text-align: center;
			.footer-handle-btn{
				display: block;
				.btn-icon{
					margin-right: 10rpx;
				}
			}
			.scan-btn{
				margin-top: 24rpx;
				margin-bottom: 20rpx;
			}
		}
	}
</style>
