sim.vue 5.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225
  1. <template>
  2. <view>
  3. <view class="section">
  4. <view class="tit">
  5. <image mode="widthFix" src="http://static.yfpyx.com/bigdata_app/image/cb/sim1.png" ></image>
  6. sim卡流量
  7. </view>
  8. <view class="item">
  9. <text>ICCID:</text>
  10. <text>{{sim.iccid}}</text>
  11. </view>
  12. <view class="item">
  13. <text>状态:</text>
  14. <text>{{sim.account_status|simStatus}}</text>
  15. </view>
  16. <view class="item">
  17. <text>套餐:</text>
  18. <text>{{sim.data_plan}}MB</text>
  19. </view>
  20. <view class="item">
  21. <text>已用流量:</text>
  22. <text>{{sim.data_usage}}MB</text>
  23. </view>
  24. <view class="item">
  25. <text>剩余流量:</text>
  26. <text>{{sim.data_balance}}MB</text>
  27. </view>
  28. <view class="item">
  29. <text>到期时间:</text>
  30. <text>{{sim.expiry_date|timeFormat}}</text>
  31. </view>
  32. </view>
  33. <template v-if="showHksimFlag">
  34. <view class="section">
  35. <view class="tit">
  36. <image mode="widthFix" src="http://static.yfpyx.com/bigdata_app/image/cb/sim2.png" ></image>
  37. 海康sim卡流量
  38. </view>
  39. <view class="item">
  40. <text>ICCID:</text>
  41. <text>{{hksim.iccid}}</text>
  42. </view>
  43. <view class="item">
  44. <text>状态:</text>
  45. <text>{{hksim.account_status|simStatus}}</text>
  46. </view>
  47. <view class="item">
  48. <text>套餐:</text>
  49. <text>{{hksim.data_plan}}MB</text>
  50. </view>
  51. <view class="item">
  52. <text>已用流量:</text>
  53. <text>{{hksim.data_usage}}MB</text>
  54. </view>
  55. <view class="item">
  56. <text>剩余流量:</text>
  57. <text>{{hksim.data_balance}}MB</text>
  58. </view>
  59. <view class="item">
  60. <text>到期时间:</text>
  61. <text>{{hksim.expiry_date|timeFormat}}</text>
  62. </view>
  63. <view class="item">
  64. <text>更换ICCID:</text>
  65. <u-input v-model="hksiminp" type="text" :custom-style="sty" />
  66. </view>
  67. <view class="submit-box">
  68. <u-button @click="submit" type="warning">确定</u-button>
  69. </view>
  70. <u-toast ref="toast" />
  71. </view>
  72. </template>
  73. </view>
  74. </template>
  75. <script>
  76. export default {
  77. data() {
  78. return {
  79. sim: {
  80. iccid: "",
  81. account_status: 0, //卡状态 0-7 未知 测试期 沉默期 使用中 停机 停机保号 预销号 销号
  82. data_plan: 0, //套餐大小
  83. data_usage: 0, //当月用量
  84. data_balance: 0, //剩余流量
  85. expiry_date: 0, //到期日期
  86. },
  87. showHksimFlag: true, //是否显示hksim卡标识
  88. hksim: {
  89. iccid: "",
  90. account_status: 0, //卡状态 0-7 未知 测试期 沉默期 使用中 停机 停机保号 预销号 销号
  91. data_plan: 0, //套餐大小
  92. data_usage: 0, //当月用量
  93. data_balance: 0, //剩余流量
  94. expiry_date: 0, //到期日期
  95. },
  96. hksiminp:'',//更换ICCID
  97. d_id:'',
  98. sty:{
  99. 'background':'#F7F8FA'
  100. }
  101. }
  102. },
  103. onLoad(option){
  104. this.d_id=option.d_id
  105. this.lookSIMCode('sim')
  106. this.lookSIMCode('hksim')
  107. },
  108. filters: {
  109. simStatus(val) {
  110. switch (val) {
  111. case 0:
  112. return "未知";
  113. case 1:
  114. return "测试期";
  115. case 2:
  116. return "沉默期";
  117. case 3:
  118. return "使用中";
  119. case 4:
  120. return "停机";
  121. case 5:
  122. return "停机保号";
  123. case 6:
  124. return "预销号";
  125. case 7:
  126. return "销号";
  127. }
  128. },
  129. },
  130. methods: {
  131. async lookSIMCode(flag){
  132. let res=await this.$myRequest({
  133. url:'/api/api_gateway?method=forecast.send_control.device_sim',
  134. data:{
  135. d_id:this.d_id,
  136. type:flag
  137. }
  138. })
  139. let res2=await this.$myRequest({
  140. url:'/api/api_gateway?method=forecast.send_control.sim_query',
  141. data:{
  142. iccid:res[0].iccid,
  143. }
  144. })
  145. let obj=eval('('+res2.data+')').data
  146. if(flag=='sim'){
  147. this.sim={
  148. iccid: res[0].iccid,
  149. account_status: obj.account_status, //卡状态 0-7 未知 测试期 沉默期 使用中 停机 停机保号 预销号 销号
  150. data_plan: obj.data_plan, //套餐大小
  151. data_usage: obj.data_usage, //当月用量
  152. data_balance:obj.data_balance, //剩余流量
  153. expiry_date:obj.expiry_date, //到期日期
  154. }
  155. }else if(flag=='hksim'){
  156. this.hksim={
  157. iccid: res[0].iccid,
  158. account_status: obj.account_status, //卡状态 0-7 未知 测试期 沉默期 使用中 停机 停机保号 预销号 销号
  159. data_plan: obj.data_plan, //套餐大小
  160. data_usage: obj.data_usage, //当月用量
  161. data_balance:obj.data_balance, //剩余流量
  162. expiry_date: obj.expiry_date, //到期日期
  163. }
  164. }
  165. },
  166. async submit(){
  167. let res=await this.$myRequest({
  168. url:'/api/api_gateway?method=forecast.send_control.device_sim',
  169. data:{
  170. d_id: this.d_id,
  171. iccid: this.hksiminp,
  172. type: "change",
  173. }
  174. })
  175. this.$refs.toast.show({
  176. title: '修改成功!',
  177. type: 'success',
  178. callback:function(){
  179. uni.navigateBack({
  180. delta: 1
  181. });
  182. }
  183. })
  184. }
  185. }
  186. }
  187. </script>
  188. <style lang="scss">
  189. page{
  190. padding:30rpx;
  191. box-sizing: border-box;
  192. .section{
  193. padding:30rpx;
  194. box-shadow: 0px 0px 5px 3px rgba(136,136,136,.1);
  195. margin-bottom:20rpx;
  196. box-sizing: border-box;
  197. .item{
  198. line-height:56rpx;
  199. font-size:26rpx;
  200. text:nth-child(1){
  201. margin-right:10rpx;
  202. }
  203. display:flex;
  204. }
  205. .tit{
  206. margin-bottom:20rpx;
  207. font-size:28rpx;
  208. image{
  209. width:22rpx;
  210. margin-right:10rpx;
  211. }
  212. }
  213. .submit-box{
  214. margin-top:20rpx;
  215. }
  216. }
  217. }
  218. </style>