<template>
	<view :style="'background-color: '+theme.bg+';color: '+theme.text" style="height: 100vh;">
		<z-paging :language="$i18n.locale" ref="paging" v-model="list" @query="queryList" :pageSize="20" :auto="false">
			<!-- 下拉刷新 -->
			<custom-refresher slot="refresher" slot-scope="{refresherStatus}" :status="refresherStatus">
			</custom-refresher>

			<!-- 头部 -->
			<myNav slot="top" :title="i18n.mine.address.title" :isRightext="true" :rightText="i18n.mine.address.add"
				rightextColor="#0165EE" @Jump="router.push('/pages/my/address/add')"></myNav>
			<!-- 身体 -->
			<view>
				<view class="listBox" v-for="(item,index) in list" :key="index" :style="'background-color: '+theme.fu_bg+';color: '+theme.text">
					<view class="width-500 height-80 flex direction-column align-start justify-between">
						<text class="width-450 font-30 numbold-font hidden-nowrap-ellipsis-1">{{item.address}}</text>
						<text class="width-450 font-26 medium-font hidden-nowrap-ellipsis-1">{{item.notice}}</text>
					</view>
					<view class="width-120 height-100 flex align-center justify-between">
						<image @click="del(item.id,index)" class="width-50 height-50"
							src="/static/imgs/my/delectImg@2x.png" mode=""></image>
						<image @click="router.push('/pages/my/address/add?id='+item.id)" class="width-50 height-50"
							src="/static/imgs/my/updataImg@2x.png" mode=""></image>
					</view>
				</view>
			</view>

		</z-paging>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				list: [],
				theme:'',
			}
		},
		computed: {
			i18n() {
				return this.$t('message');
			},
		},
		onShow() {
			if (uni.getStorageSync("theme") == "dark") {
				this.theme = this.$store.state.darkTheme
			}else{
				this.theme = this.$store.state.lightTheme
			}
			this.queryList()
		},
		methods: {
			del(id, index) {
				var that = this
				uni.showModal({
					title: this.i18n.mine.address.tishi,
					content: this.i18n.mine.address.content,
					cancelText: this.i18n.mine.address.cancelText,
					confirmText: this.i18n.mine.address.confirmText,
					success(res) {
						if (res.confirm) {
							uni.showLoading()
							that.post('/my/address_del', {
								id: id
							}).then(res => {
								console.log('删除提币地址', res)
								uni.hideLoading()
								if (res.code == 1) {
									that.tos(res.msg)
									that.$refs.paging.reload();
								}
							})
						}
					}
				})
			},
			queryList(pageNo, pageSize) {
					this.post('/my/address_list', {
						page: pageNo,
						page_num: pageSize
					}).then(res => {
						console.log('地址',res)
						if (res.code == 1) {
							this.$refs.paging.complete(res.data);
						}
					})
			},
		}
	}
</script>

<style lang="scss">
	.listBox {
		width: 690rpx;
		height: 140rpx;
		margin: 24rpx auto;
		// background: #FFFFFF;
		border-radius: 20rpx;
		display: flex;
		align-items: center;
		justify-content: center;
	}
</style>
