<!--
 * @Author: euzhi
 * @Description: 我的挪车记录
-->
<template>
	<view class="appCotent">
		<div class="myRecord">
			<scroll-list ref="list" :option="option" @load="load" @refresh="refresh">
				<div class="record__item" v-for="(vo,inx) in items" :key="inx">
					<div class="item__top">
						<div class="top__time">
							时间:{{vo.applyDate}}
						</div>
						<div class="top__state" :class="vo.state==='微信'?'':'phone__state'">
							{{vo.confirmType=="1"?'电话':'微信'}}
						</div>
					</div>
					<div class="item__content">
						<div>
							车牌号:{{vo.carNo}}
						</div>
						<div>
							通知类型:{{type}}
						</div>
						<div>
							挪车申请人:{{vo.applyUserMobile?vo.applyUserMobile:""}}
						</div>
					</div>
					<div class="item__btn" @click="goDetail(vo.id)">
						<view>
							查看详情
						</view>
					</div>
				</div>
			</scroll-list>
		</div>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				option: {
					size: 10,
					auto: true
				},
				items: [],
				type: '他人请求挪车',
			};
		},
		methods: {
			// 加载数据
			load(paging) {
				setTimeout(() => {
					let list = [];
					let opts = {
						url: '/app/moveLog/my/list?pageSize=' + paging.size + '&pageNum=' + paging.page,
						method: 'get'
					};
					this.http.httpTokenRequest(opts, {}).then(res => {
						if (res.data.code == 200) {
							list = res.data.rows || []
							this.items = [...this.items, ...list]
							// 加载成功  参数对象{list: 当前列表,total: 数据总长度(后端查询的total)}
							this.$refs.list.loadSuccess({
								list: this.items,
								total: res.data.total
							});
						} else {
							// 加载失败
							this.$refs.list.loadFail()
							uni.showToast({
								title: res.data.msg,
								icon: 'none',
								duration: 2000
							});
						}
					})
				}, this.$u.random(100, 1000));
			},
			// 刷新
			refresh(paging) {
				setTimeout(() => {
					this.items = []
					let list = [];
					let opts = {
						url: '/app/moveLog/my/list?pageSize=' + paging.size + '&pageNum=' + paging.page,
						method: 'get'
					};
					this.http.httpTokenRequest(opts, {}).then(res => {
						if (res.data.code == 200) {
							list = res.data.rows || []
							this.items = [...this.items, ...list]
							// 加载成功  参数对象{list: 当前列表,total: 数据总长度(后端查询的total)}
							this.$refs.list.refreshSuccess({
								list: this.items,
								total: res.data.total
							});
						} else {
							// 加载失败
							this.$refs.list.refreshFail()
							uni.showToast({
								title: res.data.msg,
								icon: 'none',
								duration: 2000
							});
						}
					})
				}, this.$u.random(100, 1000));
			},
			goDetail(id) {
				//console.log(id)
				uni.navigateTo({
					url: '/pagesB/pages/move-car/recordDetail?id=' + id
				})
			},
			getMyMoveLogList() {
				let opts = {
					url: '/app/moveLog/my/list',
					method: 'get'
				};
				this.http.httpTokenRequest(opts, {}).then(res => {
					if (res.data.code == 200) {
						this.items = res.data.rows
					} else {
						uni.showToast({
							title: res.data.msg,
							icon: 'none',
							duration: 2000
						});
					}
				})
			},
		},
		created() {
			//this.getMyMoveLogList()
		},
	}
</script>

<style lang="scss" scoped>
	.myRecord {
		padding: 40rpx 0rpx;

		.record__item {
			background: #FFFFFF;
			box-shadow: 0rpx 0rpx 28rpx 1rpx rgba(232, 232, 232, 0.2);
			border-radius: 20rpx;
			padding: 30rpx 0;
			margin-bottom: 30rpx;

			.item__top {
				display: flex;
				justify-content: space-between;
				align-items: center;
				padding: 0 40rpx;
				border-bottom: 1rpx solid rgba(0, 0, 0, .1);
				padding-bottom: 30rpx;
				margin-bottom: 30rpx;

				.top__time {
					font-size: 26rpx;
					font-family: PingFang SC;
					font-weight: 500;
					color: #666666;
				}

				.top__state {
					background: #cfffe2;
					width: 70rpx;
					height: 34rpx;
					font-size: 26rpx;
					font-family: PingFang SC;
					font-weight: 500;
					color: #00AD42;
					line-height: 34rpx;
					text-align: center;
					border-radius: 4rpx;
				}

				.phone__state {
					background: #ffebd8;
					color: rgba(248, 141, 40, 1);
				}

				.top__item {
					font-size: 26rpx;
					font-family: PingFang SC;
					font-weight: 500;
					color: #666666;
				}
			}

			.item__content {
				padding: 0 40rpx;
				display: flex;
				align-items: center;
				flex-wrap: wrap;
				justify-content: space-between;

				>div {
					width: 50%;
					margin-bottom: 30rpx;

					font-size: 30rpx;
					font-family: PingFang SC;
					font-weight: 500;
					color: #333333;
				}

				>div:nth-of-type(3) {
					width: 100%;
				}
			}

			.item__btn {
				display: flex;
				justify-content: flex-end;
				padding-right: 40rpx;
				font-size: 30rpx;
				font-family: PingFang SC;
				font-weight: 500;
				color: #999999;

				>view {
					width: 180rpx;
					height: 56rpx;
					text-align: center;
					line-height: 56rpx;
					border: 1rpx solid #DDDDDD;
					border-radius: 50rpx;
					font-size: 30rpx;
					font-family: PingFang SC;
					font-weight: 500;
					color: #999999;
				}
			}
		}
	}
</style>
