index.vue 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547
  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://wx.ewoogi.com:8081/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://wx.ewoogi.com:8081/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. }
  225. }
  226. });
  227. }
  228. var cs = {};
  229. var curl = window.location.href;
  230. cs.curl = curl;
  231. const res1 = this.$myRequest({
  232. url: 'Com/getAuthorizationUrl',
  233. data: cs
  234. })
  235. var turl = res1.data.turl;
  236. window.location.href =
  237. 'https://open.weixin.qq.com/connect/oauth2/authorize?appid=wx4eab2e3b5531d58b&redirect_uri=' +
  238. turl +
  239. '&response_type=code&scope=snsapi_base&state=abc123#wechat_redirect';
  240. } else {
  241. // alert('不是')
  242. //不是
  243. // uni.navigateTo({
  244. // url: '/pages/login/login',
  245. // });
  246. // setTimeout(function() {
  247. // uni.navigateTo({
  248. // url: '/pages/login/login',
  249. // });
  250. // }, 2000);
  251. }
  252. },
  253. onLoad: function(option) {
  254. let ua = navigator.userAgent.toLowerCase();
  255. if (ua.match(/MicroMessenger/i) == "micromessenger") {
  256. var init = this.init();
  257. if (init = "3001") {
  258. this.getData();
  259. }
  260. //是
  261. } else {
  262. this.getData();
  263. //不是
  264. // uni.navigateTo({
  265. // url: '/pages/login/login',
  266. // });
  267. // setTimeout(function() {
  268. // uni.navigateTo({
  269. // url: '/pages/login/login',
  270. // });
  271. // }, 2000);
  272. }
  273. this.hackReset = false;
  274. this.$nextTick(() => {
  275. this.hackReset = true;
  276. })
  277. },
  278. methods: {
  279. // start
  280. getUrlCode() {
  281. var url = location.search
  282. this.winUrl = url
  283. var theRequest = new Object()
  284. if (url.indexOf("?") != -1) {
  285. var str = url.substr(1)
  286. var strs = str.split("&")
  287. for (var i = 0; i < strs.length; i++) {
  288. theRequest[strs[i].split("=")[0]] = (strs[i].split("=")[1])
  289. }
  290. }
  291. return theRequest
  292. },
  293. async init() {
  294. var appId = "wx4eab2e3b5531d58b";
  295. // var appId = "wx8bba7ec467b61efa"; //ming测试公众号
  296. var CODE = this.getUrlCode();
  297. var code = CODE['code'];
  298. var params = {};
  299. if (code) {
  300. params.code = code;
  301. //使用code请求服务器接口,换取用户用户openID
  302. const res = await this.$myRequest({
  303. url: 'Com/getPageAuthorization',
  304. data: params
  305. })
  306. if (res.data.flag == 3000) {
  307. // alert("3000授权失败,");
  308. window.location.href = 'https://wx.ewoogi.com:8081/index.html#/';
  309. }
  310. if (res.data.flag == 3003) {
  311. // alert("3003授权失败");
  312. uni.navigateTo({
  313. url: '/pages/authority/authority',
  314. });
  315. }
  316. return res.data.flag;
  317. }
  318. var cs = {};
  319. var curl = window.location.href;
  320. cs.curl = curl;
  321. //
  322. const res1 = await this.$myRequest({
  323. url: 'Com/getAuthorizationUrl',
  324. data: cs
  325. })
  326. var turl = res1.data.turl;
  327. window.location.href =
  328. 'https://open.weixin.qq.com/connect/oauth2/authorize?appid=wx4eab2e3b5531d58b&redirect_uri=' +
  329. turl +
  330. '&response_type=code&scope=snsapi_base&state=abc123#wechat_redirect';
  331. },
  332. // end
  333. async getData() {
  334. const res = await this.$myRequest({
  335. url: 'Index/getDataStatistics',
  336. showLoading: true
  337. })
  338. this.staticData = res.data.data[0]
  339. this.alarmCount = this.staticData.alarmCount
  340. this.cuIconList[0].badge = this.staticData.unprocessedCount
  341. },
  342. handleInput() {
  343. var newlist = this.searchList2.filter(item => item.indexOf(this.searchInput) > -1)
  344. this.searchList = newlist
  345. },
  346. navItemClick(index) {
  347. let url = "";
  348. switch (index) {
  349. case 0:
  350. url = "/pages/siteListAlarming/siteListAlarming"
  351. break;
  352. case 1:
  353. url = "/pages/siteList/siteList"
  354. break;
  355. case 7:
  356. url = "/pages/eleControl/eleControl"
  357. break;
  358. default:
  359. break;
  360. }
  361. if (url) {
  362. uni.navigateTo({
  363. url: url
  364. })
  365. } else {
  366. uni.showModal({
  367. title: 'Tips',
  368. content: '此模块开发中~',
  369. showCancel: false,
  370. success: function(res) {
  371. if (res.confirm) {} else if (res.cancel) {}
  372. }
  373. });
  374. }
  375. },
  376. showTag() {
  377. this.flag = !this.flag;
  378. },
  379. InputFocus(e) {
  380. this.InputBottom = e.detail.height
  381. },
  382. InputBlur(e) {
  383. this.InputBottom = 0
  384. },
  385. changeTab(Inv) {
  386. that.navIdx = Inv;
  387. },
  388. }
  389. }
  390. //解决IOS返回页面不刷新的问题
  391. history.pushState(null, null, document.URL); //禁止网页返回上一页
  392. window.addEventListener('popstate', function() {
  393. // alert('点击返回按钮了!')
  394. });
  395. </script>
  396. <style lang="scss">
  397. body {
  398. background: #f1f1f1 !important;
  399. }
  400. .select-items {
  401. overflow: auto;
  402. height: 80vh
  403. }
  404. .static-tabs {
  405. border-radius: 50rpx;
  406. border: 1rpx solid #4074E7;
  407. }
  408. .static-tabs>view {
  409. color: #4074E7;
  410. font-size: 30rpx;
  411. }
  412. .static-tabs>view.active {
  413. color: #fff;
  414. background: #4074E7
  415. }
  416. .static-tabs>view:first-child {
  417. border-top-left-radius: 50rpx;
  418. border-bottom-left-radius: 50rpx;
  419. }
  420. .static-tabs>view:nth-child(2) {
  421. border-left: 1px solid #4074E7;
  422. border-right: 1px solid #4074E7
  423. }
  424. .static-tabs>view:last-child {
  425. border-top-right-radius: 50rpx;
  426. border-bottom-right-radius: 50rpx;
  427. }
  428. /* 检测时间 */
  429. .time {
  430. border-radius: 50rpx;
  431. background: #FAFCFF;
  432. border: 1px solid #E8F1FF;
  433. padding: 20rpx;
  434. color: #666666;
  435. font-size: 28rpx;
  436. }
  437. .chart3-box {
  438. position: relative
  439. }
  440. .chart3-icon {
  441. position: absolute;
  442. top: 60rpx;
  443. left: 30rpx
  444. }
  445. .chart3-icon li {
  446. padding-top: 25rpx
  447. }
  448. ul,
  449. li {
  450. padding: 0;
  451. margin: 0;
  452. list-style: none
  453. }
  454. </style>
  455. <style>
  456. .shadow {
  457. box-shadow: 1px 1px 4px rgb(26 26 26 / 10%);
  458. }
  459. </style>