index - 宁煤及全矿适配版本.vue 11 KB

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