<template>

	<view class="box">
		<view class="list list-mt" v-for="(item,index) in listsui.length>0?listsui:list" :key="index"
			@click="btn(item.order_id,item.member_id)">
			<view v-if="item.sales_money>0" class="list-Openonbehalf">
				特批价|代开
			</view>
			<view v-if="item.is_first_order" class="list-Openonbehalftwo">
				首单
			</view>
			<view class="list-data df jcsb">
				<div>订单编号:&emsp;{{item.order_no}}</div>
				<div>{{item.order_status_name}}</div>
				<!-- <div style="color:#FF1449 ;" v-if="item.status==0">待审核</div>
					<div style="color:#FF7D02 ;" v-if="item.status==1">待出库</div>
					<div style="color:#FF7D02 ;" v-if="item.status==2">待出库(部分)</div>
					<div style="color:#00C594 ;" v-if="item.status==3">待发货</div>
					<div style="color:#00BEF9 ;" v-if="item.status==4">已收货</div>
					<div style="color:#999999 ;" v-if="item.status==5">已取消</div> -->
			</view>
			<div class="list-Splitline"></div>
			<div class="list-hospital">客户名称<span>{{item.nickname}}</span>

				<span v-if="item.order_type==1">普通订单</span>
				<span v-if="item.order_type==2">门店订单</span>
				<span v-if="item.order_type==3">本地配送订单</span>
				<span v-if="item.order_type==4">虚拟订单</span>

				<span v-if="item.order_type==5">代客下单</span>
			</div>
			<view class="list-time">
				下单时间<span>{{item.create_time | time}}</span><span>{{item.time}}</span>
			</view>
			<view class="list-money">
				合计{{item.goods_num}}件商品，
				<span v-if="item.sales_money>0">订单金额￥{{item.sales_money}}</span>
				<span v-else>订单金额￥{{item.order_money}}</span>
				<span v-if="item.wait_status==1">(待确认)</span>
				<span v-if="item.wait_status==2">(已收款)</span>
			</view>
			<view class="list-btn df jcf">
				<div class="df aic jcsa one" v-if="item.sales_balance==1"
					@click.stop="increased(item,item.order_id,item.member_id)">新增收款</div>
				<div class="df aic jcsa two" v-if="item.sales_balance==1"
					@click.stop="affirm(item.order_id,item.member_id)">确认收款</div>
				<div class="df aic jcsa sui" @click.stop="more(item)">再次订购</div>
			</view>
		</view>

	</view>

</template>

