index.vue 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527
  1. <template>
  2. <view style="background:#f1f1f1;" class="padding-sm">
  3. <!-- 下拉选择 -->
  4. <view class="searchSelect shadow" v-if="flag">
  5. <view class="cu-bar search bg-white">
  6. <view class="search-form round" style="margin-top:0">
  7. <input @focus="InputFocus" @blur="InputBlur" @input="handleInput()" v-model="searchInput"
  8. :adjust-position="false" type="text" placeholder="" confirm-type="search"
  9. style="border:none!important"></input>
  10. <text class="cuIcon-search "></text>
  11. </view>
  12. </view>
  13. <view class="select-items">
  14. <view class=" site-item" v-if="!searchList.length" style="text-align:center">暂无结果</view>
  15. <view class="select-item" v-for="(item,index) in searchList" @click="clickSelectItem(item,index)"
  16. :key="index">{{item.owner_name}}</view>
  17. </view>
  18. </view>
  19. <!-- 下拉选择 end -->
  20. <!-- 图表 -->
  21. <view class="section1 section bg-white padding-xs">
  22. <view class=" static-tabs grid margin-bottom text-center col-3 margin-top-sm margin-bottom-sm">
  23. <view :class="['padding-sm ',Inv==0?'active':'']" @click="Inv=0">报警信息统计</view>
  24. <view :class="['padding-sm ',Inv==1?'active':'']" @click="Inv=1">数据等级统计</view>
  25. <view :class="['padding-sm ',Inv==2?'active':'']" @click="Inv=2">设备运行状态</view>
  26. </view>
  27. <view class="time text-center">统计时段:{{staticData.statisticalPeriod}}
  28. </view>
  29. <view style="height:570rpx">
  30. <view v-if="Inv == 0">
  31. <chart :fbindData="staticData" :findicator="indicator" :fdatavalue="datavalue" v-if="staticData!= '' && hackReset && JSON.stringify(staticData) != '{}'"></chart>
  32. </view>
  33. <view v-if="Inv == 1">
  34. <chart2 v-if="staticData!= ''" :bindData="staticData"></chart2>
  35. </view>
  36. <view v-if="Inv == 2" class="chart3-box">
  37. <ul class="chart3-icon">
  38. <li @tap="goOfflineList()">
  39. <image src="../../static/chart3-1.png" style="width:64rpx;height:64rpx"></image>
  40. </li>
  41. <li>
  42. <image src="../../static/chart3-2.png" style="width:64rpx;height:64rpx"></image>
  43. </li>
  44. <li>
  45. <image src="../../static/chart3-3.png" style="width:64rpx;height:64rpx"></image>
  46. </li>
  47. <li>
  48. <image src="../../static/chart3-4.png" style="width:64rpx;height:64rpx"></image>
  49. </li>
  50. <li @tap="goNormalList()">
  51. <image src="../../static/chart3-5.png" style="width:64rpx;height:64rpx"></image>
  52. </li>
  53. </ul>
  54. <chart3 v-if="staticData!= ''" :bindData="staticData">
  55. </chart3>
  56. </view>
  57. </view>
  58. </view>
  59. <!-- 图表 end-->
  60. <!-- 宫格列表 -->
  61. <view class="section2 section bg-white margin-top-sm margin-bottom-sm">
  62. <view class="cu-list grid col-3 no-border">
  63. <view class="cu-item justify-center align-center" @tap=navItemClick(index)
  64. v-for="(item,index) in cuIconList" :key="index">
  65. <image :src="item.imgUrl" style="width:100rpx;height:100rpx"></image>
  66. <view class="cu-tag badge" v-if="item.badge!=0">
  67. <block v-if="item.badge!=0">{{item.badge>99?'99+':item.badge}}</block>
  68. </view>
  69. <text>{{item.name}}</text>
  70. </view>
  71. </view>
  72. </view>
  73. <!-- 宫格列表 end -->
  74. </view>
  75. </template>
  76. <script>
  77. import chart from './components/chart/chart.vue';
  78. import chart2 from './components/chart2/chart2.vue';
  79. import chart3 from './components/chart3/chart3.vue';
  80. import searchSelect from './components/searchSelect/searchSelect.vue';
  81. import json from '../../data/json.js';
  82. //引入js sdk的封装
  83. import * as jwx from '../../util/jssdk.js'
  84. export default {
  85. components: {
  86. chart,
  87. chart2,
  88. chart3,
  89. searchSelect
  90. },
  91. data() {
  92. return {
  93. staticData: '',
  94. indicator:[],
  95. datavalue:[],
  96. dataname:[],
  97. alarmCount: json.staticData.data[0].alarmCount,
  98. cuIconList: json.cuIconList,
  99. Inv: 0,
  100. defaultSite: 0,
  101. flag: false,
  102. searchList: [],
  103. searchList2: [],
  104. searchInput: '',
  105. selectedCode: 10012,
  106. getData: [],
  107. codeResult: '',
  108. };
  109. },
  110. // 自定义导航事件
  111. onNavigationBarButtonTap(e) {
  112. if (e.float == 'right') {
  113. // alert("你点击了扫一扫");
  114. this.scanQRCode();
  115. } else {
  116. // alert("你点击了获取位置");
  117. // this.getLocation()
  118. this.showTag()
  119. }
  120. },
  121. onLoad(option) {
  122. // start
  123. if(window.location.host.indexOf('localhost') != -1 ){
  124. this.getSearchList();
  125. this.getHomeData({
  126. 'company_code': uni.getStorageSync('selectedCode') ? uni.getStorageSync('selectedCode') : this
  127. .defaultSite
  128. });
  129. this.getHandleData({
  130. 'company_code': uni.getStorageSync('selectedCode') ? uni.getStorageSync('selectedCode') : this
  131. .defaultSite
  132. });
  133. }else{
  134. if (option.op) {
  135. // alert('op')
  136. // 首页数据渲染
  137. this.getSearchList();
  138. this.getHomeData({
  139. 'company_code': uni.getStorageSync('selectedCode') ? uni.getStorageSync('selectedCode') : this
  140. .defaultSite
  141. });
  142. this.getHandleData({
  143. 'company_code': uni.getStorageSync('selectedCode') ? uni.getStorageSync('selectedCode') : this
  144. .defaultSite
  145. });
  146. } else {
  147. this.init()
  148. }
  149. }
  150. // end
  151. // if (option.op) {
  152. // // alert('op')
  153. // // 首页数据渲染
  154. // this.getSearchList();
  155. // this.getHomeData({
  156. // 'company_code': uni.getStorageSync('selectedCode') ? uni.getStorageSync('selectedCode') : this
  157. // .defaultSite
  158. // });
  159. // this.getHandleData({
  160. // 'company_code': uni.getStorageSync('selectedCode') ? uni.getStorageSync('selectedCode') : this
  161. // .defaultSite
  162. // });
  163. // } else {
  164. // this.init()
  165. // }
  166. // 首页数据渲染
  167. // this.getSearchList();
  168. // this.getHomeData({
  169. // 'company_code': uni.getStorageSync('selectedCode') ? uni.getStorageSync('selectedCode') : this
  170. // .defaultSite
  171. // });
  172. // this.getHandleData({
  173. // 'company_code': uni.getStorageSync('selectedCode') ? uni.getStorageSync('selectedCode') : this
  174. // .defaultSite
  175. // });
  176. var res = uni.getStorageSync('selectedCode');
  177. var res2 = uni.getStorageSync('selectedName');
  178. if (res) {
  179. uni.setNavigationBarTitle({
  180. title: res2
  181. });
  182. }
  183. // 图表切换渲染
  184. this.hackReset = false;
  185. this.$nextTick(() => {
  186. this.hackReset = true;
  187. })
  188. },
  189. methods: {
  190. async init() {
  191. window.location.href = this.$BASE_URL + "Com/getPageAuthorization1"
  192. },
  193. //扫码
  194. scanQRCode() {
  195. // 将this赋值给that
  196. let that = this;
  197. // 微信公众号获取位置
  198. jwx.configWeiXin(jweixin => {
  199. jweixin.scanQRCode({
  200. needResult: 1, // 默认为0,扫描结果由微信处理,1则直接返回扫描结果,
  201. scanType: ["qrCode", "barCode"], // 可以指定扫二维码还是一维码,默认二者都有
  202. success: function(res) {
  203. setTimeout(function() {
  204. /* 放1000ms后执行的代码 */
  205. alert(res.resultStr)
  206. that.getCodeResult({
  207. "ercode": res.resultStr
  208. })
  209. }, 1000)
  210. }
  211. });
  212. });
  213. },
  214. // 扫码成功后请求
  215. async getCodeResult(param = {}) {
  216. const res = await this.$myRequest({
  217. url: 'ScanPush/scan_push',
  218. data: param
  219. })
  220. if (res.data.flag) {
  221. uni.showToast({
  222. title: '扫码成功',
  223. icon: "none"
  224. })
  225. }
  226. },
  227. //获取地理位置
  228. getLocation() {
  229. alert(2)
  230. // 将this赋值给that
  231. let that = this;
  232. // 微信公众号获取位置
  233. jwx.configWeiXin(jweixin => {
  234. alert(22)
  235. jweixin.getLocation({
  236. type: 'gcj02', // 默认为wgs84的gps坐标,如果要返回直接给openLocation用的火星坐标,可传入'gcj02'
  237. success: function(res) {
  238. alert(res.longitude)
  239. }
  240. });
  241. });
  242. },
  243. // 九宫格页面跳转
  244. navItemClick(index) {
  245. let url = "";
  246. switch (index) {
  247. case 0:
  248. url = "/pages/alarmingList/alarmingList"
  249. break;
  250. case 1:
  251. url = "/pages/deviceType/deviceType"
  252. break;
  253. case 2:
  254. url = "/pages/inspectList/inspectList"
  255. break;
  256. case 3:
  257. url = "/pages/xunJian/xunJian"
  258. break;
  259. case 4:
  260. url = "/pages/repair/repair"
  261. break;
  262. case 5:
  263. url = "/pages/weiBao/weiBao"
  264. break;
  265. case 6:
  266. url = "/pages/videoList/videoList"
  267. break;
  268. case 7:
  269. url = "/pages/safeGuard/safeGuard"
  270. break;
  271. // case 8:
  272. // url = "/pages/test/test"
  273. // break;
  274. case 9:
  275. url = "/pages/deviceManage/deviceManage"
  276. break;
  277. case 10:
  278. url = "/pages/accountManage/accountManage"
  279. break;
  280. default:
  281. break;
  282. }
  283. if (url) {
  284. uni.navigateTo({
  285. url: url
  286. })
  287. } else {
  288. uni.showModal({
  289. title: 'Tips',
  290. content: '此模块开发中~',
  291. showCancel: false,
  292. success: function(res) {
  293. if (res.confirm) {} else if (res.cancel) {}
  294. }
  295. });
  296. }
  297. },
  298. // 页面跳转
  299. goOfflineList() {
  300. uni.navigateTo({
  301. url: '/pages/deviceOffLine/deviceOffLine?status_type=1',
  302. });
  303. },
  304. goNormalList() {
  305. uni.navigateTo({
  306. url: '/pages/deviceOffLine/deviceOffLine?status_type=2',
  307. });
  308. },
  309. //站点下拉请求
  310. async getSearchList(param = {}) {
  311. const res = await this.$myRequest({
  312. url: 'Index/getCompanyList',
  313. data: param
  314. })
  315. this.getData = res.data.data
  316. this.defaultSite = this.getData[0].owner_code;
  317. if (!uni.getStorageSync('selectedCode')) {
  318. uni.setStorageSync('selectedCode', this.getData[0].owner_code);
  319. uni.setStorageSync('selectedName', this.getData[0].owner_name);
  320. }
  321. res.data.data.forEach(item => {
  322. this.searchList.push(item)
  323. this.searchList2.push(item);
  324. });
  325. },
  326. showTag() {
  327. this.flag = !this.flag;
  328. },
  329. // 下拉选择
  330. clickSelectItem(item, index) {
  331. this.staticData = '';
  332. this.selectedCode = item.owner_code;
  333. uni.setStorageSync('selectedCode', item.owner_code);
  334. uni.setStorageSync('selectedName', item.owner_name);
  335. this.searchInput = item.owner_name;
  336. uni.setNavigationBarTitle({
  337. title: this.searchInput
  338. });
  339. this.getHomeData({
  340. 'company_code': uni.getStorageSync('selectedCode')
  341. });
  342. this.getHandleData({
  343. 'company_code': uni.getStorageSync('selectedCode')
  344. });
  345. this.flag = false;
  346. },
  347. handleInput() {
  348. var newlist = this.searchList2.filter(item => item.owner_name.indexOf(this.searchInput) > -1);
  349. this.searchList = newlist
  350. },
  351. InputFocus(e) {
  352. this.InputBottom = e.detail.height
  353. },
  354. InputBlur(e) {
  355. this.InputBottom = 0
  356. },
  357. changeTab(Inv) {
  358. that.navIdx = Inv;
  359. },
  360. //echarts图表请求
  361. async getHomeData(param = {}) {
  362. const res = await this.$myRequest({
  363. url: 'Index/getHomePageData',
  364. data: param
  365. })
  366. // console.log('首页请求staticData')
  367. // console.log(res.data.data[0])
  368. this.staticData = res.data.data[0];
  369. // var data = res.data.data[0]
  370. var datavalue = [this.staticData.fire_water_count, this.staticData.alarm_host_count, this.staticData.electrical_fire_count, this.staticData.other_count, this.staticData.video_monitoring_count
  371. ]
  372. var dataname = ['消防水系统', '报警主机', '电气火灾', '其他', '监控视频']
  373. var color = ['#3C8BF0', '#06CDF8', '#0ECB70', '#6744EF', '#FFD803'];
  374. var aa = [this.staticData.fire_water_count, this.staticData.alarm_host_count, this.staticData
  375. .electrical_fire_count, this.staticData.other_count, this.staticData.video_monitoring_count
  376. ]
  377. aa.sort(function(a, b) {
  378. return a - b;
  379. });
  380. aa = aa.pop();
  381. var datamax = [aa, aa, aa, aa, aa];
  382. this.datavalue = datavalue;
  383. this.dataname=dataname;
  384. dataname.map((val, ind) => {
  385. this.indicator.push({
  386. name: val,
  387. max: datamax[ind],
  388. color: color[ind]
  389. })
  390. })
  391. this.indicator=this.indicator.slice(-5)
  392. },
  393. // 未处理告警请求
  394. async getHandleData(param = {}) {
  395. const res = await this.$myRequest({
  396. url: 'Index/getFunctionalModuleStatistics',
  397. showLoading: true,
  398. data: param
  399. })
  400. this.cuIconList[0].badge = res.data.data[0].comprehensive_alarm_count;
  401. this.cuIconList[2].badge = res.data.data[0].fire_brigade_inspector_count
  402. },
  403. }
  404. }
  405. </script>
  406. <style >
  407. body {
  408. background: #f1f1f1 !important;
  409. }
  410. .select-items {
  411. overflow: auto;
  412. height: 80vh
  413. }
  414. .static-tabs {
  415. border-radius: 50rpx;
  416. border: 1rpx solid #4074E7;
  417. }
  418. .static-tabs>view {
  419. color: #4074E7;
  420. font-size: 30rpx;
  421. }
  422. .static-tabs>view.active {
  423. color: #fff;
  424. background: #4074E7
  425. }
  426. .static-tabs>view:first-child {
  427. border-top-left-radius: 50rpx;
  428. border-bottom-left-radius: 50rpx;
  429. }
  430. .static-tabs>view:nth-child(2) {
  431. border-left: 1px solid #4074E7;
  432. border-right: 1px solid #4074E7
  433. }
  434. .static-tabs>view:last-child {
  435. border-top-right-radius: 50rpx;
  436. border-bottom-right-radius: 50rpx;
  437. }
  438. /* 检测时间 */
  439. .time {
  440. border-radius: 50rpx;
  441. background: #FAFCFF;
  442. border: 1px solid #E8F1FF;
  443. padding: 20rpx;
  444. color: #666666;
  445. font-size: 30rpx;
  446. }
  447. .chart3-box {
  448. position: relative
  449. }
  450. .chart3-icon {
  451. width: 90%;
  452. position: absolute;
  453. top: 60rpx;
  454. left: 30rpx;
  455. z-index: 1;
  456. }
  457. .chart3-icon li {
  458. padding-top: 25rpx
  459. }
  460. ul,
  461. li {
  462. padding: 0;
  463. margin: 0;
  464. list-style: none
  465. }
  466. .shadow {
  467. box-shadow: 1px 1px 4px rgb(26 26 26 / 10%);
  468. }
  469. </style>
  470. <style>
  471. </style>