<template>
	<view class="loginRecord">
		<navbar :leftClick="leftClick" :title="$t('page.loginRecord.title')"></navbar>
		
		<u-list 
		@scrolltolower="scrolltolower" 
		height="calc(100vh - 90rpx)">
			<u-cell color="#fff"
			v-for="(item, index) in loginRecord">
				<view slot="title" class="title">
					<view>
						{{ $t('page.loginRecord.login_time') }}
					</view>
					<view>
						{{ $t('page.loginRecord.login_address') }}
					</view>
				</view>
				<view slot="value" class="value">
					<view>
						{{ item.createTime }}
					</view>
					<view>
						{{ item.loginIp }}
					</view>
				</view>
			</u-cell>
		</u-list>
		
		<view v-if="!loginRecord.length" class="noFans">
			{{ $t('page.loginRecord.Norecord') }}
		</view>
	</view>
</template>

<script>
	import navbar from '@/components/base/m-navbar.vue'
	export default {
		components : { navbar },
		data() {
			return {
				loginRecord : [],
				total : 0,
				queryParams: {
					pageNo: 1,
					pageSize: 10
				},
			};
		},
		onShow(){
			this.getIpLogPage()
		},
		methods : {
			leftClick() {
				uni.navigateTo({
					url: '/pages/home/home'
				})
			},
			
			//登录记录
			getIpLogPage(){
				this.request('getIpLogPage', {}, this.queryParams)
				.then(res => {
					if (res.code == 200) {
						this.loginRecord = res.result.records
						this.total = res.result.total
					}
				})
			},
			scrolltolower(){
				this.queryParams.pageSize += 10
				this.getIpLogPage()
			},
		}
	}
</script>

<style lang="scss" scoped>
.loginRecord{
	.title,
	.value{
		color: #fff;
		&>view{
			padding: 10rpx;
		}
	}
	.noFans{
		height: 100vh;
		display: flex;
		align-items: center;
		justify-content: center;
		color: #ffffff80;
	}
}
</style>
