index.vue 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360
  1. <template>
  2. <view>
  3. <image :src="worktop" style="height: 340rpx;width: 90%;margin-left: 40rpx;"></image>
  4. <!-- <uni-segmented-control :current="current" :values="items" @clickItem="onClickItem" styleType="text"
  5. activeColor="#4cd964"></uni-segmented-control>
  6. <view v-if="current === 0"> -->
  7. <view class="grid-body">
  8. <uni-card :border="false">
  9. <uni-section title="事件中心" type="line" titleFontSize='18px'>
  10. <uni-grid :column="3" :showBorder="false" @change="changeGrid">
  11. <uni-grid-item v-for="(item, index) in urlList1" :key="index">
  12. <view class="example-body">
  13. <view class="grid-item-box" @click="handleToInfo(item.menuUrl,item.menuName)">
  14. <image :src="urlIconTran(item.menuIcon)" class="tubiao"></image>
  15. <text class="text">{{ item.menuName }}</text>
  16. <u-badge v-if="item.menuName == '指令'&&unread != 0" :value="unread" type="error"
  17. class="huibiao"></u-badge>
  18. <u-badge v-if="item.menuName == '重要提醒'&&unreadTips != 0" :value="unreadTips" type="error"
  19. class="huibiao"></u-badge>
  20. </view>
  21. </view>
  22. </uni-grid-item>
  23. </uni-grid>
  24. </uni-section>
  25. <uni-section title="管理中心" type="line" titleFontSize='18px'>
  26. <uni-grid :column="3" :showBorder="false" @change="changeGrid">
  27. <uni-grid-item v-for="(item, index1) in urlList" :key="index1">
  28. <view class="example-body">
  29. <view class="grid-item-box" @click="handleToInfo(item.menuUrl,item.menuName)">
  30. <image :src="urlIconTran(item.menuIcon)" class="tubiao"></image>
  31. <text class="text">{{ item.menuName }}</text>
  32. <u-badge v-if="item.menuName == '指令'&&unread != 0" :value="unread" type="error"
  33. class="huibiao"></u-badge>
  34. <u-badge v-if="item.menuName == '重要提醒'&&unreadTips != 0" :value="unreadTips" type="error"
  35. class="huibiao"></u-badge>
  36. </view>
  37. </view>
  38. </uni-grid-item>
  39. </uni-grid>
  40. </uni-section>
  41. <uni-section title="乡镇消防工作档案" type="line" titleFontSize='18px'
  42. v-if="urlList2.length&&urlList2.length>0">
  43. <uni-grid :column="3" :showBorder="false" @change="changeGrid">
  44. <uni-grid-item v-for="(item, index) in urlList2" :key="index">
  45. <view class="example-body">
  46. <view class="grid-item-box" @click="handleToInfo(item.menuUrl,item.menuName)">
  47. <image :src="urlIconTran(item.menuIcon)" class="tubiao"></image>
  48. <text class="text">{{ item.menuName }}</text>
  49. <u-badge v-if="item.menuName == '指令'&&unread != 0" :value="unread" type="error"
  50. class="huibiao"></u-badge>
  51. <u-badge v-if="item.menuName == '重要提醒'&&unread != 0" :value="unread" type="error"
  52. class="huibiao"></u-badge>
  53. </view>
  54. </view>
  55. </uni-grid-item>
  56. </uni-grid>
  57. </uni-section>
  58. </uni-card>
  59. </view>
  60. </view>
  61. </template>
  62. <script>
  63. import storage from '@/utils/storage';
  64. import {
  65. getNoticeList, // 通知公告列表
  66. getNoticeReadData //指令未读的数量
  67. } from '@/api/notice';
  68. import {
  69. getRemindReadData //重要通知未读的数量
  70. } from "@/api/remind";
  71. import {
  72. getMenusByUser
  73. } from '@/api/login';
  74. import config from '@/config'
  75. const baseUrlImg = config.baseUrlImg
  76. export default {
  77. data() {
  78. return {
  79. urls: baseUrlImg,
  80. roles: this.$store.state.user.roles,
  81. current: 0,
  82. swiperDotIndex: 0,
  83. worktop: `${baseUrlImg}/working/worktop.png`, //图片
  84. zhudongjiancha: `${baseUrlImg}/working/zhudongjiancha.png`,
  85. yinhuanguanli: `${baseUrlImg}/working/yinhuanguanli.png`,
  86. yinhuanfucha: `${baseUrlImg}/working/yinhuanfucha.png`, //隐患复查
  87. check_inspection: `${baseUrlImg}/working/check_inspection.png`, //主动检查
  88. user_business: `${baseUrlImg}/working/user_business.png`,
  89. tabler_clock_edit: `${baseUrlImg}/working/tabler_clock_edit.png`,
  90. tabler_chart_histogram: `${baseUrlImg}/working/tabler_chart_histogram.png`, //数据统计
  91. outline_trumpet: `${baseUrlImg}/working/outline_trumpet.png`, //通知公告
  92. outline_permissions: `${baseUrlImg}/working/outline_permissions.png`,
  93. meirixuncha: `${baseUrlImg}/working/big1.png`,
  94. // fire_extinguishe: `${baseUrlImg}/working/weixingxiaofang.png`,
  95. fire_extinguishe: `${baseUrlImg}/working/fire_extinguishe.png`,
  96. unit_info: `${baseUrlImg}/working/danweixinxi.png`,
  97. zhilin: `${baseUrlImg}/working/zhilin.png`,
  98. // unit_arc: `${baseUrlImg}/working/danweijianzhu.png`,
  99. unit_arc: `${baseUrlImg}/working/unit_arc.png`,
  100. xiaofangsheshi: `${baseUrlImg}/working/xiaofangsheshi.png`,
  101. renyuan: `${baseUrlImg}/working/renyuan.png`,
  102. drill: `${baseUrlImg}/working/drill.png`,
  103. // archive: `${baseUrlImg}/working/gongzuodangan.png`,
  104. archive: `${baseUrlImg}/working/archive.png`,
  105. fireSpecial: `${baseUrlImg}/working/fireSpecial.png`,
  106. remind:`${baseUrlImg}/working/remind.png`,
  107. fireWork: `${baseUrlImg}/working/fireWork.png`,
  108. fire_inspetItem: `${baseUrlImg}/working/fire_inspetItem.png`,
  109. fire_street: `${baseUrlImg}/working/fire_street.png`,
  110. items: ['事件中心', '管理中心'],
  111. current: 0,
  112. urlList: [],
  113. urlList1: [],
  114. unread: 0, //未读数量
  115. unreadTips:0,//重要提醒未读数量
  116. urlList2: []
  117. };
  118. },
  119. onLoad() {
  120. },
  121. onShow() {
  122. this.urlList = []
  123. this.urlList1 = []
  124. this.urlList2 = [];
  125. let count = 0;
  126. const intervalId = setInterval(() => {
  127. if (this.$store.state.user && this.$store.state.user.id) {
  128. this.getData();
  129. this.getRemind();
  130. this.getMenu();
  131. clearInterval(intervalId); // 中止循环
  132. }
  133. count++;
  134. if (count >= 5) {
  135. clearInterval(intervalId); // 如果超过5秒仍未找到用户ID,中止循环
  136. }
  137. }, 1000);
  138. },
  139. methods: {
  140. getData() {
  141. getNoticeReadData({
  142. userId: this.$store.state.user.id
  143. }).then(response => {
  144. this.unread = response.data
  145. })
  146. },
  147. getRemind() {
  148. getRemindReadData({
  149. userId: this.$store.state.user.id
  150. }).then(response => {
  151. this.unreadTips = response.data
  152. })
  153. },
  154. getMenu() {
  155. getMenusByUser({
  156. id: this.$store.state.user.id
  157. }).then(response => {
  158. console.log('response======',response)
  159. response.data.map(i => {
  160. if (i.menuSort.toString().startsWith("1")) {
  161. this.urlList1.push(i);
  162. this.urlList1 = this.urlList1.sort((a, b) => a.menuSort - b.menuSort);
  163. } else if (i.menuSort.toString().startsWith("2")) {
  164. this.urlList.push(i);
  165. this.urlList = this.urlList.sort((a, b) => a.menuSort - b.menuSort);
  166. } else if (i.menuSort.toString().startsWith("3")) {
  167. this.urlList2.push(i);
  168. this.urlList2 = this.urlList2.sort((a, b) => a.menuSort - b.menuSort);
  169. }
  170. });
  171. });
  172. },
  173. urlIconTran(val) {
  174. if (val == 'outline_permissions') {
  175. return this.outline_permissions;
  176. } else if (val == 'meirixuncha') {
  177. return this.meirixuncha;
  178. } else if (val == 'zhudongjiancha') {
  179. return this.zhudongjiancha;
  180. } else if (val == 'check_inspection') {
  181. // return this.zhudongjiancha;
  182. return this.check_inspection
  183. } else if (val == 'yinhuanfucha') {
  184. // return this.yinhuanguanli
  185. return this.yinhuanfucha
  186. } else if (val == 'tabler_clock_edit') {
  187. return this.tabler_clock_edit;
  188. } else if (val == 'outline_trumpet') {
  189. return this.outline_trumpet;
  190. } else if (val == 'outline_trumpet') {
  191. return this.outline_trumpet;
  192. } else if (val == 'yinhuanguanli') {
  193. return this.yinhuanguanli;
  194. } else if (val == 'user_business') {
  195. return this.user_business;
  196. } else if (val == 'fire_extinguishe') {
  197. return this.fire_extinguishe;
  198. } else if (val == 'unit_info') {
  199. return this.unit_info;
  200. } else if (val == 'unit_arc') {
  201. return this.unit_arc;
  202. } else if (val == 'drill') {
  203. return this.drill;
  204. } else if (val == 'xiaofangsheshi') {
  205. return this.xiaofangsheshi;
  206. } else if (val == 'archive') {
  207. return this.archive;
  208. } else if (val == 'renyuan') {
  209. return this.renyuan;
  210. } else if (val == 'tabler_chart_histogram') {
  211. return this.tabler_chart_histogram;
  212. } else if (val == 'zhilin') {
  213. return this.zhilin;
  214. } else if (val == 'zlgztzs_icon') {
  215. return this.renyuan
  216. } else if (val == 'fire_inspetItem') {
  217. // return this.archive;
  218. return this.fire_inspetItem
  219. } else if (val == 'fire_street') {
  220. // return this.archive;
  221. return this.fire_street
  222. } else if (val == 'fireWork') {
  223. // return this.archive;
  224. return this.fireWork
  225. } else if (val == 'fireSpecial') {
  226. // return this.archive;
  227. return this.fireSpecial
  228. }else if (val == 'remind') {
  229. // return this.archive;
  230. return this.remind
  231. }
  232. },
  233. // 顶部个人信息跳转
  234. onClick() {
  235. uni.switchTab({
  236. url: '/pages/mine/index'
  237. });
  238. },
  239. changeGrid(e) {},
  240. // 根据不同的url,进行页面的跳转
  241. handleToInfo(url, name) {
  242. this.$tab.navigateTo(url);
  243. },
  244. // 分段器点击 事件中心、管理中心转换
  245. onClickItem(e) {
  246. if (this.current != e.currentIndex) {
  247. this.current = e.currentIndex;
  248. }
  249. }
  250. }
  251. };
  252. </script>
  253. <style lang="scss" scoped>
  254. /* #ifndef APP-NVUE */
  255. page {
  256. display: flex;
  257. flex-direction: column;
  258. box-sizing: border-box;
  259. min-height: 100%;
  260. height: auto;
  261. }
  262. .tubiao {
  263. width: 142upx;
  264. height: 142upx;
  265. }
  266. view {
  267. font-size: 14px;
  268. line-height: inherit;
  269. }
  270. .tabIcon {
  271. color: white;
  272. }
  273. /* #endif */
  274. .text {
  275. text-align: center;
  276. color: #000;
  277. font-size: 26rpx;
  278. margin-top: -18upx;
  279. // margin-top: 10rpx;
  280. }
  281. .grid-item-box {
  282. position: relative;
  283. flex: 1;
  284. /* #ifndef APP-NVUE */
  285. display: flex;
  286. /* #endif */
  287. flex-direction: column;
  288. align-items: center;
  289. justify-content: center;
  290. padding: 15px 0;
  291. }
  292. // 按钮样式
  293. button {
  294. width: 132rpx;
  295. height: 52rpx;
  296. border-radius: 50rpx;
  297. background-color: #f7d1dc;
  298. border-color: #d51a52;
  299. color: #d51a52;
  300. font-size: 25rpx;
  301. border: 3rpx solid;
  302. font-weight: bold;
  303. padding: 0;
  304. margin-left: 70rpx;
  305. }
  306. ::v-deep .u-navbar__content {
  307. // background-color: #4cb2b6 !important;
  308. }
  309. .container {
  310. height: 140vh;
  311. // height: 100vh;
  312. background-color: #fff;
  313. }
  314. // 修改分段器默认样式
  315. ::v-deep .segmented-control {
  316. border-bottom: 1px solid #e5e5e5;
  317. }
  318. ::v-deep .segmented-control__text {
  319. color: #4cb2b6 !important;
  320. }
  321. ::v-deep .segmented-control__text span {
  322. color: #3d3d3d !important;
  323. }
  324. ::v-deep .segmented-control__item--text {
  325. padding: 8px 0;
  326. }
  327. //徽标
  328. // /deep/.u-page__tag-item {
  329. // margin-right: 40px;
  330. // margin-top: 0 !important;
  331. // }
  332. /deep/.u-badge[data-v-662d25bf] {}
  333. .huibiao,
  334. /deep/.u-badge--error.data-v-662d25bf,
  335. /deep/.u-badge--error {
  336. position: absolute;
  337. right: 56rpx;
  338. top: 46rpx;
  339. }
  340. </style>