index.vue 13 KB

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