index.vue 13 KB

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