Index.vue 8.4 KB

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