Index.vue 10 KB

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