Index.vue 8.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366
  1. <template>
  2. <div :class="[{'IndexContainer':true}]" :style="{height:clientHeight}">
  3. <keep-alive>
  4. <router-view></router-view>
  5. </keep-alive>
  6. <el-dialog
  7. title="请输入设备信息"
  8. :visible.sync="viewMode"
  9. width="30%">
  10. <el-input v-model="viewEqSn" placeholder="请输入设备编码"/>
  11. <el-input v-model="viewVersion" placeholder="请输入设备版本号"/>
  12. <span slot="footer" class="dialog-footer">
  13. <el-button @click="viewMode = false">取 消</el-button>
  14. <el-button type="primary" @click="changeEqSn()">确 定</el-button>
  15. </span>
  16. </el-dialog>
  17. </div>
  18. </template>
  19. <script>
  20. import {
  21. QueryVueFramework
  22. } from '@/api/getApiRes'
  23. import "../../public/mui.js"
  24. import '../Global'
  25. let qs = require('qs');
  26. export default {
  27. name: 'Home',
  28. data() {
  29. return {
  30. handleTabsList: [{
  31. title: '系统首页',
  32. name: '1',
  33. clmurl: '/',
  34. }],
  35. autoUpdate: false,
  36. curVersion: '1.0.1',
  37. viewEqSn: localStorage.eqSn,
  38. viewVersion: localStorage.version,
  39. isPad: true,//pad 展示版本
  40. viewMode: false,//pad 展示版本
  41. clientHeight: document.documentElement.clientHeight + 'px'
  42. }
  43. },
  44. mounted() {
  45. // alert('clientWidth:' + document.documentElement.clientWidth);
  46. // alert('devicePixelRatio:' + window.devicePixelRatio);
  47. //浏览器运行时打开注释
  48. // localStorage.eqSn = '30:9C:23:0C:8B:1E';
  49. // localStorage.version = '1.1.0';
  50. this.viewMode = isViewMode;
  51. this.isMui();
  52. },
  53. methods: {
  54. changeEqSn() {
  55. let that = this;
  56. localStorage.eqSn = that.viewEqSn;
  57. localStorage.version = that.viewVersion;
  58. this.plusReady();
  59. that.viewMode = false;
  60. },
  61. isMui() {
  62. let that = this;
  63. //mui is ready
  64. if (window.plus) {
  65. //先检查升级
  66. if (runVersion != versionOffLine) {
  67. that.checkReleaseUpdate();//正式版
  68. } else {
  69. that.checkTestUpdate();//线下版
  70. }
  71. if (typeof plus == 'undefined') return false;
  72. if (!that.viewMode) {
  73. //获取本地应用资源版本号
  74. plus.runtime.getProperty(plus.runtime.appid, function (inf) {
  75. localStorage.version = inf.version;
  76. that.curVersion = inf.version;
  77. console.log("inf:", inf);
  78. });
  79. //获取手机UUID
  80. plus.device.getInfo({
  81. success: function (e) {
  82. let uuid = JSON.stringify(e.uuid).toString().substr(1);
  83. uuid = uuid.substring(0, uuid.length - 1);
  84. localStorage.eqSn = uuid;
  85. console.log('===== uuid =====:' + uuid + '\ngetDeviceInfo success: ' + JSON.stringify(e.uuid));
  86. },
  87. fail: function (e) {
  88. console.log('getDeviceInfo failed: ' + JSON.stringify(e));
  89. }
  90. });
  91. this.plusReady();
  92. }
  93. } else {
  94. console.log('mui is not ready');
  95. this.getServeIpAddress(localStorage.eqSn);
  96. document.addEventListener('plusready', plusReady, false);
  97. }
  98. },
  99. //获取当前版本号
  100. plusReady() {
  101. let that = this;
  102. // 获取转发端口地址
  103. that.getServeIpAddress(localStorage.eqSn);
  104. },
  105. //获取转发端地址
  106. getServeIpAddress(eqSn) {
  107. const that = this;
  108. //正式版请求转发段地址的url
  109. let url = 'http://cal.beswell.com:85/v1/Sensors/GetShopConfigParam'
  110. //测试版请求转发段地址的url
  111. if (runVersion == versionOffLine) {
  112. url = "http://192.168.0.3:19096/v1/Sensors/GetShopConfigParam";
  113. }
  114. console.log("url:" + url + "\neqSn:" + eqSn);
  115. let param = {eqSn: eqSn};
  116. let postData = qs.stringify(param);
  117. axios.post(url, postData).then(function (data) {
  118. let json = data.data;
  119. if (json.Code == 0) {
  120. headapi = json.Rs.DataServiceIP;
  121. } else {
  122. headapi = 'http://221.214.111.254:9000/';
  123. console.log(json.memo);
  124. that.$message.error(json.memo);
  125. }
  126. }, function (response) {
  127. console.info(response);
  128. })
  129. }
  130. ,
  131. //检查测试版本升级
  132. checkTestUpdate() {
  133. let that = this;
  134. let url = 'http://192.168.0.3:19096/v1/Sensors/QueryVueFramework';
  135. let param = {};
  136. let postData = qs.stringify(param);
  137. axios.post(url, postData).then(function (data) {
  138. let json = data.data;
  139. console.log("checkTestUpdate", json);
  140. if (json.Code == 0) {
  141. if (localStorage.version != json.VueFramework.Version) {
  142. // 测试版本下载
  143. let testVersion = "http://192.168.0.3:19096/v1/Sensors/DownloadVueFramework";
  144. that.downWgt(testVersion);
  145. }
  146. } else {
  147. console.log(json.Memo);
  148. }
  149. }, function (response) {
  150. console.info(response);
  151. })
  152. }
  153. ,
  154. //检查正式版本升级
  155. checkReleaseUpdate() {
  156. let param = {};
  157. let postData = qs.stringify(param);
  158. QueryVueFramework(postData).then(res => {
  159. let json = res;
  160. console.log("checkReleaseUpdate", json);
  161. if (json.Code == 0) {
  162. console.log('localStorage.version' + localStorage.version);
  163. //正式
  164. if (localStorage.version != json.VueFramework.Version) {
  165. let releaseVersion = "http://cal.beswell.com:85/v1/Sensors/DownloadVueFramework";
  166. this.downWgt(releaseVersion);
  167. }
  168. }
  169. })
  170. },
  171. downWgt(url) {
  172. let that = this;
  173. plus.downloader.createDownload(url, {filename: "_doc/update/"}, function (d, status) {
  174. if (status == 200) {
  175. console.log(d);
  176. console.log("下载wgt成功:" + d.filename);
  177. that.installWgt(d.filename);
  178. } else {
  179. console.log("下载wgt失败!");
  180. }
  181. plus.nativeUI.closeWaiting();
  182. }).start();
  183. },
  184. //安装wgt包
  185. installWgt(path) {
  186. plus.runtime.install(path, {}, function () {
  187. plus.nativeUI.closeWaiting();
  188. console.log("安装wgt文件成功!");
  189. plus.runtime.restart();
  190. }, function (e) {
  191. plus.nativeUI.closeWaiting();
  192. console.log("安装wgt文件失败[" + e.code + "]:" + e.message);
  193. });
  194. }
  195. },
  196. components: {}
  197. }
  198. </script>
  199. <!-- Add "scoped" attribute to limit CSS to this component only -->
  200. <style>
  201. ul, li {
  202. list-style: none;
  203. margin: 0;
  204. padding: 0;
  205. }
  206. .el-header {
  207. padding: 0 !important;
  208. height: 72px !important;
  209. }
  210. .shortElaside {
  211. width: 140px !important;
  212. overflow: hidden;
  213. height: 100%;
  214. float: left;
  215. }
  216. .lognElaside {
  217. width: 256px !important;
  218. overflow: hidden;
  219. height: 100%;
  220. float: left;
  221. }
  222. /deep/ .nav {
  223. width: 60px;
  224. }
  225. .IndexContainer {
  226. position: absolute;
  227. top: 0;
  228. bottom: 0;
  229. left: 0;
  230. right: 0;
  231. background: #F0F2F5;
  232. height: 100%;
  233. overflow-y: scroll;
  234. }
  235. /*演示版专供*/
  236. .isPad {
  237. height: 11.2rem;
  238. }
  239. .IndexContainer > .el-container {
  240. width: 100%;
  241. height: 100%;
  242. overflow: hidden;
  243. display: block;
  244. margin: 0 auto;
  245. }
  246. .footer {
  247. position: absolute;
  248. bottom: 0px;
  249. width: 100%;
  250. padding: 10px;
  251. overflow: hidden;
  252. display: block;
  253. margin: 0 auto;
  254. text-align: center;
  255. text-indent: -30%;
  256. font-size: 12px;
  257. color: #BDBDBD;
  258. background: #F0F2F5;
  259. z-index: 222;
  260. }
  261. .el-main {
  262. width: 100%;
  263. height: 100%;
  264. /*min-height: 800px;*/
  265. overflow: hidden;
  266. display: block;
  267. margin: 0 auto;
  268. overflow-y: hidden;
  269. padding: 10px 20px;
  270. }
  271. /*ipad only*/
  272. @media only screen and (max-width: 1366px) {
  273. .lognElaside {
  274. width: 70px !important;
  275. }
  276. .logoContainer img {
  277. display: none !important;
  278. }
  279. .el-main {
  280. padding: 3px !important;
  281. overflow-y: scroll;
  282. }
  283. .el-main > .context {
  284. /*height: 640px;*/
  285. /*overflow-y: scroll;*/
  286. padding: 6px !important;
  287. }
  288. .table {
  289. /*width: 950px;*/
  290. /*overflow-x: scroll;*/
  291. }
  292. .el-dialog {
  293. max-width: 960px;
  294. }
  295. .el-dialog__body {
  296. padding: 3px;
  297. }
  298. .el-transfer__buttons {
  299. width: 60px;
  300. padding: 3px;
  301. }
  302. .el-transfer .el-button + .el-button {
  303. float: right;
  304. }
  305. .el-container.is-vertical {
  306. position: absolute;
  307. left: 140px;
  308. top: 0;
  309. right: 0;
  310. bottom: 0;
  311. height: 100%;
  312. }
  313. .context {
  314. border-radius: 12px;
  315. height: 823px !important;
  316. overflow-y: scroll;
  317. }
  318. .el-dialog {
  319. padding: 5px;
  320. padding-bottom: 15px;
  321. }
  322. }
  323. #__vconsole {
  324. display: none;
  325. }
  326. #__vconsole.show {
  327. display: block;
  328. }
  329. </style>