index.vue 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570
  1. <template>
  2. <view style="background:#f1f1f1;" class="padding-sm">
  3. <view class="searchSelect shadow" v-if="flag">
  4. <view class="cu-bar search bg-white">
  5. <view class="search-form round">
  6. <input @focus="InputFocus" @blur="InputBlur" @input="handleInput()" v-model="searchInput" :adjust-position="false"
  7. type="text" placeholder="" confirm-type="search"></input>
  8. <text class="cuIcon-search "></text>
  9. </view>
  10. </view>
  11. <view class="select-items">
  12. <view class="select-item" v-for="(item,index) in searchList" @click="clickSelectItem(item,index)" :key="index">{{item}}</view>
  13. </view>
  14. </view>
  15. <view class="section1 section bg-white padding-xs">
  16. <view class=" static-tabs grid margin-bottom text-center col-3 margin-top-sm margin-bottom-sm">
  17. <view :class="['padding-sm ',Inv==0?'active':'']" @click="Inv=0">报警信息统计</view>
  18. <view :class="['padding-sm ',Inv==1?'active':'']" @click="Inv=1">数据等级统计</view>
  19. <view :class="['padding-sm ',Inv==2?'active':'']" @click="Inv=2">设备运行状态</view>
  20. </view>
  21. <view class="time text-center">统计时段:{{staticData.statisticalPeriod}}
  22. </view>
  23. <view style="height:570rpx">
  24. <view v-if="Inv == 0">
  25. <chart :bindData="staticData" v-if="hackReset"></chart>
  26. </view>
  27. <view v-if="Inv == 1">
  28. <chart2 :bindData="staticData"></chart2>
  29. </view>
  30. <view v-if="Inv == 2" class="chart3-box">
  31. <ul class="chart3-icon">
  32. <li>
  33. <image src="../../static/chart3-1.png" style="width:64rpx;height:64rpx"></image>
  34. </li>
  35. <li>
  36. <image src="../../static/chart3-2.png" style="width:64rpx;height:64rpx"></image>
  37. </li>
  38. <li>
  39. <image src="../../static/chart3-3.png" style="width:64rpx;height:64rpx"></image>
  40. </li>
  41. <li>
  42. <image src="../../static/chart3-4.png" style="width:64rpx;height:64rpx"></image>
  43. </li>
  44. <li>
  45. <image src="../../static/chart3-5.png" style="width:64rpx;height:64rpx"></image>
  46. </li>
  47. </ul>
  48. <chart3 :bindData="staticData">
  49. </chart3>
  50. </view>
  51. </view>
  52. </view>
  53. <!-- 宫格列表 -->
  54. <!-- <square :cuIconList="cuIconList"></square> -->
  55. <view class="section2 section bg-white margin-top-sm margin-bottom-sm">
  56. <view class="cu-list grid col-3 no-border">
  57. <view class="cu-item justify-center align-center" @tap=navItemClick(index) v-for="(item,index) in cuIconList" :key="index">
  58. <image :src="item.imgUrl" style="width:100rpx;height:100rpx"></image>
  59. <view class="cu-tag badge" v-if="item.badge!=0">
  60. <block v-if="item.badge!=1">{{item.badge>99?'99+':item.badge}}</block>
  61. </view>
  62. <text>{{item.name}}</text>
  63. </view>
  64. </view>
  65. </view>
  66. </view>
  67. </template>
  68. <script>
  69. import chart from './components/chart/chart.vue';
  70. import chart2 from './components/chart2/chart2.vue';
  71. import chart3 from './components/chart3/chart3.vue';
  72. import chart4 from './components/chart4/chart4.vue';
  73. import json from '../../data/json.js';
  74. export default {
  75. components: {
  76. chart,
  77. chart2,
  78. chart3,
  79. chart4
  80. },
  81. data() {
  82. return {
  83. componentKey: 0,
  84. arr: [],
  85. searchInput: '',
  86. alarmCount: '',
  87. flag: false,
  88. // 宫格列表数据
  89. cuIconList: [{
  90. imgUrl: '../../static/square1.png',
  91. badge: 111,
  92. name: '综合报警',
  93. redirectUrl: '/pages/siteList/siteList?type=1'
  94. }, {
  95. imgUrl: '../../static/square2.png',
  96. badge: 100,
  97. name: '运行监测',
  98. redirectUrl: '/pages/siteList/siteList?type=2'
  99. }, {
  100. imgUrl: '../../static/square-wb.png',
  101. badge: 0,
  102. name: '维保',
  103. redirectUrl: ''
  104. }, {
  105. imgUrl: '../../static/square-bx.png',
  106. badge: 0,
  107. name: '报修',
  108. redirectUrl: ''
  109. }, {
  110. imgUrl: '../../static/square-rl.png',
  111. badge: 0,
  112. name: '人脸识别',
  113. redirectUrl: ''
  114. }, {
  115. imgUrl: '../../static/square-xj.png',
  116. badge: 0,
  117. badge: 0,
  118. name: '巡检',
  119. redirectUrl: ''
  120. }, {
  121. imgUrl: '../../static/square-bz.png',
  122. badge: 0,
  123. badge: 0,
  124. name: '风险保障',
  125. redirectUrl: ''
  126. }],
  127. Inv: 0,
  128. searchList: [],
  129. searchList2: [],
  130. staticData: {}
  131. };
  132. },
  133. onNavigationBarButtonTap(e) {
  134. if (e.float == 'right') {
  135. console.log("你点击了扫一扫")
  136. uni.scanCode({
  137. // success: function(res) {
  138. // console.log('条码类型:' + res.scanType);
  139. // console.log('条码内容:' + res.result);
  140. // }
  141. success: function(res) {
  142. let result = res.result;
  143. if (result.indexOf('http://') == 0 || result.indexOf('https://') == 0) {
  144. //是网址,直接跳转
  145. plus.runtime.openURL(result); //调用手机浏览器
  146. //怎么在APP内跳转网址?
  147. } else {
  148. //不是网址,打印出结果
  149. uni.showToast({
  150. title: res.result
  151. })
  152. }
  153. },
  154. fail: function(err) {
  155. console.log('扫码失败', err)
  156. }
  157. });
  158. } else {
  159. this.showTag()
  160. }
  161. },
  162. created: function() {
  163. // alert('created')
  164. },
  165. beforeCreate: function() {
  166. // alert('beforeCreate')
  167. let ua = navigator.userAgent.toLowerCase();
  168. if (ua.match(/MicroMessenger/i) == "micromessenger") {
  169. // alert('是')
  170. //是
  171. // alert('init')
  172. var appId = "wx4eab2e3b5531d58b";
  173. var params = {};
  174. var url = location.search
  175. this.winUrl = url
  176. var theRequest = new Object()
  177. if (url.indexOf("?") != -1) {
  178. var str = url.substr(1)
  179. var strs = str.split("&")
  180. for (var i = 0; i < strs.length; i++) {
  181. theRequest[strs[i].split("=")[0]] = (strs[i].split("=")[1])
  182. }
  183. }
  184. var CODE = theRequest;
  185. var code = CODE['code'];
  186. // alert(code)
  187. if (code) {
  188. params.code = code;
  189. // alert('code')
  190. //使用code请求服务器接口,换取用户用户openID
  191. uni.request({
  192. url: 'https://qhome.usky.cn/USKYOF/USKYOF.php/Home/Com/getPageAuthorization', //仅为示例,并非真实接口地址。
  193. // data: {
  194. // text: 'uni.request'
  195. // },
  196. method: 'POST',
  197. header: {
  198. 'Content-Type': 'application/x-www-form-urlencoded;charset=UTF-8'
  199. },
  200. success: (res) => {
  201. // alert(res.data.flag)
  202. if (res.data.flag == 3000) {
  203. // alert("3000授权失败,请重新登录");
  204. window.location.href = 'https://qhome.usky.cn/index.html#/';
  205. }
  206. if (res.data.flag == 3003) {
  207. // alert("3003");
  208. uni.navigateTo({
  209. url: '/pages/authority/authority',
  210. });
  211. }
  212. if (res.data.flag == 3002) {
  213. // alert("3002授权失败,请重新登录");
  214. window.location.href = 'https://qhome.usky.cn/index.html#/';
  215. }
  216. }
  217. });
  218. }
  219. var cs = {};
  220. var curl = window.location.href;
  221. cs.curl = curl;
  222. const res1 = this.$myRequest({
  223. url: 'Com/getAuthorizationUrl',
  224. data: cs
  225. })
  226. var turl = res1.data.turl;
  227. window.location.href =
  228. 'https://open.weixin.qq.com/connect/oauth2/authorize?appid=wx4eab2e3b5531d58b&redirect_uri=' + turl +
  229. '&response_type=code&scope=snsapi_base&state=abc123#wechat_redirect';
  230. } else {
  231. // alert('不是')
  232. //不是
  233. // uni.navigateTo({
  234. // url: '/pages/login/login',
  235. // });
  236. // setTimeout(function() {
  237. // uni.navigateTo({
  238. // url: '/pages/login/login',
  239. // });
  240. // }, 2000);
  241. }
  242. },
  243. onLaunch: function() {
  244. // alert('onLaunch')
  245. },
  246. onLoad: function(option) {
  247. // alert('onload')
  248. let ua = navigator.userAgent.toLowerCase();
  249. if (ua.match(/MicroMessenger/i) == "micromessenger") {
  250. // alert('是')
  251. var init=this.init();
  252. if(init="3001"){
  253. this.getData();
  254. this.getSearchList();
  255. }
  256. //是
  257. } else {
  258. this.getData();
  259. this.getSearchList();
  260. // alert('不是')
  261. //不是
  262. // uni.navigateTo({
  263. // url: '/pages/login/login',
  264. // });
  265. // setTimeout(function() {
  266. // uni.navigateTo({
  267. // url: '/pages/login/login',
  268. // });
  269. // }, 2000);
  270. }
  271. this.hackReset = false;
  272. this.$nextTick(() => {
  273. this.hackReset = true;
  274. })
  275. },
  276. methods: {
  277. // start
  278. getUrlCode() {
  279. var url = location.search
  280. this.winUrl = url
  281. var theRequest = new Object()
  282. if (url.indexOf("?") != -1) {
  283. var str = url.substr(1)
  284. var strs = str.split("&")
  285. for (var i = 0; i < strs.length; i++) {
  286. theRequest[strs[i].split("=")[0]] = (strs[i].split("=")[1])
  287. }
  288. }
  289. return theRequest
  290. },
  291. async getUrlPrams(key) {
  292. var reg = new RegExp("(^|&)" + key + "=([^&]*)(&|$)", "i");
  293. var r = window.location.search.substr(1).match(reg); //获取url中"?"符后的字符串并正则匹配
  294. var context = "";
  295. if (r != null) {
  296. context = r[2];
  297. }
  298. return context;
  299. },
  300. async init() {
  301. var appId = "wx4eab2e3b5531d58b";
  302. var params = {};
  303. var CODE = this.getUrlCode();
  304. var code = CODE['code'];
  305. if (code) {
  306. params.code = code;
  307. //使用code请求服务器接口,换取用户用户openID
  308. const res = await this.$myRequest({
  309. url: 'Com/getPageAuthorization',
  310. data: params
  311. })
  312. if (res.data.flag == 3000) {
  313. // alert("3000授权失败,");
  314. window.location.href = 'https://qhome.usky.cn/index.html#/';
  315. }
  316. if (res.data.flag == 3003) {
  317. // alert("3003授权失败");
  318. uni.navigateTo({
  319. url: '/pages/authority/authority',
  320. });
  321. }
  322. return res.data.flag;
  323. }
  324. var cs = {};
  325. var curl = window.location.href;
  326. cs.curl = curl;
  327. const res1 = await this.$myRequest({
  328. url: 'Com/getAuthorizationUrl',
  329. data: cs
  330. })
  331. var turl = res1.data.turl;
  332. window.location.href =
  333. 'https://open.weixin.qq.com/connect/oauth2/authorize?appid=wx4eab2e3b5531d58b&redirect_uri=' + turl +
  334. '&response_type=code&scope=snsapi_base&state=abc123#wechat_redirect';
  335. },
  336. // end
  337. //首页初始化授权
  338. async getPageAuthorization(ming = {}) {
  339. const res = await this.$myRequest({
  340. url: 'Com/getPageAuthorization',
  341. data: ming
  342. })
  343. if (res.data.flag == 3000) {
  344. uni.navigateTo({
  345. url: '/pages/login/login',
  346. });
  347. }
  348. if (res.data.flag == 3002) {
  349. uni.navigateTo({
  350. url: 'https://open.weixin.qq.com/connect/oauth2/authorize?appid=wx4eab2e3b5531d58b&redirect_uri=' + res.data
  351. .tourl + '&response_type=code&scope=snsapi_base&state=abc123#wechat_redirect',
  352. });
  353. }
  354. },
  355. async getData() {
  356. const res = await this.$myRequest({
  357. url: 'Index/getDataStatistics',
  358. showLoading: true
  359. })
  360. this.staticData = res.data.data[0]
  361. this.alarmCount = this.staticData.alarmCount
  362. },
  363. async getSearchList(ming = {}) {
  364. const res = await this.$myRequest({
  365. url: 'Index/getSiteDropDownBox',
  366. data: ming
  367. })
  368. res.data.data.forEach(item => {
  369. this.searchList.push(item.siteName)
  370. this.searchList2.push(item.siteName)
  371. });
  372. },
  373. clickSelectItem(item, index) {
  374. this.getSearchList({
  375. "siteName": item
  376. });
  377. this.flag = false
  378. },
  379. handleInput() {
  380. var newlist = this.searchList2.filter(item => item.indexOf(this.searchInput) > -1)
  381. this.searchList = newlist
  382. },
  383. navItemClick(index) {
  384. let url = "";
  385. switch (index) {
  386. case 0:
  387. url = "/pages/siteListAlarming/siteListAlarming"
  388. break;
  389. case 1:
  390. url = "/pages/siteList/siteList"
  391. break;
  392. default:
  393. break;
  394. }
  395. if (url) {
  396. uni.navigateTo({
  397. url: url
  398. })
  399. } else {
  400. uni.showModal({
  401. title: 'Tips',
  402. content: '此模块开发中~',
  403. showCancel: false,
  404. success: function(res) {
  405. if (res.confirm) {} else if (res.cancel) {}
  406. }
  407. });
  408. }
  409. },
  410. showTag() {
  411. this.flag = !this.flag;
  412. },
  413. InputFocus(e) {
  414. this.InputBottom = e.detail.height
  415. },
  416. InputBlur(e) {
  417. this.InputBottom = 0
  418. },
  419. changeTab(Inv) {
  420. that.navIdx = Inv;
  421. },
  422. }
  423. }
  424. </script>
  425. <style lang="scss">
  426. body {
  427. background: #f1f1f1 !important;
  428. }
  429. .select-items {
  430. overflow: auto;
  431. height: 80vh
  432. }
  433. .static-tabs {
  434. border-radius: 50rpx;
  435. border: 1rpx solid #4074E7;
  436. }
  437. .static-tabs>view {
  438. color: #4074E7;
  439. font-size: 30rpx;
  440. }
  441. .static-tabs>view.active {
  442. color: #fff;
  443. background: #4074E7
  444. }
  445. .static-tabs>view:first-child {
  446. border-top-left-radius: 50rpx;
  447. border-bottom-left-radius: 50rpx;
  448. }
  449. .static-tabs>view:nth-child(2) {
  450. border-left: 1px solid #4074E7;
  451. border-right: 1px solid #4074E7
  452. }
  453. .static-tabs>view:last-child {
  454. border-top-right-radius: 50rpx;
  455. border-bottom-right-radius: 50rpx;
  456. }
  457. /* 检测时间 */
  458. .time {
  459. border-radius: 50rpx;
  460. background: #FAFCFF;
  461. border: 1px solid #E8F1FF;
  462. padding: 20rpx;
  463. color: #666666;
  464. font-size: 28rpx;
  465. }
  466. .chart3-box {
  467. position: relative
  468. }
  469. .chart3-icon {
  470. position: absolute;
  471. top: 60rpx;
  472. left: 30rpx
  473. }
  474. .chart3-icon li {
  475. padding-top: 25rpx
  476. }
  477. ul,
  478. li {
  479. padding: 0;
  480. margin: 0;
  481. list-style: none
  482. }
  483. </style>
  484. <style>
  485. .shadow {
  486. box-shadow: 1px 1px 4px rgb(26 26 26 / 10%);
  487. }
  488. </style>