<template>
	<view class="content">
		<view class="list" v-if="yearArr.length > 0">
			<view class="listItem" v-for="(item, index) in yearArr" :key="index">
				<view class="listItem-no">
					订单号：{{item.order_no}}
				</view>
				<view class="listItem-cont">
					<view class="listItem-cont-label">
						<view class="listItem-cont-name">
							订单类型
						</view>
						<view class="listItem-cont-text listItem-cont-status">
							{{item.synthesis.title}}
						</view>
					</view>
					<view class="listItem-cont-label">
						<view class="listItem-cont-name">
							业务联系人
						</view>
						<view class="listItem-cont-text listItem-cont-price">
							{{item.user.parent.nickname}}
						</view>
					</view>
					<view class="listItem-cont-label" v-if="item.lawyer">
						<view class="listItem-cont-name">
							所属律师
						</view>
						<view class="listItem-cont-text listItem-cont-price">
							{{item.lawyer.name}}
						</view>
					</view>
					<!-- <view class="listItem-cont-label" v-if="item.lawyer">
						<view class="listItem-cont-name">
							律师电话
						</view>
						<view class="listItem-cont-text listItem-cont-price">
							{{item.lawyer.username}}
						</view>
					</view> -->
				</view>
				<view class="listItem-labor">
					<view class="listItem-labor-time">
						{{item.created_at}}
					</view>
					<view class="listItem-labor-btn">
						<view @click="$Router.push({name: 'Pay', params: {orderId: item.order_id, orderType: item.order_type}})" class="listItem-labor-go yellow" v-if="item.can.pay">
							去支付
						</view>
						
						<view @click="$Router.push({name: 'FeeConfirm', params: {synthesisId: item.synthesis_order_id}})" class="listItem-labor-go yellow" v-if="item.can.look">
							查看详情
						</view>
					</view>
				</view>
			</view>
		</view>
		
		<view class="pack-center pages-hint" v-else>
		    <image src="https://douhuo-storage.oss-cn-beijing.aliyuncs.com/images/2023/06/06/7ad417d0c215db601b8e1bead05c3a5e.png"></image>
		    <view>暂无订单</view>
		</view>
	</view>
</template>

<script>
	import { seekOrder } from '@/apis/interfaces/synthesis'
	export default {
		data() {
			return {
				yearStatus 	 : 0,	   // 0 未付款 1 2
				yearArr	 	 : [],     // 咨询单列表
				page         : {},     // 分页信息
				lodingStats  : false,  // 加载状态
			}
		},
		
		created() {
			// 获取-咨询单-列表
			this.yearServe();
		},
		
		methods: {
			// 咨询单-列表
			// status	: this.yearStatus,
			yearServe(page){
				seekOrder({
					page	: page || 1
				}).then(res => {
					let esArr = res.data
					let list = this.yearArr,
					    newData = []
					    if(page == 1 || page == undefined) list = []
					    newData = list.concat(esArr)
					this.yearArr     = newData
					this.page        = res.page
					this.lodingStats = false
					uni.stopPullDownRefresh()
				}).catch(err => {
					uni.showToast({
						title: err.message,
						icon : 'none'
					})
				})
			},
			
			// 状态选择
			stateClick(state) {
				this.yearStatus = state
				
				// 获取-咨询单列表
				this.yearServe();
			},
			
			// 订单支付
			canClick(e) {
				// pay_status == 1可支付
				if(e.can.pay_status == 1) {
					// pay_way为1的时线上支付, 为2时线下支付
					if(e.service.pay_way == 1) {
						this.$Router.push({name: 'FeePay', params: {orderId: e.service_order_id}})
					}
				}
			},
			
			// 选择支付方式
			expressSheet(item) {
				uni.showActionSheet({
				    itemList: ['微信支付', '打款凭证'],
				    success: sheetRes => {
						console.log(sheetRes)
				    },
				    fail: sheetFail => {}
				})
			},
			
			// 页面相关事件处理函数--监听用户下拉动作
			onPullDownRefresh() {
			    // 获取-咨询单-列表
			    this.yearServe();
			},
			        
			// 上拉加载
			onReachBottom(){
			    this.lodingStats = true
			    let pageNumber = this.page.current
			    if(this.page.has_more){
			        pageNumber++
			        // 获取-咨询单-列表
			        this.yearServe(pageNumber);
			    }
			}
		}
	}
</script>

<style lang="scss" scoped>
	.content {
		background-color: #f7f9fa;
		overflow-y: scroll;
		height: 100%;
		position: absolute;
		width: 100%;
	}
	
	.list {
		padding: 30rpx;
		box-sizing: border-box;
		.listItem {
			background-color: #ffffff;
			border-radius: 10rpx;
			margin-bottom: 30rpx;
			.listItem-no {
				line-height: 90rpx;
				padding: 0 30rpx;
				box-sizing: border-box;
				border-bottom: 2rpx solid #eeeeee;
			}
			.listItem-cont {
				padding: 15rpx 30rpx;
				box-sizing: border-box;
				.listItem-cont-label {
					display: flex;
					line-height: 60rpx;
					color: #666666;
					font-size: 28rpx;
					.listItem-cont-name {
						flex: 1;
					}
					.listItem-cont-text {
						color: #000000;
						&.listItem-cont-status {
							color: #da2b56;
						}
						&.listItem-cont-price {
							font-weight: 600;
						}
					}
				}
			}
			.listItem-labor {
				border-top: 2rpx solid #eeeeee;
				line-height: 50rpx;
				padding: 25rpx 30rpx;
				box-sizing: border-box;
				font-size: 26rpx;
				display: flex;
				.listItem-labor-time {
					flex: 1;
					color: #999999;
				}
				.listItem-labor-go {
					display: inline-block;
					border: 2rpx solid #da2b56;
					color: #da2b56;
					border-radius: 80rpx;
					padding: 0 20rpx;
					&.active {
						border-color: #999999;
						color: #666666;
					}
					&.yellow {
						border-color: #ec7647;
						color: #ec7647;
					}
				}
			}
		}
	}
</style>