index.vue 5.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244
  1. <template>
  2. <view>
  3. <view class="top_bg_color">
  4. <view class="bg_img" :style="{backgroundImage:'url('+top_bg_color_img+')'}"></view>
  5. <t-i-navbar :mine_code="mine_code" :navbar_bg_color="navbar_bg_color"></t-i-navbar>
  6. <!-- notice -->
  7. <t-i-notice :text="text"></t-i-notice>
  8. <!-- banner -->
  9. <t-i-banner :banner="banners" :mine_code="mine_code" @change_top_bg_color_img="change_top_bg_color_img"></t-i-banner>
  10. </view>
  11. <!-- 固定入口 -->
  12. <t-i-icon :iconList="iconList" :mine_code="mine_code"></t-i-icon>
  13. <!-- 常用功能 -->
  14. <t-i-common v-if="mine_code == 'ningdongyunying'"></t-i-common>
  15. <!-- 新闻列表 -->
  16. <t-i-news :newsList="newsList" :mine_code="mine_code"></t-i-news>
  17. <!-- 开屏通告 -->
  18. <openingNotice></openingNotice>
  19. <!-- 宁东运营 -->
  20. <view v-if="mine_code == 'ningdongyunying'">
  21. <t-i-ningdongyunying :mine_code="mine_code"></t-i-ningdongyunying>
  22. </view>
  23. <!-- 金家渠 -->
  24. <view v-if="mine_code == 'jinjiaqu'">
  25. <t-i-jinjiaqu :mine_code="mine_code"></t-i-jinjiaqu>
  26. </view>
  27. <!-- 羊场湾 -->
  28. <view v-if="mine_code == 'yangchangwan'">
  29. <t-i-yangchangwan :mine_code="mine_code" :home_link="home_link"></t-i-yangchangwan>
  30. </view>
  31. </view>
  32. </template>
  33. <script>
  34. import {
  35. set_base_url
  36. } from '@/common/set_base_url.js'
  37. // 版本控制
  38. import upApp from "@/uni_modules/uni-upgrade-center-app/utils/check-update"
  39. export default {
  40. data() {
  41. return {
  42. // 当前煤矿编码
  43. mine_code: "",
  44. // 首页接口的基础请求路径 默认为当前矿编码的基础路径
  45. base_url: " ",
  46. // 轮播图
  47. banners: [],
  48. // 新闻列表
  49. newsList: "",
  50. // 值班公告
  51. text: "暂无公告。",
  52. // 固定入口
  53. iconList: [],
  54. // 首页链接
  55. home_link: [],
  56. // 背景色
  57. top_bg_color_img: "",
  58. // 标题栏背景色
  59. navbar_bg_color: ""
  60. }
  61. },
  62. onPullDownRefresh() {
  63. uni.reLaunch({
  64. url: "./index"
  65. })
  66. setTimeout(function() {
  67. uni.stopPullDownRefresh();
  68. }, 1000);
  69. },
  70. onLoad() {
  71. // 初始化当前煤矿编码
  72. this.mine_code = uni.getStorageSync('mine_code')
  73. // 检查更新
  74. upApp()
  75. // token过期验证
  76. this.$api.worksheet_classify_list({
  77. }).then((res) => {
  78. // console.log(res)
  79. if (res.data.code == 401) {
  80. uni.showToast({
  81. icon: "none",
  82. title: "登录失效、请重新登录"
  83. })
  84. setTimeout(function() {
  85. uni.redirectTo({
  86. url: "../../my/login/login"
  87. })
  88. }, 2000)
  89. } else {
  90. // console.log(res)
  91. }
  92. })
  93. },
  94. onPageScroll: function(e) {
  95. if (e.scrollTop > 400) {
  96. this.navbar_bg_color = "#009fe8"
  97. } else {
  98. this.navbar_bg_color = ""
  99. }
  100. },
  101. onShow() {
  102. // E信-切换矿
  103. uni.$on('update_kuang', (data) => {
  104. console.log('监听到事件来自 update_kuang ,携带参数 msg 为:' + data.msg);
  105. this.mine_code = data.msg
  106. console.log(this.mine_code)
  107. })
  108. this.$forceUpdate()
  109. // 根据矿编码切换首页接口不同的请求基础路径
  110. this.base_url = set_base_url(this.mine_code)
  111. // 获取轮播图
  112. this.get_banner()
  113. // 获取首页新闻列表
  114. this.getNews()
  115. // 值班公告
  116. this.get_notice()
  117. // 固定入口
  118. this.get_list()
  119. this.get_home_link()
  120. },
  121. methods: {
  122. // 获取轮播图
  123. get_banner() {
  124. uni.request({
  125. url: this.base_url + "/scrollImg/list",
  126. method: "GET",
  127. success: (res) => {
  128. this.banners = res.data.data.data
  129. this.top_bg_color_img = this.banners[0].imgURL
  130. }
  131. })
  132. },
  133. // 请求新闻动态
  134. getNews() {
  135. uni.request({
  136. url: this.base_url + "/article/list",
  137. method: "GET",
  138. data: {
  139. pageSize: 4
  140. },
  141. success: (res) => {
  142. this.newsList = res.data.data.data
  143. }
  144. })
  145. },
  146. // 值班公告
  147. get_notice() {
  148. uni.request({
  149. url: this.base_url + "/notice/list",
  150. method: "GET",
  151. success: (res) => {
  152. if (!res.data.data.content) {
  153. this.text = res.data.data.message
  154. } else {
  155. this.text = res.data.data.content.replace(/<br /g, " ").replace(/>/g, " ").replace(
  156. /\//g, " ")
  157. // console.log(this.text)
  158. }
  159. }
  160. })
  161. },
  162. // 固定入口
  163. get_list() {
  164. uni.request({
  165. url: this.base_url + "/homeNav/list",
  166. method: "GET",
  167. success: (res) => {
  168. // this.iconList = res.data.data.data.slice(0, 5)
  169. this.iconList = res.data.data.data
  170. }
  171. })
  172. },
  173. // 首页链接
  174. get_home_link() {
  175. uni.request({
  176. url: this.base_url + "/home/links",
  177. method: "GET",
  178. success: (res) => {
  179. // console.log(res)
  180. this.home_link = res.data.data
  181. }
  182. })
  183. },
  184. // 切换背景图片
  185. change_top_bg_color_img(index) {
  186. this.top_bg_color_img = this.banners[index].imgURL
  187. }
  188. }
  189. }
  190. </script>
  191. <style lang="scss">
  192. page {
  193. background-color: #F6FAF6;
  194. }
  195. .top_bg_color {
  196. position: relative;
  197. width: 750rpx;
  198. overflow: hidden;
  199. .bg_img {
  200. width: 750rpx;
  201. height: 440rpx;
  202. position: absolute;
  203. top: 0;
  204. left: 0;
  205. z-index: 0;
  206. background-position: center;
  207. background-size: 100% 100%;
  208. filter: blur(50px);
  209. transform: scale(2);
  210. opacity: 0.9;
  211. }
  212. }
  213. </style>