index.vue 12 KB

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