<template>
	<view class="order">
		<view class="order-header">
			<view class="order-header-text">
				<view class="order-header-text-neishi" @click="topgi">
					<view class="order-header-text-icon">
						<image src="https://cdn.bjtdba.com/vod/image/2022-08-11/20220811133828415.png" mode="widthFix">
						</image>
					</view>
				</view>
				<view class="order-header-text-title">
					我的订单
				</view>
			</view>
		</view>
		<view class="order-nbeirong">
			<view class="order-nbeirong-yi" v-for="(item,index) in num" :key="index" @click="ysne(index,item.status)"
				:style="index==indexs?'font-weight: 500;color: #1F7CFF;':'font-weight: 400;color: #333333;'">
				{{item.name}}
				<view class="order-nbeirong-yi-xiabiapo" v-if="index==indexs?true:false">

				</view>
			</view>
		</view>
		<view class="order-list">
			<view :class="item.status=='待发货'?downP:incrseP" v-for="(item,index) in list" :key="index"
				@click="details(item.order_id)">
				<view class="order-list-yi-top">
					<view class="order-list-yi-top-left">
						订单编号：{{item.order_id}}
					</view>
					<view class="order-list-yi-top-right">
						{{item.status}}
					</view>
				</view>
				<view class="order-list-yi-in">
					<view class="osjdhujfhueihfg">
						<view class="order-list-yi-in-neibu" v-for="(items,indexs) in item.procductList" :key="indexs">
							<view class="order-list-yi-in-neibu-left">
								<view class="order-list-yi-in-neibu-left-img">
									<image :src="items.image" mode="widthFix"></image>
								</view>
								<view class="order-list-yi-in-neibu-left-url">
									<view class="order-list-yi-in-neibu-left-url-top">
										{{items.store_name}}
									</view>
									<view class="order-list-yi-in-neibu-left-url-top-bot">
										{{items.sku}}
									</view>
								</view>
							</view>
							<view class="order-list-yi-in-neibu-right">
								<view class="order-list-yi-in-neibu-right-im">
									¥{{items.pay_price}}
								</view>
								<view class="order-list-yi-in-neibu-right-in">
									共{{items.cart_num}}件
								</view>
							</view>
						</view>
						
						<view class="" v-if="item.status=='待发货'?true:false"
							style="width: 142rpx;height: 58rpx;border-radius: 30rpx;border: 1rpx solid #999999;font-size: 24rpx;font-weight: 400;color: #333333;text-align: center;line-height: 58rpx;">
							立即发货
						</view>
					</view>
				</view>
				<view class="order-list-yi-bot">
					<view class="order-list-yi-bot-xiangxi">
						<view class="order-list-yi-bot-xiangxier">
							<image src="https://cdn.bjtdba.com/vod/image/2022-08-13/20220813164638215.png"
								mode="widthFix"></image>
						</view>
						<view class="order-list-yi-bot-xadasrfe">
							<view class="order-list-yi-bot-xadasrfe-top">
								{{item.user_address}}
							</view>
							<view class="order-list-yi-bot-xadasrfe-bot">
								<view class="">
									{{item.real_name}}
								</view>
								<view class="" style="margin-left: 32rpx;">
									{{item.user_phone.substr(0, 3) + '****' + item.user_phone.substr(7)}}
								</view>
							</view>
						</view>
					</view>
				</view>
			</view>
			<view class="" v-if="tihsi==0" style="margin: 60rpx 0 30rpx 0; color: #999999; font-size: 26rpx;">
				—— 已经到最底部了哦 ——
			</view>
		</view>
	</view>
</template>

