Index.vue 9.3 KB

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