<template>
	<view class="container">
		<view class="bgf pof">

			<view class="flex-center search-content">
				<view class="search flex-y-center" style="margin-bottom: 0;">
					<icon type="search" size="16" />
					<input placeholder="请输入订单编号搜索" class="flex-grow-1" type="text" value="" @confirm="firmSeach"
						@input="putSeach" />
				</view>
				<text @click="bindSeach">搜索</text>
			</view>

			<view class="box-pack-between header-hg100 flex-y-center ">
				<view class="flex-y-center flex-grow-1 ft26 header-text">
					<view class="flex-grow-1 flex-center" data-text="1" :class="act_index==1?'act':''"
						@click="onTopBtnTap(1)">
						{{collage_id_text}}
						<view class="d3" :style="'border-color:'+act_index==1?'#007AFF':''"></view>
					</view>
					<view class="flex-grow-1 flex-center" data-text="1" :class="act_index==2?'act':''"
						@click="onTopBtnTap(2)">
						{{order_status_text}}
						<view class="d3" :style="'border-color:'+act_index==1?'#007AFF':''"></view>
					</view>
					<view class="flex-grow-1 flex-center" data-text="3" :class="act_index==3?'act':''"
						@click="onTopBtnTap(3)">
						{{is_refund_text}}
						<view class="d3"></view>
					</view>

					<view class="flex-grow-1 flex-center" data-text="4" :class="act_index==4?'act':''"
						@click="onTopBtnTap(4)">
						{{send_type_text}}
						<view class="d3"></view>
					</view>
					<view class="flex-grow-1 flex-center" data-text="5" :class="act_index==5?'act':''"
						@click="onTopBtnTap(5)">
						{{status_text}}
						<view class="d3"></view>
					</view>

				</view>
			</view>
		</view>


		<view class="list">
			<navigator :url="`/saomaDiancan/order/pintuanOrderDetail?id=${item.id}`" class="item"
				v-for="(item,index) in list" :key="index">
				<view class="top flex flex-y-center box-pack-between">
					<view class="name text-1">{{item.order_no}}</view>

				</view>
				<view class="content" style="border-bottom: 1rpx solid #f1f1f1;">

					<view class="box-pack-between">
						<view class="cell flex flex-y-center">
							<view class="title">支付金额：</view>
							<view class="desc" style="color:red">￥{{item.pay_price}}</view>
						</view>
						<view class="pay-info flex flex-y-center">
							<image
								:src="item.pay_type == 1?'../../static/images/wx.png':item.pay_type == 2?'../../static/images/ali.png':'../static/images/yu.png'"
								class="pay-type-icon"></image>
							<view class="pay-status">{{['待支付','拼团中','拼团成功','拼团失败','已取消'][item.order_status-1]}}
							</view>
						</view>
					</view>
					<view class="cell flex flex-y-center">
						<view class="title">付款方式：</view>
						<view class="desc" style="color:red">
							{{['微信','支付宝','余额'][item.pay_type-1]}}
						</view>
					</view>
					<view class="cell flex flex-y-center">
						<view class="title">提货方式：</view>
						<view class="desc" style="color:red">
							{{item.send_types}}
						</view>
					</view>

					<view class="cell flex flex-y-center arr-r">
						<view class="title">订单时间 ：</view>
						<view class="desc">{{item.create_time}}</view>
					</view>
				</view>

			</navigator>

			<view class="no-more" v-if="is_bottom">
				---没有更多了---
			</view>

		</view>

		<uni-popup-top ref="popup" type="top" :top="top" :maskClass="maskClass">

			<view class="showpay">
				<block v-if='act_index==1'>
					<view class="box-li" :class="collage_id==''?'active':''" @click="onChangeStatus('collage_id','','活动')" data-type=''
						data-text='全部'>全部
					</view>
					<view class="box-li" :class="collage_id==item.id?'active':''" @click="onChangeStatus('collage_id',item.id,item.name)"
						:data-type="item.id" :data-text="item.name" v-for="(item,index) in hdList">{{item.name}}
					</view>

				</block>
				<block v-if='act_index==2'>
					<view class="box-li" :class="order_status==''?'active':''" @click="onChangeStatus('order_status','','订单状态')"
						data-type='' data-text='全部'>全部
					</view>
					<view class="box-li" :class="order_status==1?'active':''" @click="onChangeStatus('order_status',1,'待支付')"
						data-type='1' data-text='待支付'>待支付
					</view>
					<view class="box-li" :class="order_status==2?'active':''" @click="onChangeStatus('order_status',2,'拼团中')"
						data-type='2' data-text='拼团中'>拼团中
					</view>
					<view class="box-li" :class="order_status==3?'active':''" @click="onChangeStatus('order_status',3,'拼团成功')"
						data-type='3' data-text='拼团成功'>拼团成功
					</view>
					<view class="box-li" :class="order_status==4?'active':''" @click="onChangeStatus('order_status',4,'拼团失败')"
						data-type='4' data-text='拼团失败'>拼团失败
					</view>
					<view class="box-li" :class="order_status==5?'active':''" @click="onChangeStatus('order_status',5,'已取消')"
						data-type='5' data-text='已取消'>已取消
					</view>
				</block>

				<block v-if='act_index==3'>
					<view class="box-li" :class="is_refund==''?'active':''" @click="onChangeStatus('is_refund','','退款状态')" data-text='全部'>
						全部
					</view>
					<view class="box-li" :class="is_refund==1?'active':''" @click="onChangeStatus('is_refund',1,'退款中')" data-text='退款中'>
						退款中
					</view>
					<view class="box-li" :class="is_refund==2?'active':''" @click="onChangeStatus('is_refund',2,'退款成功')" data-text='退款成功'>
						退款成功
					</view>
					<view class="box-li" :class="is_refund==3?'active':''" @click="onChangeStatus('is_refund',3,'退款失败')" data-text='退款失败'>
						退款失败
					</view>
				</block>

				<block v-if='act_index==4'>
					<view class="box-li" :class="send_type==''?'active':''" @click="onChangeStatus('send_type','','提货方式')" data-text='全部'>
						全部
					</view>
					<view class="box-li" :class="send_type==1?'active':''" @click="onChangeStatus('send_type',1,'外卖')" data-text='外卖'>外卖
					</view>
					<view class="box-li" :class="send_type==2?'active':''" @click="onChangeStatus('send_type',2,'自提')" data-text='自提'>自提
					</view>
					<view class="box-li" :class="send_type==3?'active':''" @click="onChangeStatus('send_type',3,'快递')" data-text='快递'>快递
					</view>
				</block>
				<block v-if='act_index==5'>
					<view class="box-li" :class="status==''?'active':''" @click="onChangeStatus('status','','配送状态')" data-text='全部'>
						全部
					</view>
					<view class="box-li" :class="status==1?'active':''" @click="onChangeStatus('status',1,'待配送')" data-text='待配送'>
						待配送
					</view>
					<view class="box-li" :class="status==2?'active':''" @click="onChangeStatus('status',2,'已收货')" data-text='已收货'>
						已收货
					</view>
					<view class="box-li" :class="status==3?'active':''" @click="onChangeStatus('status',3,'已完成')" data-text='已完成'>
						已完成
					</view>
				</block>

			</view>
		</uni-popup-top>
	</view>
