<template>
	<view style="height: 100vh;display: flex;flex-direction: column;" @click="ejectOpen=false">
		<topBar height="343rpx" title="订单列表">
			<view slot="coment">
				<view class="header_seach">
					<view class="header_seach_seach">
						<view class="seach_input">
							<uni-easyinput :candidate='candidate' :ejectOpen='ejectOpen' @ejectFn='ejectFn'
								:letfText='letfText' confirmType='search' @confirm='seachFn'
								placeholder-style="color:#bbbbbb;font-weight: 100;" v-model="seachValue"
								:placeholder="letfText=='订单号'? '订单编号':letfText=='司机'?'司机姓名,手机号码':letfText=='企业'?'企业名称,企业编号':'油站名称'"
								@iconClick="onClick">
							</uni-easyinput>
						</view>
					</view>
					<view class="Navigation">
						<view @tap="seleFn(item);seleindex=index"
							:class="seleindex==index?'navigation_seleitem':'navigation_item'"
							v-for="(item,index) in navigation">
							{{item.text}}
							<uni-icons :animation="animationData" class="icoon" v-if="index==0" type="refreshempty"
								style="margin-left: 10rpx;" size="15" color="#bbbbbb"></uni-icons>
						</view>
					</view>
				</view>
			</view>
		</topBar>
		<view style="flex: 1;overflow: hidden;">
			<scroll-view v-if="listData.length!=0" style="height: 100%;" scroll-y="true" @scrolltolower='scrolltolower'>
				<view v-for="(item,index) in listData" class="form_body">
					<view @tap="jump(1,item)" class="form_body_item">
						<view class="form_body_item_top">
							<view :style="{backgroundColor:item.payAccountType==0?'#FD9500':'#2866FF' }"
								class="form_body_item_top_label">{{item.payAccountType==0?'个人':'企业'}}</view>
							<view>{{item.orderSerialNumber}}</view>
						</view>
						<view style="padding: 0 25rpx; margin-top: 23rpx;">
							<view class="from_body_item_container">
								<view class="flex between">
									<view class="flex">
										<view>{{item.phone}}</view>
										<view class="samll_txext" style="margin-left:23rpx;">{{item.userName}}</view>
									</view>
									<view style="color: ;"
										v-if="item.orderWfStatus==0&& String(item.siteName).indexOf('壳牌')!==-1">待核销
									</view>
								</view>
								<view style="margin-bottom:23rpx ; font-size: 26rpx;" class="text">
									{{item.companyName?item.companyName:'暂无'}}
								</view>
								<view class="flex between">
									<view class="flex">
										<view class="samll_txext">{{item.siteName}}</view>
									</view>
									<view style="color: #999999;" class="bgtext">{{item.volume}}L</view>
								</view>
								<view class="flex between">
									<view class="flex">
										<view class="samll_txext">{{item.oilsCode}} {{item.realPrice}}/L</view>
									</view>
									<view class="bgtext">¥{{item.payRealAmount}}</view>
								</view>
							</view>
						</view>
						<view class="form_body_item_footer">
							<view style="font-size: 22rpx;" class="samll_txext">{{item.createTime}}</view>
							<view :style="{fontSize: '24rpx', color:option(item.orderStatus).color }">
								{{option(item.orderStatus).text}}</view>
						</view>
					</view>
				</view>
			</scroll-view>
			<view v-if="listData.length==0"
				style="width: 100vw; height: 100%; display: flex;align-items: center;justify-content: center;">
				<image src="@/static/qx.png" style="width: 536rpx; height: 399rpx;"></image>
			</view>
		</view>
	</view>
</template>

