index.vue 10 KB

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