Headside.vue 5.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239
  1. <template>
  2. <div class="headerContainer dv1">
  3. <div class="lt" @click="showfullScreen()">
  4. <em> {{ nowWeeks }}</em> <span> {{ nowDay }}</span>
  5. </div>
  6. <div class="rt">
  7. {{ nowTime }}
  8. <span @click="showUuid()">版本:{{ version }}</span>
  9. <img @click="showConsole()" src="../static/img/blue.svg"/>
  10. <img src="../static/img/wifi.svg"/>
  11. </div>
  12. <el-dialog
  13. title=""
  14. :visible.sync="dialogVisible"
  15. width="60%"
  16. >
  17. <span class="eqSnText">当前设备uuid</span>
  18. <br>
  19. <span class="eqSnText">{{ eqSn }}</span>
  20. <div id='qrcode' class="qrcode" ref="qrCodeUrl">
  21. </div>
  22. <table>
  23. <th>
  24. <td>版本</td>
  25. <td>热点IP</td>
  26. </th>
  27. <tr>
  28. <td>{{currunVersion}}</td>
  29. <td>{{curheadapi}}</td>
  30. </tr>
  31. </table>
  32. <span slot="footer" class="dialog-footer">
  33. <el-button @click="dialogVisible = false">了解</el-button>
  34. </span>
  35. </el-dialog>
  36. </div>
  37. </template>
  38. <script>
  39. import global from '../Global'
  40. import '../libs/rem';
  41. import QRCode from 'qrcodejs2'
  42. export default {
  43. data() {
  44. return {
  45. dialogVisible: false,
  46. lastClickTime: 0,
  47. count:0,
  48. eqSn: localStorage.eqSn,
  49. nowWeeks: '',
  50. nowDay: '',
  51. nowTime: '',
  52. version: '',
  53. currunVersion:runVersion,
  54. curheadapi:headapi,
  55. }
  56. },
  57. mounted() {
  58. this.nowtimer = setInterval(() => {
  59. let date = new Date();
  60. let h = date.getHours() < 10 ? '0' + date.getHours() + ':' : date.getHours() + ':';
  61. let m = date.getMinutes() < 10 ? '0' + date.getMinutes() + ':' : date.getMinutes() + ':';
  62. let s = date.getSeconds() < 10 ? '0' + date.getSeconds() : date.getSeconds();
  63. this.nowTime = h + m + s;
  64. this.nowDayFunc();
  65. // 获取版本号
  66. this.version = localStorage.version;
  67. this.currunVersion = runVersion
  68. this.curheadapi = headapi
  69. }, 1000);
  70. this.getCurVersion();
  71. },
  72. beforeDestroy() {
  73. clearInterval(this.timer);
  74. },
  75. methods: {
  76. // 手动开启输出控制台
  77. showConsole() {
  78. let vconDom = document.getElementById('__vconsole');
  79. this.toggleClass(vconDom,'show')
  80. },
  81. hasClass(obj, cls) {
  82. return obj.className.match(new RegExp('(\\s|^)' + cls + '(\\s|$)'));
  83. },
  84. addClass(obj, cls) {
  85. if (!this.hasClass(obj, cls)) obj.className += " " + cls;
  86. },
  87. toggleClass(obj,cls){
  88. if(this.hasClass(obj,cls)){
  89. this.removeClass(obj, cls);
  90. }else{
  91. this.addClass(obj, cls);
  92. }
  93. },
  94. removeClass(obj, cls) {
  95. if (this.hasClass(obj, cls)) {
  96. var reg = new RegExp('(\\s|^)' + cls + '(\\s|$)');
  97. obj.className = obj.className.replace(reg, ' ');
  98. }
  99. },
  100. // 全屏展示
  101. showfullScreen() {
  102. let elem = document.body;
  103. if (elem.webkitRequestFullScreen) {
  104. elem.webkitRequestFullScreen();
  105. } else if (elem.mozRequestFullScreen) {
  106. elem.mozRequestFullScreen();
  107. } else if (elem.requestFullScreen) {
  108. elem.requestFullscreen();
  109. } else {
  110. notice.notice_show("浏览器不支持全屏API或已被禁用", null, null, null, true, true);
  111. }
  112. },
  113. nowDayFunc() {
  114. let days = new Date().getDay();
  115. let wd = numberToWeekdays(days);
  116. this.nowWeeks = wd;
  117. this.nowDay = globalcurrent();
  118. },
  119. // 获取当前版本
  120. getCurVersion() {
  121. // console.log(version)
  122. },
  123. qrcode(code) {
  124. this.$refs.qrCodeUrl.innerHTML = "";
  125. let qrcode = new QRCode(this.$refs.qrCodeUrl, {
  126. width: 100,
  127. height: 100, // 高度
  128. text: code, // 二维码内容
  129. image: '',
  130. render: 'canvas',// 设置渲染方式(有两种方式 table和canvas,默认是canvas)
  131. background: '#f0f',
  132. foreground: '#ff0',
  133. });
  134. },
  135. showUuid() {
  136. this.eqSn = localStorage.eqSn;
  137. this.dialogVisible = true;
  138. this.$nextTick(function () {
  139. setTimeout(() => {
  140. this.qrcode(localStorage.eqSn);
  141. }, 500);
  142. })
  143. }
  144. }
  145. }
  146. </script>
  147. <style scoped>
  148. .headerContainer {
  149. height: 4%;
  150. overflow: hidden;
  151. display: block;
  152. margin: 0 auto;
  153. margin-top: 1%;
  154. padding: 2%;
  155. background: url("../static/img/logo.svg");
  156. background-position: top center;
  157. background-repeat: no-repeat;
  158. background-size: 14%;
  159. }
  160. * {
  161. font-family: vista;
  162. }
  163. .lt {
  164. width: 40%;
  165. float: left;
  166. font-family: vista;
  167. font-weight: normal;
  168. font-size: 0.4rem;
  169. text-align: left;
  170. color: #fff;
  171. line-height: 20%;
  172. }
  173. .rt {
  174. width: 40%;
  175. float: right;
  176. font-family: vista;
  177. font-weight: normal;
  178. font-size: 0.4rem;
  179. text-align: right;
  180. color: #fff;
  181. line-height: 20%;
  182. padding-right: 14%;
  183. }
  184. .rt img {
  185. position: absolute;
  186. top: 4%;
  187. right: 9%;
  188. padding: 0;
  189. margin: 0;
  190. float: right;
  191. width: 0.4rem;
  192. height: 0.4rem;
  193. }
  194. .rt img:nth-child(2) {
  195. right: 12%;
  196. }
  197. em {
  198. float: left;
  199. font-style: normal;
  200. margin-right: 0.5rem;
  201. }
  202. .rt span {
  203. position: absolute;
  204. top: 4%;
  205. right: 2%;
  206. float: right;
  207. color: #fff;
  208. font-size: 0.2rem;
  209. text-align: center;
  210. background: rgba(0, 0, 0, 0.35);
  211. width: 1.2rem;
  212. height: 0.4rem;
  213. line-height: 0.4rem;
  214. cursor: pointer;
  215. }
  216. #qrcode {
  217. width: 100%;
  218. overflow: hidden;
  219. display: block;
  220. margin: 0 auto;
  221. }
  222. .eqSnText {
  223. font-size: 0.4rem;
  224. }
  225. </style>