lj 4 år sedan
förälder
incheckning
cc1bf8cb7c
1 ändrade filer med 134 tillägg och 13 borttagningar
  1. 134 13
      pages/cb/sim/sim.vue

+ 134 - 13
pages/cb/sim/sim.vue

@@ -11,23 +11,23 @@
 			</view>
 			<view class="item">
 				<text>状态:</text>
-				<text>{{sim.account_status}}</text>
+				<text>{{sim.account_status|simStatus}}</text>
 			</view>
 			<view class="item">
 				<text>套餐:</text>
-				<text>{{sim.data_plan}}</text>
+				<text>{{sim.data_plan}}MB</text>
 			</view>
 			<view class="item">
 				<text>已用流量:</text>
-				<text>{{sim.data_usage}}</text>
+				<text>{{sim.data_usage}}MB</text>
 			</view>
 			<view class="item">
 				<text>剩余流量:</text>
-				<text>{{sim.data_balance}}</text>
+				<text>{{sim.data_balance}}MB</text>
 			</view>
 			<view class="item">
 				<text>到期时间:</text>
-				<text>{{sim.expiry_date}}</text>
+				<text>{{sim.expiry_date|timeFormat}}</text>
 			</view>
 		</view>
 		<template v-if="showHksimFlag">
@@ -36,6 +36,38 @@
 					<image mode="widthFix" src="/static/image/cb/sim2.png" ></image>
 					海康sim卡流量
 				</view>
+				<view class="item">
+					<text>ICCID:</text>
+					<text>{{hksim.iccid}}</text>
+				</view>
+				<view class="item">
+					<text>状态:</text>
+					<text>{{hksim.account_status|simStatus}}</text>
+				</view>
+				<view class="item">
+					<text>套餐:</text>
+					<text>{{hksim.data_plan}}MB</text>
+				</view>
+				<view class="item">
+					<text>已用流量:</text>
+					<text>{{hksim.data_usage}}MB</text>
+				</view>
+				<view class="item">
+					<text>剩余流量:</text>
+					<text>{{hksim.data_balance}}MB</text>
+				</view>
+				<view class="item">
+					<text>到期时间:</text>
+					<text>{{hksim.expiry_date|timeFormat}}</text>
+				</view>
+				<view class="item">
+					<text>更换ICCID:</text>
+					<u-input v-model="hksiminp" type="text" :custom-style="sty"  />
+				</view>
+				<view class="submit-box">
+					<u-button  @click="submit" type="warning">确定</u-button>
+				</view>
+				<u-toast ref="toast" />
 			</view>
 		</template>
 		
@@ -63,38 +95,127 @@
 					data_balance: 0, //剩余流量
 					expiry_date: 0, //到期日期
 				  },
-				 d_id:''
+				hksiminp:'',//更换ICCID
+				d_id:'',
+				sty:{
+					'background':'#F7F8FA'
+				}
 			}
 		},
 		onLoad(option){
 			this.d_id=option.d_id
-			console.log(this.d_id)
+			this.lookSIMCode('sim')
+			this.lookSIMCode('hksim')
 		},
+		 filters: {
+			simStatus(val) {
+			  switch (val) {
+				case 0:
+				  return "未知";
+				case 1:
+				  return "测试期";
+				case 2:
+				  return "沉默期";
+				case 3:
+				  return "使用中";
+				case 4:
+				  return "停机";
+				case 5:
+				  return "停机保号";
+				case 6:
+				  return "预销号";
+				case 7:
+				  return "销号";
+			  }
+			},
+		  },
 		methods: {
-			
+			async lookSIMCode(flag){
+				let res=await this.$myRequest({
+					url:'/api/api_gateway?method=forecast.send_control.device_sim',
+					data:{
+						d_id:this.d_id,
+						type:flag
+					}
+				})
+				let res2=await this.$myRequest({
+					url:'/api/api_gateway?method=forecast.send_control.sim_query',
+					data:{
+						iccid:res[0].iccid,
+					}
+				})
+				let obj=eval('('+res2.data+')').data
+				if(flag=='sim'){
+					this.sim={
+						iccid: res[0].iccid,
+						account_status: obj.account_status, //卡状态 0-7 未知 测试期 沉默期 使用中 停机 停机保号 预销号 销号
+						data_plan: obj.data_plan, //套餐大小
+						data_usage: obj.data_usage, //当月用量
+						data_balance:obj.data_balance, //剩余流量
+						expiry_date:obj.expiry_date, //到期日期
+					}
+					
+				}else if(flag=='hksim'){
+					this.hksim={
+						iccid: res[0].iccid,
+						account_status: obj.account_status, //卡状态 0-7 未知 测试期 沉默期 使用中 停机 停机保号 预销号 销号
+						data_plan: obj.data_plan, //套餐大小
+						data_usage: obj.data_usage, //当月用量
+						data_balance:obj.data_balance, //剩余流量
+						expiry_date: obj.expiry_date, //到期日期
+					}
+				}
+			},
+			async submit(){
+				let res=await this.$myRequest({
+					url:'/api/api_gateway?method=forecast.send_control.device_sim',
+					data:{
+						d_id: this.d_id,
+						 iccid: this.hksiminp,
+						 type: "change",
+					}
+				})
+				this.$refs.toast.show({
+					title: '修改成功!',
+					type: 'success',
+					callback:function(){
+						uni.navigateBack({
+							delta: 1
+						});	
+					}
+				})	
+			}
 		}
 	}
 </script>
 
 <style lang="scss">
 	page{
-		padding:20rpx;
+		padding:30rpx;
 		.section{
-			padding:20rpx;
+			padding:30rpx;
 			box-shadow: 0px 0px 5px 3px rgba(136,136,136,.1);
 			margin-bottom:20rpx;
 			.item{
-				line-height:50rpx;
-				font-size:24rpx;
+				line-height:56rpx;
+				font-size:26rpx;
+				text:nth-child(1){
+					margin-right:10rpx;
+				}
+				display:flex;
 			}
 			.tit{
-				font-size:26rpx;
+				margin-bottom:20rpx;
+				font-size:28rpx;
 				image{
 					width:22rpx;
 					margin-right:10rpx;
 				
 				}
 			}
+			.submit-box{
+				margin-top:20rpx;
+			}
 		}
 	}