<script>
	import orderList from '@/api/orderList'
	export default {
		data() {
			return {
				animation: null,
				animationData: null,
				listData: [],
				letfText: '订单号',
				seleindex: 0,
				candidate: ['企业', '司机', '订单号', '油站名称'],
				ejectOpen: false,
				seachValue: '',
				navigation: [{
						text: '全部',
						index: ''
					},
					{
						text: '待核销',
						index: 1
					},
					{
						text: '退款',
						index: -1
					}
				],
				getData: {
					pageSize: 15,
					currentPage: 1,
					params: {
						id: '',
						companyName: '',
						userName: '',
						orderStatus: '',
						orderWfStatus: '',
						siteName: ''
					}
				},
			}
		},
		onShow() {
			this.getlist()
		},
		onLoad() {
			this.rotateFn()
		},
		methods: {
			jump(e, w) {
				switch (e) {

					case 1:
						uni.navigateTo({
							url: '../orderDetails/orderDetails?jsData=' + JSON.stringify(w)
						})
						break;
				}
			},
			scrolltolower() {
				this.getData.currentPage += 1
				this.getlist()
			},
			option(e) {
				switch (e) {
					case 0:
						return {
							text: '待支付',
								color: '#EBC153'
						}
						break;
					case 1:
						return {
							text: '已支付',
								color: '#17A00E'
						}
						break;
					case -1:
						return {
							text: '支付失败',
								color: '#EC4645'
						}
						break;
					case 2:
						return {
							text: '已取消',
								color: '#999999'
						}
						break;
					case 3:
						return {
							text: '已退款',
								color: '#999999'
						}
						break;
					case 4:
						return {
							text: '退款中',
								color: '#EBC153'
						}
						// return '退款中'
						break;
					case 5:
						return {
							text: '退款失败',
								color: '#EC4645'
						}
						// return '退款失败'
						break;
				}
			},
			animationFns() {
				console.log('恢复动画')
				var animation = uni.createAnimation({
					duration: 0,
					timingFunction: 'ease',
				})
				this.animation = animation
				this.animation.rotate(0).step()
				this.animationData = this.animation.export()
			},
			rotateFn() {
				var animation = uni.createAnimation({
					duration: 1000,
					timingFunction: 'ease',
				})
				this.animation = animation
				this.animation.rotate(360).step()
				this.animationData = this.animation.export()
				setTimeout(() => {
					this.animationFns()
				}, 1000)
			},
			getlist(e) {
				orderList.getByCustomerPage(this.getData).then(res => {
					if (res.code !== 20000) return
					if (res.data.list.length == 0) {
						uni.showToast({
							title: '没有数据了哦',
							icon: 'none'
						})
					}
					if (this.getData.currentPage !== 1) {
						this.listData = this.listData.concat(res.data.list);
						return
					}
					this.listData = res.data.list
				})
			},
			seleFn(e) {
				this.seleindex = e
				this.getData.currentPage = 1
				if (e.index == '') {
					// this.getData.params.orderWfStatus = ''
					switch (this.getData.params.orderStatus) {
						case '':
							this.getData.params.orderStatus = 0
							this.navigation[0].text = '待支付'
							break;
						case 0:
							this.getData.params.orderStatus = 1
							this.navigation[0].text = '已支付'
							break;
						case 1:
							this.getData.params.orderStatus = -1
							this.navigation[0].text = '支付失败'
							break;
						case -1:
							this.getData.params.orderStatus = ''
							this.navigation[0].text = '全部'
							break
						case 3:
							this.getData.params.orderWfStatus = ''
							this.getData.params.orderStatus = ''
							this.navigation[0].text = '全部'
							break
					}
					if (this.getData.params.orderWfStatus === 0) {
						this.getData.params.orderWfStatus = ''
						this.getData.params.orderStatus = ''
						this.navigation[0].text = '全部'
					}
				}
				if (e.index == 1) {
					this.getData.params.orderStatus = ''
					this.getData.params.orderWfStatus = 0
				}
				if (e.index == -1) {
					this.getData.params.orderWfStatus = null
					this.getData.params.orderStatus = 3
				}
				this.rotateFn()
				console.log(this.getData.params, this.navigation[0].text)
				this.getlist()
			},
			onClick() {
				this.ejectOpen = !this.ejectOpen
				console.log('点击图标')
			},
			seachFn() {
				console.log(this.seachValue)
				this.getData.params.userName = ''
				this.getData.params.id = ''
				this.getData.params.companyName = ''
				this.getData.params.siteName = ''
				if (this.letfText == '企业') {
					this.getData.params.companyName = this.seachValue
					console.log('现在是企业 companyName', this.letfText, )
				} else if (this.letfText == '订单号') {
					this.getData.params.id = this.seachValue
					console.log('现在是订单 id', this.letfText, this.getData.params.id, this.getData.params)
				} else if (this.letfText == '司机') {
					this.getData.params.userName = this.seachValue
					console.log('现在是司机 userName', this.letfText, )
				} else {
					this.getData.params.siteName = this.seachValue
					console.log('现在是其他 siteName', this.letfText, )
				}
				this.getData.currentPage = 1
				this.getlist()
			},
			ejectFn(e) {
				this.letfText = e
				if (this.letfText == '企业') {

				}
				console.log(e)
			},
		}
	}
