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