<template>
	<view>
		<view class="cell" :key="index" v-for="(item, index) in dataList">
			<view class="cell-top">
				<view class="title"> {{`订单号：${item.orderNo}`}}</view>
				<view class="time"> {{item.createTime}}</view>
			</view>
			<view cell-desc>
				<view class="cell-desc-item">
					{{`${orderType[item.scene]}:+ ${item.money}元`}}
				</view>
				<view class="cell-desc-item">
					门店名称:{{item.merchantName }}
				</view>
				<view class="cell-desc-item">
					下单方式:{{ orderSource[item.orderSource] }}<text v-if="item.orderSource == 20 || item.orderSource == 30 "> {{item.isRenew?'续费':'首期'}}</text>
				</view>
				<view class="cell-desc-item">
					设备编号:{{item.equipmentCode }}
				</view>
				
			</view>
		</view>
		<empty v-if="dataList.length == 0"></empty>
		<!-- <uni-list>
			<uni-list-item  :title=""
				:note="`${orderType[item.scene]}:+ ${item.money}元`" :rightText="item.createTime">
			</uni-list-item>
		</uni-list> -->
	</view>
</template>

<script>
	import * as LogApi from '@/api/shop/profitLog.js'
	import {
		mapGetters
	} from 'vuex'
	import storage from '../../../utils/storage';
	 import Empty from '@/components/empty'
	export default {
		components: {Empty},
		data() {
			return {
				dataList: [],
				hasMore: true,
				page: 1,
				limit: 20,
				where: {},
				orderType: {
					1: "投资收益",
					3: "推广收益",
					4: "门店收益",
					5: "区域经理收益",
				},
				orderSource: {
					10: "销售",
					20: "分期",
					30: "以租代购",
					40: "租赁",
				}
			};
		},
		computed: {
			...mapGetters(['userId'])
		},
		onLoad() {
			this.queryList()
		},
		methods: {
			queryList() {
				LogApi.list({
					page: this.page,
					limit: this.limit,
					userId: storage.get("userId")
				}).then(res => {
					if (res.code == 0) {
						
						res.data.list.forEach(item => {
							item.createTime = item.createTime.replace(/-/gi, '/')
							item.createTime = this.$u.timeFormat(item.createTime, 'yyyy-mm-dd hh:MM');
						})
						this.dataList.push(...res.data.list)
						
						this.hasMore = this.dataList.length < res.data.count

					}
				}).finally(() => {
					uni.stopPullDownRefresh()
				})
			},
			scrolltolower(e) {
				console.log(e);
			}
		},
		onPullDownRefresh() {
			this.page == 1;
			this.dataList = [];
			this.queryList();
			this.hasMore = true
		},
		onReachBottom() {
			if (this.hasMore) {
				this.page++
				this.queryList();
			}
		}
	}
</script>

<style lang="scss">
	.cell{
		padding: 27rpx 30rpx;
		&-top {
			display: flex;
			justify-content: space-between;
			align-items: center;
		}
		border-bottom: solid #e8e8e8 1px;
	}
	.title{
		font-size: 28rpx;
	}
	
	.time {
		font-size: 24rpx;
		color: #999;
	}
</style>