index.vue 13 KB

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