sim.vue 8.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330
  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="$imageURL+'/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="$imageURL+'/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" />
  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. if (option.device_type != 4) {
  122. this.lookSIMCode('hksim')
  123. }
  124. this.loding = true
  125. this.loding2 = true
  126. },
  127. methods: {
  128. async lookSIMCode(flag) {
  129. let res = await this.$myRequest({
  130. url: '/api/api_gateway?method=forecast.send_control.device_sim',
  131. data: {
  132. d_id: this.d_id,
  133. type: flag
  134. }
  135. })
  136. let res2 = await this.$myRequest({
  137. url: '/api/api_gateway?method=forecast.send_control.sim_query',
  138. data: {
  139. iccid: res[0].iccid,
  140. }
  141. })
  142. let obj = res2.data.data
  143. this.loding = false
  144. this.loding2 = false
  145. if (res2.code == 1) { //企鹏 新
  146. var state = ""
  147. switch (obj.deviceStatus) {
  148. case "TEST_READY_NAME":
  149. state = "可测试"
  150. break;
  151. case "INVENTORY_NAME":
  152. state = "库存"
  153. break;
  154. case "ACTIVATION_READY_NAME":
  155. state = "可激活"
  156. break;
  157. case "ACTIVATED_NAME":
  158. state = "已激活"
  159. break;
  160. case "DEACTIVATED_NAME":
  161. state = "已停卡"
  162. break;
  163. case "RETIRED_NAME":
  164. state = "已销卡"
  165. break;
  166. case "PURGED_NAME":
  167. state = "已清除"
  168. break;
  169. }
  170. if (flag == 'sim') {
  171. this.sim = {
  172. iccid: res[0].iccid,
  173. account_status: state,
  174. data_plan: obj.totalDataVolume, //套餐大小
  175. data_usage: obj.usedDataVolume, //当月用量
  176. data_balance: Number(obj.totalDataVolume) - Number(obj.usedDataVolume), //剩余流量
  177. expiry_date: obj.dateDeactivated, //到期日期,
  178. simnew: "新"
  179. }
  180. // this.loding = false
  181. } else if (flag == 'hksim') {
  182. this.hksim = {
  183. iccid: res[0].iccid,
  184. account_status: state,
  185. data_plan: obj.totalDataVolume, //套餐大小
  186. data_usage: obj.usedDataVolume, //当月用量
  187. data_balance: Number(obj.totalDataVolume) - Number(obj.usedDataVolume), //剩余流量
  188. expiry_date: obj.expireDate, //到期日期
  189. simnew: "新"
  190. }
  191. // this.loding2 = false
  192. }
  193. } else if (res2.code == 2) { //合宙 旧
  194. var state = ""
  195. switch (obj.account_status) {
  196. case 0:
  197. state = "未知"
  198. break;
  199. case 1:
  200. state = "测试期"
  201. break;
  202. case 2:
  203. state = "沉默期"
  204. break;
  205. case 3:
  206. state = "使用中"
  207. break;
  208. case 4:
  209. state = "停机"
  210. break;
  211. case 5:
  212. state = "停机保号"
  213. break;
  214. case 6:
  215. state = "预销号"
  216. break;
  217. case 7:
  218. state = "销号"
  219. break;
  220. }
  221. this.simnew = "旧"
  222. if (flag == 'sim') {
  223. this.sim = {
  224. iccid: res[0].iccid,
  225. account_status: state, //卡状态 0-7 未知 测试期 沉默期 使用中 停机 停机保号 预销号 销号
  226. data_plan: obj.data_plan, //套餐大小
  227. data_usage: obj.data_usage, //当月用量
  228. data_balance: obj.data_balance, //剩余流量
  229. expiry_date: obj.expiry_date, //到期日期
  230. simnew: "旧"
  231. }
  232. // this.loding = false
  233. } else if (flag == 'hksim') {
  234. this.hksim = {
  235. iccid: res[0].iccid,
  236. account_status: state, //卡状态 0-7 未知 测试期 沉默期 使用中 停机 停机保号 预销号 销号
  237. data_plan: obj.data_plan, //套餐大小
  238. data_usage: obj.data_usage, //当月用量
  239. data_balance: obj.data_balance, //剩余流量
  240. expiry_date: obj.expiry_date, //到期日期
  241. simnew: "旧"
  242. }
  243. // this.loding2 = false
  244. }
  245. }
  246. },
  247. async submit() {
  248. let res = await this.$myRequest({
  249. url: '/api/api_gateway?method=forecast.send_control.device_sim',
  250. data: {
  251. d_id: this.d_id,
  252. iccid: this.hksiminp,
  253. type: "change",
  254. }
  255. })
  256. this.$refs.toast.show({
  257. title: '修改成功!',
  258. type: 'success',
  259. callback: function() {
  260. uni.navigateBack({
  261. delta: 1
  262. });
  263. }
  264. })
  265. }
  266. }
  267. }
  268. </script>
  269. <style lang="scss">
  270. page {
  271. padding: 30rpx;
  272. box-sizing: border-box;
  273. .section {
  274. padding: 30rpx;
  275. box-shadow: 0px 0px 5px 3px rgba(136, 136, 136, .1);
  276. margin-bottom: 20rpx;
  277. box-sizing: border-box;
  278. position: relative;
  279. .sim_info_loding {
  280. position: absolute;
  281. top: 0;
  282. left: 0;
  283. width: 100%;
  284. background-color: rgba(0, 0, 0, 0.3);
  285. border-radius: 20rpx;
  286. height: 100%;
  287. display: flex;
  288. justify-content: space-around;
  289. align-items: center;
  290. .img {
  291. width: 400rpx;
  292. height: 350rpx;
  293. }
  294. }
  295. .item {
  296. line-height: 56rpx;
  297. font-size: 26rpx;
  298. text:nth-child(1) {
  299. margin-right: 10rpx;
  300. }
  301. display:flex;
  302. }
  303. .tit {
  304. margin-bottom: 20rpx;
  305. font-size: 28rpx;
  306. image {
  307. width: 22rpx;
  308. margin-right: 10rpx;
  309. }
  310. }
  311. .submit-box {
  312. margin-top: 20rpx;
  313. }
  314. }
  315. }
  316. </style>