index.vue 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668
  1. <template>
  2. <view>
  3. <!-- 首页风格切换-1-切换风格 -->
  4. <view class="top_bg_color">
  5. <!-- 背景虚化轮播图 -->
  6. <!-- <view class="bg_img" :style="{backgroundImage:'url('+top_bg_color_img+')'}"></view> -->
  7. <!-- 固定安全色 -->
  8. <view class="bg_img" :style="{backgroundColor:top_bg_color}"></view>
  9. <t-i-navbar :mine_code="mine_code" :navbar_bg_color="navbar_bg_color"></t-i-navbar>
  10. <t-i-notice :text="text"></t-i-notice>
  11. <t-i-banner :banner="banners" :mine_code="mine_code" @change_top_bg_color_img="change_top_bg_color_img">
  12. </t-i-banner>
  13. </view>
  14. <view v-for="(item,index) in common">
  15. <view class="fixed_system" v-if="item.type_name == '七个建设' && item.index == index">
  16. <view class="line">
  17. <view class="item" v-for="(item_2,index_2) in item.data" :key="index_2" v-if="index_2 < 3" @click="go_page(item_2)">
  18. <view class="icon">
  19. <image :src="item_2.thumb" mode=""></image>
  20. </view>
  21. <view class="text">{{item_2.title}}</view>
  22. </view>
  23. </view>
  24. <view class="line">
  25. <view class="item" v-for="(item_2,index_2) in item.data" :key="index_2" v-if="index_2 > 2" @click="go_page(item_2)">
  26. <view class="icon">
  27. <image :src="item_2.thumb" mode=""></image>
  28. </view>
  29. <view class="text">{{item_2.title}}</view>
  30. </view>
  31. </view>
  32. </view>
  33. <view class="todo" v-if="item.type_name == '待办事项' && item.index == index">
  34. <view class="left">
  35. <view class="title">
  36. <view class="icon"></view>
  37. <view class="text">待办事项</view>
  38. </view>
  39. </view>
  40. <view class="right">
  41. <view class="tip">您有 <text style="color: #FF0000;">0</text> 项待办</view>
  42. <view class="detail">
  43. 详情 <uni-icons type="right" size="12" color="#B5B5B5"></uni-icons>
  44. </view>
  45. </view>
  46. </view>
  47. <view class="nav" v-if="item.type_name == '实操应用' && item.index == index">
  48. <view class="section" v-for="(item_2,index_2) in item.data" :key="index_2">
  49. <view class="title">
  50. <view class="icon"></view>
  51. <view class="text">{{item_2.title}}</view>
  52. </view>
  53. <view class="list">
  54. <view class="item" v-for="(item_3,index_3) in item_2.children" :key="index_3" @click="go_page(item_3)">
  55. <view class="icon">
  56. <image :src="item_3.thumb" mode=""></image>
  57. </view>
  58. <view class="text">{{item_3.title}}</view>
  59. </view>
  60. </view>
  61. </view>
  62. </view>
  63. <view class="nav" v-if="item.type_name == '数据平台' && item.index == index">
  64. <view class="section" v-for="(item_2,index_2) in item.data" :key="index_2">
  65. <view class="title">
  66. <view class="icon"></view>
  67. <view class="text">{{item_2.title}}</view>
  68. </view>
  69. <view class="list">
  70. <view class="item" v-for="(item_3,index_3) in item_2.children" :key="index_3" @click="go_page(item_3)">
  71. <view class="icon">
  72. <image :src="item_3.thumb" mode=""></image>
  73. </view>
  74. <view class="text">{{item_3.title}}</view>
  75. </view>
  76. </view>
  77. </view>
  78. </view>
  79. <view class="nav" v-if="item.type_name == '学习资料' && item.index == index">
  80. <view class="section" v-for="(item_2,index_2) in item.data" :key="index_2">
  81. <view class="title">
  82. <view class="icon"></view>
  83. <view class="text">{{item_2.title}}</view>
  84. </view>
  85. <view class="list">
  86. <view class="item" v-for="(item_3,index_3) in item_2.children" :key="index_3" @click="go_page(item_3)">
  87. <view class="icon">
  88. <image :src="item_3.thumb" mode=""></image>
  89. </view>
  90. <view class="text">{{item_3.title}}</view>
  91. </view>
  92. </view>
  93. </view>
  94. </view>
  95. <view class="news" v-if="item.type_name == '动态信息' && item.index == index">
  96. <view class="title_box">
  97. <view class="left">
  98. <view class="title">
  99. <view class="icon"></view>
  100. <view class="text">动态信息</view>
  101. </view>
  102. </view>
  103. <view class="right" @click="go_more()">
  104. <view class="detail">
  105. 查看全部 <uni-icons type="right" size="12" color="#B5B5B5"></uni-icons>
  106. </view>
  107. </view>
  108. </view>
  109. <view class="list">
  110. <view class="item" v-for="(item,index) in newsList" :key="index" @click="go_detail(item.id)">
  111. <view class="icon"></view>
  112. <view class="inner">
  113. <view class="new_title">{{item.title}}</view>
  114. <view class="tip">
  115. <view class="time">{{item.created_at}}</view>
  116. <view class="detail">
  117. 详情<image src="./icon/new_detail.png" mode=""></image>
  118. </view>
  119. </view>
  120. </view>
  121. </view>
  122. </view>
  123. </view>
  124. </view>
  125. </view>
  126. </template>
  127. <script>
  128. import {
  129. set_base_url
  130. } from '@/common/set_base_url.js'
  131. import {
  132. goToLink
  133. } from '@/common/common.js'
  134. // 版本控制
  135. import upApp from "@/uni_modules/uni-upgrade-center-app/utils/check-update"
  136. export default {
  137. data() {
  138. return {
  139. // 根_mine_code
  140. app_mine_code: "",
  141. // 当前煤矿编码
  142. mine_code: "",
  143. // 首页接口的基础请求路径 默认为当前矿编码的基础路径
  144. base_url: " ",
  145. // 轮播图
  146. banners: [],
  147. // 新闻列表
  148. newsList: "",
  149. // 值班公告
  150. text: "",
  151. // 背景虚化图片
  152. top_bg_color_img: "",
  153. // 背景安全色
  154. top_bg_color: "#7372c2",
  155. top_bg_color_list: ['#d62b2b', '#00a2e8', '#b08654',"#7372c2"],
  156. // 标题栏背景色
  157. navbar_bg_color: "",
  158. common:[]
  159. }
  160. },
  161. onPullDownRefresh() {
  162. uni.reLaunch({
  163. url: "./index"
  164. })
  165. setTimeout(function() {
  166. uni.stopPullDownRefresh();
  167. }, 1000);
  168. },
  169. onLoad() {
  170. // 初始化当前煤矿编码
  171. this.mine_code = uni.getStorageSync('mine_code')
  172. // 根据矿编码切换首页接口不同的请求基础路径
  173. this.base_url = set_base_url(this.mine_code)
  174. // #ifdef H5
  175. if (this.mine_code == 'ningmeijituan') {
  176. if (window.location.href.indexOf('token') != -1) {
  177. this.$api.oauth_getNoPasswordToken({
  178. token: window.location.href.split('token=')[1].split('&')[0],
  179. caller: window.location.href.split('token=')[1].split('&')[1].split('=')[1]
  180. }).then((res) => {
  181. uni.setStorageSync('Authorization', res.data.data.accessToken)
  182. uni.setStorageSync('token_type', res.data.data.token_type)
  183. // 存储用户基本信息
  184. uni.setStorageSync('user', res.data.data.user);
  185. uni.setStorageSync('people_code', res.data.data.user.people_code);
  186. // 存储电话号码
  187. uni.setStorageSync('mobile', res.data.data.user.mobile);
  188. })
  189. }else{
  190. this.check_token()
  191. }
  192. }else{
  193. this.check_token()
  194. }
  195. // #endif
  196. // 检查更新
  197. upApp()
  198. // #ifdef APP-PLUS
  199. this.check_token()
  200. // #endif
  201. // 获取轮播图
  202. this.get_banner()
  203. // 获取首页新闻列表
  204. this.getNews()
  205. // 值班公告
  206. this.get_notice()
  207. this.get_home_aqyk_newLinks()
  208. },
  209. onPageScroll: function(e) {
  210. if (e.scrollTop > 300) {
  211. this.navbar_bg_color = "#009fe8"
  212. } else {
  213. this.navbar_bg_color = ""
  214. }
  215. },
  216. methods: {
  217. // 单点登录及token过期验证
  218. check_token() {
  219. // token过期验证
  220. this.$api.worksheet_classify_list({
  221. }).then((res) => {
  222. // console.log(res)
  223. if (res.data.code == 401) {
  224. uni.showToast({
  225. icon: "none",
  226. title: "登录失效、请重新登录"
  227. })
  228. uni.clearStorageSync('Authorization');
  229. setTimeout(function() {
  230. uni.redirectTo({
  231. url: "../../my/login/login"
  232. })
  233. }, 1500)
  234. } else {
  235. // console.log(res)
  236. }
  237. })
  238. },
  239. get_home_aqyk_newLinks() {
  240. this.$api.home_aqyk_newLinks({
  241. }).then((res) => {
  242. // console.log(res.data)
  243. let data = res.data
  244. data.forEach((item,index)=>{
  245. item['index'] = index
  246. })
  247. // console.log(data)
  248. this.common = data
  249. })
  250. },
  251. // 获取轮播图
  252. get_banner() {
  253. uni.request({
  254. url: this.base_url + "/scrollImg/list",
  255. method: "GET",
  256. success: (res) => {
  257. // console.log(res.data.data.data)
  258. this.banners = res.data.data.data
  259. this.top_bg_color_img = this.banners[0].imgURL
  260. }
  261. })
  262. },
  263. // 请求新闻动态
  264. getNews() {
  265. uni.request({
  266. url: this.base_url + "/article/list",
  267. method: "GET",
  268. data: {
  269. pageSize: 4
  270. },
  271. success: (res) => {
  272. this.newsList = res.data.data.data
  273. }
  274. })
  275. },
  276. // 值班公告
  277. get_notice() {
  278. uni.request({
  279. url: this.base_url + "/notice/list",
  280. method: "GET",
  281. success: (res) => {
  282. if (!res.data.data.content) {
  283. this.text = res.data.data.message
  284. } else {
  285. this.text = res.data.data.content.replace(/<br /g, " ").replace(/>/g, " ").replace(
  286. /\//g, " ")
  287. }
  288. }
  289. })
  290. },
  291. // 切换背景图片
  292. change_top_bg_color_img(index) {
  293. if (index > 3) {
  294. index = parseInt(4 * Math.random())
  295. }
  296. this.top_bg_color = this.top_bg_color_list[index]
  297. },
  298. go_page(item){
  299. if(item.link == null){
  300. uni.showToast({
  301. icon:"none",
  302. title:"暂未开通"
  303. })
  304. return
  305. }
  306. if(item.link.indexOf('pageId') != -1){
  307. let url = item.link.split("&amp;").join("&")
  308. let obj = {link:url}
  309. goToLink(obj, this.mine_code)
  310. }else{
  311. goToLink(item, this.mine_code)
  312. }
  313. },
  314. // 打开详情页
  315. go_detail(id) {
  316. uni.navigateTo({
  317. url: "../../index/news/news?id=" + id + "&mine_code=ningmeijituan"
  318. })
  319. },
  320. // 打开列表
  321. go_more() {
  322. uni.navigateTo({
  323. url: "../../index/news/news_list/news_list?mine_code=ningmeijituan"
  324. })
  325. }
  326. }
  327. }
  328. </script>
  329. <style lang="scss">
  330. page {
  331. background-color: #FFFFFF;
  332. }
  333. .top_bg_color {
  334. position: relative;
  335. width: 750rpx;
  336. overflow: hidden;
  337. .bg_img {
  338. width: 750rpx;
  339. height: 440rpx;
  340. position: absolute;
  341. top: 0;
  342. left: 0;
  343. z-index: 0;
  344. background-position: center;
  345. background-size: 100% 100%;
  346. filter: blur(50px);
  347. transform: scale(2);
  348. opacity: 0.9;
  349. }
  350. }
  351. .fixed_system {
  352. box-sizing: border-box;
  353. padding: 25rpx 0;
  354. width: 750rpx;
  355. height: 436rpx;
  356. background-image: url(./icon/section.png);
  357. background-size: 100% 100%;
  358. background-repeat: no-repeat;
  359. .line {
  360. box-sizing: border-box;
  361. padding: 25rpx;
  362. display: flex;
  363. justify-content: center;
  364. .item {
  365. margin-right: 54rpx;
  366. .icon {
  367. image {
  368. width: 109rpx;
  369. height: 109rpx;
  370. display: block;
  371. }
  372. }
  373. .text {
  374. font-size: 28rpx;
  375. color: #171717;
  376. }
  377. }
  378. }
  379. .line:first-child {
  380. .item:nth-child(3) {
  381. margin-right: 0;
  382. }
  383. }
  384. .line:last-child {
  385. .item:nth-child(4) {
  386. margin-right: 0;
  387. }
  388. }
  389. }
  390. .todo {
  391. box-sizing: border-box;
  392. padding: 25rpx;
  393. display: flex;
  394. justify-content: space-between;
  395. align-items: center;
  396. .left {
  397. .title {
  398. display: flex;
  399. align-items: center;
  400. .icon {
  401. width: 9rpx;
  402. height: 34rpx;
  403. background-color: #04A0E8;
  404. border-radius: 5rpx;
  405. }
  406. .text {
  407. margin-left: 10rpx;
  408. color: #6A6A6A;
  409. font-size: 33rpx;
  410. font-weight: 700;
  411. }
  412. }
  413. }
  414. .right {
  415. display: flex;
  416. align-items: baseline;
  417. .tip {
  418. font-size: 25rpx;
  419. color: #6A6A6A;
  420. }
  421. .detail {
  422. margin-left: 24rpx;
  423. font-size: 25rpx;
  424. color: #B5B5B5;
  425. }
  426. }
  427. }
  428. .nav {
  429. background-color: #F7F9F7;
  430. width: 750rpx;
  431. padding: 10rpx 0;
  432. .section {
  433. background-color: #FFFFFF;
  434. box-sizing: border-box;
  435. padding: 25rpx;
  436. .title {
  437. padding: 20rpx 0;
  438. display: flex;
  439. align-items: center;
  440. .icon {
  441. width: 9rpx;
  442. height: 34rpx;
  443. background-color: #04A0E8;
  444. border-radius: 5rpx;
  445. }
  446. .text {
  447. margin-left: 10rpx;
  448. color: #6A6A6A;
  449. font-size: 33rpx;
  450. font-weight: 700;
  451. }
  452. }
  453. .list {
  454. width: 700rpx;
  455. overflow: hidden;
  456. .item {
  457. margin-top: 20rpx;
  458. float: left;
  459. margin-right: 20rpx;
  460. width: 120rpx;
  461. text-align: center;
  462. .icon {
  463. image {
  464. width: 73rpx;
  465. height: 73rpx;
  466. }
  467. }
  468. .text {
  469. color: #171717;
  470. font-size: 26rpx;
  471. white-space: nowrap;
  472. overflow: hidden;
  473. text-overflow: ellipsis;
  474. }
  475. }
  476. .item:nth-child(5n) {
  477. margin-right: 0;
  478. }
  479. }
  480. }
  481. }
  482. .news {
  483. background-color: #F7F9F7;
  484. padding-top: 20rpx;
  485. .title_box {
  486. background-color: #FFFFFF;
  487. box-sizing: border-box;
  488. padding: 25rpx;
  489. display: flex;
  490. justify-content: space-between;
  491. align-items: center;
  492. .left {
  493. .title {
  494. display: flex;
  495. align-items: center;
  496. .icon {
  497. width: 9rpx;
  498. height: 34rpx;
  499. background-color: #04A0E8;
  500. border-radius: 5rpx;
  501. }
  502. .text {
  503. margin-left: 10rpx;
  504. color: #6A6A6A;
  505. font-size: 33rpx;
  506. font-weight: 700;
  507. }
  508. }
  509. }
  510. .right {
  511. display: flex;
  512. align-items: baseline;
  513. .tip {
  514. font-size: 25rpx;
  515. color: #6A6A6A;
  516. }
  517. .detail {
  518. margin-left: 24rpx;
  519. font-size: 25rpx;
  520. color: #B5B5B5;
  521. }
  522. }
  523. }
  524. .list {
  525. box-sizing: border-box;
  526. padding: 25rpx;
  527. background-color: #FFFFFF;
  528. .item {
  529. margin-bottom: 20rpx;
  530. display: flex;
  531. justify-content: space-between;
  532. border-bottom: 1rpx solid #F5F6F7;
  533. .icon {
  534. position: relative;
  535. top: 16rpx;
  536. width: 8rpx;
  537. height: 8rpx;
  538. background: #999999;
  539. border-radius: 50%;
  540. }
  541. .inner {
  542. width: 680rpx;
  543. .new_title {
  544. color: #171717;
  545. font-size: 29rpx;
  546. line-height: 44rpx;
  547. }
  548. .tip {
  549. margin: 20rpx 0;
  550. display: flex;
  551. justify-content: space-between;
  552. .time {
  553. font-size: 26rpx;
  554. color: #999999;
  555. }
  556. .detail {
  557. color: #FD6B5C;
  558. font-size: 23rpx;
  559. image {
  560. margin-left: 8rpx;
  561. width: 19rpx;
  562. height: 16rpx;
  563. }
  564. }
  565. }
  566. }
  567. }
  568. .item:last-child {
  569. border: none;
  570. }
  571. }
  572. }
  573. </style>