<script>
	import {
		orderList
	} from '@/commit/order.js'
	export default {
		data() {
			return {
				page: 1,
				limit: 10,
				tihsi: '',
				is_panudn: true,
				//uid: 11, //	用户ID 查询用户订单列表需要传
				mer_id: '', //商户ID    查询商户订单列表的时候需要传
				status: '', //0：待发货；1：待收货；2：待评价；3：已完成；4已申请退款；-1：已退款）5未支付WADDW
				indexs: 0,
				// sty: true,
				incrseP: 'order-list-yi',
				downP: 'order-list-yissss',
				list: [],
				num: [{
						name: "待付款",
						status: 5
					},
					{
						name: "待发货",
						status: 0
					},
					{
						name: "待收货",
						status: 1
					},
					{
						name: "待评价",
						status: 2
					},
					// {
					// 	name: "已完成"
					// }
				]
			}
		},
		onLoad(e) {
			let selectmerchant = uni.getStorageSync('selectmerchant')
			this.mer_id = selectmerchant.merId
			this.status = e.status //进入状态
			this.indexs = e.index
			this.orderList()
		},
		onPullDownRefresh() {
			uni.showLoading({
				title: '加载中',
			});
			this.page = 1
			this.is_panudn = true
			this.list = []
			this.orderList();
		},
		onReachBottom() {
			if (this.is_panudn == true) {
				this.page++;
				this.orderList();
			} else {
				return
			}
		},
		methods: {
			// 正向订单列表
			orderList() {
				uni.showLoading({
					title: '加载中',
				});
				orderList({
					pageNum: this.page,
					pageSize: this.limit,
					mer_id: this.mer_id,
					status: this.status
				}).then(res => {
					uni.stopPullDownRefresh();
					if (res.data.status == 200) {
						this.tihsi = res.data.data.pageInfo.list.length
						if (res.data.data.pageInfo.list.length > 0) {
							if (this.page == 1) {
								this.list = res.data.data.pageInfo.list
							} else {
								this.list = this.list.concat(res.data.data.pageInfo.list)
							}
						} else {
							if (this.page == 1) {
								this.list = []
							}
							this.is_panudn = false
						}
						uni.hideLoading();
					}
				}, fail => {
					console.log(fail)
					uni.hideLoading();
				})
			},
			details(e) {
				uni.redirectTo({
					// + "&status=" + this.status + "&indexs=" + this.indexs
					url: './details?order_id=' + e + "&status=" + this.status + "&indexs=" + this.indexs
				});
			},
			ysne(e, i) {
				this.status = i
				this.indexs = e
				this.page = 1
				this.is_panudn = true
				this.orderList()
			},
			topgi() {
				uni.switchTab({
					url: '../../pages/ordermanagement/index'
				});
			},
		}
	}
</script>

<style>
	page {
		background-color: #F7F8FC;
	}
