sim.vue 8.1 KB

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