<template>
	<view class="page">
		<pyh-nv ref="nv" :config="nvConfig"></pyh-nv>
		<view class="listBox" :style="{'padding-top':(pageTop+'px')}">
			<view class="content">
				<!-- 订单列表 -->
				<view class="order-list">
					<view class="list" v-for="(item,index) in list" @click="onOrderList" :key="index">
						<view class="title-status">
							<view class="title">
								<text>逝者编号：{{item.orderNumber}}</text>
								<image src="../../static/right1.png"></image>
							</view>
							<!-- <view class="status">
								<text>待评价</text>
							</view> -->
						</view>
						<view class="goods-list">
							<view class="goods">
								<view class="item">
									<view class="goods-name">
										<view class="goods-name-title">逝者姓名：{{item.deceasedName}}</view>
										<view>创建时间：{{item.createdTime}}</view>
									</view>
								</view>
							</view>
						</view>
						<view class="status-btn">
							<view></view>
							<view class="btn" @click="mydeathdetail(item)">
								<image src="../../static/btn.png" mode="widthFix"></image>
								<text>查看详情</text>
							</view>
						</view>
					</view>
				</view>
			</view>
		</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				OrderType: 0,
				nvConfig: {
					title: "报丧记录",
					bgColor: "#ffffff",
					color: "#000000",
					fixedAssist: {
						hide: true,
					},
				},
				info:{
					pageNum:1,
					pageSize:10,
					userId:"",
					filingStatus:"0"
				},
				list:[],
				total:0,
			};
		},
		onPageScroll(e) {
			this.$refs.nv.pageScroll(e)
		},
		computed: {
			pageTop() {
				return parseInt(88 * uni.getSystemInfoSync().windowWidth / 750) + uni.getSystemInfoSync().statusBarHeight
			}
		},
		onLoad(params) {
			this.OrderType = params.type;
			this.getinfo();
		},
		methods: {
			mydeathdetail(item) {
				var info = JSON.stringify(item)
				uni.navigateTo({
					url: '/pages/mydeathdetail/mydeathdetail?info=' + info
				})
			},
			getinfo(){
				if(uni.getStorageSync('userjs') == '调度员'){
					this.info.userId = ''
				}else{
					this.info.userId = uni.getStorageSync("USERS_KEY").userId
				}
				console.log("user",uni.getStorageSync("USERS_KEY"));
				this.API.getwsyy(this.info).then(res=>{
					console.log("获取网上报丧信息",res);
					this.total = res.total
					for(let i = 0;i < res.rows.length;i++){
						this.list.push(res.rows[i])
					}
				})
			},
		},
		onReachBottom() {
			var page = parseInt(this.total / 10 );
			var s = parseInt(this.total % 10 );
			console.log(page,s);
			if(s > 0){
				page = page + 1
			}
			if(page > 0){
				if(this.info.pageNum < page){
					this.info.pageNum = this.info.pageNum + 1
					this.getinfo();
				}else{
					console.log("没有了");
				}
			}
		},
	}
</script>

<style scoped lang="scss">
	@import 'mydeath.scss';
</style>
