index.vue 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501
  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" :mine_code="mine_code"></t-i-icon>
  31. <!-- 新闻列表 -->
  32. <t-i-news :newsList="newsList" :mine_code="mine_code"></t-i-news>
  33. <!-- 固定入口 -->
  34. <t-i-icon v-if="mine_code != 'ningmeijituan' && iconList.length > 0" :iconList="iconList" :mine_code="mine_code"></t-i-icon>
  35. <!-- 常用功能 -->
  36. <t-i-common v-if="mine_code == 'ningdongyunying'"></t-i-common>
  37. <!-- 开屏通告 -->
  38. <openingNotice></openingNotice>
  39. <!-- 宁东运营 -->
  40. <view v-if="mine_code == 'ningdongyunying'">
  41. <t-i-ningdongyunying :mine_code="mine_code" :home_link="home_link" v-if="home_link.length > 0">
  42. </t-i-ningdongyunying>
  43. </view>
  44. <!-- 宁煤集团 -->
  45. <view v-if="mine_code == 'ningmeijituan'">
  46. <t-i-ningmeijituan :mine_code="mine_code" :home_link="home_link" v-if="home_link.length > 0">
  47. </t-i-ningmeijituan>
  48. </view>
  49. <!-- 金家渠 -->
  50. <view v-if="mine_code == 'jinjiaqu' || mine_code == 'jinjiaqu_neiwang'">
  51. <t-i-jinjiaqu :mine_code="mine_code" :home_link="home_link" v-if="home_link.length > 0"></t-i-jinjiaqu>
  52. </view>
  53. <!-- 石槽村 -->
  54. <view v-if="mine_code == 'shicaocun'">
  55. <t-i-shicaocun :mine_code="mine_code" :home_link="home_link" v-if="home_link.length > 0"></t-i-shicaocun>
  56. </view>
  57. <!-- 金凤 -->
  58. <view v-if="mine_code == 'jinfeng' || mine_code == 'jinfeng_neiwang'">
  59. <t-i-jinfeng :mine_code="mine_code" :home_link="home_link" v-if="home_link.length > 0"></t-i-jinfeng>
  60. </view>
  61. <!-- 羊场湾 -->
  62. <view v-if="mine_code == 'yangchangwan'">
  63. <t-i-yangchangwan :mine_code="mine_code" :home_link="home_link" v-if="home_link.length > 0">
  64. </t-i-yangchangwan>
  65. </view>
  66. <!-- 枣泉 -->
  67. <view v-if="mine_code == 'zaoquan'">
  68. <t-i-zaoquan :mine_code="mine_code" :home_link="home_link" v-if="home_link.length > 0"></t-i-zaoquan>
  69. </view>
  70. </view>
  71. </template>
  72. <script>
  73. import {
  74. set_base_url
  75. } from '@/common/set_base_url.js'
  76. import {
  77. goToLink
  78. } from '@/common/common.js'
  79. // 版本控制
  80. import upApp from "@/uni_modules/uni-upgrade-center-app/utils/check-update"
  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. // 检查更新
  158. upApp()
  159. // #ifdef APP-PLUS
  160. this.check_token()
  161. // #endif
  162. // 获取轮播图
  163. this.get_banner()
  164. // 获取首页新闻列表
  165. this.getNews()
  166. // 值班公告
  167. this.get_notice()
  168. // 固定入口
  169. this.get_list()
  170. this.get_home_link()
  171. // 获取信息平台
  172. this.get_ICE_list()
  173. },
  174. onPageScroll: function(e) {
  175. if (e.scrollTop > 300) {
  176. this.navbar_bg_color = "#009fe8"
  177. } else {
  178. this.navbar_bg_color = ""
  179. }
  180. },
  181. onShow() {
  182. // E信-切换矿
  183. uni.$on('update_kuang', (data) => {
  184. this.mine_code = data.msg
  185. // 根据矿编码切换首页接口不同的请求基础路径
  186. this.base_url = set_base_url(this.mine_code)
  187. // uni.setStorageSync('base_url',this.base_url)
  188. // 获取轮播图
  189. this.get_banner()
  190. // 获取首页新闻列表
  191. this.getNews()
  192. // 值班公告
  193. this.get_notice()
  194. // 固定入口
  195. this.get_list()
  196. this.get_home_link()
  197. // 获取信息平台
  198. this.get_ICE_list()
  199. this.$forceUpdate()
  200. })
  201. uni.$on('common_update_kuang', (data) => {
  202. this.mine_code = data.msg
  203. // 根据矿编码切换首页接口不同的请求基础路径
  204. this.base_url = set_base_url(this.mine_code)
  205. // uni.setStorageSync('base_url',this.base_url)
  206. // 获取轮播图
  207. this.get_banner()
  208. // 获取首页新闻列表
  209. this.getNews()
  210. // 值班公告
  211. this.get_notice()
  212. // 固定入口
  213. this.get_list()
  214. this.get_home_link()
  215. // 获取信息平台
  216. this.get_ICE_list()
  217. this.$forceUpdate()
  218. })
  219. if (this.app_mine_code == 'ningdongyunying') {
  220. this.setTabBarBadge()
  221. }
  222. },
  223. methods: {
  224. // 单点登录及token过期验证
  225. check_token() {
  226. // token过期验证
  227. this.$api.worksheet_classify_list({
  228. }).then((res) => {
  229. // console.log(res)
  230. if (res.data.code == 401) {
  231. uni.showToast({
  232. icon: "none",
  233. title: "登录失效、请重新登录"
  234. })
  235. uni.clearStorageSync('Authorization');
  236. setTimeout(function() {
  237. uni.redirectTo({
  238. url: "../../my/login/login"
  239. })
  240. }, 1500)
  241. } else {
  242. // console.log(res)
  243. }
  244. })
  245. },
  246. // 获取轮播图
  247. get_banner() {
  248. uni.request({
  249. url: this.base_url + "/scrollImg/list",
  250. method: "GET",
  251. header:{
  252. 'accesskey': "b364b449a18af327867f7edc3431b541"
  253. },
  254. success: (res) => {
  255. // console.log(res.data.data.data)
  256. this.banners = res.data.data.data
  257. this.top_bg_color_img = this.banners[0].imgURL
  258. }
  259. })
  260. },
  261. // 请求新闻动态
  262. getNews() {
  263. uni.request({
  264. url: this.base_url + "/article/list",
  265. method: "GET",
  266. header:{
  267. 'accesskey': "b364b449a18af327867f7edc3431b541"
  268. },
  269. data: {
  270. pageSize: 4
  271. },
  272. success: (res) => {
  273. this.newsList = res.data.data.data
  274. }
  275. })
  276. },
  277. // 信息平台
  278. get_ICE_list() {
  279. this.ice_list = []
  280. uni.request({
  281. url: this.base_url + "/home/links",
  282. header:{
  283. 'accesskey': "b364b449a18af327867f7edc3431b541"
  284. },
  285. success: (res) => {
  286. // console.log(res.data.data)
  287. if (this.mine_code == 'jinfeng') {
  288. this.ice_list = res.data.data[2].children
  289. } else if (this.mine_code == 'ningdongyunying') {
  290. this.ice_list = res.data.data[1].children
  291. } else if (this.mine_code == 'ningmeijituan') {
  292. this.ice_list = res.data.data[1].children
  293. } else if (this.mine_code == 'shicaocun') {
  294. this.ice_list = res.data.data[0].children
  295. } else if (this.mine_code == 'yangchangwan') {
  296. this.ice_list = res.data.data[1].children
  297. } else if (this.mine_code == 'shicaocun') {
  298. this.ice_list = res.data.data[0].children
  299. }
  300. }
  301. })
  302. },
  303. // 值班公告
  304. get_notice() {
  305. uni.request({
  306. url: this.base_url + "/notice/list",
  307. method: "GET",
  308. header:{
  309. 'accesskey': "b364b449a18af327867f7edc3431b541"
  310. },
  311. success: (res) => {
  312. if (!res.data.data.content) {
  313. this.text = res.data.data.message
  314. } else {
  315. this.text = res.data.data.content.replace(/<br /g, " ").replace(/>/g, " ").replace(
  316. /\//g, " ")
  317. }
  318. }
  319. })
  320. },
  321. // 固定入口
  322. get_list() {
  323. this.iconList = []
  324. // 加分组
  325. uni.request({
  326. url: this.base_url + "/homeNav/listByCategory",
  327. header:{
  328. 'accesskey': "b364b449a18af327867f7edc3431b541"
  329. },
  330. method: "GET",
  331. success: (res) => {
  332. // console.log(res.data.data)
  333. this.iconList = res.data.data
  334. }
  335. })
  336. },
  337. // 首页链接
  338. get_home_link() {
  339. this.home_link = []
  340. uni.request({
  341. url: this.base_url + "/home/links",
  342. method: "GET",
  343. header:{
  344. 'accesskey': "b364b449a18af327867f7edc3431b541"
  345. },
  346. success: (res) => {
  347. // console.log(res)
  348. this.home_link = res.data.data
  349. }
  350. })
  351. },
  352. // 切换背景图片
  353. change_top_bg_color_img(index) {
  354. // this.top_bg_color_img = this.banners[index].imgURL
  355. if (index > 2) {
  356. index = parseInt(3 * Math.random())
  357. }
  358. this.top_bg_color = this.top_bg_color_list[index]
  359. },
  360. setTabBarBadge() {
  361. // 闭环管理
  362. this.$api.five_fixed_fiveFixedNewCategory({
  363. }).then((res) => {
  364. // console.log(res.data.content.data)
  365. let data = res.data.content.data
  366. let num = 0
  367. data.forEach((item, index) => {
  368. num = num + item.no_num
  369. })
  370. if (this.mine_code == 'ningdongyunying') {
  371. if (num > 0) {
  372. uni.showTabBarRedDot({
  373. index: 2,
  374. })
  375. }
  376. }
  377. })
  378. this.$api.workflow_todo_query({
  379. staff_num: uni.getStorageSync('user').staff_num,
  380. query_type: 2
  381. }).then((res) => {
  382. let num = 0
  383. num = res.data.content.data
  384. if (this.mine_code == 'ningdongyunying') {
  385. if (num > 0) {
  386. uni.showTabBarRedDot({
  387. index: 2,
  388. })
  389. }
  390. }
  391. })
  392. this.$api.workflow_todo_query({
  393. staff_num: uni.getStorageSync('user').staff_num,
  394. query_type: 1
  395. }).then((res) => {
  396. let num = 0
  397. num = res.data.content.data
  398. if (this.mine_code == 'ningdongyunying') {
  399. if (num > 0) {
  400. uni.showTabBarRedDot({
  401. index: 2,
  402. })
  403. }
  404. }
  405. })
  406. }
  407. }
  408. }
  409. </script>
  410. <style lang="scss">
  411. page {
  412. background-color: #F6FAF6;
  413. }
  414. .top_bg_color {
  415. position: relative;
  416. width: 750rpx;
  417. overflow: hidden;
  418. .bg_img {
  419. width: 750rpx;
  420. height: 440rpx;
  421. position: absolute;
  422. top: 0;
  423. left: 0;
  424. z-index: 0;
  425. background-position: center;
  426. background-size: 100% 100%;
  427. filter: blur(50px);
  428. transform: scale(2);
  429. opacity: 0.9;
  430. }
  431. }
  432. </style>