</script>

<style>
	@import url("./index.css");

	.icoon :active {
		color: #007AFF;
	}

	.yuan {
		width: 13rpx;
		height: 13rpx;
		background: #E9CF31;
		border-radius: 50%;
		margin-right: 5rpx;
	}

	.large_text {
		font-size: 32rpx;
		font-family: PingFang SC;
		font-weight: bold;
		color: #333333;
	}

	.company_msg_content {
		max-width: 330rpx;
		font-size: 28rpx;
		font-family: PingFang SC;
		font-weight: 500;
		color: #333333;
		text-align: end;
	}

	.examine_popup_body {
		padding: 0 47rpx;
		margin: 33rpx 0;
	}

	.company_msg {
		display: flex;
		justify-content: space-between;
		align-items: baseline;
	}

	.bgtext {


		font-size: 28rpx;
		font-family: PingFang SC;
		font-weight: bold;
		color: #333333;

	}

	.item_price {
		font-size: 24rpx;
		font-family: PingFang SC;
		font-weight: 500;
		color: #333333;
	}

	.text {

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

	.samll_txext {
		font-size: 24rpx;
		font-family: PingFang SC;
		font-weight: 500;
		color: #999999;
		display: flex;
		align-items: center;

	}

	.leftTip {
		position: absolute;
		top: 0;
		left: 0;
		height: 100%;
		background-color: #E9CF31;
		width: 10rpx;
	}

	.seach_input {
		background-color: #FFFFFF;
		border-radius: 12rpx;
		flex: 1;
	}

	.typeyuan {
		background-color: #17A00E;
		width: 14rpx;
		height: 14rpx;
		border-radius: 50px;
		margin-right: 6rpx;
	}

	.seletypeyuan {
		background-color: red;
		width: 14rpx;
		height: 14rpx;
		border-radius: 50px;
		margin-right: 6rpx;
	}

	.is-input-border {
		border: 0px !important;
	}

	page {
		background-color: #F0F2FF;
	}

	.form_body_item {
		min-height: 339rpx;
		background: #FFFFFF;
		box-shadow: 0px 3px 9px 0px rgba(88, 88, 88, 0.2);
		border-radius: 12rpx;
		font-size: 28rpx;
		/* padding: 20rpx; */
		display: flex;
		flex-direction: column;
		/* padding-bottom: 0; */
		position: relative;
		overflow: hidden;
		/* padding-top: 0; */
	}

	.form_body {
		width: 100vw;
		padding: 0 10px;
		margin-top: 40rpx;
		box-sizing: border-box;
	}

	.navigation_seleitem {
		width: 150rpx;
		height: 59rpx;
		background: #F0F2FF;
		border-top-left-radius: 11rpx;
		border-top-right-radius: 11rpx;
		font-size: 26rpx;
		color: #333333;
		display: flex;
		justify-content: center;
		align-items: center;
		transition: all 0.3s;
		position: relative;
		bottom: -2px;
	}

	.navigation_item {
		width: 150rpx;
		height: 59rpx;
		border-top-left-radius: 11rpx;
		border-top-right-radius: 11rpx;
		font-size: 26rpx;
		color: #F0F2FF;
		display: flex;
		justify-content: center;
		align-items: center;
		transition: all 0.3s;
		bottom: -2px;
	}

	.Navigation {
		display: flex;
		position: absolute;
		bottom: 0px;
		transition: all .5s;
	}

	.header_seach_butten {
		font-size: 24rpx !important;
		display: flex !important;
		align-items: center !important;
		margin: 0 !important;
		flex-shrink: 1;
		margin-left: 9rpx !important;
		background: #FFFFFF !important;
		justify-content: center;
	}

	.uni-easyinput__content {
		height: 80rpx;
	}

	.uni-easyinput {
		height: 80rpx;
	}

	.header_seach_seach {
		display: flex;
		height: 80rpx;
		margin-top: 23rpx;
	}

	.header_seach_title {
		display: flex;
		align-items: center;
	}

	.header_seach {
		font-size: 26rpx;
		padding: 0 10px;
	}

	.uni-navbar--border {
		border: 0px !important;
	}

	.uni-navbar__header-btns-right {
		padding-right: 0 !important;
		width: 120rpx !important;
	}

	.top {
		height: var(--status-bar-height);
	}
</style>
