upgrade.html 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273
  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 v-if="isshezhi" style="margin-top: 1rem; text-align: center">
  51. <h1 style="font-size: 0.7rem;text-align: center">绿色地球</h1>
  52. <input type="text" class="inputstyle" disabled v-model="value" placeholder="">
  53. <div v-for="(item,index) in phonedata" style="font-size: .5rem;margin-top: .3rem;" @click="tapphone(item)">
  54. {{item}}
  55. </div>
  56. <input type="text" class="inputstyle" v-model="phone" placeholder="请输入DTU绑定手机卡号">
  57. <br />
  58. <select class="inputstyle" v-model="typevalue" @change="changeProduct($event)">
  59. <option value="1">四箱</option>
  60. <option value="2">五箱</option>
  61. <option value="3">四箱可回收</option>
  62. <option value="4">五箱可回收</option>
  63. </select>
  64. <button @click="shezhi" class="btnstyle">立即设置</button>
  65. </div>
  66. <div class="container" style="align-items: flex-start;" v-if="isbox">
  67. <div style="font-size: .5rem;">
  68. 设备IMEI号:{{equipment}}
  69. </div>
  70. <div style="font-size: .5rem;margin-top: .4rem;display: flex;align-items: center;">
  71. 设备状态:{{isxian}}
  72. </div>
  73. <div style="font-size: .5rem;margin-top: .4rem;display: flex;align-items: center;">
  74. 设备版本号:{{versionNum}}
  75. </div>
  76. <div style="margin-top: .4rem;width: 100%;text-align: center;">
  77. <button class="btnstyle" @click="resetbtn">重置设备</button>
  78. <button class="btnstyle" @click="upbtn">升级程序</button>
  79. </div>
  80. <div style="font-size: .3rem;margin-top: .4rem;">
  81. 备注:
  82. </div>
  83. <div style="font-size: .3rem;margin-top: .2rem;">
  84. 1. 点击任何按钮后,设备需保持通电状态3-5分钟,中途不能断电,否则可能造成设备损坏
  85. </div>
  86. <div style="font-size: .3rem; margin-top: .2rem;">
  87. 2. 设备重置/升级后,所有主板的奇数口会变更为通电状态,成功获取版本号后可继续测试设备
  88. </div>
  89. <div style="font-size: .3rem; margin-top: .2rem;">
  90. 3. 重置设备为将现有设备重新重置状态并升级到最新版本,会清空设备原有设置所有命令,并直接获取设备版本号
  91. </div>
  92. </div>
  93. </div>
  94. <script src="https://cdn.bootcdn.net/ajax/libs/vue/2.6.9/vue.min.js"></script>
  95. <script src="https://cdn.bootcdn.net/ajax/libs/axios/0.20.0/axios.min.js"></script>
  96. <script src="./auto-size.js"></script>
  97. <script>
  98. const vm = new Vue({
  99. el: '#main',
  100. data: {
  101. isInstall: true,
  102. value: "",
  103. equipment: "",
  104. isxian: "",
  105. versionNum: "",
  106. isnew: "",
  107. Numarr: [],
  108. list: [],
  109. typevalue: "1",
  110. phone: "",
  111. type: 1,
  112. isbox: false,
  113. isshezhi: false,
  114. phoneList: [],
  115. phonedata: []
  116. },
  117. mounted() {
  118. this.getNum()
  119. this.getphone()
  120. },
  121. watch: {
  122. value(newdata, jiu) {
  123. if (typeof newdata === 'string') {
  124. if (newdata.trim().length !== 0) {
  125. this.debounce(this.changeStr, 1500);
  126. } else { }
  127. }
  128. if (newdata == "") {
  129. this.list = []
  130. }
  131. },
  132. phone(newdata, jiu) {
  133. console.log(newdata)
  134. if (typeof newdata === 'string') {
  135. if (newdata.trim().length !== 0) {
  136. this.debounce(this.phonechange, 1500);
  137. } else { }
  138. }
  139. if (newdata == "") {
  140. this.phonedata = []
  141. }
  142. }
  143. },
  144. methods: {
  145. shezhi() {
  146. if (this.phone != "") {
  147. if (confirm("请再次确定选择的手机号和箱体类型选择正确,提交后不可变更")) {
  148. axios.get("/updateDevice?id=" + this.value + "&type=" + this.type + "&phone=" + this.phone).then(res => {
  149. console.log(res)
  150. if (res.data.status == 200) {
  151. this.isshezhi = false
  152. this.isbox = true
  153. alert('设备更新中')
  154. }
  155. })
  156. }
  157. } else {
  158. alert("请输入手机号")
  159. }
  160. },
  161. changeProduct(e) {
  162. console.log(e)
  163. this.type = e.target.value
  164. },
  165. getNum() {
  166. axios.get("/getDevcielist").then(res => {
  167. this.Numarr = res.data.data
  168. })
  169. },
  170. tapvalue(item) {
  171. this.value = item
  172. this.list = []
  173. },
  174. tapphone(item) {
  175. this.phone = item
  176. this.phonedata = []
  177. },
  178. changeStr() {
  179. this.list = []
  180. this.Numarr.forEach(item => {
  181. if (item.substr(item.length - 4) == this.value) {
  182. this.list.push(item)
  183. }
  184. })
  185. console.log(this.list)
  186. },
  187. phonechange() {
  188. this.phonedata = []
  189. this.phoneList.forEach(item => {
  190. if (item.substr(item.length - 4) == this.phone) {
  191. this.phonedata.push(item)
  192. }
  193. })
  194. console.log(this.phonedata)
  195. },
  196. debounce(fn, wait) {
  197. if (this.fun !== null) {
  198. clearTimeout(this.fun)
  199. }
  200. this.fun = setTimeout(fn, wait)
  201. },
  202. resetbtn() {
  203. if (this.isxian == '在营') {
  204. axios.get("/upVersion?id=" + this.value + "&type=" + 2).then(res => {
  205. if (res.data.status == 200) {
  206. alert("重置命令发送成功,请耐心等待30s,系统将自动重置")
  207. }
  208. })
  209. } else {
  210. alert('设备已离线')
  211. }
  212. },
  213. installbtn() {
  214. if (this.value != "") {
  215. axios.get("/getDevice?id=" + this.value).then(res => {
  216. console.log(res)
  217. if (res.data.status == 200) {
  218. if (res.data.data.phone != null && res.data.data.device_type != null && res.data.data.is_last == 0) {
  219. this.isInstall = false
  220. this.isbox = true
  221. this.equipment = res.data.data.id
  222. this.isxian = res.data.data.status
  223. this.versionNum = res.data.data.version
  224. this.isnew = res.data.data.is_last
  225. } else if (res.data.data.phone == null && res.data.data.device_type == null && res.data.data.is_last == 0) {
  226. this.isInstall = false
  227. this.isshezhi = true
  228. this.equipment = res.data.data.id
  229. this.isxian = res.data.data.status
  230. this.versionNum = res.data.data.version
  231. this.isnew = res.data.data.is_last
  232. } else {
  233. alert('当前设备已是最新版本,已有箱体和已绑定手机号无需设置升级')
  234. }
  235. } else {
  236. alert("无效设备")
  237. }
  238. })
  239. } else {
  240. alert("请输入编号")
  241. }
  242. },
  243. upbtn() {
  244. if (this.isxian == '在营' && this.isnew == 0) {
  245. axios.get("/upVersion?id=" + this.value + "&type=" + 1).then(res => {
  246. if (res.data.status == 200) {
  247. alert('升级命令发送成功,请耐心等待3-5分钟设备升级完成后,所有锁口会变为通电状态')
  248. }
  249. })
  250. } else if (this.isxian != "在营") {
  251. alert('设备已离线')
  252. } else {
  253. alert('设备已是最新版本,无需更新')
  254. }
  255. },
  256. getphone() {
  257. axios.get("/getPhonelist").then(res => {
  258. this.phoneList = res.data.data
  259. })
  260. }
  261. }
  262. })
  263. </script>
  264. </body>
  265. </html>