</template>

<script>
	import uniPopupTop from '@/components/zx-uni-popup/uni-popup-top.vue'
	export default {
		components: {
			uniPopupTop
		},
		data() {
			return {
				hdList: [],
				collage_id: '',
				order_status: '',
				is_refund: '',
				send_type: '',
				status: '',
				URL: getApp().globalData.URL,
				admin_id: "",

				list: [],
				page: 1,
				is_bottom: false,
				act_index: 1,

				top: "200rpx",
				maskClass: {
					'position': 'fixed',
					'bottom': 0,
					'top': "100rpx",
					'left': 0,
					'right': 0,
					'backgroundColor': 'rgba(0, 0, 0, 0.4)'
				},
				collage_id_text: '活动',
				order_status_text: '订单状态',
				is_refund_text: '退款状态',
				send_type_text: '提货方式',
				status_text: '配送状态',
			}
		},

		onLoad(options) {
			this.admin_id = options.admin_id || uni.getStorageSync('admin_id');
			this.getHdList()
			this.getData(1);
		},

		onShow() {
			
		},

		onReachBottom() {
			if (!this.is_bottom) {
				this.getData(this.page + 1)
			}
		},

		methods: {
			//活动列表
			getHdList() {
				//
				this.request({
					url: 'smdcshop/collage_list',
					data: {
						admin_id: this.admin_id,
					}
				}).then(res => {
					this.hdList = res.data
				})
			},
			// 键盘完成事件
			firmSeach(e) {
				this.serch = e.detail.value;
				this.getData(1);
				this.$refs.popup.close();
			},

			// 监听input
			putSeach(e) {
				this.serch = e.detail.value;
				if (!e.detail.value) {
					this.getData(1);
				}
			},

			// 搜索
			bindSeach(e) {
				this.getData(1);
				this.$refs.popup.close();
			},
			onChangeStatus(field,val,text){
				this[field] = val;
				this[`${field}_text`] = text;
				this.getData(1);
				this.$refs.popup.close();
			},
			

			onTopBtnTap(e) {
				this.act_index = e;
				this.$refs.popup.open();
			},

			getData(page) {
				if (page == 1) {
					this.list = []
					this.page = 1
					this.is_bottom = false
				}
				this.request({
					url: 'smdcshop/collage_orderlist',
					data: {
						page,
						limit: 10,
						admin_id: this.admin || uni.getStorageSync('admin_id'),
						keywords: this.serch,
						collage_id: this.collage_id,
						order_status: this.order_status || '',
						is_refund: this.is_refund,
						send_type: this.send_type,
						status: this.status,

					}
				}).then(res => {
					if (res.code == 200 && res.data.length) {
						this.list = this.list.concat(res.data)
						this.page = page

					} else {
						this.is_bottom = true
					}
				})
			},
		},
	}
