sim.vue 8.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324
  1. <template>
  2. <view>
  3. <view class="section">
  4. <view class="sim_info_loding" v-if="loding">
  5. <image src="../../../static/images/cb/6286299.gif" mode="" class="img"></image>
  6. </view>
  7. <view class="tit">
  8. <image mode="widthFix" src="http://www.hnyfwlw.com:8006/bigdata_app/image/cb/sim1.png"></image>
  9. 数据sim卡流量{{"("+sim.simnew+")"}}
  10. </view>
  11. <view class="item">
  12. <text>ICCID:</text>
  13. <text>{{sim.iccid}}</text>
  14. </view>
  15. <view class="item">
  16. <text>状态:</text>
  17. <text>{{sim.account_status}}</text>
  18. </view>
  19. <view class="item">
  20. <text>套餐:</text>
  21. <text>{{sim.data_plan}}MB</text>
  22. </view>
  23. <view class="item">
  24. <text>已用流量:</text>
  25. <text>{{sim.data_usage.toFixed(2)}}MB</text>
  26. </view>
  27. <view class="item">
  28. <text>剩余流量:</text>
  29. <text>{{sim.data_balance.toFixed(2)}}MB</text>
  30. </view>
  31. <view class="item">
  32. <text>到期时间:</text>
  33. <text v-if="sim.simnew=='新'">{{sim.expiry_date|timeFormat}}</text>
  34. <text v-else>{{sim.expiry_date|timeFormat}}</text>
  35. </view>
  36. </view>
  37. <template v-if="showHksimFlag">
  38. <view class="section">
  39. <view class="sim_info_loding" v-if="loding2">
  40. <image src="../../../static/images/cb/6286299.gif" mode="" class="img"></image>
  41. </view>
  42. <view class="tit">
  43. <image mode="widthFix" src="http://www.hnyfwlw.com:8006/bigdata_app/image/cb/sim2.png"></image>
  44. 图片sim卡流量{{"("+hksim.simnew+")"}}
  45. </view>
  46. <view class="item">
  47. <text>ICCID:</text>
  48. <text>{{hksim.iccid}}</text>
  49. </view>
  50. <view class="item">
  51. <text>状态:</text>
  52. <text>{{hksim.account_status}}</text>
  53. </view>
  54. <view class="item">
  55. <text>套餐:</text>
  56. <text>{{hksim.data_plan}}MB</text>
  57. </view>
  58. <view class="item">
  59. <text>已用流量:</text>
  60. <text>{{hksim.data_usage}}MB</text>
  61. </view>
  62. <view class="item">
  63. <text>剩余流量:</text>
  64. <text>{{hksim.data_balance}}MB</text>
  65. </view>
  66. <view class="item">
  67. <text>到期时间:</text>
  68. <text v-if="hksim.simnew=='新'">{{hksim.expiry_date}}</text>
  69. <text v-else>{{hksim.expiry_date|timeFormat}}</text>
  70. </view>
  71. <view class="item">
  72. <text>更换ICCID:</text>
  73. <u-input v-model="hksiminp" type="text" :custom-style="sty" style="z-index: 1;"/>
  74. </view>
  75. <view class="submit-box">
  76. <u-button @click="submit" type="warning">确定</u-button>
  77. </view>
  78. <u-toast ref="toast" />
  79. </view>
  80. </template>
  81. </view>
  82. </template>
  83. <script>
  84. export default {
  85. data() {
  86. return {
  87. sim: {
  88. iccid: "",
  89. account_status: 0, //卡状态 0-7 未知 测试期 沉默期 使用中 停机 停机保号 预销号 销号
  90. data_plan: 0, //套餐大小
  91. data_usage: 0, //当月用量
  92. data_balance: 0, //剩余流量
  93. expiry_date: 0, //到期日期,
  94. simnew:""
  95. },
  96. showHksimFlag: true, //是否显示hksim卡标识
  97. hksim: {
  98. iccid: "",
  99. account_status: 0, //卡状态 0-7 未知 测试期 沉默期 使用中 停机 停机保号 预销号 销号
  100. data_plan: 0, //套餐大小
  101. data_usage: 0, //当月用量
  102. data_balance: 0, //剩余流量
  103. expiry_date: 0, //到期日期
  104. simnew:""
  105. },
  106. hksiminp: '', //更换ICCID
  107. d_id: '',
  108. sty: {
  109. 'background': '#F7F8FA'
  110. },
  111. loding:false,
  112. loding2:false
  113. }
  114. },
  115. onLoad(option) {
  116. if (Number(option.device_type) == 4) {
  117. this.showHksimFlag = false
  118. }
  119. this.d_id = option.d_id
  120. this.lookSIMCode('sim')
  121. this.lookSIMCode('hksim')
  122. this.loding = true
  123. this.loding2 = true
  124. },
  125. methods: {
  126. async lookSIMCode(flag) {
  127. let res = await this.$myRequest({
  128. url: '/api/api_gateway?method=forecast.send_control.device_sim',
  129. data: {
  130. d_id: this.d_id,
  131. type: flag
  132. }
  133. })
  134. let res2 = await this.$myRequest({
  135. url: '/api/api_gateway?method=forecast.send_control.sim_query',
  136. data: {
  137. iccid: res[0].iccid,
  138. }
  139. })
  140. let obj = res2.data.data
  141. if (res2.code == 1) { //企鹏 新
  142. var state = ""
  143. switch (obj.deviceStatus) {
  144. case "ACTIVATION_READY_NAME":
  145. state = "可测试"
  146. break;
  147. case "TEST_READY_NAME":
  148. state = "库存"
  149. break;
  150. case "INVENTORY_NAME":
  151. state = "可激活"
  152. break;
  153. case "ACTIVATION_READY_NAME":
  154. state = "已激活"
  155. break;
  156. case "ACTIVATED_NAME":
  157. state = "已停卡"
  158. break;
  159. case "DEACTIVATED_NAME":
  160. state = "已销卡"
  161. break;
  162. case "RETIRED_NAME":
  163. state = "已清除"
  164. break;
  165. }
  166. console.log(obj)
  167. if (flag == 'sim') {
  168. this.sim = {
  169. iccid: res[0].iccid,
  170. account_status: state,
  171. data_plan: obj.totalDataVolume, //套餐大小
  172. data_usage: obj.usedDataVolume, //当月用量
  173. data_balance: Number(obj.totalDataVolume) - Number(obj.usedDataVolume), //剩余流量
  174. expiry_date: obj.ratePlanExpirationDate, //到期日期,
  175. simnew:"新"
  176. }
  177. this.loding = false
  178. } else if (flag == 'hksim') {
  179. this.hksim = {
  180. iccid: res[0].iccid,
  181. account_status: state,
  182. data_plan: obj.totalDataVolume, //套餐大小
  183. data_usage: obj.usedDataVolume, //当月用量
  184. data_balance: Number(obj.totalDataVolume) - Number(obj.usedDataVolume), //剩余流量
  185. expiry_date: obj.ratePlanExpirationDate, //到期日期
  186. simnew:"新"
  187. }
  188. this.loding2 = false
  189. }
  190. } else if (res2.code == 2) { //合宙 旧
  191. var state = ""
  192. switch (obj.account_status) {
  193. case 0:
  194. state = "未知"
  195. break;
  196. case 1:
  197. state = "测试期"
  198. break;
  199. case 2:
  200. state = "沉默期"
  201. break;
  202. case 3:
  203. state = "使用中"
  204. break;
  205. case 4:
  206. state = "停机"
  207. break;
  208. case 5:
  209. state = "停机保号"
  210. break;
  211. case 6:
  212. state = "预销号"
  213. break;
  214. case 7:
  215. state = "销号"
  216. break;
  217. }
  218. this.simnew = "旧"
  219. if (flag == 'sim') {
  220. this.sim = {
  221. iccid: res[0].iccid,
  222. account_status: state, //卡状态 0-7 未知 测试期 沉默期 使用中 停机 停机保号 预销号 销号
  223. data_plan: obj.data_plan, //套餐大小
  224. data_usage: obj.data_usage, //当月用量
  225. data_balance: obj.data_balance, //剩余流量
  226. expiry_date: obj.expiry_date, //到期日期
  227. simnew:"旧"
  228. }
  229. this.loding = false
  230. } else if (flag == 'hksim') {
  231. this.hksim = {
  232. iccid: res[0].iccid,
  233. account_status: state, //卡状态 0-7 未知 测试期 沉默期 使用中 停机 停机保号 预销号 销号
  234. data_plan: obj.data_plan, //套餐大小
  235. data_usage: obj.data_usage, //当月用量
  236. data_balance: obj.data_balance, //剩余流量
  237. expiry_date: obj.expiry_date, //到期日期
  238. simnew:"旧"
  239. }
  240. this.loding2 = false
  241. }
  242. }
  243. },
  244. async submit() {
  245. let res = await this.$myRequest({
  246. url: '/api/api_gateway?method=forecast.send_control.device_sim',
  247. data: {
  248. d_id: this.d_id,
  249. iccid: this.hksiminp,
  250. type: "change",
  251. }
  252. })
  253. this.$refs.toast.show({
  254. title: '修改成功!',
  255. type: 'success',
  256. callback: function() {
  257. uni.navigateBack({
  258. delta: 1
  259. });
  260. }
  261. })
  262. }
  263. }
  264. }
  265. </script>
  266. <style lang="scss">
  267. page {
  268. padding: 30rpx;
  269. box-sizing: border-box;
  270. .section {
  271. padding: 30rpx;
  272. box-shadow: 0px 0px 5px 3px rgba(136, 136, 136, .1);
  273. margin-bottom: 20rpx;
  274. box-sizing: border-box;
  275. position: relative;
  276. .sim_info_loding{
  277. position: absolute;
  278. top: 0;
  279. left: 0;
  280. width: 100%;
  281. background-color: rgba(0,0,0,0.3);
  282. border-radius: 20rpx;
  283. height: 100%;
  284. display: flex;
  285. justify-content: space-around;
  286. align-items: center;
  287. z-index: 10;
  288. .img{
  289. width: 400rpx;
  290. height: 350rpx;
  291. }
  292. }
  293. .item {
  294. line-height: 56rpx;
  295. font-size: 26rpx;
  296. text:nth-child(1) {
  297. margin-right: 10rpx;
  298. }
  299. display:flex;
  300. }
  301. .tit {
  302. margin-bottom: 20rpx;
  303. font-size: 28rpx;
  304. image {
  305. width: 22rpx;
  306. margin-right: 10rpx;
  307. }
  308. }
  309. .submit-box {
  310. margin-top: 20rpx;
  311. }
  312. }
  313. }
  314. </style>