Index.vue 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329
  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. function plusReady() {
  52. if (typeof plus == 'undefined') return false;
  53. // 获取本地应用资源版本号
  54. plus.runtime.getProperty(plus.runtime.appid, function (inf) {
  55. localStorage.version = inf.version;
  56. that.curVersion = inf.version;
  57. //首发版本 '1.1.0' 在线版不需要自动升级
  58. that.checkUpdate(that.curVersion); //开启自动升级
  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);
  67. // const h = this.$createElement;
  68. // that.$notify({
  69. // title: '获取UUID',
  70. // message: h('i', {style: 'color: teal'}, 'uuid:'+JSON.stringify(e).uuid)
  71. // });
  72. // 8e501b0bde9ce600
  73. // 打印uuid
  74. // alert('getDeviceInfo success: ' + JSON.stringify(e.uuid));
  75. // alert('clientWidth:' + document.documentElement.clientWidth);
  76. // alert('clientWidth:' + document.documentElement.clientHeight);
  77. // alert('devicePixelRatio:' + window.devicePixelRatio);
  78. console.log('getDeviceInfo success: ' + JSON.stringify(e.uuid));
  79. // 正式版打开
  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. console.log(json.memo);
  168. that.$message.error(json.memo);
  169. }
  170. }, function (response) {
  171. console.info(response);
  172. })
  173. }
  174. },
  175. components: {}
  176. }
  177. </script>
  178. <!-- Add "scoped" attribute to limit CSS to this component only -->
  179. <style>
  180. ul, li {
  181. list-style: none;
  182. margin: 0;
  183. padding: 0;
  184. }
  185. .el-header {
  186. padding: 0 !important;
  187. height: 72px !important;
  188. }
  189. .shortElaside {
  190. width: 140px !important;
  191. overflow: hidden;
  192. height: 100%;
  193. float: left;
  194. }
  195. .lognElaside {
  196. width: 256px !important;
  197. overflow: hidden;
  198. height: 100%;
  199. float: left;
  200. }
  201. /deep/ .nav {
  202. width: 60px;
  203. }
  204. .IndexContainer {
  205. position: absolute;
  206. top: 0;
  207. bottom: 0;
  208. left: 0;
  209. right: 0;
  210. background: #F0F2F5;
  211. }
  212. .IndexContainer > .el-container {
  213. width: 100%;
  214. height: 100%;
  215. overflow: hidden;
  216. display: block;
  217. margin: 0 auto;
  218. }
  219. .footer {
  220. position: absolute;
  221. bottom: 0px;
  222. width: 100%;
  223. padding: 10px;
  224. overflow: hidden;
  225. display: block;
  226. margin: 0 auto;
  227. text-align: center;
  228. text-indent: -30%;
  229. font-size: 12px;
  230. color: #BDBDBD;
  231. background: #F0F2F5;
  232. z-index: 222;
  233. }
  234. .el-main {
  235. width: 100%;
  236. height: 100%;
  237. /*min-height: 800px;*/
  238. overflow: hidden;
  239. display: block;
  240. margin: 0 auto;
  241. overflow-y: hidden;
  242. padding: 10px 20px;
  243. }
  244. /*ipad only*/
  245. @media only screen and (max-width: 1366px) {
  246. .lognElaside {
  247. width: 70px !important;
  248. }
  249. .logoContainer img {
  250. display: none !important;
  251. }
  252. .el-main {
  253. padding: 3px !important;
  254. overflow-y: scroll;
  255. }
  256. .el-main > .context {
  257. /*height: 640px;*/
  258. /*overflow-y: scroll;*/
  259. padding: 6px !important;
  260. }
  261. .table {
  262. /*width: 950px;*/
  263. /*overflow-x: scroll;*/
  264. }
  265. .el-dialog {
  266. max-width: 960px;
  267. }
  268. .el-dialog__body {
  269. padding: 3px;
  270. }
  271. .el-transfer__buttons {
  272. width: 60px;
  273. padding: 3px;
  274. }
  275. .el-transfer .el-button + .el-button {
  276. float: right;
  277. }
  278. .el-container.is-vertical {
  279. position: absolute;
  280. left: 140px;
  281. top: 0;
  282. right: 0;
  283. bottom: 0;
  284. height: 100%;
  285. }
  286. .context {
  287. border-radius: 12px;
  288. height: 823px !important;
  289. overflow-y: scroll;
  290. }
  291. .el-dialog {
  292. padding: 5px;
  293. padding-bottom: 15px;
  294. }
  295. }
  296. </style>