<template>
	<view>
		<view style="position: fixed;z-index: 100;width: 100%;">
			<uni-nav-bar @clickLeft="clickLeft" left-icon="back" left-text="返回" title="sim卡详情"></uni-nav-bar>
		</view>
		<view class="sim_info">
			<view class="sim_info_title">
				<image src="../../static/image/cb/sim1.png" mode=""></image>
				<p>sim卡查询</p>
			</view>
			<view class="sim_info_text">
				<p>ICCID：{{iccid}}</p>
				<p>状态：{{state[siminfo.data.account_status]}}</p>
				<p>套餐：{{siminfo.data.data_plan}}MB</p>
				<p>已用流量：{{siminfo.data.data_usage}}MB</p>
				<p>剩余流量：{{siminfo.data.data_balance}}MB</p>
				<p>到期时间：{{siminfo.data.outbound_date|timeFormat()}}</p>
			</view>
		</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				iccid:'',
				siminfo:[],
				state:['未知', '测试期' ,'沉默期' ,'使用中' ,'停机', '停机保号' ,'预销号' ,'销号'],
				id:''
			}
		},
		methods: {
			async simid(data) { //设备列表
				const res = await this.$myRequest({
					url: '/api/api_gateway?method=forecast.send_control.device_sim',
					data: {
						 d_id:data,
						 type:'sim'
					}
				})
				this.iccid = res[0].iccid
				this.simdata(this.iccid)
			},
			async simdata(data) { //设备列表
				const res = await this.$myRequest({
					url: '/api/api_gateway?method=forecast.send_control.sim_query',
					data: {
						iccid:data
					}
				})
				this.siminfo = JSON.parse(res.data)
				console.log(this.siminfo.data)
			},
			clickLeft(){
				uni.navigateBack({
					delta:1
				})
			}
		},
		onLoad(option){
			this.id = option.id
			this.simid(this.id)
		}
	}
</script>

<style lang="scss">
	.sim_info{
		width: 90%;
		position: absolute;
		top:54px;
		left: 5%;
		box-shadow: 0 0 10rpx #bcb9ca;
		padding: 30rpx 20rpx 50rpx;
		border-radius: 20rpx;
		box-sizing: border-box;
		.sim_info_title{
			width: 100%;
			display: flex;
			image{
				width: 24rpx;
				height: 32rpx;
				margin: 6rpx 20rpx 0 0;
			}
			p{
				font-weight: 700;
			}
		}
		.sim_info_text{
			width: 100%;
			padding-left: 44rpx;
			p{
				height: 30rpx;
				margin-top: 20rpx;
				font-size: 26rpx;
			}
		}
	}
</style>
