index.vue 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420
  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" @tap="goDeviceList()">
  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 json from '../../data/json.js';
  73. export default {
  74. components: {
  75. chart,
  76. chart2,
  77. chart3,
  78. },
  79. data() {
  80. return {
  81. componentKey: 0,
  82. arr: [],
  83. searchInput: '',
  84. alarmCount:'',
  85. flag: false,
  86. cuIconList: json.cuIconList,
  87. Inv: 0,
  88. searchList: [],
  89. searchList2: [],
  90. staticData: {}
  91. };
  92. },
  93. onNavigationBarButtonTap(e) {
  94. if (e.float == 'right') {
  95. console.log("你点击了扫一扫")
  96. uni.scanCode({
  97. // success: function(res) {
  98. // console.log('条码类型:' + res.scanType);
  99. // console.log('条码内容:' + res.result);
  100. // }
  101. success: function(res) {
  102. let result = res.result;
  103. if (result.indexOf('http://') == 0 || result.indexOf('https://') == 0) {
  104. //是网址,直接跳转
  105. plus.runtime.openURL(result); //调用手机浏览器
  106. //怎么在APP内跳转网址?
  107. } else {
  108. //不是网址,打印出结果
  109. uni.showToast({
  110. title: res.result
  111. })
  112. }
  113. },
  114. fail: function(err) {
  115. console.log('扫码失败', err)
  116. }
  117. });
  118. } else {
  119. this.showTag()
  120. }
  121. },
  122. onLoad(option) {
  123. let ua = navigator.userAgent.toLowerCase();
  124. if (ua.match(/MicroMessenger/i) == "micromessenger"){
  125. //是
  126. this.init();
  127. }else{
  128. //不是
  129. // uni.navigateTo({
  130. // url: '/pages/login/login',
  131. // });
  132. // setTimeout(function() {
  133. // uni.navigateTo({
  134. // url: '/pages/login/login',
  135. // });
  136. // }, 2000);
  137. }
  138. this.hackReset = false;
  139. this.$nextTick(() => {
  140. this.hackReset = true;
  141. })
  142. this.getData();
  143. this.getSearchList();
  144. },
  145. methods: {
  146. // start
  147. getUrlCode() {
  148. var url = location.search
  149. this.winUrl = url
  150. var theRequest = new Object()
  151. if (url.indexOf("?") != -1) {
  152. var str = url.substr(1)
  153. var strs = str.split("&")
  154. for (var i = 0; i < strs.length; i++) {
  155. theRequest[strs[i].split("=")[0]] = (strs[i].split("=")[1])
  156. }
  157. }
  158. return theRequest
  159. },
  160. async getUrlPrams(key) {
  161. var reg = new RegExp("(^|&)" + key + "=([^&]*)(&|$)", "i");
  162. var r = window.location.search.substr(1).match(reg); //获取url中"?"符后的字符串并正则匹配
  163. var context = "";
  164. if (r != null) {
  165. context = r[2];
  166. }
  167. return context;
  168. },
  169. async init() {
  170. var appId = "wx4eab2e3b5531d58b";
  171. var params = {};
  172. var CODE = this.getUrlCode();
  173. var code = CODE['code'];
  174. if (code) {
  175. params.code = code;
  176. //使用code请求服务器接口,换取用户用户openID
  177. const res = await this.$myRequest({
  178. url: 'Com/getPageAuthorization',
  179. data: params
  180. })
  181. if (res.data.flag == 3000) {
  182. // alert("授权失败,请重新登录");
  183. window.location.href ='https://qhome.usky.cn/index.html#/';
  184. }
  185. if (res.data.flag == 3003) {
  186. uni.navigateTo({
  187. url: '/pages/authority/authority',
  188. });
  189. }
  190. if (res.data.flag == 3002) {
  191. // alert("授权失败,请重新登录");
  192. window.location.href ='https://qhome.usky.cn/index.html#/';
  193. }
  194. return "ok";
  195. }
  196. var cs = {};
  197. var curl = window.location.href;
  198. cs.curl = curl;
  199. const res1 = await this.$myRequest({
  200. url: 'Com/getAuthorizationUrl',
  201. data: cs
  202. })
  203. var turl = res1.data.turl;
  204. window.location.href =
  205. 'https://open.weixin.qq.com/connect/oauth2/authorize?appid=wx4eab2e3b5531d58b&redirect_uri=' + turl +
  206. '&response_type=code&scope=snsapi_base&state=abc123#wechat_redirect';
  207. },
  208. // end
  209. //首页初始化授权
  210. async getPageAuthorization(ming = {}) {
  211. const res = await this.$myRequest({
  212. url: 'Com/getPageAuthorization',
  213. data: ming
  214. })
  215. if (res.data.flag == 3000) {
  216. uni.navigateTo({
  217. url: '/pages/login/login',
  218. });
  219. }
  220. if (res.data.flag == 3002) {
  221. uni.navigateTo({
  222. url: 'https://open.weixin.qq.com/connect/oauth2/authorize?appid=wx4eab2e3b5531d58b&redirect_uri=' + res.data
  223. .tourl + '&response_type=code&scope=snsapi_base&state=abc123#wechat_redirect',
  224. });
  225. }
  226. },
  227. async getData() {
  228. const res = await this.$myRequest({
  229. url: 'Index/getDataStatistics',
  230. showLoading: true
  231. })
  232. this.staticData = res.data.data[0]
  233. this.alarmCount=this.staticData.alarmCount
  234. },
  235. async getSearchList(ming = {}) {
  236. const res = await this.$myRequest({
  237. url: 'Index/getSiteDropDownBox',
  238. data: ming
  239. })
  240. res.data.data.forEach(item => {
  241. this.searchList.push(item.siteName)
  242. this.searchList2.push(item.siteName)
  243. });
  244. },
  245. clickSelectItem(item, index) {
  246. this.getSearchList({
  247. "siteName": item
  248. });
  249. this.flag = false
  250. },
  251. handleInput() {
  252. var newlist = this.searchList2.filter(item => item.indexOf(this.searchInput) > -1)
  253. this.searchList = newlist
  254. },
  255. navItemClick(index) {
  256. let url = "";
  257. switch (index) {
  258. case 0:
  259. url = "/pages/alarmingList/alarmingList"
  260. break;
  261. case 1:
  262. url = "/pages/siteList/siteList"
  263. break;
  264. default:
  265. break;
  266. }
  267. if (url) {
  268. uni.navigateTo({
  269. url: url
  270. })
  271. } else {
  272. uni.showModal({
  273. title: 'Tips',
  274. content: '此模块开发中~',
  275. showCancel: false,
  276. success: function(res) {
  277. if (res.confirm) {
  278. } else if (res.cancel) {
  279. }
  280. }
  281. });
  282. }
  283. },
  284. showTag() {
  285. this.flag = !this.flag;
  286. },
  287. InputFocus(e) {
  288. this.InputBottom = e.detail.height
  289. },
  290. InputBlur(e) {
  291. this.InputBottom = 0
  292. },
  293. changeTab(Inv) {
  294. that.navIdx = Inv;
  295. },
  296. // 页面跳转
  297. goDeviceList() {
  298. uni.navigateTo({
  299. url: '/pages/deviceOffLine/deviceOffLine',
  300. success: res => {},
  301. fail: () => {},
  302. complete: () => {}
  303. });
  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. position: absolute;
  354. top: 60rpx;
  355. left: 30rpx
  356. }
  357. .chart3-icon li {
  358. padding-top: 25rpx
  359. }
  360. ul,
  361. li {
  362. padding: 0;
  363. margin: 0;
  364. list-style: none
  365. }
  366. </style>
  367. <style>
  368. .shadow {
  369. box-shadow: 1px 1px 4px rgb(26 26 26 / 10%);
  370. }
  371. </style>