</style>
<style lang="scss" scoped>
	.order {
		width: 100%;
		height: 100%;
		display: flex;
		flex-direction: column;
		align-items: center;

		.order-header {
			position: fixed;
			top: 0;
			left: 0;
			z-index: 111;
			width: 100%;
			height: 176rpx;
			background: #FFFFFF;
			display: flex;
			justify-content: center;

			.order-header-text {
				width: 686rpx;
				font-size: 36rpx;
				font-weight: 500;
				color: #333333;
				display: flex;
				margin-top: 107rpx;
				align-items: center;

				.order-header-text-neishi {
					width: 45rpx;
					height: 45rpx;
					margin-right: 17rpx;

					.order-header-text-icon {
						width: 36rpx;
						height: 36rpx;
						margin-top: 2rpx;

						image {
							width: 100%;
							height: 100%;
						}
					}
				}
			}
		}

		.order-nbeirong {
			width: 686rpx;
			height: 30rpx;
			margin: 204rpx 0 38rpx 0;
			display: flex;
			justify-content: space-around;
			align-items: center;

			.order-nbeirong-yi {
				font-size: 30rpx;
				position: relative;
				display: flex;
				justify-content: center;

				.order-nbeirong-yi-xiabiapo {
					position: absolute;
					top: 45rpx;
					width: 50rpx;
					height: 6rpx;
					background: #1F7CFF;
					border-radius: 3rpx;
				}
			}
		}

		.order-list {
			width: 100%;
			height: 100%;
			display: flex;
			flex-direction: column;
			align-items: center;

			.order-list-yi {
				width: 686rpx;
				// height: 472rpx;
				background: #FFFFFF;
				border-radius: 16rpx;
				margin-bottom: 20rpx;
				display: flex;
				flex-direction: column;
				justify-content: space-between;
				align-items: center;

				.order-list-yi-top {
					width: 100%;
					// height: 90rpx;
					padding: 32rpx 0 32rpx 0;
					border-bottom: 1rpx solid #E5E5E5;
					display: flex;
					justify-content: space-between;
					align-items: center;
					font-size: 26rpx;

					.order-list-yi-top-left {
						font-weight: 500;
						color: #333333;
						margin-left: 26rpx;
					}

					.order-list-yi-top-right {
						font-weight: 400;
						color: #1F7CFF;
						margin-right: 26rpx;
					}
				}

				.order-list-yi-in {
					width: 100%;
					// height: 210rpx;
					padding: 26rpx 0 26rpx 0;
					border-bottom: 1rpx solid #E5E5E5;
					display: flex;
					align-items: center;
					justify-content: center;

					.order-list-yi-in-neibu {
						width: 634rpx;
						height: 158rpx;
						display: flex;
						margin: 10rpx 0 10rpx 0;
						justify-content: space-between;
						align-items: flex-start;

						.order-list-yi-in-neibu-left {
							width: 474rpx;
							height: 100%;
							display: flex;
							align-items: flex-start;
							justify-content: space-between;

							.order-list-yi-in-neibu-left-img {
								width: 158rpx;
								height: 158rpx;
								overflow: hidden;

								image {
									width: 100%;
									height: 100%;
								}
							}

							.order-list-yi-in-neibu-left-url {
								width: 290rpx;
								height: 70rpx;
								display: flex;
								flex-direction: column;
								justify-content: space-between;

								.order-list-yi-in-neibu-left-url-top {
									width: 100%;
									font-weight: 400;
									color: #333333;
									font-size: 28rpx;
									display: inline-block;
									overflow: hidden;
									text-overflow: ellipsis;
									white-space: nowrap;
								}

								.order-list-yi-in-neibu-left-url-top-bot {
									width: 100%;
									font-size: 24rpx;
									font-weight: 400;
									color: #666666;
									display: inline-block;
									overflow: hidden;
									text-overflow: ellipsis;
									white-space: nowrap;
								}
							}
						}

						.order-list-yi-in-neibu-right {
							height: 73rpx;
							font-size: 28rpx;
							font-weight: 500;
							color: #333333;
							display: flex;
							flex-direction: column;
							justify-content: space-between;
							align-items: flex-end;

							.order-list-yi-in-neibu-right-im {
								font-size: 28rpx;
								font-weight: 500;
								color: #333333;
							}

							.order-list-yi-in-neibu-right-in {
								font-size: 24rpx;
								font-weight: 400;
								color: #666666;
							}
						}
					}
				}

				.order-list-yi-bot {
					width: 100%;
					// height: 170rpx;
					padding: 26rpx 0 32rpx 0;
					display: flex;
					align-items: center;
					justify-content: center;

					.order-list-yi-bot-xiangxi {
						width: 634rpx;
						height: 112rpx;
						display: flex;
						align-items: flex-start;

						.order-list-yi-bot-xiangxier {
							width: 38rpx;
							height: 38rpx;

							image {
								width: 100%;
								height: 100%;
							}
						}

						.order-list-yi-bot-xadasrfe {
							width: 544rpx;
							height: 100%;
							margin-left: 16rpx;
							display: flex;
							flex-direction: column;
							justify-content: space-between;
							align-items: flex-start;

							.order-list-yi-bot-xadasrfe-top {
								width: 100%;
								font-size: 26rpx;
								font-weight: 400;
								color: #333333;
								display: -webkit-box;
								-webkit-box-orient: vertical;
								-webkit-line-clamp: 2;
								overflow: hidden;
							}

							.order-list-yi-bot-xadasrfe-bot {
								font-size: 28rpx;
								font-weight: 400;
								color: #999999;
								display: flex;
							}
						}
					}
				}
			}

			.order-list-yissss {
				width: 686rpx;
				// height: 556rpx;
				background: #FFFFFF;
				border-radius: 16rpx;
				margin-bottom: 20rpx;
				display: flex;
				flex-direction: column;
				justify-content: space-between;
				align-items: center;

				.order-list-yi-top {
					width: 100%;
					// height: 90rpx;
					padding: 32rpx 0 32rpx 0;
					border-bottom: 1rpx solid #E5E5E5;
					display: flex;
					justify-content: space-between;
					align-items: center;
					font-size: 26rpx;

					.order-list-yi-top-left {
						font-weight: 500;
						color: #333333;
						margin-left: 26rpx;
					}

					.order-list-yi-top-right {
						font-weight: 400;
						color: #1F7CFF;
						margin-right: 26rpx;
					}
				}

				.order-list-yi-in {
					width: 100%;
					// height: 294rpx;
					border-bottom: 1rpx solid #E5E5E5;
					display: flex;
					align-items: center;
					justify-content: center;
					padding: 26rpx 0 26rpx 0;

					.osjdhujfhueihfg {
						width: 634rpx;
						// height: 272rpx;

						display: flex;
						flex-direction: column;
						justify-content: space-between;
						align-items: flex-end;


						.order-list-yi-in-neibu {
							width: 634rpx;
							height: 158rpx;
							// background-color: #1F7CFF;
							display: flex;
							justify-content: space-between;
							align-items: flex-start;
							padding: 10rpx 0 10rpx 0;

							.order-list-yi-in-neibu-left {
								width: 474rpx;
								height: 100%;
								display: flex;
								align-items: flex-start;
								justify-content: space-between;

								.order-list-yi-in-neibu-left-img {
									width: 158rpx;
									height: 158rpx;
									// background-color: #1F7CFF;
									overflow: hidden;

									image {
										width: 100%;
										height: auto;
									}
								}

								.order-list-yi-in-neibu-left-url {
									width: 290rpx;
									height: 70rpx;
									display: flex;
									flex-direction: column;
									justify-content: space-between;

									.order-list-yi-in-neibu-left-url-top {
										width: 100%;
										font-weight: 400;
										color: #333333;
										font-size: 28rpx;
										display: inline-block;
										overflow: hidden;
										text-overflow: ellipsis;
										white-space: nowrap;
									}

									.order-list-yi-in-neibu-left-url-top-bot {
										width: 100%;
										font-size: 24rpx;
										font-weight: 400;
										color: #666666;
										display: inline-block;
										overflow: hidden;
										text-overflow: ellipsis;
										white-space: nowrap;
									}
								}
							}

							.order-list-yi-in-neibu-right {
								height: 73rpx;
								font-size: 28rpx;
								font-weight: 500;
								color: #333333;
								display: flex;
								flex-direction: column;
								justify-content: space-between;
								align-items: flex-end;

								.order-list-yi-in-neibu-right-im {
									font-size: 28rpx;
									font-weight: 500;
									color: #333333;
								}

								.order-list-yi-in-neibu-right-in {
									font-size: 24rpx;
									font-weight: 400;
									color: #666666;
								}
							}
						}
					}

				}

				.order-list-yi-bot {
					width: 100%;
					height: 170rpx;
					display: flex;
					align-items: center;
					justify-content: center;

					.order-list-yi-bot-xiangxi {
						width: 634rpx;
						height: 112rpx;
						display: flex;
						align-items: flex-start;

						.order-list-yi-bot-xiangxier {
							width: 38rpx;
							height: 38rpx;

							image {
								width: 100%;
								height: 100%;
							}
						}

						.order-list-yi-bot-xadasrfe {
							width: 544rpx;
							height: 100%;
							margin-left: 16rpx;
							display: flex;
							flex-direction: column;
							justify-content: space-between;
							align-items: flex-start;

							.order-list-yi-bot-xadasrfe-top {
								width: 100%;
								font-size: 26rpx;
								font-weight: 400;
								color: #333333;
								display: -webkit-box;
								-webkit-box-orient: vertical;
								-webkit-line-clamp: 2;
								overflow: hidden;
							}

							.order-list-yi-bot-xadasrfe-bot {
								font-size: 28rpx;
								font-weight: 400;
								color: #999999;
								display: flex;
							}
						}
					}
				}
			}
		}
	}
</style>
