Index.vue 9.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387
  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. testMode: 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.eqSn = 'd104bd6ffec3d5ba';
  50. localStorage.version = '2.2.0';
  51. if (window.plus) {
  52. plusReady();
  53. } else {
  54. console.log('mui is not ready');
  55. // 调试时候关闭
  56. this.getServeIpAddress(localStorage.eqSn);
  57. // plusReady();
  58. document.addEventListener('plusready', plusReady, false);
  59. }
  60. function plusReady() {
  61. if (typeof plus == 'undefined') return false;
  62. // 获取本地应用资源版本号
  63. plus.runtime.getProperty(plus.runtime.appid, function (inf) {
  64. localStorage.version = inf.version;
  65. that.curVersion = inf.version;
  66. });
  67. // 获取手机UUID
  68. plus.device.getInfo({
  69. success: function (e) {
  70. let uuid = JSON.stringify(e.uuid).toString().substr(1);
  71. uuid = uuid.substring(0, uuid.length - 1);
  72. localStorage.eqSn = uuid;
  73. console.log('===== uuid =====:' + uuid);
  74. console.log('getDeviceInfo success: ' + JSON.stringify(e.uuid));
  75. // 正式版打开
  76. // 获取转发端口地址
  77. that.getServeIpAddress(e.uuid);
  78. // 公司测试机用公司版本升级
  79. // if (uuid == "1277fcb4c81e29d2" || uuid == "8e501b0bde9ce600") {
  80. if (uuid == "d104bd6ffec3d5ba" || uuid == "30:9C:23:0C:8B:1E") { // 内测版
  81. that.testMode = true;
  82. } else { // 正式版
  83. that.testMode = false;
  84. }
  85. // 教室版本自动升级,户外版禁用自动升级
  86. if (runVersion == 'outDoor') {
  87. console.log('户外版禁用自动升级');
  88. return false
  89. } else if (runVersion == 'localtest') {
  90. console.log('本机测试禁用自动升级');
  91. plus.nativeUI.toast("本机测试 禁用自动升级 UUID: " + uuid);
  92. return false
  93. } else {
  94. that.checkUpdate();
  95. // 每10分钟检测一下升级信息
  96. setInterval(() => {
  97. // console.log("$route.path: " + that.$route.path);
  98. // console.log("$route.name: " + that.$route.name);
  99. if (that.$route.name == "Wait") {
  100. console.log("===> checkUpdate");
  101. that.checkUpdate();
  102. }
  103. }, 600000);
  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. vfType: 3 //新版电视端-Http接口
  117. };
  118. let postdata = qs.stringify(param);
  119. const h = that.$createElement;
  120. QueryVueFramework(postdata, that.testMode).then(res => {
  121. let json = res;
  122. if (json.Code == 0) {
  123. console.log('localStorage.version: ' + localStorage.version);
  124. console.log('json.VueFramework.Version: ' + json.VueFramework.Version);
  125. // plus.nativeUI.toast("当前安装版本: " + localStorage.version);
  126. if (localStorage.version != json.VueFramework.Version) {
  127. // 正式
  128. plus.nativeUI.toast("发现新版本 " + json.VueFramework.Version + ",准备升级...");
  129. let url = DownloadVueFramework(that.testMode);
  130. that.downWgt(url);
  131. }
  132. }
  133. })
  134. },
  135. downWgt(url) {
  136. let that = this;
  137. plus.downloader.createDownload(url, {
  138. // method: "POST",
  139. // data: "{vfType:3}",
  140. filename: "_doc/update/"
  141. }, function (d, status) {
  142. if (status == 200) {
  143. console.log(d);
  144. console.log("下载wgt成功:" + d.filename);
  145. that.installWgt(d.filename); // 安装wgt包
  146. } else {
  147. console.log("下载wgt失败!");
  148. plus.nativeUI.toast("下载升级包失败!");
  149. }
  150. // plus.nativeUI.closeWaiting();
  151. }).start();
  152. },
  153. installWgt(path) {
  154. plus.nativeUI.showWaiting("正在升级,请稍候...");
  155. plus.runtime.install(path, {}, function () {
  156. plus.nativeUI.closeWaiting();
  157. console.log("安装wgt文件成功!");
  158. plus.nativeUI.toast("升级完成!");
  159. plus.runtime.restart();
  160. // });
  161. }, function (e) {
  162. plus.nativeUI.closeWaiting();
  163. console.log("安装wgt文件失败[" + e.code + "]:" + e.message);
  164. plus.nativeUI.toast("升级失败[" + e.code + "]:" + e.message);
  165. });
  166. },
  167. // 获取转发端口地址
  168. getServeIpAddress(eqsn) {
  169. const that = this;
  170. let url = '';
  171. if (runVersion == 'test') { //演示模式
  172. headapi = "http://cal.beswell.com:85/DataTransfer/";
  173. console.log("runVersion = " + runVersion + " headapi = " + headapi);
  174. return false
  175. }
  176. if (runVersion == 'localtest') { //本机测试 TV端映射到本机进行测试
  177. headapi = "http://127.0.0.1/";
  178. console.log("runVersion = " + runVersion + " headapi = " + headapi);
  179. return false
  180. }
  181. // 测试使用0.3心率系统
  182. if (eqsn == '1277fcb4c81e29d2' || eqsn == '30:9C:23:0C:8B:1E') {
  183. url = "http://192.168.0.3:19096/v1/Sensors/GetShopConfigParam";
  184. } else {
  185. url = 'http://cal.beswell.com:85/v1/Sensors/GetShopConfigParam'
  186. }
  187. let param = {
  188. eqSn: eqsn
  189. };
  190. let postdata = qs.stringify(param);
  191. axios.post(url, postdata).then(function (data) {
  192. console.log(eqsn, url);
  193. let json = data.data;
  194. console.log(json);
  195. if (json.Code == 0) {
  196. // 户外版使用HotsPotDataServiceIP
  197. if (runVersion == 'outDoor') {
  198. headapi = json.Rs.HotsPotDataServiceIP;
  199. // 内网测试版
  200. // headapi = 'http://192.168.0.3:19096/v1/Sensors/';
  201. if (!json.Rs.HotsPotDataServiceIP) {
  202. that.$message.error("未获取到HotsPotDataServiceIP");
  203. return false
  204. }
  205. } else {
  206. headapi = json.Rs.DataServiceIP;
  207. // console.log("正式版 headapi = " + headapi);
  208. }
  209. } else {
  210. headapi = 'http://192.168.0.10:8080/'; //树莓派数据转发
  211. }
  212. console.log("headapi = " + headapi);
  213. }, function (response) {
  214. console.info(response);
  215. })
  216. }
  217. },
  218. components: {}
  219. }
  220. </script>
  221. <!-- Add "scoped" attribute to limit CSS to this component only -->
  222. <style>
  223. ul, li {
  224. list-style: none;
  225. margin: 0;
  226. padding: 0;
  227. }
  228. .el-header {
  229. padding: 0 !important;
  230. height: 72px !important;
  231. }
  232. .shortElaside {
  233. width: 140px !important;
  234. overflow: hidden;
  235. height: 100%;
  236. float: left;
  237. }
  238. .lognElaside {
  239. width: 256px !important;
  240. overflow: hidden;
  241. height: 100%;
  242. float: left;
  243. }
  244. /deep/ .nav {
  245. width: 60px;
  246. }
  247. .IndexContainer {
  248. position: absolute;
  249. top: 0;
  250. bottom: 0;
  251. left: 0;
  252. right: 0;
  253. background: #F0F2F5;
  254. height: 100%;
  255. overflow-y: scroll;
  256. }
  257. /*演示版专供*/
  258. .isPad {
  259. height: 11.2rem;
  260. }
  261. .IndexContainer > .el-container {
  262. width: 100%;
  263. height: 100%;
  264. overflow: hidden;
  265. display: block;
  266. margin: 0 auto;
  267. }
  268. .footer {
  269. position: absolute;
  270. bottom: 0px;
  271. width: 100%;
  272. padding: 10px;
  273. overflow: hidden;
  274. display: block;
  275. margin: 0 auto;
  276. text-align: center;
  277. text-indent: -30%;
  278. font-size: 12px;
  279. color: #BDBDBD;
  280. background: #F0F2F5;
  281. z-index: 222;
  282. }
  283. .el-main {
  284. width: 100%;
  285. height: 100%;
  286. /*min-height: 800px;*/
  287. overflow: hidden;
  288. display: block;
  289. margin: 0 auto;
  290. overflow-y: hidden;
  291. padding: 10px 20px;
  292. }
  293. /*ipad only*/
  294. @media only screen and (max-width: 1366px) {
  295. .lognElaside {
  296. width: 70px !important;
  297. }
  298. .logoContainer img {
  299. display: none !important;
  300. }
  301. .el-main {
  302. padding: 3px !important;
  303. overflow-y: scroll;
  304. }
  305. .el-main > .context {
  306. /*height: 640px;*/
  307. /*overflow-y: scroll;*/
  308. padding: 6px !important;
  309. }
  310. .table {
  311. /*width: 950px;*/
  312. /*overflow-x: scroll;*/
  313. }
  314. .el-dialog {
  315. max-width: 960px;
  316. }
  317. .el-dialog__body {
  318. padding: 3px;
  319. }
  320. .el-transfer__buttons {
  321. width: 60px;
  322. padding: 3px;
  323. }
  324. .el-transfer .el-button + .el-button {
  325. float: right;
  326. }
  327. .el-container.is-vertical {
  328. position: absolute;
  329. left: 140px;
  330. top: 0;
  331. right: 0;
  332. bottom: 0;
  333. height: 100%;
  334. }
  335. .context {
  336. border-radius: 12px;
  337. height: 823px !important;
  338. overflow-y: scroll;
  339. }
  340. .el-dialog {
  341. padding: 5px;
  342. padding-bottom: 15px;
  343. }
  344. }
  345. #__vconsole {
  346. display: none;
  347. }
  348. #__vconsole.show {
  349. display: block;
  350. }
  351. </style>