Index.vue 8.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345
  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. });
  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 == "a1f2d679c1624d3a" || 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. that.checkUpdate();
  105. }
  106. },
  107. fail: function (e) {
  108. console.log('getDeviceInfo failed: ' + JSON.stringify(e));
  109. }
  110. });
  111. }
  112. },
  113. // 是否有新版本
  114. checkUpdate() {
  115. let that = this;
  116. let param = {};
  117. let postdata = qs.stringify(param);
  118. const h = this.$createElement;
  119. QueryVueFramework(postdata).then(res => {
  120. let json = res;
  121. if (json.Code == 0) {
  122. console.log('localStorage.version' + localStorage.version);
  123. if (localStorage.version != json.VueFramework.Version) {
  124. // 正式
  125. let url = "http://cal.beswell.com:85/v1/Sensors/DownloadVueFramework";
  126. this.downWgt(url);
  127. // that.downWgt(url, json.Version);
  128. // that.$notify({
  129. // title: '升级提醒',
  130. // message: h('i', {style: 'color: teal'}, '检测到新的版本,正在下载最新版本')
  131. // });
  132. }
  133. }
  134. })
  135. },
  136. downWgt(url) {
  137. let that = this;
  138. plus.downloader.createDownload(url, {filename: "_doc/update/"}, function (d, status) {
  139. // plus.downloader.createDownload(url, {}, function (d, status) {
  140. if (status == 200) {
  141. console.log(d);
  142. console.log("下载wgt成功:" + d.filename);
  143. that.installWgt(d.filename); // 安装wgt包
  144. } else {
  145. console.log("下载wgt失败!");
  146. // plus.nativeUI.alert("下载wgt失败!");
  147. }
  148. plus.nativeUI.closeWaiting();
  149. }).start();
  150. },
  151. installWgt(path) {
  152. // plus.nativeUI.showWaiting("安装wgt文件...");
  153. plus.runtime.install(path, {}, function () {
  154. plus.nativeUI.closeWaiting();
  155. console.log("安装wgt文件成功!");
  156. // plus.nativeUI.alert("应用资源更新完成!", function () {
  157. plus.runtime.restart();
  158. // });
  159. }, function (e) {
  160. plus.nativeUI.closeWaiting();
  161. console.log("安装wgt文件失败[" + e.code + "]:" + e.message);
  162. // plus.nativeUI.alert("安装wgt文件失败[" + e.code + "]:" + e.message);
  163. });
  164. },
  165. // 获取转发端口地址
  166. getServeIpAddress(eqsn) {
  167. const that = this;
  168. let url = '';
  169. // 测试使用0.3心率系统
  170. if (eqsn == 'a1f2d679c1624d3a' || eqsn == '30:9C:23:0C:8B:1E') {
  171. url = "http://192.168.0.3:19096/v1/Sensors/GetShopConfigParam";
  172. } else {
  173. url = 'http://cal.beswell.com:85/v1/Sensors/GetShopConfigParam'
  174. }
  175. let param = {
  176. eqSn: eqsn
  177. };
  178. let postdata = qs.stringify(param);
  179. axios.post(url, postdata).then(function (data) {
  180. let json = data.data;
  181. if (json.Code == 0) {
  182. headapi = json.Rs.DataServiceIP;
  183. } else {
  184. headapi = 'http://192.168.0.10:8080/';
  185. console.log(json.memo);
  186. that.$message.error(json.memo);
  187. }
  188. }, function (response) {
  189. console.info(response);
  190. })
  191. }
  192. },
  193. components: {}
  194. }
  195. </script>
  196. <!-- Add "scoped" attribute to limit CSS to this component only -->
  197. <style>
  198. ul, li {
  199. list-style: none;
  200. margin: 0;
  201. padding: 0;
  202. }
  203. .el-header {
  204. padding: 0 !important;
  205. height: 72px !important;
  206. }
  207. .shortElaside {
  208. width: 140px !important;
  209. overflow: hidden;
  210. height: 100%;
  211. float: left;
  212. }
  213. .lognElaside {
  214. width: 256px !important;
  215. overflow: hidden;
  216. height: 100%;
  217. float: left;
  218. }
  219. /deep/ .nav {
  220. width: 60px;
  221. }
  222. .IndexContainer {
  223. position: absolute;
  224. top: 0;
  225. bottom: 0;
  226. left: 0;
  227. right: 0;
  228. background: #F0F2F5;
  229. }
  230. .IndexContainer > .el-container {
  231. width: 100%;
  232. height: 100%;
  233. overflow: hidden;
  234. display: block;
  235. margin: 0 auto;
  236. }
  237. .footer {
  238. position: absolute;
  239. bottom: 0px;
  240. width: 100%;
  241. padding: 10px;
  242. overflow: hidden;
  243. display: block;
  244. margin: 0 auto;
  245. text-align: center;
  246. text-indent: -30%;
  247. font-size: 12px;
  248. color: #BDBDBD;
  249. background: #F0F2F5;
  250. z-index: 222;
  251. }
  252. .el-main {
  253. width: 100%;
  254. height: 100%;
  255. /*min-height: 800px;*/
  256. overflow: hidden;
  257. display: block;
  258. margin: 0 auto;
  259. overflow-y: hidden;
  260. padding: 10px 20px;
  261. }
  262. /*ipad only*/
  263. @media only screen and (max-width: 1366px) {
  264. .lognElaside {
  265. width: 70px !important;
  266. }
  267. .logoContainer img {
  268. display: none !important;
  269. }
  270. .el-main {
  271. padding: 3px !important;
  272. overflow-y: scroll;
  273. }
  274. .el-main > .context {
  275. /*height: 640px;*/
  276. /*overflow-y: scroll;*/
  277. padding: 6px !important;
  278. }
  279. .table {
  280. /*width: 950px;*/
  281. /*overflow-x: scroll;*/
  282. }
  283. .el-dialog {
  284. max-width: 960px;
  285. }
  286. .el-dialog__body {
  287. padding: 3px;
  288. }
  289. .el-transfer__buttons {
  290. width: 60px;
  291. padding: 3px;
  292. }
  293. .el-transfer .el-button + .el-button {
  294. float: right;
  295. }
  296. .el-container.is-vertical {
  297. position: absolute;
  298. left: 140px;
  299. top: 0;
  300. right: 0;
  301. bottom: 0;
  302. height: 100%;
  303. }
  304. .context {
  305. border-radius: 12px;
  306. height: 823px !important;
  307. overflow-y: scroll;
  308. }
  309. .el-dialog {
  310. padding: 5px;
  311. padding-bottom: 15px;
  312. }
  313. }
  314. </style>