upgrade.html 7.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187
  1. <!DOCTYPE html>
  2. <html lang="en">
  3. <head>
  4. <meta charset="UTF-8">
  5. <meta name="viewport" content="width=device-width, initial-scale=1.0">
  6. <title>设备调试</title>
  7. <style>
  8. #main {
  9. display: flex;
  10. justify-content: center;
  11. align-items: center;
  12. height: 15rem;
  13. padding: 0 .5rem;
  14. }
  15. .inputstyle {
  16. width: 8rem;
  17. height: .8rem;
  18. border-radius: .8rem;
  19. outline: none;
  20. border: 1px solid #efefef;
  21. padding: 0 .3rem;
  22. }
  23. .container {
  24. display: flex;
  25. justify-content: center;
  26. align-items: center;
  27. flex-direction: column;
  28. }
  29. .btnstyle {
  30. width: 3rem;
  31. height: 1rem;
  32. outline: none;
  33. border: solid rgb(118, 206, 169);
  34. background-color: rgb(118, 206, 169);
  35. color: #fff;
  36. border-radius: .8rem;
  37. margin-top: .3rem;
  38. }
  39. </style>
  40. </head>
  41. <body>
  42. <div id="main">
  43. <div class="container" v-if="isInstall">
  44. <div v-for="(item,index) in list" style="font-size: .5rem;margin-top: .3rem;" @click="tapvalue(item)">
  45. {{item}}
  46. </div>
  47. <input class="inputstyle" type="text" v-model="value" placeholder="请输入你需要升级的设备IMEI号码">
  48. <button class="btnstyle" @click="installbtn">点击设置</button>
  49. </div>
  50. <div class="container" style="align-items: flex-start;" v-else>
  51. <div style="font-size: .5rem;">
  52. 设备IMEI号:{{equipment}}
  53. </div>
  54. <div style="font-size: .5rem;margin-top: .4rem;display: flex;align-items: center;">
  55. 设备状态:{{isxian}}
  56. </div>
  57. <div style="font-size: .5rem;margin-top: .4rem;display: flex;align-items: center;">
  58. 设备版本号:{{versionNum}}
  59. </div>
  60. <div style="margin-top: .4rem;width: 100%;text-align: center;">
  61. <button class="btnstyle" @click="resetbtn">重置设备</button>
  62. <button class="btnstyle" @click="upbtn">升级程序</button>
  63. </div>
  64. <div style="font-size: .3rem;margin-top: .4rem;">
  65. 备注:
  66. </div>
  67. <div style="font-size: .3rem;margin-top: .2rem;">
  68. 1. 点击任何按钮后,设备需保持通电状态3-5分钟,中途不能断电,否则可能造成设备损坏
  69. </div>
  70. <div style="font-size: .3rem; margin-top: .2rem;">
  71. 2. 设备重置/升级后,所有主板的奇数口会变更为通电状态,成功获取版本号后可继续测试设备
  72. </div>
  73. <div style="font-size: .3rem; margin-top: .2rem;">
  74. 3. 重置设备为将现有设备重新重置状态并升级到最新版本,会清空设备原有设置所有命令,并直接获取设备版本号
  75. </div>
  76. </div>
  77. </div>
  78. <script src="https://cdn.bootcdn.net/ajax/libs/vue/2.6.9/vue.min.js"></script>
  79. <script src="https://cdn.bootcdn.net/ajax/libs/axios/0.20.0/axios.min.js"></script>
  80. <script src="./auto-size.js"></script>
  81. <script>
  82. const vm = new Vue({
  83. el: '#main',
  84. data: {
  85. isInstall: true,
  86. value: "",
  87. equipment: "",
  88. isxian: "",
  89. versionNum: "",
  90. isnew: "",
  91. Numarr: [],
  92. list: []
  93. },
  94. mounted() {
  95. this.getNum()
  96. },
  97. watch: {
  98. value(newdata, jiu) {
  99. if (typeof newdata === 'string') {
  100. if (newdata.trim().length !== 0) {
  101. this.debounce(this.changeStr, 1500);
  102. } else { }
  103. }
  104. if (newdata == "") {
  105. this.list = []
  106. }
  107. }
  108. },
  109. methods: {
  110. getNum() {
  111. axios.get("/getDevcielist").then(res => {
  112. this.Numarr = res.data.data
  113. })
  114. },
  115. tapvalue(item) {
  116. this.value = item
  117. this.list = []
  118. },
  119. changeStr() {
  120. this.list = []
  121. this.Numarr.forEach(item => {
  122. if (item.substr(item.length - 4) == this.value) {
  123. this.list.push(item)
  124. }
  125. })
  126. console.log(this.list)
  127. },
  128. debounce(fn, wait) {
  129. if (this.fun !== null) {
  130. clearTimeout(this.fun)
  131. }
  132. this.fun = setTimeout(fn, wait)
  133. },
  134. resetbtn() {
  135. if (this.isxian == '在营') {
  136. axios.get("/upVersion?id=" + this.value + "&type=" + 2).then(res => {
  137. if (res.data.status == 200) {
  138. alert("重置命令发送成功,请耐心等待30s,系统将自动重置")
  139. }
  140. })
  141. } else {
  142. alert('设备已离线')
  143. }
  144. },
  145. installbtn() {
  146. if (this.value != "") {
  147. axios.get("/getDevice?id=" + this.value).then(res => {
  148. console.log(res)
  149. if (res.data.status == 200) {
  150. this.isInstall = false
  151. this.equipment = res.data.data.id
  152. this.isxian = res.data.data.status
  153. this.versionNum = res.data.data.version
  154. this.isnew = res.data.data.is_last
  155. } else {
  156. alert("无效设备")
  157. }
  158. })
  159. } else {
  160. alert("请输入编号")
  161. }
  162. },
  163. upbtn() {
  164. if (this.isxian == '在营' && this.isnew == 0) {
  165. axios.get("/upVersion?id=" + this.value + "&type=" + 1).then(res => {
  166. if (res.data.status == 200) {
  167. alert('升级命令发送成功,请耐心等待3-5分钟设备升级完成后,所有锁口会变为通电状态')
  168. }
  169. })
  170. } else if (this.isxian != "在营") {
  171. alert('设备已离线')
  172. } else {
  173. alert('设备已是最新版本,无需更新')
  174. }
  175. }
  176. }
  177. })
  178. </script>
  179. </body>
  180. </html>