index.vue 4.2 KB

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