<script>
	const timesfm = require('@/common/js/map/message.js')
	import eventBus from '@/common/js/bus.js'
	export default {
		data() {
			return {
				list: [],
				page: 1,
				listsui: [],
				dataList: []
			}
		},
		created() {
			this.$api.sendRequest({
				url: '/api/salasmanorder/lists',
				data: {
					order_status: 'close'
				},
				success: res => {
					this.list = res.data.list
				}
			})
		},
		methods: {
			getwrong(order_status, member_id, is_today, sales_status, searchText,start_time,end_time) {

				console.log(order_status, member_id, is_today, sales_status, searchText,start_time,end_time);
				let obj = {
					order_status,
					member_id,
					is_today,
					sales_status,
					searchText,start_time,end_time
				}
				obj.order_status = 'close'
				if (searchText) {
					delete obj.sales_status
				}
				if(is_today){
					delete obj.sales_status
				}
				if (!sales_status) {
					delete obj.sales_status
				}
				this.$api.sendRequest({
					url: '/api/salasmanorder/lists',
					data: obj,
					success: res => {
						this.list = res.data.list
					}
				})
			},
			// getwrong(order_status, member_id, is_today, sales_status, searchText, one){
			// 	let obj = {
			// 		order_status,
			// 		member_id,
			// 		is_today,
			// 		sales_status,
			// 		searchText
			// 	}
			// 	obj.order_status='all'
			// 	if (searchText) {
			// 		delete obj.sales_status
			// 	}
			// 	this.$api.sendRequest({
			// 		url: '/api/salasmanorder/lists',
			// 		data: obj,
			// 		success: res => {
			// 			this.listsui = res.data.list
			// 		}
			// 	})
			// },
			getwrongtllisttwo() {
				this.$api.sendRequest({
					url: '/api/salasmanorder/lists',
					data: {
						order_status: 'close',
						// sales_status:false,
						// wait_status:1
					},
					success: res => {
						console.log(res, '已收货');
						this.list = res.data.list
						uni.stopPullDownRefresh()
					}
				})
			},
			getwrongtllistsui() {
				this.page += 1
				this.$api.sendRequest({
					url: '/api/salasmanorder/lists',
					data: {
						order_status: 'close',
						page: this.page
					},
					success: res => {

						this.list = [...this.list, ...res.data.list]
						console.log(this.list, '已收货');
						uni.stopPullDownRefresh()
					}
				})
			},
			queryList(pageNo, pageSize) {
				console.log(pageNo, pageSize);
				// this.page+=10
				// this.$api.sendRequest({
				// 	url:'/api/salasmanorder/lists',
				// 	data:{
				// 		order_status:'close',
				// 		page:this.page
				// 	},
				// 	success:res=>{
				// 		console.log(res,'已收货');
				// 		this.list=res.data.list
				// 	}
				// })
				this.$refs.paging.complete(this.list)
				// this.$refs.paging.complete(false);
			},
			btn(order, member) {
				console.log(order, member);
				let _this = this
				setTimeout(() => {
					eventBus.$emit('urlone', 5)
				}, 500)

				uni.navigateTo({
					// url:this.list[this.current.URL]
					url: `../../page_salesman_order/Goods_received/Goods_received?or=${order}&me=${member}`,
					fail: function(res) {
						console.log(res);
					}

				})

			},
			increased(item, order, member) {
				// event.stopPropagation();
				// console.log(item);
				setTimeout(() => {
					uni.$emit('Collection', item)
				}, 500)
				uni.navigateTo({
					url: `/page_salesman_order/Customer_payment/Customer_payment?id=${order}&di=${member}`
				})
			},
			affirm(order_id, member_id) {
				let _this = this
				// event.stopPropagation();
				console.log(order_id, member_id);
				this.$api.sendRequest({
					url: '/api/salasmanorder/detail',
					data: {
						order_id: order_id,
						member_id: member_id
					},
					success: res => {
						this.data = res.data
						console.log(res.data, '订单详情');
						// setTimeout(()=>{
						// 	uni.$emit('CommodityList',res.data.order_goods)
						// },500)
						// uni.navigateTo({
						// 	// url:this.list[this.current.URL]
						// 	url:`/page_salesman_index/Commodity_list/Commodity_list`
						// })
						uni.navigateTo({
							// url:this.list[this.current.URL]
							url: `../Collection_record/Collection_record?id=${res.data.member_id}&di=${res.data.order_id}`
						})
					}
				})
			},
			more(item) {
				event.stopPropagation();
				setTimeout(() => {
					uni.$emit('zaicidinggou', {
						one: item.order_goods,
						two: 1
					})
				}, 500)
				uni.navigateTo({
					url: `/page_salesman_index/Select_item/Select_item?st=${item.member_id}&di=${item.store_id}`
				})
			}
		},
		filters: {
			time(num) {
				return timesfm(num * 1000)

			}
		}
	}
</script>

