<template>
	<view class="page">
		<uni-nav-bar @clickLeft="goto(1, 1)" left-icon="back"  :border="false" :shadow="false" :fixed="true"
		:title="$t('address.title')" backgroundColor="#fff" :statusBar="true"></uni-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: 80rpx; float: left;">
					<image v-if="item.network == 'TRC-20'" src="/static/images/s1.png" mode="cover" style="width: 70rpx; height: 70rpx;"></image>
					<image v-if="item.network == 'BEP-20'" src="/static/images/s2.png" mode="cover" style="width: 70rpx; height: 70rpx;"></image>
				</view>
				<view>
					<view style="font-size: 32rpx; font-weight: 600; color: #333;">{{item.title}}</view>
					<view style="font-size: 24rpx; color: #999; font-weight: 400;">{{item.address}}</view>
				</view>
			</view>
			<view class="cell_right arrow"></view>
		</view>
		
		<view style="text-align: center; padding-bottom: 160rpx;" v-if="list.length == 0">
			<image src="/static/images/w5.png" mode="cover" style="width: 360rpx; height: 360rpx; margin: 160rpx auto 10rpx auto;"></image>
			<view style="color: #999; font-size: 28rpx; font-weight: 400;">{{$t('nodata')}}</view>
		</view>
		<view style="bottom: 0rpx; position: absolute; width:100vw; height: 120rpx;">
			<button type="primary" @click="onPageJump('/pages/address/add')" style="width: 90%; border-radius: 30rpx; border: 2rpx 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,
				lastPage: 1,
			};
		},
		computed: {
		},
		//第一次加载
		onLoad(e) {
			
		},
		//页面显示
		onShow() {
			this.getlist();
		},
		//方法
		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){
						res.data.data.forEach(item => {
							this.list.push(item);
						});
						this.lastPage = res.data.last_page;
					}
				});
			},
			goto(url, type) {
			    if (type == 2) {
			        return uni.switchTab({ url: url })
			    }
			    if (type == 1) {
			        return uni.navigateBack({ delta: url });
			    }
			    uni.navigateTo({
			        url: url
			    })
			},
			onPageJump(url) {
				uni.navigateTo({
					url: url
				});
			},
			handleClose(done) {
				this.dialogVisible = false;
			}
		},
		//页面隐藏
		onHide() {},
		//页面卸载
		onUnload() {},
		//页面下来刷新
		onPullDownRefresh() {},
		//页面上拉触底
		onReachBottom() {
			if(this.page<this.lastPage){
				this.page = this.page + 1;
				this.getlist();
			}
			
		},
		//用户点击分享
		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: 32rpx;
		color: #3d3d3d
	}
	.cell_right image {
		width: 140rpx;
		height: 140rpx;
		border-radius: 50%;
	}
</style>