index.vue 8.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364
  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" :adjust-position="false"
  7. type="text" placeholder="" confirm-type="search"></input>
  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)" :key="index">{{item}}</view>
  13. </view>
  14. </view>
  15. <view class="section1 section bg-white padding-xs">
  16. <view class=" static-tabs grid margin-bottom text-center col-3 margin-top-sm margin-bottom-sm">
  17. <view :class="['padding-sm ',Inv==0?'active':'']" @click="Inv=0">报警信息统计</view>
  18. <view :class="['padding-sm ',Inv==1?'active':'']" @click="Inv=1">数据等级统计</view>
  19. <view :class="['padding-sm ',Inv==2?'active':'']" @click="Inv=2">设备运行状态</view>
  20. </view>
  21. <view class="time text-center">统计时段:{{staticData.statisticalPeriod}}
  22. </view>
  23. <view style="height:570rpx">
  24. <view v-if="Inv == 0">
  25. <chart :bindData="staticData" v-if="hackReset"></chart>
  26. </view>
  27. <view v-if="Inv == 1">
  28. <chart2 :bindData="staticData"></chart2>
  29. </view>
  30. <view v-if="Inv == 2" class="chart3-box">
  31. <ul class="chart3-icon">
  32. <li>
  33. <image src="../../static/chart3-1.png" style="width:64rpx;height:64rpx"></image>
  34. </li>
  35. <li>
  36. <image src="../../static/chart3-2.png" style="width:64rpx;height:64rpx"></image>
  37. </li>
  38. <li>
  39. <image src="../../static/chart3-3.png" style="width:64rpx;height:64rpx"></image>
  40. </li>
  41. <li>
  42. <image src="../../static/chart3-4.png" style="width:64rpx;height:64rpx"></image>
  43. </li>
  44. <li>
  45. <image src="../../static/chart3-5.png" style="width:64rpx;height:64rpx"></image>
  46. </li>
  47. </ul>
  48. <chart3 :bindData="staticData">
  49. </chart3>
  50. </view>
  51. </view>
  52. </view>
  53. <!-- 宫格列表 -->
  54. <!-- <square :cuIconList="cuIconList"></square> -->
  55. <view class="section2 section bg-white margin-top-sm margin-bottom-sm">
  56. <view class="cu-list grid col-3 no-border">
  57. <view class="cu-item justify-center align-center" @tap=navItemClick(index) v-for="(item,index) in cuIconList" :key="index">
  58. <image :src="item.imgUrl" style="width:100rpx;height:100rpx"></image>
  59. <view class="cu-tag badge" v-if="item.badge!=0">
  60. <block v-if="item.badge!=1">{{item.badge>99?'99+':item.badge}}</block>
  61. </view>
  62. <text>{{item.name}}</text>
  63. </view>
  64. </view>
  65. </view>
  66. </view>
  67. </template>
  68. <script>
  69. import chart from './components/chart/chart.vue';
  70. import chart2 from './components/chart2/chart2.vue';
  71. import chart3 from './components/chart3/chart3.vue';
  72. import chart4 from './components/chart4/chart4.vue';
  73. import json from '../../data/json.js';
  74. export default {
  75. components: {
  76. chart,
  77. chart2,
  78. chart3,
  79. chart4
  80. },
  81. data() {
  82. return {
  83. componentKey: 0,
  84. arr: [],
  85. searchInput: '',
  86. flag: false,
  87. // 宫格列表数据
  88. cuIconList: json.cuIconList,
  89. Inv: 0,
  90. searchList: [],
  91. searchList2: [],
  92. staticData: {}
  93. // staticData: {
  94. // "statisticalPeriod": "2021-02-22~2021-03-22",
  95. // "smartElectricityCount": "5",
  96. // "videoMonitoringCount": "75",
  97. // "alarmCount": 80,
  98. // "eventCount": 0,
  99. // "hiddenDangerCount": 0,
  100. // "offlineCount": "0",
  101. // "faultCount": 0,
  102. // "earlyWarningCount": 0,
  103. // "otherCount": 0,
  104. // "normalCount": "0",
  105. // "integratedAlarmCount": 80
  106. // }
  107. };
  108. },
  109. onNavigationBarButtonTap(e) {
  110. if (e.float == 'right') {
  111. console.log("你点击了扫一扫")
  112. uni.scanCode({
  113. // success: function(res) {
  114. // console.log('条码类型:' + res.scanType);
  115. // console.log('条码内容:' + res.result);
  116. // }
  117. success: function(res) {
  118. let result = res.result;
  119. if (result.indexOf('http://') == 0 || result.indexOf('https://') == 0) {
  120. //是网址,直接跳转
  121. plus.runtime.openURL(result); //调用手机浏览器
  122. //怎么在APP内跳转网址?
  123. } else {
  124. //不是网址,打印出结果
  125. uni.showToast({
  126. title: res.result
  127. })
  128. }
  129. },
  130. fail: function(err) {
  131. console.log('扫码失败', err)
  132. }
  133. });
  134. } else {
  135. // alert("你点击了下拉");
  136. this.showTag()
  137. }
  138. },
  139. onLoad(option) {
  140. console.log('option')
  141. console.log(option)
  142. if(!option.code){
  143. alert(1)
  144. this.getPageAuthorization()
  145. }else{
  146. alert(option.code);
  147. this.getPageAuthorization({"code":option.code})
  148. }
  149. this.hackReset = false;
  150. this.$nextTick(() => {
  151. this.hackReset = true;
  152. })
  153. this.getData();
  154. this.getSearchList();
  155. },
  156. methods: {
  157. //首页初始化授权
  158. async getPageAuthorization(ming={}) {
  159. const res = await this.$myRequest({
  160. url: 'Com/getPageAuthorization',
  161. data:ming
  162. })
  163. alert(res.data.flag)
  164. console.log('res.data');
  165. console.log(res.data);
  166. if(res.data.flag==3000){
  167. uni.navigateTo({
  168. url: '/pages/login/login',
  169. });
  170. }
  171. if(res.data.flag==3002){
  172. uni.navigateTo({
  173. url: 'https://open.weixin.qq.com/connect/oauth2/authorize?appid=wx4eab2e3b5531d58b&redirect_uri=' +res.data.tourl+'&response_type=code&scope=snsapi_base&state=abc123#wechat_redirect',
  174. });
  175. }
  176. },
  177. async getData() {
  178. const res = await this.$myRequest({
  179. url: 'Index/getDataStatistics',
  180. showLoading:true
  181. })
  182. // alert(res.data.flag);
  183. this.staticData = res.data.data[0]
  184. },
  185. async getSearchList(ming = {}) {
  186. const res = await this.$myRequest({
  187. url: 'Index/getSiteDropDownBox',
  188. data: ming
  189. })
  190. res.data.data.forEach(item => {
  191. this.searchList.push(item.siteName)
  192. this.searchList2.push(item.siteName)
  193. });
  194. },
  195. clickSelectItem(item, index) {
  196. // alert(index);
  197. alert(item);
  198. this.getSearchList({
  199. "siteName": item
  200. });
  201. this.flag = false
  202. },
  203. handleInput() {
  204. // this.searchList = this.searchList.filter(item => item.indexOf(this.searchInput) > -1);
  205. var newlist = this.searchList2.filter(item => item.indexOf(this.searchInput) > -1)
  206. this.searchList = newlist
  207. },
  208. navItemClick(index) {
  209. // log(index)
  210. let url = "";
  211. switch (index) {
  212. case 0:
  213. url = "/pages/siteListAlarming/siteListAlarming"
  214. break;
  215. case 1:
  216. url = "/pages/siteList/siteList"
  217. break;
  218. default:
  219. break;
  220. }
  221. if (url) {
  222. uni.navigateTo({
  223. url: url
  224. })
  225. } else {
  226. // uni.showToast({
  227. // title: '此模块开发中~',
  228. // icon: 'none'
  229. // });
  230. uni.showModal({
  231. title: 'Tips',
  232. content: '此模块开发中~',
  233. showCancel: false,
  234. success: function(res) {
  235. if (res.confirm) {
  236. console.log('用户点击确定');
  237. } else if (res.cancel) {
  238. console.log('用户点击取消');
  239. }
  240. }
  241. });
  242. }
  243. },
  244. showTag() {
  245. this.flag = !this.flag;
  246. },
  247. InputFocus(e) {
  248. this.InputBottom = e.detail.height
  249. },
  250. InputBlur(e) {
  251. this.InputBottom = 0
  252. },
  253. changeTab(Inv) {
  254. that.navIdx = Inv;
  255. },
  256. }
  257. }
  258. </script>
  259. <style lang="scss">
  260. body {
  261. background: #f1f1f1 !important;
  262. }
  263. .select-items {
  264. overflow: auto;
  265. height: 80vh
  266. }
  267. .static-tabs {
  268. border-radius: 50rpx;
  269. border: 1rpx solid #4074E7;
  270. }
  271. .static-tabs>view {
  272. color: #4074E7;
  273. font-size: 30rpx;
  274. }
  275. .static-tabs>view.active {
  276. color: #fff;
  277. background: #4074E7
  278. }
  279. .static-tabs>view:first-child {
  280. border-top-left-radius: 50rpx;
  281. border-bottom-left-radius: 50rpx;
  282. }
  283. .static-tabs>view:nth-child(2) {
  284. border-left: 1px solid #4074E7;
  285. border-right: 1px solid #4074E7
  286. }
  287. .static-tabs>view:last-child {
  288. border-top-right-radius: 50rpx;
  289. border-bottom-right-radius: 50rpx;
  290. }
  291. /* 检测时间 */
  292. .time {
  293. border-radius: 50rpx;
  294. background: #FAFCFF;
  295. border: 1px solid #E8F1FF;
  296. padding: 20rpx;
  297. color: #666666;
  298. font-size: 28rpx;
  299. }
  300. .chart3-box {
  301. position: relative
  302. }
  303. .chart3-icon {
  304. position: absolute;
  305. top: 60rpx;
  306. left: 30rpx
  307. }
  308. .chart3-icon li {
  309. padding-top: 25rpx
  310. }
  311. ul,
  312. li {
  313. padding: 0;
  314. margin: 0;
  315. list-style: none
  316. }
  317. </style>
  318. <style>
  319. .shadow {
  320. box-shadow: 1px 1px 4px rgb(26 26 26 / 10%);
  321. }
  322. </style>