index.vue 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435
  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. <!-- <search-Select :flag="flag"></search-Select> -->
  21. <!-- 图表 -->
  22. <view class="section1 section bg-white padding-xs">
  23. <view class=" static-tabs grid margin-bottom text-center col-3 margin-top-sm margin-bottom-sm">
  24. <view :class="['padding-sm ',Inv==0?'active':'']" @click="Inv=0">报警信息统计</view>
  25. <view :class="['padding-sm ',Inv==1?'active':'']" @click="Inv=1">数据等级统计</view>
  26. <view :class="['padding-sm ',Inv==2?'active':'']" @click="Inv=2">设备运行状态</view>
  27. </view>
  28. <view class="time text-center">统计时段:{{staticData.statisticalPeriod}}
  29. </view>
  30. <view style="height:570rpx">
  31. <view v-if="Inv == 0">
  32. <chart :bindData="staticData" v-if="hackReset&& JSON.stringify(staticData) != '{}'"></chart>
  33. </view>
  34. <view v-if="Inv == 1">
  35. <chart2 :bindData="staticData"></chart2>
  36. </view>
  37. <view v-if="Inv == 2" class="chart3-box">
  38. <ul class="chart3-icon">
  39. <li @tap="goOfflineList()">
  40. <image src="../../static/chart3-1.png" style="width:64rpx;height:64rpx"></image>
  41. </li>
  42. <li @tap="goFaultList()">
  43. <image src="../../static/chart3-2.png" style="width:64rpx;height:64rpx"></image>
  44. </li>
  45. <li>
  46. <image src="../../static/chart3-3.png" style="width:64rpx;height:64rpx"></image>
  47. </li>
  48. <li>
  49. <image src="../../static/chart3-4.png" style="width:64rpx;height:64rpx"></image>
  50. </li>
  51. <li>
  52. <image src="../../static/chart3-5.png" style="width:64rpx;height:64rpx"></image>
  53. </li>
  54. </ul>
  55. <chart3 :bindData="staticData">
  56. </chart3>
  57. </view>
  58. </view>
  59. </view>
  60. <!-- 图表 end-->
  61. <!-- 宫格列表 -->
  62. <view class="section2 section bg-white margin-top-sm margin-bottom-sm">
  63. <view class="cu-list grid col-3 no-border">
  64. <view class="cu-item justify-center align-center" @tap=navItemClick(index)
  65. v-for="(item,index) in cuIconList" :key="index">
  66. <image :src="item.imgUrl" style="width:100rpx;height:100rpx"></image>
  67. <view class="cu-tag badge" v-if="item.badge!=0">
  68. <block v-if="item.badge!=1">{{item.badge>99?'99+':item.badge}}</block>
  69. </view>
  70. <text>{{item.name}}</text>
  71. </view>
  72. </view>
  73. </view>
  74. <!-- 宫格列表 end -->
  75. </view>
  76. </template>
  77. <script>
  78. import chart from './components/chart/chart.vue';
  79. import chart2 from './components/chart2/chart2.vue';
  80. import chart3 from './components/chart3/chart3.vue';
  81. import searchSelect from './components/searchSelect/searchSelect.vue';
  82. import json from '../../data/json.js';
  83. //引入js sdk的封装
  84. import * as jwx from '../../util/jssdk.js'
  85. export default {
  86. components: {
  87. chart,
  88. chart2,
  89. chart3,
  90. searchSelect
  91. },
  92. data() {
  93. return {
  94. staticData: {},
  95. alarmCount: json.staticData.data[0].alarmCount,
  96. cuIconList: json.cuIconList,
  97. Inv: 0,
  98. flag: false,
  99. searchList: [],
  100. searchList2: [],
  101. searchInput: '',
  102. selectedCode: 10012,
  103. getData: []
  104. };
  105. },
  106. // 自定义导航事件
  107. onNavigationBarButtonTap(e) {
  108. if (e.float == 'right') {
  109. console.log("你点击了扫一扫");
  110. this.scanQRCode();
  111. } else {
  112. this.showTag()
  113. }
  114. },
  115. onLoad(option) {
  116. console.log('$websiteUrl')
  117. console.log(this.$websiteUrl)
  118. console.log(this.$BASE_URL)
  119. // console.log(BASE_URL)
  120. var res = uni.getStorageSync('selectedCode');
  121. var res2 = uni.getStorageSync('selectedName');
  122. if (res) {
  123. uni.setNavigationBarTitle({
  124. title: res2
  125. });
  126. }
  127. // 数据渲染
  128. this.getHomeData();
  129. // 图表切换渲染
  130. this.hackReset = false;
  131. this.$nextTick(() => {
  132. this.hackReset = true;
  133. })
  134. this.getHandleData();
  135. this.getSearchList()
  136. },
  137. methods: {
  138. //新增
  139. scanQRCode() {
  140. // alert(1)
  141. // 将this赋值给that
  142. let that = this;
  143. // 微信公众号获取位置
  144. jwx.configWeiXin(jweixin => {
  145. wx.scanQRCode({
  146. needResult: 0, // 默认为0,扫描结果由微信处理,1则直接返回扫描结果,
  147. scanType: ["qrCode", "barCode"], // 可以指定扫二维码还是一维码,默认二者都有
  148. success: function(res) {
  149. console.log('res')
  150. console.log(res)
  151. // that.longitude=res.longitude
  152. // var result = res.resultStr; // 当needResult 为 1 时,扫码返回的结果
  153. }
  154. });
  155. // jwx.configWeiXin(jweixin => {
  156. // wx.getLocation({
  157. // type: 'gcj02', // 默认为wgs84的gps坐标,如果要返回直接给openLocation用的火星坐标,可传入'gcj02'
  158. // success: function (res) {
  159. // that.longitude=res.longitude
  160. // that.latitude=res.latitude
  161. // }
  162. // });
  163. // });
  164. });
  165. },
  166. // 九宫格页面跳转
  167. navItemClick(index) {
  168. let url = "";
  169. switch (index) {
  170. case 0:
  171. url = "/pages/alarmingList/alarmingList"
  172. break;
  173. case 1:
  174. url = "/pages/deviceType/deviceType"
  175. break;
  176. case 2:
  177. url = "/pages/inspectList/inspectList"
  178. break;
  179. case 3:
  180. url = "/pages/xunJian/xunJian"
  181. break;
  182. case 4:
  183. url = "/pages/repair/repair"
  184. break;
  185. case 5:
  186. url = "/pages/weiBao/weiBao"
  187. break;
  188. case 6:
  189. url = "/pages/videoList/videoList"
  190. break;
  191. case 7:
  192. url = "/pages/safeGuard/safeGuard"
  193. break;
  194. // case 8:
  195. // url = "/pages/test/test"
  196. // break;
  197. case 9:
  198. url = "/pages/deviceManage/deviceManage"
  199. break;
  200. case 10:
  201. url = "/pages/accountManage/accountManage"
  202. break;
  203. default:
  204. break;
  205. }
  206. if (url) {
  207. uni.navigateTo({
  208. url: url
  209. })
  210. } else {
  211. uni.showModal({
  212. title: 'Tips',
  213. content: '此模块开发中~',
  214. showCancel: false,
  215. success: function(res) {
  216. if (res.confirm) {} else if (res.cancel) {}
  217. }
  218. });
  219. }
  220. },
  221. // 页面跳转
  222. goOfflineList() {
  223. uni.navigateTo({
  224. url: '/pages/deviceOffLine/deviceOffLine?type=离线',
  225. });
  226. },
  227. goFaultList() {
  228. uni.navigateTo({
  229. url: '/pages/deviceOffLine/deviceOffLine?type=故障',
  230. });
  231. },
  232. //站点下拉请求
  233. async getSearchList(param = {}) {
  234. const res = await this.$myRequest({
  235. url: 'Index/getCompanyList',
  236. data: param
  237. })
  238. this.getData = res.data.data
  239. if (!uni.getStorageSync('selectedCode')) {
  240. uni.setStorageSync('selectedCode', this.getData[0].owner_code);
  241. uni.setStorageSync('selectedName', this.getData[0].owner_name);
  242. }
  243. res.data.data.forEach(item => {
  244. this.searchList.push(item)
  245. this.searchList2.push(item);
  246. });
  247. console.log('this.searchList')
  248. console.log(this.searchList)
  249. },
  250. showTag() {
  251. this.flag = !this.flag;
  252. },
  253. // 下拉选择
  254. clickSelectItem(item, index) {
  255. this.selectedCode = item.owner_code;
  256. uni.setStorageSync('selectedCode', item.owner_code);
  257. uni.setStorageSync('selectedName', item.owner_name);
  258. this.searchInput = item.owner_name;
  259. uni.setNavigationBarTitle({
  260. title: this.searchInput
  261. });
  262. this.flag = false
  263. },
  264. handleInput() {
  265. var newlist = this.searchList2.filter(item => item.owner_name.indexOf(this.searchInput) > -1);
  266. this.searchList = newlist
  267. },
  268. InputFocus(e) {
  269. this.InputBottom = e.detail.height
  270. },
  271. InputBlur(e) {
  272. this.InputBottom = 0
  273. },
  274. changeTab(Inv) {
  275. that.navIdx = Inv;
  276. },
  277. //echarts图表请求
  278. async getHomeData(param = {}) {
  279. const res = await this.$myRequest({
  280. url: 'Index/getHomePageData',
  281. data: param
  282. })
  283. // console.log('首页请求staticData')
  284. // console.log(res.data.data[0])
  285. this.staticData = res.data.data[0]
  286. },
  287. // 未处理告警请求
  288. async getHandleData() {
  289. const res = await this.$myRequest({
  290. url: 'Index/getFunctionalModuleStatistics',
  291. showLoading: true
  292. })
  293. this.cuIconList[0].badge = res.data.data[0].comprehensive_alarm_count;
  294. this.cuIconList[2].badge = res.data.data[0].fire_brigade_inspector_count
  295. },
  296. }
  297. }
  298. </script>
  299. <style lang="scss">
  300. body {
  301. background: #f1f1f1 !important;
  302. }
  303. .select-items {
  304. overflow: auto;
  305. height: 80vh
  306. }
  307. .static-tabs {
  308. border-radius: 50rpx;
  309. border: 1rpx solid #4074E7;
  310. }
  311. .static-tabs>view {
  312. color: #4074E7;
  313. font-size: 30rpx;
  314. }
  315. .static-tabs>view.active {
  316. color: #fff;
  317. background: #4074E7
  318. }
  319. .static-tabs>view:first-child {
  320. border-top-left-radius: 50rpx;
  321. border-bottom-left-radius: 50rpx;
  322. }
  323. .static-tabs>view:nth-child(2) {
  324. border-left: 1px solid #4074E7;
  325. border-right: 1px solid #4074E7
  326. }
  327. .static-tabs>view:last-child {
  328. border-top-right-radius: 50rpx;
  329. border-bottom-right-radius: 50rpx;
  330. }
  331. /* 检测时间 */
  332. .time {
  333. border-radius: 50rpx;
  334. background: #FAFCFF;
  335. border: 1px solid #E8F1FF;
  336. padding: 20rpx;
  337. color: #666666;
  338. font-size: 30rpx;
  339. }
  340. .chart3-box {
  341. position: relative
  342. }
  343. .chart3-icon {
  344. width: 90%;
  345. position: absolute;
  346. top: 60rpx;
  347. left: 30rpx;
  348. z-index: 1;
  349. }
  350. .chart3-icon li {
  351. padding-top: 25rpx
  352. }
  353. ul,
  354. li {
  355. padding: 0;
  356. margin: 0;
  357. list-style: none
  358. }
  359. </style>
  360. <style>
  361. .shadow {
  362. box-shadow: 1px 1px 4px rgb(26 26 26 / 10%);
  363. }
  364. </style>