<template>
	<view>
		<view>
			<view>
				<u-list @scrolltolower="scrolltolower">
					<!-- <view class="listTermDate">
						 <u-cell-group>
								<u-cell :title="from.date" arrow-direction="down" @click="dateShow = true" isLink></u-cell>
							</u-cell-group> 
						<view>
							<u-datetime-picker :show="dateShow" closeOnClickOverlay v-model="from.date" mode="date"
								@cancel="dateShow = false" @confirm="submitDate" :formatter="formatter"
								@change="change">
							</u-datetime-picker>
						</view>
					</view> -->
					<view class="hand">
						<u-row>
							<u-col span="8">
								<view class="orgTop">
									<uni-row>
										<uni-col :span="10">
											<u--text text="所属机构" size="22" bold color="#619f8a"></u--text>
										</uni-col>
										<uni-col :span="24">
											<u--text :text="from.organizationName" size="22" bold color="#757575">
											</u--text>
										</uni-col>
									</uni-row>
								</view>
							</u-col>
							<!--<u-col span="4">
										<view>
											<u-button class="sxButton" size="normal" loadingMode="circle" color="#65c1aa">统计查看
											</u-button>
										</view>
									</u-col> -->
						</u-row>
					</view>
					<view v-if="indexList.length === 0" style="padding: 0 50px;">
						<image style="margin: 0 auto; width: 100%;" src="../../../static/img/page/empty_view.png">
						</image>
					</view>
					<view v-for="(item, index) in indexList" :key="index">
						<view :data-index="index" class="order-item">
							<view class="listItemStyle">
								<u-row>
									<u-col span="3">
										<view class="orderFoodStyle orderFoodType0">
											{{item.statusText}}
										</view>
									</u-col>
									<u-col span="5" class="orderFoodStyle orderFoodType">
										<view style="font-size: 26rpx;">
											订单：{{item.orderNumber}}
										</view>
									</u-col>
									<u-col span="4" textAlign="right">
										<view class="moneyText">
											{{"- "+item.orderTotal+""}}
										</view>
									</u-col>
								</u-row>
								<u-row>
									<u-col span="5" class="orderTimeText">{{item.paytime}}</u-col>
									<u-col span="1" class="orderTimeText">
									</u-col>
									<u-col span="2" class="orderTimeText">
										<view style="color: #1787ff;font-size: 34rpx;" @click="toJDPage(item)">
											进度
										</view>
									</u-col>
									<u-col span="3" class="orderTimeText">
										<view style="color: #1787ff;font-size: 34rpx;" @click="getDetails(item)">
											详情
										</view>
									</u-col>
									<u-col span="2" class="orderTimeText">
										<view v-if="item.isNews === '1'"
											style="font-size: 22rpx;color: rgb(55,186,189);" @click="toJDPage(item)">
											新消息
										</view>
									</u-col>
								</u-row>
							</view>
						</view>
					</view>
				</u-list>
				<u-modal :show="modalContent1.show" :title="modalContent1.title" :showCancelButton="true"
					confirmColor="#53a591" @confirm="backSubmit()" @cancel="modalContent1.show = false">
					{{modalContent1.content}}
				</u-modal>
				<u-modal :show="modalContent2.show" :title="modalContent2.title" :content='modalContent2.content'
					confirmColor="#53a591" @confirm="modalContent2.show = false">
				</u-modal>
			</view>
		</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				type: uni.getStorageSync("tabType"),
				dateShow: false,
				data: {},
				from: {
					organizationName: ''
				},
				indexList: [],
				modalContent1: {
					show: false,
					title: '提示',
					content: '确认退单吗？'
				},
				modalContent2: {
					show: false,
					title: '提示',
					content: ''
				},
				//列表数据（
				indexList: [],
				//左滑默认宽度
				startX: 0,
				startY: 0,
				delBtnWidth: 90,
				pageNum: 1,
				pageSize: 10,
				total: 1
			}
		},
		onLoad() {
			this.getExpenseCalendarList()
		},
		onShow() {
			this.getExpenseCalendarList()
		},
		onHide() {
			this.getExpenseCalendarList()
		},
		methods: {
			toJDPage(item) {
				uni.setStorageSync('order', item)
				this.$goto('../orderProcess')
			},
			getDetails(item) {
				uni.setStorageSync('order', item)
				this.$goto('details')
			},
			async getExpenseCalendarList() {
				if (this.indexList.length >= this.total) {
					return;
				}
				const orgInfo = uni.getStorageSync("orgInfo")
				this.from.organizationName = orgInfo.organizationName
				this.from.userName = uni.getStorageSync('userInfo').userName
				this.from.organizationCode = orgInfo.organizationCode
				// 发送请求
				const {
					data: res
				} = await this.$httpRequest({
					url: '/app/getOrder?' + "pageNum=" + this.pageNum + "&" + "pageSize=" + this.pageSize,
					method: 'post',
					data: this.from,
					urlType: 2
				});
				if (res.code === 200) {
					this.total = res.total
					this.loadmore(res.rows)
				}
			},
			change(e) {
				//this.changeDate = this.result(e.value, e.mode)
			},
			scrolltolower() {
				this.pageNum++;
				this.getExpenseCalendarList()
			},
			loadmore(data) {
				if (data.length === 0) {
					return;
				}
				for (var i = 0; i < data.length; i++) {
					this.indexList.push(data[i])
				}
			},
			formatter(type, value) {
				if (type === 'year') {
					return `${value}年`
				}
				if (type === 'month') {
					return `${value}月`
				}
				if (type === 'day') {
					return `${value}日`
				}
				return value
			},
			//删除方法
			delData(item) {
				this.modalContent1.show = true;
				uni.setStorageSync("orderNumber", item.orderNumber)
				//关闭侧边滑动
				item.right = 0
			}
		}
	}
</script>

<style>

	.hand {
		margin-top: 2px;
		padding: 5%;
		border-radius: 10px 10px 0 0;
		background: linear-gradient(to bottom right, #85c1bf, #f1fef9);
	}

	.orgTop {
		margin-bottom: 5px;
	}

	.sxButton {
		width: 100px;
		display: flex;
		flex-direction: column;
		align-items: center;
	}

	.order-item {
		position: relative;
	}

	.remove {
		width: 100px;
		height: 100%;
		background-color: #57aa8e;
		color: white;
		position: absolute;
		top: 0;
		right: -100px;
		display: flex;
		justify-content: center;
		align-items: center;
		font-size: 18px;
	}

	.listTermDate {
		padding: 10px 0;
	}

	.listItemStyle {
		background-color: #ffffff;
		padding: 15px;
		border: 1px solid #d8d8d8;
		margin: 10rpx;
	}

	.orderFoodStyle {
		font-size: 20px;
	}

	.orderFoodType {
		color: #000000;
	}

	.orderFoodType0 {
		color: #1787ff;
	}

	.orderFoodType1 {
		color: #da0000;
	}

	.orderFoodType2 {
		color: #00af00;
	}

	.moneyText {
		font-size: 26rpx;
		color: #b30000;
	}

	.orderTimeText {
		position: relative;
		top: 5px;
		color: #bebebe;
		font-size: 16px;
	}
</style>