<style lang="scss">
	.box .list:nth-child(1) {
		margin: 34rpx 24rpx 0 24rpx !important;
		// margin: 0 !important;
	}

	.box {
		margin-top: -28rpx !important;
	}

	.list {
		margin: 42rpx 24rpx 0 24rpx;
		width: 702rpx;
		height: 424rpx;
		background: #FFFFFF;
		border-radius: 24rpx;
		// padding: 32rpx;
		box-sizing: border-box;

		padding: 24rpx;
		position: relative;

		.list-Openonbehalf {
			text-align: center;
			background: #00C594;
			border-radius: 30rpx;
			position: absolute;
			top: -10rpx;
			left: 0;
			width: 142rpx;
			height: 34rpx;
			font-size: 24rpx;
			font-family: PingFangSC-Regular, PingFang SC;
			font-weight: 400;
			color: #FFFFFF;
			line-height: 34rpx;
		}

		.list-Openonbehalftwo {
			text-align: center;
			background: #ff5500;
			border-radius: 30rpx;
			position: absolute;
			top: -10rpx;
			left: 140rpx;
			width: 100rpx;
			height: 34rpx;
			font-size: 24rpx;
			font-family: PingFangSC-Regular, PingFang SC;
			font-weight: 400;
			color: #FFFFFF;
			line-height: 34rpx;
		}

		.list-data {}

		.list-data div:nth-child(1) {

			font-size: 28rpx;
			font-family: PingFangSC-Regular, PingFang SC;
			font-weight: 400;
			color: #222222;
			line-height: 40rpx;
		}

		.list-data div:nth-child(2) {
			font-size: 28rpx;
			font-family: PingFangSC-Regular, PingFang SC;
			font-weight: 400;

			line-height: 40rpx;
		}

		.list-Splitline {
			width: 638rpx;
			height: 2rpx;
			background: #F2F2F2;
			border-radius: 16rpx;
			margin-top: 28rpx;
		}

		.list-hospital {
			font-size: 28rpx;
			font-family: PingFangSC-Regular, PingFang SC;
			font-weight: 400;
			color: #999999;
			line-height: 40rpx;
			margin-top: 30rpx;
		}

		.list-hospital span:nth-child(1) {

			font-size: 28rpx;
			font-family: PingFangSC-Regular, PingFang SC;
			font-weight: 400;
			color: #222222;
			line-height: 40rpx;
			margin-left: 42rpx;
			margin-right: 16rpx;
		}

		.list-hospital span:nth-child(2) {
			width: 92rpx;
			height: 36rpx;
			font-size: 20rpx;
			font-family: PingFangSC-Regular, PingFang SC;
			font-weight: 400;
			color: #FF7D02;
			line-height: 28rpx;
			background-color: rgb(255, 240, 226);
		}

		.list-time {
			margin-top: 24rpx;
			font-size: 28rpx;
			font-family: PingFangSC-Regular, PingFang SC;
			font-weight: 400;
			color: #999999;
			line-height: 40rpx;
		}

		.list-time span:nth-child(1) {
			font-size: 28rpx;
			font-family: PingFangSC-Regular, PingFang SC;
			font-weight: 400;
			color: #222222;
			line-height: 40rpx;
			margin-right: 10rpx;
			margin-left: 42rpx;
		}

		.list-time span:nth-child(2) {
			font-size: 28rpx;
			font-family: PingFangSC-Regular, PingFang SC;
			font-weight: 400;
			color: #222222;
			line-height: 40rpx;
		}

		.list-money {
			margin-top: 24rpx;
			font-size: 24rpx;
			font-family: PingFangSC-Regular, PingFang SC;
			font-weight: 400;
			color: #999999;
			line-height: 34rpx;
		}

		.list-money span:nth-child(1) {
			color: rgb(58, 58, 58);
			font-family: PingFangSC-Regular, PingFang SC;
			font-size: 28rpx;
		}

		.list-money span:nth-child(2) {
			color: rgb(58, 58, 58);
			font-family: PingFangSC-Regular, PingFang SC;
			font-size: 28rpx;
		}

		.list-btn {
			margin-top: 32rpx;

			.one {
				width: 176rpx;
				height: 60rpx;
				border-radius: 30rpx;
				border: 2rpx solid #E8E8E8;
				margin-left: 94rpx;
				font-size: 24rpx;
				font-family: PingFangSC-Regular, PingFang SC;
				font-weight: 400;
				color: #333333;
				line-height: 34rpx;
			}

			.two {
				width: 176rpx;
				height: 60rpx;
				border-radius: 30rpx;
				border: 2rpx solid #E8E8E8;
				margin-left: 24rpx;
				font-size: 24rpx;
				font-family: PingFangSC-Regular, PingFang SC;
				font-weight: 400;
				color: #333333;
				line-height: 34rpx;
			}

			.sui {
				width: 176rpx;
				height: 60rpx;
				background: #21BBF3;
				border-radius: 30rpx;
				margin-left: 24rpx;

				font-size: 24rpx;
				font-family: PingFangSC-Medium, PingFang SC;
				font-weight: 500;
				color: #FFFFFF;
				line-height: 34rpx;
			}
		}


	}

	.list-mt {
		margin-top: 28rpx;
	}
</style>