index.vue 10 KB

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