<template>
	<view class="page">
		<nav-bar :title="$t('address.title')" bgColor="#fff"></nav-bar>
		<view class="cell_list" v-if="list.length > 0" v-for="item in list" :key="item.id" @click="onPageJump('/pages/address/add?id='+item.id)">
			<view class="cell_left txt">
				<view style="width: 40px; float: left;">
					<image v-if="item.network == 'TRC-20'" src="/static/images/s1.png" mode="cover" style="width: 35px; height: 35px;"></image>
					<image v-if="item.network == 'BEP-20'" src="/static/images/s2.png" mode="cover" style="width: 35px; height: 35px;"></image>
				</view>
				<view>
					<view style="font-size: 16px; font-weight: 600; color: #333;">{{item.title}}</view>
					<view style="font-size: 12px; color: #999; font-weight: 400;">{{item.address}}</view>
				</view>
			</view>
			<view class="cell_right arrow"></view>
		</view>
		
		<view style="text-align: center; padding-bottom: 80px;" v-if="list.length == 0">
			<image src="/static/images/w5.png" mode="cover" style="width: 180px; height: 180px; margin: 80px auto 5px auto;"></image>
			<view style="color: #999; font-size: 14px; font-weight: 400;">{{$t('nodata')}}</view>
		</view>
		<view style="bottom: 0px; position: absolute; width:100vw; height: 60px;">
			<button type="primary" @click="onPageJump('/pages/address/add')" style="width: 90%; border-radius: 15px; border: 1px solid #fff; margin: auto; ">{{$t('address.text1')}}</button>
		</view>
	</view>
</template>

<script>
	import {
		mapState,
		mapMutations
	} from 'vuex';
	export default {
		data() {
			return {
				list:[],
				page: 1,
				limit: 10
			};
		},
		computed: {
		},
		//第一次加载
		onLoad(e) {
			this.getlist();
		},
		//页面显示
		onShow() {},
		//方法
		methods: {
			...mapMutations(['setUserInfo']),
			getlist(){
				let data = {
					page: this.page,
					limit: this.limit,
					lang: this.$i18n.locale
				}
				this.$http.post('/api/address/list', data).then(res => {
					if(res.code == 0){
						this.list = res.data.data;
					}
				});
			},
			onPageJump(url) {
				uni.navigateTo({
					url: url
				});
			},
			onTokenJump(url) {
				this.judgeLogin(() => {
					uni.navigateTo({
						url: url
					});
				});
			},
			handleClose(done) {
				this.dialogVisible = false;
			}
		},
		//页面隐藏
		onHide() {},
		//页面卸载
		onUnload() {},
		//页面下来刷新
		onPullDownRefresh() {},
		//页面上拉触底
		onReachBottom() {
			this.page = this.page + 1;
			let data = {
				page: this.page,
				limit: this.limit,
				lang: this.$i18n.locale
			}
			this.$http.post('/api/address/list', data).then(res => {
				if(res.code == 0){
					res.data.data.forEach(item => {
						this.list.push(item);
					});
				}
			}).catch(err => {
				this.page = this.page - 1;
			});
		},
		//用户点击分享
		onShareAppMessage(e) {
			return this.wxShare();
		}
	};
</script>
<style lang="scss" scoped>
	@import '@/style/mixin.scss';
	body{background-color: #F8F8F8;}
	.page{min-height: 100vh;position: relative; background-color: #F8F8F8;}
	.cell_list {
		padding: 30rpx;
		margin: 20rpx 30rpx;
		
	}
	.txt{
		font-weight: 500;
		font-size: 16px;
		color: #3d3d3d
	}
	.cell_right image {
		width: 140rpx;
		height: 140rpx;
		border-radius: 50%;
	}
</style>