</script>
<style lang="scss">
	.store-name {
		max-width: 150rpx;
		text-overflow: ellipsis;
		white-space: nowrap;
		overflow: hidden;
	}

	.header-text .act {
		color: red;

	}

	.header-text .act .d3 {
		border-color: red transparent transparent transparent;
	}

	.pof {
		position: fixed;
		left: 0;
		z-index: 999;
		background: #fff;
		width: 100%;
	}

	.search-content {
		width: 100%;
		height: 100rpx;
		font-size: 28rpx;
		top: 0;

		.search {
			width: 80%;
			border: 1rpx solid #F1F1F1;
			margin-right: 15rpx;
			padding: 10rpx;
			border-radius: 50rpx;

			icon {
				margin-right: 15rpx;
			}
		}
	}

	.model {
		width: 100%;
		z-index: 10;
		background: #FFFFFF;
		padding-bottom: 20rpx;

		.model-date {
			width: 100%;
			padding: 20rpx 80rpx;
			border-bottom: 1rpx solid #F1F1F1;

			.model-item {
				width: 270rpx;
				text-align: center;
				font-size: 28rpx;
				color: #999;
				position: relative;
				padding: 10rpx 0;
				text-align: center;
				border-radius: 8rpx;
				border: 1rpx solid #999;
			}

			.act {
				// color: #FFFFFF;
				// background: #FFBE2C;
				// border: 1rpx solid #FFBE2C;
			}
		}

		.model-btn {
			border-radius: 8rpx;
			box-shadow: 0px 0px 8rpx 0px rgba(51, 135, 255, 0.20);
			margin: 0 auto;
			margin-top: 20rpx;
			text-align: center;
			width: 41%;
			height: 80rpx;
			border-radius: none;
		}

		.model-btn-close {
			border: 1rpx solid #F1F1F1;
			color: #000;
		}

		.model-btn-success {
			color: #FFFFFF;
			background: linear-gradient(315deg, #3387ff 2%, #569bff 99%);

		}
	}

	page {
		background-color: #F4F5F7;
	}

	.showpay .active {
		color: red
	}

	.header-hg100 {
		height: 100rpx;
		top: 100rpx;
		width: 100%;
	}

	.list {
		padding: 210rpx 25rpx 0;
	}

	.list .item {
		background-color: #fff;
		border-radius: 8rpx;
		overflow: hidden;
		padding: 0 25rpx;
		margin-bottom: 30rpx;
		box-shadow: 0rpx 6rpx 10rpx 0rpx rgba(213, 213, 213, 0.04);
	}

	.list .item .top {
		height: 80rpx;
		border-bottom: 1rpx solid #f5f5f5;
	}

	.list .item .top .pay-info {
		flex: none;
	}

	.pay-type-icon {
		display: block;
		width: 28rpx;
		height: 28rpx;
		flex: none;
		margin-right: 8rpx;
	}

	.pay-status {
		font-size: 28rpx;
		color: #464646;
	}

	.list .item .content {
		padding: 20rpx 0;
	}

	.list .content .cell {
		margin-bottom: 16rpx;
		font-size: 26rpx;
		color: #99A0AD;
	}

	.list .content .cell:last-child {
		margin-bottom: 0;
	}

	.list .content .cell .title {
		color: #99A0AD;
	}

	.list .content .cell .desc {
		color: #666;
	}

	.qc-btn {
		background-color: #3387FF;
		color: #fff;
		border-radius: 6rpx;
		height: 48rpx;
		line-height: 48rpx;
		padding: 0 20rpx;
		margin-left: 10rpx;

	}

	.header-text {
		text-align: center;
	}

	.box-li {
		background-color: #fff;
		text-align: center;
		border-bottom: 1rpx solid #f1f1f1;
		height: 80rpx;
		line-height: 80rpx;
		font-size: 26rpx;
	}

	.goods_list {
		font-size: 28rpx;
	}

	.goods_list-title {
		padding: 20rpx 0;
	}


	.goods_list-price {
		font-size: 26rpx;
		color: red;
	}

	.goods_list-num {
		font-size: 26rpx;
	}

	.d3 {
		width: 0;
		height: 0;
		border-width: 12rpx;
		border-style: solid;
		border-color: #000 transparent transparent transparent;
		margin-top: 14rpx;
		margin-left: 6rpx;
	}
</style>
