index.vue 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539
  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. Inv: 0,
  130. searchList: [],
  131. searchList2: [],
  132. staticData: {}
  133. };
  134. },
  135. onNavigationBarButtonTap(e) {
  136. if (e.float == 'right') {
  137. console.log("你点击了扫一扫")
  138. uni.scanCode({
  139. // success: function(res) {
  140. // console.log('条码类型:' + res.scanType);
  141. // console.log('条码内容:' + res.result);
  142. // }
  143. success: function(res) {
  144. let result = res.result;
  145. if (result.indexOf('http://') == 0 || result.indexOf('https://') == 0) {
  146. //是网址,直接跳转
  147. plus.runtime.openURL(result); //调用手机浏览器
  148. //怎么在APP内跳转网址?
  149. } else {
  150. //不是网址,打印出结果
  151. uni.showToast({
  152. title: res.result
  153. })
  154. }
  155. },
  156. fail: function(err) {
  157. console.log('扫码失败', err)
  158. }
  159. });
  160. } else {
  161. this.showTag()
  162. }
  163. },
  164. created: function() {
  165. // alert('created')
  166. },
  167. mounted() {
  168. document.querySelector('.uni-page-head-hd').style.display = 'none'
  169. },
  170. beforeCreate: function() {
  171. let ua = navigator.userAgent.toLowerCase();
  172. if (ua.match(/MicroMessenger/i) == "micromessenger") {
  173. var appId = "wx4eab2e3b5531d58b";
  174. var params = {};
  175. var url = location.search
  176. this.winUrl = url
  177. var theRequest = new Object()
  178. if (url.indexOf("?") != -1) {
  179. var str = url.substr(1)
  180. var strs = str.split("&")
  181. for (var i = 0; i < strs.length; i++) {
  182. theRequest[strs[i].split("=")[0]] = (strs[i].split("=")[1])
  183. }
  184. }
  185. var CODE = theRequest;
  186. var code = CODE['code'];
  187. // alert(code)
  188. if (code) {
  189. params.code = code;
  190. // alert('code')
  191. //使用code请求服务器接口,换取用户用户openID
  192. uni.request({
  193. url: 'https://qhome.usky.cn/USKYOF/USKYOF.php/Home/Com/getPageAuthorization', //仅为示例,并非真实接口地址。
  194. // data: {
  195. // text: 'uni.request'
  196. // },
  197. method: 'POST',
  198. header: {
  199. 'Content-Type': 'application/x-www-form-urlencoded;charset=UTF-8'
  200. },
  201. success: (res) => {
  202. // alert(res.data.flag)
  203. if (res.data.flag == 3000) {
  204. // alert("3000授权失败,请重新登录");
  205. window.location.href = 'https://qhome.usky.cn/index.html#/';
  206. }
  207. if (res.data.flag == 3003) {
  208. // alert("3003");
  209. uni.navigateTo({
  210. url: '/pages/authority/authority',
  211. });
  212. }
  213. if (res.data.flag == 3002) {
  214. // alert("3002授权失败,请重新登录");
  215. uni.switchTab({
  216. url: '/pages/index/index'
  217. });
  218. // window.location.href = 'https://qhome.usky.cn/index.html#/';
  219. }
  220. }
  221. });
  222. }
  223. var cs = {};
  224. var curl = window.location.href;
  225. cs.curl = curl;
  226. const res1 = this.$myRequest({
  227. url: 'Com/getAuthorizationUrl',
  228. data: cs
  229. })
  230. var turl = res1.data.turl;
  231. window.location.href =
  232. 'https://open.weixin.qq.com/connect/oauth2/authorize?appid=wx4eab2e3b5531d58b&redirect_uri=' +
  233. turl +
  234. '&response_type=code&scope=snsapi_base&state=abc123#wechat_redirect';
  235. } else {
  236. // alert('不是')
  237. //不是
  238. // uni.navigateTo({
  239. // url: '/pages/login/login',
  240. // });
  241. // setTimeout(function() {
  242. // uni.navigateTo({
  243. // url: '/pages/login/login',
  244. // });
  245. // }, 2000);
  246. }
  247. },
  248. onLoad: function(option) {
  249. let ua = navigator.userAgent.toLowerCase();
  250. if (ua.match(/MicroMessenger/i) == "micromessenger") {
  251. var init = this.init();
  252. if (init = "3001") {
  253. this.getData();
  254. }
  255. //是
  256. } else {
  257. this.getData();
  258. //不是
  259. // uni.navigateTo({
  260. // url: '/pages/login/login',
  261. // });
  262. // setTimeout(function() {
  263. // uni.navigateTo({
  264. // url: '/pages/login/login',
  265. // });
  266. // }, 2000);
  267. }
  268. this.hackReset = false;
  269. this.$nextTick(() => {
  270. this.hackReset = true;
  271. })
  272. },
  273. methods: {
  274. // start
  275. getUrlCode() {
  276. var url = location.search
  277. this.winUrl = url
  278. var theRequest = new Object()
  279. if (url.indexOf("?") != -1) {
  280. var str = url.substr(1)
  281. var strs = str.split("&")
  282. for (var i = 0; i < strs.length; i++) {
  283. theRequest[strs[i].split("=")[0]] = (strs[i].split("=")[1])
  284. }
  285. }
  286. return theRequest
  287. },
  288. async init() {
  289. var appId = "wx4eab2e3b5531d58b";
  290. // var appId = "wx8bba7ec467b61efa"; //ming测试公众号
  291. var CODE = this.getUrlCode();
  292. var code = CODE['code'];
  293. var params = {};
  294. if (code) {
  295. params.code = code;
  296. //使用code请求服务器接口,换取用户用户openID
  297. const res = await this.$myRequest({
  298. url: 'Com/getPageAuthorization',
  299. data: params
  300. })
  301. if (res.data.flag == 3000) {
  302. // alert("3000授权失败,");
  303. window.location.href = 'https://qhome.usky.cn/index.html#/';
  304. }
  305. if (res.data.flag == 3003) {
  306. // alert("3003授权失败");
  307. uni.navigateTo({
  308. url: '/pages/authority/authority',
  309. });
  310. }
  311. return res.data.flag;
  312. }
  313. var cs = {};
  314. var curl = window.location.href;
  315. cs.curl = curl;
  316. //
  317. const res1 = await this.$myRequest({
  318. url: 'Com/getAuthorizationUrl',
  319. data: cs
  320. })
  321. var turl = res1.data.turl;
  322. window.location.href =
  323. 'https://open.weixin.qq.com/connect/oauth2/authorize?appid=wx4eab2e3b5531d58b&redirect_uri=' +
  324. turl +
  325. '&response_type=code&scope=snsapi_base&state=abc123#wechat_redirect';
  326. },
  327. // end
  328. async getData() {
  329. const res = await this.$myRequest({
  330. url: 'Index/getDataStatistics',
  331. showLoading: true
  332. })
  333. this.staticData = res.data.data[0]
  334. this.alarmCount = this.staticData.alarmCount
  335. this.cuIconList[0].badge = this.staticData.unprocessedCount
  336. },
  337. handleInput() {
  338. var newlist = this.searchList2.filter(item => item.indexOf(this.searchInput) > -1)
  339. this.searchList = newlist
  340. },
  341. navItemClick(index) {
  342. let url = "";
  343. switch (index) {
  344. case 0:
  345. url = "/pages/siteListAlarming/siteListAlarming"
  346. break;
  347. case 1:
  348. url = "/pages/siteList/siteList"
  349. break;
  350. default:
  351. break;
  352. }
  353. if (url) {
  354. uni.navigateTo({
  355. url: url
  356. })
  357. } else {
  358. uni.showModal({
  359. title: 'Tips',
  360. content: '此模块开发中~',
  361. showCancel: false,
  362. success: function(res) {
  363. if (res.confirm) {} else if (res.cancel) {}
  364. }
  365. });
  366. }
  367. },
  368. showTag() {
  369. this.flag = !this.flag;
  370. },
  371. InputFocus(e) {
  372. this.InputBottom = e.detail.height
  373. },
  374. InputBlur(e) {
  375. this.InputBottom = 0
  376. },
  377. changeTab(Inv) {
  378. that.navIdx = Inv;
  379. },
  380. }
  381. }
  382. //解决IOS返回页面不刷新的问题
  383. history.pushState(null, null, document.URL); //禁止网页返回上一页
  384. window.addEventListener('popstate', function() {
  385. // alert('点击返回按钮了!')
  386. });
  387. </script>
  388. <style lang="scss">
  389. body {
  390. background: #f1f1f1 !important;
  391. }
  392. .select-items {
  393. overflow: auto;
  394. height: 80vh
  395. }
  396. .static-tabs {
  397. border-radius: 50rpx;
  398. border: 1rpx solid #4074E7;
  399. }
  400. .static-tabs>view {
  401. color: #4074E7;
  402. font-size: 30rpx;
  403. }
  404. .static-tabs>view.active {
  405. color: #fff;
  406. background: #4074E7
  407. }
  408. .static-tabs>view:first-child {
  409. border-top-left-radius: 50rpx;
  410. border-bottom-left-radius: 50rpx;
  411. }
  412. .static-tabs>view:nth-child(2) {
  413. border-left: 1px solid #4074E7;
  414. border-right: 1px solid #4074E7
  415. }
  416. .static-tabs>view:last-child {
  417. border-top-right-radius: 50rpx;
  418. border-bottom-right-radius: 50rpx;
  419. }
  420. /* 检测时间 */
  421. .time {
  422. border-radius: 50rpx;
  423. background: #FAFCFF;
  424. border: 1px solid #E8F1FF;
  425. padding: 20rpx;
  426. color: #666666;
  427. font-size: 28rpx;
  428. }
  429. .chart3-box {
  430. position: relative
  431. }
  432. .chart3-icon {
  433. position: absolute;
  434. top: 60rpx;
  435. left: 30rpx
  436. }
  437. .chart3-icon li {
  438. padding-top: 25rpx
  439. }
  440. ul,
  441. li {
  442. padding: 0;
  443. margin: 0;
  444. list-style: none
  445. }
  446. </style>
  447. <style>
  448. .shadow {
  449. box-shadow: 1px 1px 4px rgb(26 26 26 / 10%);
  450. }
  451. </style>