index.vue 8.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389
  1. <template>
  2. <view style="background:#f1f1f1;" class="padding-sm">
  3. <view class="searchSelect shadow" v-if="flag">
  4. <view class="cu-bar search bg-white">
  5. <view class="search-form round">
  6. <input @focus="InputFocus" @blur="InputBlur" @input="handleInput()" v-model="searchInput"
  7. :adjust-position="false" type="text" placeholder="" />
  8. <text class="cuIcon-search "></text>
  9. </view>
  10. </view>
  11. <view class="select-items">
  12. <view class="select-item" v-for="(item,index) in searchList" @click="clickSelectItem(item,index)"
  13. :key="index">{{item}}</view>
  14. </view>
  15. </view>
  16. <view class="section1 section bg-white padding-xs">
  17. <view class=" static-tabs grid margin-bottom text-center col-3 margin-top-sm margin-bottom-sm">
  18. <view :class="['padding-sm ',Inv==0?'active':'']" @click="Inv=0">报警信息统计</view>
  19. <view :class="['padding-sm ',Inv==1?'active':'']" @click="Inv=1">数据等级统计</view>
  20. <view :class="['padding-sm ',Inv==2?'active':'']" @click="Inv=2">设备运行状态</view>
  21. </view>
  22. <view class="time text-center">统计时段:{{staticData.statisticalPeriod}}
  23. </view>
  24. <view style="height:570rpx">
  25. <view v-if="Inv == 0">
  26. <chart :bindData="staticData" v-if="hackReset"></chart>
  27. </view>
  28. <view v-if="Inv == 1">
  29. <chart2 :bindData="staticData"></chart2>
  30. </view>
  31. <view v-if="Inv == 2" class="chart3-box">
  32. <ul class="chart3-icon">
  33. <li>
  34. <image src="../../static/chart3-1.png" style="width:64rpx;height:64rpx"></image>
  35. </li>
  36. <li>
  37. <image src="../../static/chart3-2.png" style="width:64rpx;height:64rpx"></image>
  38. </li>
  39. <li>
  40. <image src="../../static/chart3-3.png" style="width:64rpx;height:64rpx"></image>
  41. </li>
  42. <li>
  43. <image src="../../static/chart3-4.png" style="width:64rpx;height:64rpx"></image>
  44. </li>
  45. <li>
  46. <image src="../../static/chart3-5.png" style="width:64rpx;height:64rpx"></image>
  47. </li>
  48. </ul>
  49. <chart3 :bindData="staticData">
  50. </chart3>
  51. </view>
  52. </view>
  53. </view>
  54. <!-- 宫格列表 -->
  55. <!-- <square :cuIconList="cuIconList"></square> -->
  56. <view class="section2 section bg-white margin-top-sm margin-bottom-sm">
  57. <view class="cu-list grid col-3 no-border">
  58. <view class="cu-item justify-center align-center" @tap=navItemClick(index)
  59. v-for="(item,index) in cuIconList" :key="index">
  60. <div v-if="item.onShow">
  61. <image :src="item.imgUrl" style="width:100rpx;height:100rpx"></image>
  62. <view class="cu-tag badge" v-if="item.badge!=0">
  63. <block v-if="item.badge!=0">{{item.badge>99?'99+':item.badge}}</block>
  64. </view>
  65. <text>{{item.name}}</text>
  66. </div>
  67. </view>
  68. </view>
  69. </view>
  70. </view>
  71. </template>
  72. <script>
  73. import chart from "./components/chart/chart.vue";
  74. import chart2 from "./components/chart2/chart2.vue";
  75. import chart3 from "./components/chart3/chart3.vue";
  76. import chart4 from "./components/chart4/chart4.vue";
  77. import json from "../../data/json.js";
  78. export default {
  79. components: {
  80. chart,
  81. chart2,
  82. chart3,
  83. chart4,
  84. },
  85. data() {
  86. return {
  87. componentKey: 0,
  88. arr: [],
  89. searchInput: "",
  90. alarmCount: "",
  91. flag: false,
  92. // 宫格列表数据
  93. cuIconList: [{
  94. imgUrl: "../../static/square1.png",
  95. badge: 0,
  96. name: "综合报警",
  97. redirectUrl: "/pages/siteList/siteList?type=1",
  98. onShow: true,
  99. },
  100. {
  101. imgUrl: "../../static/square2.png",
  102. badge: 0,
  103. name: "运行监测",
  104. redirectUrl: "/pages/siteList/siteList?type=2",
  105. onShow: true,
  106. },
  107. {
  108. imgUrl: "../../static/square-wb.png",
  109. badge: 0,
  110. name: "维保",
  111. redirectUrl: "",
  112. onShow: true,
  113. },
  114. {
  115. imgUrl: "../../static/square-bx.png",
  116. badge: 0,
  117. name: "报修",
  118. redirectUrl: "",
  119. onShow: true,
  120. },
  121. {
  122. imgUrl: "../../static/square-rl.png",
  123. badge: 0,
  124. name: "人脸识别",
  125. redirectUrl: "",
  126. onShow: true,
  127. },
  128. {
  129. imgUrl: "../../static/square-xj.png",
  130. badge: 0,
  131. name: "巡检",
  132. redirectUrl: "",
  133. onShow: true,
  134. },
  135. {
  136. imgUrl: "../../static/square-bz.png",
  137. badge: 0,
  138. name: "风险保障",
  139. redirectUrl: "",
  140. onShow: true,
  141. },
  142. {
  143. imgUrl: "../../static/square-dljc.png",
  144. badge: 0,
  145. name: "电力监察",
  146. redirectUrl: "",
  147. onShow: true,
  148. },
  149. ],
  150. Inv: 0,
  151. searchList: [],
  152. searchList2: [],
  153. staticData: {},
  154. };
  155. },
  156. onNavigationBarButtonTap(e) {
  157. if (e.float == "right") {
  158. console.log("你点击了扫一扫");
  159. uni.scanCode({
  160. // success: function(res) {
  161. // console.log('条码类型:' + res.scanType);
  162. // console.log('条码内容:' + res.result);
  163. // }
  164. success: function(res) {
  165. let result = res.result;
  166. if (
  167. result.indexOf("http://") == 0 ||
  168. result.indexOf("https://") == 0
  169. ) {
  170. //是网址,直接跳转
  171. plus.runtime.openURL(result); //调用手机浏览器
  172. //怎么在APP内跳转网址?
  173. } else {
  174. //不是网址,打印出结果
  175. uni.showToast({
  176. title: res.result,
  177. });
  178. }
  179. },
  180. fail: function(err) {
  181. console.log("扫码失败", err);
  182. },
  183. });
  184. } else {
  185. this.showTag();
  186. }
  187. },
  188. created: function() {},
  189. mounted() {
  190. document.querySelector(".uni-page-head-hd").style.display = "none";
  191. },
  192. beforeCreate: function() {},
  193. onLoad: function(option) {
  194. if (option.op) {
  195. this.getData();
  196. } else {
  197. if (window.location.host.indexOf("localhost") == -1) {
  198. this.init();
  199. } else {
  200. this.getData();
  201. }
  202. }
  203. this.hackReset = false;
  204. this.$nextTick(() => {
  205. this.hackReset = true;
  206. });
  207. },
  208. methods: {
  209. async init() {
  210. window.location.href = this.$BASE_URL + "Com/getPageAuthorization1";
  211. },
  212. // end
  213. async getData() {
  214. const res = await this.$myRequest({
  215. url: "Index/getDataStatistics",
  216. showLoading: true,
  217. });
  218. this.staticData = res.data.data[0];
  219. this.alarmCount = this.staticData.alarmCount;
  220. this.cuIconList[0].badge = this.staticData.unprocessedCount;
  221. const resOne = await this.$myRequest({
  222. url: "Com/getAuthorization",
  223. showLoading: true,
  224. data: undefined,
  225. });
  226. var permissionLabel = resOne.data.permissionLabel;
  227. this.cuIconList.forEach((el) => {
  228. if (el.name === "电力监察" && permissionLabel == 4) {
  229. el.onShow = false;
  230. }
  231. });
  232. },
  233. handleInput() {
  234. var newlist = this.searchList2.filter(
  235. (item) => item.indexOf(this.searchInput) > -1
  236. );
  237. this.searchList = newlist;
  238. },
  239. navItemClick(index) {
  240. let url = "";
  241. switch (index) {
  242. case 0:
  243. url = "/pages/siteListAlarming/siteListAlarming";
  244. break;
  245. case 1:
  246. url = "/pages/siteList/siteList";
  247. break;
  248. case 7:
  249. url = "/pages/eleControl/eleControl";
  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. showTag() {
  270. this.flag = !this.flag;
  271. },
  272. InputFocus(e) {
  273. this.InputBottom = e.detail.height;
  274. },
  275. InputBlur(e) {
  276. this.InputBottom = 0;
  277. },
  278. changeTab(Inv) {
  279. that.navIdx = Inv;
  280. },
  281. },
  282. };
  283. //解决IOS返回页面不刷新的问题
  284. history.pushState(null, null, document.URL); //禁止网页返回上一页
  285. window.addEventListener("popstate", function() {
  286. // alert('点击返回按钮了!')
  287. });
  288. </script>
  289. <style lang="scss">
  290. body {
  291. background: #f1f1f1 !important;
  292. }
  293. .select-items {
  294. overflow: auto;
  295. height: 80vh;
  296. }
  297. .static-tabs {
  298. border-radius: 50rpx;
  299. border: 1rpx solid #4074e7;
  300. }
  301. .static-tabs>view {
  302. color: #4074e7;
  303. font-size: 30rpx;
  304. }
  305. .static-tabs>view.active {
  306. color: #fff;
  307. background: #4074e7;
  308. }
  309. .static-tabs>view:first-child {
  310. border-top-left-radius: 50rpx;
  311. border-bottom-left-radius: 50rpx;
  312. }
  313. .static-tabs>view:nth-child(2) {
  314. border-left: 1px solid #4074e7;
  315. border-right: 1px solid #4074e7;
  316. }
  317. .static-tabs>view:last-child {
  318. border-top-right-radius: 50rpx;
  319. border-bottom-right-radius: 50rpx;
  320. }
  321. /* 检测时间 */
  322. .time {
  323. border-radius: 50rpx;
  324. background: #fafcff;
  325. border: 1px solid #e8f1ff;
  326. padding: 20rpx;
  327. color: #666666;
  328. font-size: 28rpx;
  329. }
  330. .chart3-box {
  331. position: relative;
  332. }
  333. .chart3-icon {
  334. position: absolute;
  335. top: 60rpx;
  336. left: 30rpx;
  337. }
  338. .chart3-icon li {
  339. padding-top: 25rpx;
  340. }
  341. ul,
  342. li {
  343. padding: 0;
  344. margin: 0;
  345. list-style: none;
  346. }
  347. </style>
  348. <style>
  349. .shadow {
  350. box-shadow: 1px 1px 4px rgb(26 26 26 / 10%);
  351. }
  352. </style>