sim.vue 8.6 KB

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