Index.vue 9.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376
  1. <template>
  2. <div :class="[{'IndexContainer':true}]" :style="{height:ClentHeight}">
  3. <keep-alive>
  4. <router-view></router-view>
  5. </keep-alive>
  6. </div>
  7. </template>
  8. <script>
  9. import {
  10. QueryVueFramework,
  11. DownloadVueFramework,
  12. getCheckUpdate,
  13. getUserList
  14. } from '@/api/getApiRes'
  15. import "../../public/mui.js"
  16. import '../Global'
  17. let qs = require('qs');
  18. export default {
  19. name: 'Home',
  20. data() {
  21. return {
  22. autoUpdate: false,//自动升级
  23. aSideState: false,
  24. thisClick: 0,
  25. tabwildState: 1,
  26. handleTabsList: [{
  27. title: '系统首页',
  28. name: '1',
  29. clmurl: '/',
  30. }],
  31. editableTabsValue: '1',
  32. curVersion: '2.0',
  33. isPad: true,// pad 展示版本
  34. ClentHeight: document.documentElement.clientHeight + 'px'
  35. }
  36. },
  37. mounted() {
  38. //浏览器默认的
  39. localStorage.eqSn = '30:9C:23:0C:8B:1E';
  40. localStorage.version = '2.0';
  41. this.getCurVersion();
  42. },
  43. methods: {
  44. // 获取当前版本号
  45. getCurVersion() {
  46. let that = this;
  47. //浏览器默认的
  48. localStorage.eqSn = '30:9C:23:0C:8B:1E';
  49. localStorage.version = '2.0';
  50. if (window.plus) {
  51. plusReady();
  52. } else {
  53. console.log('mui is not ready');
  54. // 调试时候关闭
  55. this.getServeIpAddress(localStorage.eqSn);
  56. // plusReady();
  57. document.addEventListener('plusready', plusReady, false);
  58. }
  59. function plusReady() {
  60. if (typeof plus == 'undefined') return false;
  61. // 获取本地应用资源版本号
  62. plus.runtime.getProperty(plus.runtime.appid, function (inf) {
  63. localStorage.version = inf.version;
  64. that.curVersion = inf.version;
  65. });
  66. // 获取手机UUID
  67. plus.device.getInfo({
  68. success: function (e) {
  69. let uuid = JSON.stringify(e.uuid).toString().substr(1);
  70. uuid = uuid.substring(0, uuid.length - 1);
  71. localStorage.eqSn = uuid;
  72. console.log('===== uuid =====:' + uuid);
  73. console.log('getDeviceInfo success: ' + JSON.stringify(e.uuid));
  74. // 正式版打开
  75. // 获取转发端口地址
  76. that.getServeIpAddress(e.uuid);
  77. // 公司测试机用公司版本升级
  78. // if (uuid == "a1f2d679c1624d3a" || uuid == "8e501b0bde9ce600") {
  79. if (uuid == "1277fcb4c81e29d2" || uuid == "8e501b0bde9ce600") {
  80. //首发版本 '1.1.0' 在线版不需要自动升级
  81. // 内测版自动升级
  82. let url = 'http://192.168.0.3:19096/v1/Sensors/QueryVueFramework';
  83. let param = {};
  84. let postdata = qs.stringify(param);
  85. axios.post(url, postdata).then(function (data) {
  86. let json = data.data;
  87. if (json.Code == 0) {
  88. if (localStorage.version != json.VueFramework.Version) {
  89. // 测试版本下载
  90. console.log(332);
  91. let downUrl = "http://192.168.0.3:19096/v1/Sensors/DownloadVueFramework";
  92. that.downWgt(downUrl);
  93. }
  94. } else {
  95. console.log(json.Memo);
  96. }
  97. }, function (response) {
  98. console.info(response);
  99. })
  100. } else {
  101. console.log(223);
  102. // 正式版
  103. //开启自动升级
  104. // 教室版本自动升级,户外版禁用自动升级
  105. if (runVersion == 'outDoor') {
  106. console.log('户外版禁用自动升级');
  107. return false
  108. } else {
  109. that.checkUpdate();
  110. }
  111. }
  112. },
  113. fail: function (e) {
  114. console.log('getDeviceInfo failed: ' + JSON.stringify(e));
  115. }
  116. });
  117. }
  118. },
  119. // 是否有新版本
  120. checkUpdate() {
  121. let that = this;
  122. let param = {};
  123. let postdata = qs.stringify(param);
  124. const h = this.$createElement;
  125. QueryVueFramework(postdata).then(res => {
  126. let json = res;
  127. if (json.Code == 0) {
  128. console.log('localStorage.version' + localStorage.version);
  129. if (localStorage.version != json.VueFramework.Version) {
  130. // 正式
  131. let url = "http://cal.beswell.com:85/v1/Sensors/DownloadVueFramework";
  132. this.downWgt(url);
  133. }
  134. }
  135. })
  136. },
  137. downWgt(url) {
  138. let that = this;
  139. plus.downloader.createDownload(url, {filename: "_doc/update/"}, function (d, status) {
  140. // plus.downloader.createDownload(url, {}, function (d, status) {
  141. if (status == 200) {
  142. console.log(d);
  143. console.log("下载wgt成功:" + d.filename);
  144. that.installWgt(d.filename); // 安装wgt包
  145. } else {
  146. console.log("下载wgt失败!");
  147. // plus.nativeUI.alert("下载wgt失败!");
  148. }
  149. plus.nativeUI.closeWaiting();
  150. }).start();
  151. },
  152. installWgt(path) {
  153. // plus.nativeUI.showWaiting("安装wgt文件...");
  154. plus.runtime.install(path, {}, function () {
  155. plus.nativeUI.closeWaiting();
  156. console.log("安装wgt文件成功!");
  157. // plus.nativeUI.alert("应用资源更新完成!", function () {
  158. plus.runtime.restart();
  159. // });
  160. }, function (e) {
  161. plus.nativeUI.closeWaiting();
  162. console.log("安装wgt文件失败[" + e.code + "]:" + e.message);
  163. // plus.nativeUI.alert("安装wgt文件失败[" + e.code + "]:" + e.message);
  164. });
  165. },
  166. // 获取转发端口地址
  167. getServeIpAddress(eqsn) {
  168. const that = this;
  169. let url = '';
  170. if (runVersion == 'test') {
  171. headapi = "http://cal.beswell.com:85/DataTransfer/";
  172. return false
  173. }
  174. // 测试使用0.3心率系统
  175. if (eqsn == '1277fcb4c81e29d2' || eqsn == '30:9C:23:0C:8B:1E') {
  176. url = "http://192.168.0.3:19096/v1/Sensors/GetShopConfigParam";
  177. } else {
  178. url = 'http://cal.beswell.com:85/v1/Sensors/GetShopConfigParam'
  179. }
  180. let param = {
  181. eqSn: eqsn
  182. };
  183. let postdata = qs.stringify(param);
  184. axios.post(url, postdata).then(function (data) {
  185. let json = data.data;
  186. if (json.Code == 0) {
  187. // 户外版使用HotsPotDataServiceIP
  188. if (runVersion == 'outDoor') {
  189. headapi = json.Rs.HotsPotDataServiceIP;
  190. // 内网测试版
  191. // headapi = 'http://192.168.0.3:19096/v1/Sensors/';
  192. if (!json.Rs.HotsPotDataServiceIP) {
  193. that.$message.error("未获取到HotsPotDataServiceIP");
  194. return false
  195. }
  196. } else {
  197. headapi = json.Rs.DataServiceIP;
  198. }
  199. } else {
  200. headapi = 'http://192.168.0.10:8080/';
  201. }
  202. }, function (response) {
  203. console.info(response);
  204. })
  205. }
  206. },
  207. components: {}
  208. }
  209. </script>
  210. <!-- Add "scoped" attribute to limit CSS to this component only -->
  211. <style>
  212. ul, li {
  213. list-style: none;
  214. margin: 0;
  215. padding: 0;
  216. }
  217. .el-header {
  218. padding: 0 !important;
  219. height: 72px !important;
  220. }
  221. .shortElaside {
  222. width: 140px !important;
  223. overflow: hidden;
  224. height: 100%;
  225. float: left;
  226. }
  227. .lognElaside {
  228. width: 256px !important;
  229. overflow: hidden;
  230. height: 100%;
  231. float: left;
  232. }
  233. /deep/ .nav {
  234. width: 60px;
  235. }
  236. .IndexContainer {
  237. position: absolute;
  238. top: 0;
  239. bottom: 0;
  240. left: 0;
  241. right: 0;
  242. background: #F0F2F5;
  243. height: 100%;
  244. overflow-y: scroll;
  245. }
  246. /*演示版专供*/
  247. .isPad {
  248. height: 11.2rem;
  249. }
  250. .IndexContainer > .el-container {
  251. width: 100%;
  252. height: 100%;
  253. overflow: hidden;
  254. display: block;
  255. margin: 0 auto;
  256. }
  257. .footer {
  258. position: absolute;
  259. bottom: 0px;
  260. width: 100%;
  261. padding: 10px;
  262. overflow: hidden;
  263. display: block;
  264. margin: 0 auto;
  265. text-align: center;
  266. text-indent: -30%;
  267. font-size: 12px;
  268. color: #BDBDBD;
  269. background: #F0F2F5;
  270. z-index: 222;
  271. }
  272. .el-main {
  273. width: 100%;
  274. height: 100%;
  275. /*min-height: 800px;*/
  276. overflow: hidden;
  277. display: block;
  278. margin: 0 auto;
  279. overflow-y: hidden;
  280. padding: 10px 20px;
  281. }
  282. /*ipad only*/
  283. @media only screen and (max-width: 1366px) {
  284. .lognElaside {
  285. width: 70px !important;
  286. }
  287. .logoContainer img {
  288. display: none !important;
  289. }
  290. .el-main {
  291. padding: 3px !important;
  292. overflow-y: scroll;
  293. }
  294. .el-main > .context {
  295. /*height: 640px;*/
  296. /*overflow-y: scroll;*/
  297. padding: 6px !important;
  298. }
  299. .table {
  300. /*width: 950px;*/
  301. /*overflow-x: scroll;*/
  302. }
  303. .el-dialog {
  304. max-width: 960px;
  305. }
  306. .el-dialog__body {
  307. padding: 3px;
  308. }
  309. .el-transfer__buttons {
  310. width: 60px;
  311. padding: 3px;
  312. }
  313. .el-transfer .el-button + .el-button {
  314. float: right;
  315. }
  316. .el-container.is-vertical {
  317. position: absolute;
  318. left: 140px;
  319. top: 0;
  320. right: 0;
  321. bottom: 0;
  322. height: 100%;
  323. }
  324. .context {
  325. border-radius: 12px;
  326. height: 823px !important;
  327. overflow-y: scroll;
  328. }
  329. .el-dialog {
  330. padding: 5px;
  331. padding-bottom: 15px;
  332. }
  333. }
  334. #__vconsole {
  335. display: none;
  336. }
  337. #__vconsole.show {
  338. display: block;
  339. }
  340. </style>