sim.vue 8.6 KB

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