<template>
	<view>
		<view class="view">
			<view v-if="type === 0" class="listItemStyle" @click="toJDPage">
				<u-text text="查看订单进度" color="rgb(0, 170, 255)" size="20"></u-text>
			</view>
			<u-list @scrolltolower="scrolltolower">
				<view v-if="dataList.length === 0" style="padding: 0 50px;">
					<image style="margin: 0 auto; width: 100%;" src="../../../static/img/page/empty_view.png"></image>
				</view>
				<u-list-item v-for="(item, index) in dataList" :key="index">
					<view v-if="item.amount !== 0 && item.amount" class="listItemStyle">
						<u-row>
							<u-col span="3">
								<u--image :showLoading="true" shape="circle" :src="baseURL+item.cuisinePictrue"
									width="70px" height="70px" style="margin: 10px;"></u--image>
							</u-col>
							<u-col span="7" style="margin-left: 5px;">
								<view>
									<u--text :text="item.cuisineName" size="20"></u--text>
								</view>
								<view style="margin-top: 10px;">
									<u--text :text="'￥'+item.price" size="20"></u--text>
								</view>
							</u-col>
							<u-col span="2">
								<view>
									<u--text :text="item.amount+'份'" size="25"></u--text>
								</view>
							</u-col>
						</u-row>
					</view>
				</u-list-item>
			</u-list>
		</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				baseURL: this.$BASE_URL,
				priceSum: 0.0,
				dateShow: false,
				data: {
					organizationName: "",
				},
				from: {
					orderNumber: '',
					organizationCode: ''
				},
				dataList: [],
				dataListNow: [],
				type: uni.getStorageSync("tabType")
			}
		},
		onLoad() {
			this.submitOrder()
		},
		methods: {
			toJDPage() {
				this.$goto('../../../pageA/card/orderProcess')
			},
			async submitOrder() {
				var order = uni.getStorageSync('order')
				this.from.orderNumber = order.orderNumber
				this.from.organizationCode = order.jgid
				let urlType = 1
				if (uni.getStorageSync('orgInfo').organizationCode == 'G00000003') {
					urlType = 2;
				}
				// 发送请求
				const {
					data: res
				} = await this.$httpRequest({
					url: '/app/getOrderDetail',
					method: 'post',
					data: this.from,
					urlType: this.$getUrlType()
				});
				if (res.code === 200) {
					this.dataList = res.rows
				}
			},
			loadmore(data) {
				for (var i = 0; i < data.length; i++) {
					this.dataList.push(data[i])
				}
			},
			result(time, mode) {
				const timeFormat = uni.$u.timeFormat
				switch (mode) {
					case 'datetime':
						return timeFormat(time, 'yyyy-mm-dd hh:MM')
					case 'date':
						return timeFormat(time, 'yyyy-mm-dd')
					case 'year-month':
						return timeFormat(time, 'yyyy-mm')
					case 'time':
						return time
					default:
						return ''
				}
			}
		}
	}
</script>

<style>
	.view {
		background-color: #ebebeb;
		padding-top: 10px;
	}

	.listTermDate {
		padding: 10px 0;
	}

	.listItemStyle {
		margin: 5px 12px;
		padding: 10px;
		border-radius: 15px;
		background-color: #fafafa;
	}
</style>
