index.vue 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530
  1. <template>
  2. <view>
  3. <!-- 首页风格切换-1-切换风格 -->
  4. <view class="top_bg_color" v-if="index_type == 1">
  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. <!-- 首页风格切换-2-默认风格 -->
  15. <view v-if="index_type == 2">
  16. <t-i-navbar-2 :mine_code="mine_code"></t-i-navbar-2>
  17. <t-i-notice-2 :text="text"></t-i-notice-2>
  18. <t-i-banner-2 :banner="banners" :mine_code="mine_code" @change_top_bg_color_img="change_top_bg_color_img">
  19. </t-i-banner-2>
  20. </view>
  21. <view v-if="mine_code == 'ningdongyunying'">
  22. <t-i-ice :iceList="ice_list" :mine_code="mine_code"></t-i-ice>
  23. </view>
  24. <view v-if="mine_code == 'yangchangwan'">
  25. <t-i-ice :iceList="ice_list" :mine_code="mine_code"></t-i-ice>
  26. </view>
  27. <view v-if="mine_code == 'shicaocun'">
  28. <t-i-ice :iceList="ice_list" :mine_code="mine_code"></t-i-ice>
  29. </view>
  30. <t-i-icon v-if="mine_code == 'ningmeijituan' || 'wuyegongsi'" :iconList="iconList"
  31. :mine_code="mine_code"></t-i-icon>
  32. <!-- 新闻列表 -->
  33. <t-i-news :newsList="newsList" :mine_code="mine_code"></t-i-news>
  34. <!-- 固定入口 -->
  35. <t-i-icon v-if="mine_code != 'ningmeijituan' && iconList.length > 0" :iconList="iconList"
  36. :mine_code="mine_code"></t-i-icon>
  37. <!-- 常用功能 -->
  38. <t-i-common v-if="mine_code == 'ningdongyunying'"></t-i-common>
  39. <!-- 开屏通告 -->
  40. <openingNotice></openingNotice>
  41. <!-- 宁东运营 -->
  42. <view v-if="mine_code == 'ningdongyunying'">
  43. <t-i-ningdongyunying :mine_code="mine_code" :home_link="home_link" v-if="home_link.length > 0">
  44. </t-i-ningdongyunying>
  45. </view>
  46. <!-- 宁煤集团 -->
  47. <view v-if="mine_code == 'ningmeijituan'">
  48. <t-i-ningmeijituan :mine_code="mine_code" :home_link="home_link" v-if="home_link.length > 0">
  49. </t-i-ningmeijituan>
  50. </view>
  51. <!-- 金家渠 -->
  52. <view v-if="mine_code == 'jinjiaqu' || mine_code == 'jinjiaqu_neiwang'">
  53. <t-i-jinjiaqu :mine_code="mine_code" :home_link="home_link" v-if="home_link.length > 0"></t-i-jinjiaqu>
  54. </view>
  55. <!-- 石槽村 -->
  56. <view v-if="mine_code == 'shicaocun'">
  57. <t-i-shicaocun :mine_code="mine_code" :home_link="home_link" v-if="home_link.length > 0"></t-i-shicaocun>
  58. </view>
  59. <!-- 金凤 -->
  60. <view v-if="mine_code == 'jinfeng' || mine_code == 'jinfeng_neiwang'">
  61. <t-i-jinfeng :mine_code="mine_code" :home_link="home_link" v-if="home_link.length > 0"></t-i-jinfeng>
  62. </view>
  63. <!-- 羊场湾 -->
  64. <view v-if="mine_code == 'yangchangwan'">
  65. <t-i-yangchangwan :mine_code="mine_code" :home_link="home_link" v-if="home_link.length > 0">
  66. </t-i-yangchangwan>
  67. </view>
  68. <!-- 枣泉 -->
  69. <view v-if="mine_code == 'zaoquan'">
  70. <t-i-zaoquan :mine_code="mine_code" :home_link="home_link" v-if="home_link.length > 0"></t-i-zaoquan>
  71. </view>
  72. </view>
  73. </template>
  74. <script>
  75. import {
  76. set_base_url
  77. } from '@/common/set_base_url.js'
  78. import {
  79. goToLink
  80. } from '@/common/common.js'
  81. export default {
  82. data() {
  83. return {
  84. // 根_mine_code
  85. app_mine_code: "",
  86. // 当前煤矿编码
  87. mine_code: "",
  88. // 首页接口的基础请求路径 默认为当前矿编码的基础路径
  89. base_url: " ",
  90. // 轮播图
  91. banners: [],
  92. // 新闻列表
  93. newsList: "",
  94. // 值班公告
  95. text: "",
  96. // 固定入口
  97. iconList: [],
  98. iconList_arr: [],
  99. iconList_data: [],
  100. // 首页链接
  101. home_link: [],
  102. // 背景虚化图片
  103. top_bg_color_img: "",
  104. // 背景安全色
  105. top_bg_color: "#7372c2",
  106. // top_bg_color_list: ['#3e88c6', '#e75038', '#305471', '#f8bf3c', '#37ba73', '#7372c2'],
  107. top_bg_color_list: ['#d62b2b', '#00a2e8', '#b08654'],
  108. // 标题栏背景色
  109. navbar_bg_color: "",
  110. index_type: 1,
  111. // 信息平台链接
  112. ice_list: []
  113. }
  114. },
  115. onPullDownRefresh() {
  116. uni.reLaunch({
  117. url: "./index"
  118. })
  119. setTimeout(function() {
  120. uni.stopPullDownRefresh();
  121. }, 1000);
  122. },
  123. onLoad() {
  124. this.app_mine_code = uni.getStorageSync('mine_code')
  125. // 初始化当前煤矿编码
  126. this.mine_code = uni.getStorageSync('mine_code')
  127. // 根据矿编码切换首页接口不同的请求基础路径
  128. this.base_url = set_base_url(this.mine_code)
  129. // 风格定义
  130. // this.$api.home_style_setting({
  131. // }).then((res) => {
  132. // console.log(res.data.data)
  133. // this.index_type = res.data.data.value
  134. // })
  135. // #ifdef H5
  136. if (this.app_mine_code == 'ningmeijituan') {
  137. if (window.location.href.indexOf('token') != -1) {
  138. this.$api.oauth_getNoPasswordToken({
  139. token: window.location.href.split('token=')[1].split('&')[0],
  140. caller: window.location.href.split('token=')[1].split('&')[1].split('=')[1]
  141. }).then((res) => {
  142. uni.setStorageSync('Authorization', res.data.data.accessToken)
  143. uni.setStorageSync('token_type', res.data.data.token_type)
  144. // 存储用户基本信息
  145. uni.setStorageSync('user', res.data.data.user);
  146. uni.setStorageSync('people_code', res.data.data.user.people_code);
  147. // 存储电话号码
  148. uni.setStorageSync('mobile', res.data.data.user.mobile);
  149. })
  150. } else {
  151. this.check_token()
  152. }
  153. } else {
  154. this.check_token()
  155. }
  156. // #endif
  157. // #ifdef APP-PLUS
  158. this.check_token()
  159. // #endif
  160. // 获取轮播图
  161. this.get_banner()
  162. // 获取首页新闻列表
  163. this.getNews()
  164. // 值班公告
  165. this.get_notice()
  166. // 固定入口
  167. this.get_list()
  168. this.get_home_link()
  169. // 获取信息平台
  170. this.get_ICE_list()
  171. },
  172. onPageScroll: function(e) {
  173. if (e.scrollTop > 300) {
  174. this.navbar_bg_color = "#009fe8"
  175. } else {
  176. this.navbar_bg_color = ""
  177. }
  178. },
  179. onShow() {
  180. // E信-切换矿
  181. uni.$on('update_kuang', (data) => {
  182. this.mine_code = data.msg
  183. // 根据矿编码切换首页接口不同的请求基础路径
  184. this.base_url = set_base_url(this.mine_code)
  185. // uni.setStorageSync('base_url',this.base_url)
  186. // 获取轮播图
  187. this.get_banner()
  188. // 获取首页新闻列表
  189. this.getNews()
  190. // 值班公告
  191. this.get_notice()
  192. // 固定入口
  193. this.get_list()
  194. this.get_home_link()
  195. // 获取信息平台
  196. this.get_ICE_list()
  197. this.$forceUpdate()
  198. })
  199. uni.$on('common_update_kuang', (data) => {
  200. this.mine_code = data.msg
  201. // 根据矿编码切换首页接口不同的请求基础路径
  202. this.base_url = set_base_url(this.mine_code)
  203. // uni.setStorageSync('base_url',this.base_url)
  204. // 获取轮播图
  205. this.get_banner()
  206. // 获取首页新闻列表
  207. this.getNews()
  208. // 值班公告
  209. this.get_notice()
  210. // 固定入口
  211. this.get_list()
  212. this.get_home_link()
  213. // 获取信息平台
  214. this.get_ICE_list()
  215. this.$forceUpdate()
  216. })
  217. if (this.app_mine_code == 'ningdongyunying') {
  218. this.setTabBarBadge()
  219. }
  220. },
  221. methods: {
  222. // 单点登录及token过期验证
  223. check_token() {
  224. // token过期验证
  225. this.$api.worksheet_classify_list({
  226. }).then((res) => {
  227. // console.log(res)
  228. if (res.data.code == 401) {
  229. uni.showToast({
  230. icon: "none",
  231. title: "登录失效、请重新登录"
  232. })
  233. uni.clearStorageSync('Authorization');
  234. setTimeout(function() {
  235. uni.redirectTo({
  236. url: "../../my/login/login"
  237. })
  238. }, 1500)
  239. } else {
  240. // console.log(res)
  241. }
  242. })
  243. },
  244. // 获取轮播图
  245. get_banner() {
  246. if (this.mine_code != "zaoquan") {
  247. uni.request({
  248. url: this.base_url + "/scrollImg/list",
  249. method: "GET",
  250. header: {
  251. 'accesskey': "b364b449a18af327867f7edc3431b541"
  252. },
  253. success: (res) => {
  254. // console.log(res.data.data.data)
  255. this.banners = res.data.data.data
  256. this.top_bg_color_img = this.banners[0].imgURL
  257. }
  258. })
  259. } else {
  260. this.$api.zaoquan_article_list({
  261. type: "mkxw",
  262. page_num: 1,
  263. page_size: 10
  264. }).then((res) => {
  265. let newArray = []
  266. res.data.content.forEach((item,index)=>{
  267. let banner = {}
  268. banner.imgURL = item.main_img
  269. banner.title = item.title
  270. banner.text = item.text
  271. newArray.push(banner)
  272. })
  273. this.banners = newArray
  274. })
  275. }
  276. },
  277. // 请求新闻动态
  278. getNews() {
  279. if (this.mine_code != "zaoquan") {
  280. uni.request({
  281. url: this.base_url + "/article/list",
  282. method: "GET",
  283. header: {
  284. 'accesskey': "b364b449a18af327867f7edc3431b541"
  285. },
  286. data: {
  287. pageSize: 4
  288. },
  289. success: (res) => {
  290. this.newsList = res.data.data.data
  291. }
  292. })
  293. } else {
  294. this.$api.zaoquan_article_list({
  295. type: "mkxw",
  296. page_num: 1,
  297. page_size: 4
  298. }).then((res) => {
  299. this.newsList = res.data.content
  300. })
  301. }
  302. },
  303. // 信息平台
  304. get_ICE_list() {
  305. this.ice_list = []
  306. uni.request({
  307. url: this.base_url + "/home/links",
  308. header: {
  309. 'accesskey': "b364b449a18af327867f7edc3431b541"
  310. },
  311. success: (res) => {
  312. // console.log(res.data.data)
  313. if (this.mine_code == 'jinfeng') {
  314. this.ice_list = res.data.data[2].children
  315. } else if (this.mine_code == 'ningdongyunying') {
  316. this.ice_list = res.data.data[1].children
  317. } else if (this.mine_code == 'ningmeijituan') {
  318. this.ice_list = res.data.data[1].children
  319. } else if (this.mine_code == 'shicaocun') {
  320. this.ice_list = res.data.data[0].children
  321. } else if (this.mine_code == 'yangchangwan') {
  322. this.ice_list = res.data.data[1].children
  323. } else if (this.mine_code == 'shicaocun') {
  324. this.ice_list = res.data.data[0].children
  325. }
  326. }
  327. })
  328. },
  329. // 值班公告
  330. get_notice() {
  331. uni.request({
  332. url: this.base_url + "/notice/list",
  333. method: "GET",
  334. header: {
  335. 'accesskey': "b364b449a18af327867f7edc3431b541"
  336. },
  337. success: (res) => {
  338. if (!res.data.data.content) {
  339. this.text = res.data.data.message
  340. } else {
  341. this.text = res.data.data.content.replace(/<br /g, " ").replace(/>/g, " ").replace(
  342. /\//g, " ")
  343. }
  344. }
  345. })
  346. },
  347. // 固定入口
  348. get_list() {
  349. this.iconList = []
  350. // 加分组
  351. uni.request({
  352. url: this.base_url + "/homeNav/listByCategory",
  353. header: {
  354. 'accesskey': "b364b449a18af327867f7edc3431b541"
  355. },
  356. method: "GET",
  357. success: (res) => {
  358. // console.log(res.data.data)
  359. this.iconList = res.data.data
  360. }
  361. })
  362. },
  363. // 首页链接
  364. get_home_link() {
  365. this.home_link = []
  366. uni.request({
  367. url: this.base_url + "/home/links",
  368. method: "GET",
  369. header: {
  370. 'accesskey': "b364b449a18af327867f7edc3431b541"
  371. },
  372. success: (res) => {
  373. // console.log(res)
  374. this.home_link = res.data.data
  375. }
  376. })
  377. },
  378. // 切换背景图片
  379. change_top_bg_color_img(index) {
  380. // this.top_bg_color_img = this.banners[index].imgURL
  381. if (index > 2) {
  382. index = parseInt(3 * Math.random())
  383. }
  384. this.top_bg_color = this.top_bg_color_list[index]
  385. },
  386. setTabBarBadge() {
  387. // 闭环管理
  388. this.$api.five_fixed_fiveFixedNewCategory({
  389. }).then((res) => {
  390. // console.log(res.data.content.data)
  391. let data = res.data.content.data
  392. let num = 0
  393. data.forEach((item, index) => {
  394. num = num + item.no_num
  395. })
  396. if (this.mine_code == 'ningdongyunying') {
  397. if (num > 0) {
  398. uni.showTabBarRedDot({
  399. index: 2,
  400. })
  401. }
  402. }
  403. })
  404. this.$api.workflow_todo_query({
  405. staff_num: uni.getStorageSync('user').staff_num,
  406. query_type: 2
  407. }).then((res) => {
  408. let num = 0
  409. num = res.data.content.data
  410. if (this.mine_code == 'ningdongyunying') {
  411. if (num > 0) {
  412. uni.showTabBarRedDot({
  413. index: 2,
  414. })
  415. }
  416. }
  417. })
  418. this.$api.workflow_todo_query({
  419. staff_num: uni.getStorageSync('user').staff_num,
  420. query_type: 1
  421. }).then((res) => {
  422. let num = 0
  423. num = res.data.content.data
  424. if (this.mine_code == 'ningdongyunying') {
  425. if (num > 0) {
  426. uni.showTabBarRedDot({
  427. index: 2,
  428. })
  429. }
  430. }
  431. })
  432. }
  433. }
  434. }
  435. </script>
  436. <style lang="scss">
  437. page {
  438. background-color: #F6FAF6;
  439. }
  440. .top_bg_color {
  441. position: relative;
  442. width: 750rpx;
  443. overflow: hidden;
  444. .bg_img {
  445. width: 750rpx;
  446. height: 440rpx;
  447. position: absolute;
  448. top: 0;
  449. left: 0;
  450. z-index: 0;
  451. background-position: center;
  452. background-size: 100% 100%;
  453. filter: blur(50px);
  454. transform: scale(2);
  455. opacity: 0.9;
  456. }
  457. }
  458. </style>