home.vue 6.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265
  1. <template>
  2. <view class="nav-pages">
  3. <view v-show="[1,2].includes(pattern)">
  4. <view v-show="pattern === 1">
  5. <top ref="affairTopRef" :pattern="1" :active-pattern="pattern" :statusBarHeight="statusBarHeight"
  6. :scrollTop="scrollTop" :topKongLimList="topKongLimList" :toQyKongLimList="toQyKongLimList"
  7. :weatherInfo="weatherInfo" />
  8. <view class=" zw-pages-content">
  9. <kong-kim :type='1' ref="kongKimRef_1" />
  10. </view>
  11. <affair ref="affairRef" :patternType="1" :active-pattern="pattern" />
  12. </view>
  13. <!-- 生活 -->
  14. <view v-show="pattern === 2">
  15. <top ref="lifeTopRef" :pattern="2" :active-pattern="pattern" :statusBarHeight="statusBarHeight"
  16. :scrollTop="scrollTop" :topKongLimList="topKongLimList" :toQyKongLimList="toQyKongLimList"
  17. :weatherInfo="weatherInfo" />
  18. <view class="zw-pages-content">
  19. <kong-kim :type='2' ref="kongKimRef_2" />
  20. </view>
  21. <life ref="lifeRef" :patternType="2" :active-pattern="pattern" :statusBarHeight="statusBarHeight" />
  22. </view>
  23. <template v-if="showSopupSwiper">
  24. <popup :pattern="pattern" />
  25. </template>
  26. </view>
  27. <!-- 关怀模式 -->
  28. <view v-if="pattern === 3">
  29. <care-top :statusBarHeight="statusBarHeight" :scrollTop="scrollTop" />
  30. <showSolicitude :statusBarHeight="statusBarHeight" />
  31. </view>
  32. <technical-support />
  33. </view>
  34. </template>
  35. <script>
  36. import top from "./home/module/top.vue"
  37. import kongKim from './home/module/kong-kim.vue'
  38. import affair from "./home/affair.vue"
  39. import life from "./home/life.vue"
  40. import showSolicitude from "./home/showSolicitude.vue"
  41. import careTop from "./home/module/care-top.vue"
  42. import popup from "./home/module/popup.vue"
  43. import {
  44. getAPPList,
  45. versionNewest
  46. } from "@/api/government.js"
  47. import {
  48. http
  49. } from '@/common/request';
  50. import {
  51. getWeatherInfo_Fn
  52. } from "@/utils/weather/index.js"
  53. export default {
  54. components: {
  55. kongKim,
  56. top,
  57. affair,
  58. life,
  59. showSolicitude,
  60. careTop,
  61. popup
  62. },
  63. provide() {
  64. return {
  65. home: this,
  66. };
  67. },
  68. data() {
  69. return {
  70. statusBarHeight: 0,
  71. pattern: 1, // 1:政务 , 2:生活 , 3:关怀模式
  72. scrollTop: 0,
  73. weatherInfo: null,
  74. topKongLimList: [],
  75. toQyKongLimList: [],
  76. showSopupSwiper: false,
  77. newest: {},
  78. }
  79. },
  80. onLoad() {
  81. this.statusBarHeight = uni.getSystemInfoSync().statusBarHeight;
  82. // #ifdef APP-PLUS
  83. if (plus.os.name == 'iOS') {
  84. // 首先获取一次网络状态
  85. uni.getNetworkType({
  86. success: (res) => {
  87. if (res.networkType != 'none') {
  88. this.oneNetwork();
  89. this.getVersionNewest();
  90. }
  91. }
  92. });
  93. // 监听网络变化
  94. uni.onNetworkStatusChange((res) => {
  95. if (res.isConnected) {
  96. this.oneNetwork();
  97. this.getVersionNewest()
  98. this.$refs.affairRef.init()
  99. this.$refs.kongKimRef_1.init();
  100. this.$refs.affairTopRef.init();
  101. this.$refs.lifeRef.init()
  102. this.$refs.kongKimRef_2.init();
  103. this.$refs.lifeTopRef.init();
  104. }
  105. });
  106. } else {
  107. this.oneNetwork();
  108. this.getVersionNewest()
  109. }
  110. // #endif
  111. // #ifdef H5
  112. this.oneNetwork();
  113. this.getVersionNewest()
  114. // #endif
  115. },
  116. onPageScroll: function(e) { //nvue暂不支持滚动监听,可用bindingx代替
  117. this.scrollTop = e.scrollTop
  118. },
  119. onPullDownRefresh() {
  120. // uni.stopPullDownRefresh();
  121. // var ws=null;
  122. // var list=null;
  123. // // 扩展API加载完毕,现在可以正常调用扩展API
  124. // ws=plus.webview.currentWebview();
  125. // ws.setPullToRefresh({support:true,
  126. // height:'50px',
  127. // range:'200px',
  128. // contentdown:{
  129. // caption:'下拉可以刷新'
  130. // },
  131. // contentover:{
  132. // caption:'释放立即刷新'
  133. // },
  134. // contentrefresh:{
  135. // caption:'正在刷新...'
  136. // }
  137. // },onRefresh);
  138. // plus.nativeUI.toast('下拉可以刷新')
  139. this.initAtPresent()
  140. },
  141. onReachBottom() {
  142. if (this.pattern == 2) {
  143. this.$refs.lifeRef.moreGoods()
  144. }
  145. },
  146. onShow() {
  147. // setTimeout(() => {
  148. // this.$skipWeb('http://10.46.4.212/auth/')
  149. // },3000)
  150. },
  151. mounted() {
  152. },
  153. methods: {
  154. init(e) {
  155. this.pattern = e
  156. },
  157. initAtPresent() {
  158. this.oneNetwork();
  159. try {
  160. switch (this.pattern) {
  161. case 1:
  162. this.$refs.affairTopRef.init();
  163. this.$refs.affairRef.init();
  164. this.$refs.kongKimRef_1.init();
  165. break;
  166. case 2:
  167. this.$refs.lifeTopRef.init();
  168. this.$refs.lifeRef.init();
  169. this.$refs.kongKimRef_2.init();
  170. break;
  171. }
  172. } catch (e) {
  173. //TODO handle the exception
  174. console.log('eeeeee = ', e)
  175. };
  176. setTimeout(() => {
  177. uni.stopPullDownRefresh();
  178. }, 2000)
  179. },
  180. oneNetwork() {
  181. getWeatherInfo_Fn().then(res => {
  182. this.weatherInfo = res
  183. })
  184. const keys = [this.$keys.SY_TOP_KONGKIM, this.$keys.SY_qiye_KONGKIM]
  185. keys.forEach(el => {
  186. getAPPList(el).then(res => {
  187. const list = res.data || []
  188. if (list.length > 0) {
  189. this.setService(list, el, keys)
  190. }
  191. }).catch(err => {
  192. this.setService([], el, keys)
  193. })
  194. })
  195. },
  196. setService(data, key, keys) {
  197. switch (key) {
  198. case keys[0]:
  199. // 首页顶金刚区
  200. this.topKongLimList = data || []
  201. break;
  202. case keys[1]:
  203. // 首页企业入口
  204. this.toQyKongLimList = data || []
  205. break;
  206. }
  207. },
  208. // 获取更新包
  209. getVersionNewest() {
  210. setTimeout(() => {
  211. // #ifdef APP
  212. const systemInfo = uni.getSystemInfoSync();
  213. let version_number = systemInfo.appVersion;
  214. let platform = uni.getSystemInfoSync().platform;
  215. let type = 0
  216. if (platform == 'ios') {
  217. type = 1
  218. } else if (platform == 'android') {
  219. type = 0
  220. }
  221. versionNewest({
  222. type: type
  223. }).then(res => {
  224. this.newest = res.data;
  225. if (version_number < this.newest.version) {
  226. uni.navigateTo({
  227. url: "/components/appUpdatePop?type=1"
  228. })
  229. } else {
  230. this.showSopupSwiper = true
  231. }
  232. }).catch(err => {
  233. this.showSopupSwiper = true
  234. })
  235. // #endif
  236. // #ifdef WEB
  237. this.showSopupSwiper = true
  238. // #endif
  239. }, 200)
  240. }
  241. }
  242. }
  243. </script>
  244. <style>
  245. page {
  246. /* opacity: 0.2; */
  247. /* rgba(75,90,255,0.2), rgba(74,181,255,0.2) 8%, */
  248. background: #fcfcfc;
  249. }
  250. </style>