index.vue 8.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377
  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 v-if="text != ''" :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"></t-i-banner>
  12. </view>
  13. <!-- 首页风格切换-2-默认风格 -->
  14. <view v-if="index_type == 2">
  15. <t-i-navbar-2 :mine_code="mine_code"></t-i-navbar-2>
  16. <t-i-notice-2 v-if="text != ''" :text="text"></t-i-notice-2>
  17. <t-i-banner-2 :banner="banners" :mine_code="mine_code" @change_top_bg_color_img="change_top_bg_color_img"></t-i-banner-2>
  18. </view>
  19. <!-- 宁东运营-信息平台 -->
  20. <view v-if="mine_code == 'ningdongyunying'">
  21. <t-i-ice :iceList="ice_list" :mine_code="mine_code"></t-i-ice>
  22. </view>
  23. <!-- <t-i-ice :iceList="ice_list" :mine_code="mine_code"></t-i-ice> -->
  24. <!-- 固定入口 -->
  25. <t-i-icon :iconList="iconList" :mine_code="mine_code"></t-i-icon>
  26. <!-- 新闻列表 -->
  27. <t-i-news :newsList="newsList" :mine_code="mine_code"></t-i-news>
  28. <!-- 常用功能 -->
  29. <t-i-common v-if="mine_code == 'ningdongyunying'"></t-i-common>
  30. <!-- 开屏通告 -->
  31. <openingNotice></openingNotice>
  32. <!-- 宁东运营 -->
  33. <view v-if="mine_code == 'ningdongyunying'">
  34. <t-i-ningdongyunying :mine_code="mine_code"></t-i-ningdongyunying>
  35. </view>
  36. <!-- 金家渠 -->
  37. <view v-if="mine_code == 'jinjiaqu' || mine_code == 'jinjiaqu_neiwang'">
  38. <t-i-jinjiaqu :mine_code="mine_code"></t-i-jinjiaqu>
  39. </view>
  40. <!-- 石槽村 -->
  41. <view v-if="mine_code == 'shicaocun'">
  42. <t-i-shicaocun :mine_code="mine_code"></t-i-shicaocun>
  43. </view>
  44. <!-- 金凤 -->
  45. <view v-if="mine_code == 'jinfeng' || mine_code == 'jinfeng_neiwang'">
  46. <t-i-jinfeng :mine_code="mine_code"></t-i-jinfeng>
  47. </view>
  48. <!-- 羊场湾 -->
  49. <view v-if="mine_code == 'yangchangwan'">
  50. <t-i-yangchangwan :mine_code="mine_code" :home_link="home_link"></t-i-yangchangwan>
  51. </view>
  52. </view>
  53. </template>
  54. <script>
  55. import {
  56. set_base_url
  57. } from '@/common/set_base_url.js'
  58. // 版本控制
  59. import upApp from "@/uni_modules/uni-upgrade-center-app/utils/check-update"
  60. export default {
  61. data() {
  62. return {
  63. // 当前煤矿编码
  64. mine_code: "",
  65. // 首页接口的基础请求路径 默认为当前矿编码的基础路径
  66. base_url: " ",
  67. // 轮播图
  68. banners: [],
  69. // 新闻列表
  70. newsList: "",
  71. // 值班公告
  72. text: "",
  73. // 固定入口
  74. iconList: [],
  75. // 首页链接
  76. home_link: [],
  77. // 背景虚化图片
  78. top_bg_color_img: "",
  79. // 背景安全色
  80. top_bg_color: "#7372c2",
  81. // top_bg_color_list: ['#3e88c6', '#e75038', '#305471', '#f8bf3c', '#37ba73', '#7372c2'],
  82. top_bg_color_list: ['#d62b2b', '#00a2e8', '#b08654'],
  83. // 标题栏背景色
  84. navbar_bg_color: "",
  85. index_type: 1,
  86. // 信息平台链接
  87. ice_list: []
  88. }
  89. },
  90. onPullDownRefresh() {
  91. uni.reLaunch({
  92. url: "./index"
  93. })
  94. setTimeout(function() {
  95. uni.stopPullDownRefresh();
  96. }, 1000);
  97. },
  98. onLoad() {
  99. // 检查更新
  100. upApp()
  101. // 初始化当前煤矿编码
  102. this.mine_code = uni.getStorageSync('mine_code')
  103. // 风格定义
  104. this.$api.home_style_setting({
  105. }).then((res) => {
  106. // console.log(res.data.data)
  107. this.index_type = res.data.data.value
  108. })
  109. // token过期验证
  110. this.$api.worksheet_classify_list({
  111. }).then((res) => {
  112. // console.log(res)
  113. if (res.data.code == 401) {
  114. uni.showToast({
  115. icon: "none",
  116. title: "登录失效、请重新登录"
  117. })
  118. uni.clearStorageSync('Authorization');
  119. setTimeout(function() {
  120. uni.redirectTo({
  121. url: "../../my/login/login"
  122. })
  123. }, 1500)
  124. } else {
  125. // console.log(res)
  126. }
  127. })
  128. },
  129. onPageScroll: function(e) {
  130. if (e.scrollTop > 300) {
  131. this.navbar_bg_color = "#009fe8"
  132. } else {
  133. this.navbar_bg_color = ""
  134. }
  135. },
  136. onShow() {
  137. // E信-切换矿
  138. uni.$on('update_kuang', (data) => {
  139. console.log('监听到事件来自 update_kuang ,携带参数 msg 为:' + data.msg);
  140. this.mine_code = data.msg
  141. console.log(this.mine_code)
  142. })
  143. this.$forceUpdate()
  144. // 根据矿编码切换首页接口不同的请求基础路径
  145. this.base_url = set_base_url(this.mine_code)
  146. // uni.setStorageSync('base_url',this.base_url)
  147. // 获取轮播图
  148. this.get_banner()
  149. // 获取首页新闻列表
  150. this.getNews()
  151. // 值班公告
  152. this.get_notice()
  153. // 固定入口
  154. this.get_list()
  155. this.get_home_link()
  156. // 获取信息平台
  157. this.get_ICE_list()
  158. // this.setTabBarBadge()
  159. },
  160. methods: {
  161. // 获取轮播图
  162. get_banner() {
  163. uni.request({
  164. url: this.base_url + "/scrollImg/list",
  165. method: "GET",
  166. success: (res) => {
  167. // console.log(res.data.data.data)
  168. this.banners = res.data.data.data
  169. this.top_bg_color_img = this.banners[0].imgURL
  170. }
  171. })
  172. },
  173. // 请求新闻动态
  174. getNews() {
  175. uni.request({
  176. url: this.base_url + "/article/list",
  177. method: "GET",
  178. data: {
  179. pageSize: 4
  180. },
  181. success: (res) => {
  182. this.newsList = res.data.data.data
  183. }
  184. })
  185. },
  186. // 信息平台
  187. get_ICE_list() {
  188. uni.request({
  189. url: this.base_url + "/home/links",
  190. success: (res) => {
  191. // console.log(res.data.data)
  192. if(this.mine_code == 'jinfeng'){
  193. this.ice_list = res.data.data[2].children
  194. }else if(this.mine_code == 'ningdongyunying'){
  195. this.ice_list = res.data.data[1].children
  196. }else if(this.mine_code == 'shicaocun'){
  197. this.ice_list = res.data.data[0].children
  198. }
  199. }
  200. })
  201. },
  202. // 值班公告
  203. get_notice() {
  204. uni.request({
  205. url: this.base_url + "/notice/list",
  206. method: "GET",
  207. success: (res) => {
  208. if (!res.data.data.content) {
  209. this.text = res.data.data.message
  210. } else {
  211. this.text = res.data.data.content.replace(/<br /g, " ").replace(/>/g, " ").replace(
  212. /\//g, " ")
  213. }
  214. }
  215. })
  216. },
  217. // 固定入口
  218. get_list() {
  219. // uni.request({
  220. // url: this.base_url + "/homeNav/list",
  221. // method: "GET",
  222. // success: (res) => {
  223. // console.log(res.data.data.data)
  224. // // this.iconList = res.data.data.data.slice(0, 5)
  225. // this.iconList = res.data.data.data
  226. // }
  227. // })
  228. // 加分组
  229. uni.request({
  230. url: this.base_url + "/homeNav/listByCategory",
  231. method: "GET",
  232. success: (res) => {
  233. // console.log(res.data)
  234. this.iconList = res.data.data
  235. }
  236. })
  237. },
  238. // 首页链接
  239. get_home_link() {
  240. uni.request({
  241. url: this.base_url + "/home/links",
  242. method: "GET",
  243. success: (res) => {
  244. // console.log(res)
  245. this.home_link = res.data.data
  246. }
  247. })
  248. },
  249. // 切换背景图片
  250. change_top_bg_color_img(index) {
  251. // this.top_bg_color_img = this.banners[index].imgURL
  252. if (index > 2) {
  253. index = parseInt(3 * Math.random())
  254. }
  255. this.top_bg_color = this.top_bg_color_list[index]
  256. },
  257. setTabBarBadge() {
  258. // 工作台
  259. this.$api.workflow_todo_query({
  260. staff_num: uni.getStorageSync('user').staff_num,
  261. query_type: 2
  262. }).then((res) => {
  263. let num_1 = res.data.content.data
  264. this.$api.workflow_todo_query({
  265. staff_num: uni.getStorageSync('user').staff_num,
  266. query_type: 1
  267. }).then((res) => {
  268. let num_2 = res.data.content.data
  269. let num = num_1 + num_2
  270. if(num > 0){
  271. uni.setTabBarBadge({
  272. index: 2,
  273. text: '' + num + ''
  274. })
  275. }
  276. })
  277. })
  278. // 消息
  279. this.$api.five_fixed_fiveFixedNewCategory({
  280. }).then((res)=>{
  281. // console.log(res.data.content.data)
  282. let data = res.data.content.data
  283. let num = 0
  284. data.forEach((item,index)=>{
  285. num = num + item.no_num
  286. })
  287. if(num > 0){
  288. uni.setTabBarBadge({
  289. index: 1,
  290. text: '' + num + ''
  291. })
  292. }
  293. })
  294. }
  295. }
  296. }
  297. </script>
  298. <style lang="scss">
  299. page {
  300. background-color: #F6FAF6;
  301. }
  302. .top_bg_color {
  303. position: relative;
  304. width: 750rpx;
  305. overflow: hidden;
  306. .bg_img {
  307. width: 750rpx;
  308. height: 440rpx;
  309. position: absolute;
  310. top: 0;
  311. left: 0;
  312. z-index: 0;
  313. background-position: center;
  314. background-size: 100% 100%;
  315. filter: blur(50px);
  316. transform: scale(2);
  317. opacity: 0.9;
  318. }
  319. }
  320. </style>