sim.vue 8.7 KB

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