123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265 |
- <template>
- <view class="nav-pages">
- <view v-show="[1,2].includes(pattern)">
- <view v-show="pattern === 1">
- <top ref="affairTopRef" :pattern="1" :active-pattern="pattern" :statusBarHeight="statusBarHeight"
- :scrollTop="scrollTop" :topKongLimList="topKongLimList" :toQyKongLimList="toQyKongLimList"
- :weatherInfo="weatherInfo" />
- <view class=" zw-pages-content">
- <kong-kim :type='1' ref="kongKimRef_1" />
- </view>
- <affair ref="affairRef" :patternType="1" :active-pattern="pattern" />
- </view>
- <!-- 生活 -->
- <view v-show="pattern === 2">
- <top ref="lifeTopRef" :pattern="2" :active-pattern="pattern" :statusBarHeight="statusBarHeight"
- :scrollTop="scrollTop" :topKongLimList="topKongLimList" :toQyKongLimList="toQyKongLimList"
- :weatherInfo="weatherInfo" />
- <view class="zw-pages-content">
- <kong-kim :type='2' ref="kongKimRef_2" />
- </view>
- <life ref="lifeRef" :patternType="2" :active-pattern="pattern" :statusBarHeight="statusBarHeight" />
- </view>
- <template v-if="showSopupSwiper">
- <popup :pattern="pattern" />
- </template>
- </view>
- <!-- 关怀模式 -->
- <view v-if="pattern === 3">
- <care-top :statusBarHeight="statusBarHeight" :scrollTop="scrollTop" />
- <showSolicitude :statusBarHeight="statusBarHeight" />
- </view>
- <technical-support />
-
- </view>
- </template>
- <script>
- import top from "./home/module/top.vue"
- import kongKim from './home/module/kong-kim.vue'
- import affair from "./home/affair.vue"
- import life from "./home/life.vue"
- import showSolicitude from "./home/showSolicitude.vue"
- import careTop from "./home/module/care-top.vue"
- import popup from "./home/module/popup.vue"
- import {
- getAPPList,
- versionNewest
- } from "@/api/government.js"
- import {
- http
- } from '@/common/request';
- import {
- getWeatherInfo_Fn
- } from "@/utils/weather/index.js"
- export default {
- components: {
- kongKim,
- top,
- affair,
- life,
- showSolicitude,
- careTop,
- popup
- },
- provide() {
- return {
- home: this,
- };
- },
- data() {
- return {
- statusBarHeight: 0,
- pattern: 1, // 1:政务 , 2:生活 , 3:关怀模式
- scrollTop: 0,
- weatherInfo: null,
- topKongLimList: [],
- toQyKongLimList: [],
- showSopupSwiper: false,
- newest: {},
- }
- },
- onLoad() {
- this.statusBarHeight = uni.getSystemInfoSync().statusBarHeight;
- // #ifdef APP-PLUS
- if (plus.os.name == 'iOS') {
- // 首先获取一次网络状态
- uni.getNetworkType({
- success: (res) => {
- if (res.networkType != 'none') {
- this.oneNetwork();
- this.getVersionNewest();
- }
- }
- });
- // 监听网络变化
- uni.onNetworkStatusChange((res) => {
- if (res.isConnected) {
- this.oneNetwork();
- this.getVersionNewest()
- this.$refs.affairRef.init()
- this.$refs.kongKimRef_1.init();
- this.$refs.affairTopRef.init();
- this.$refs.lifeRef.init()
- this.$refs.kongKimRef_2.init();
- this.$refs.lifeTopRef.init();
- }
- });
- } else {
- this.oneNetwork();
- this.getVersionNewest()
- }
- // #endif
- // #ifdef H5
- this.oneNetwork();
- this.getVersionNewest()
- // #endif
- },
- onPageScroll: function(e) { //nvue暂不支持滚动监听,可用bindingx代替
- this.scrollTop = e.scrollTop
- },
- onPullDownRefresh() {
- // uni.stopPullDownRefresh();
- // var ws=null;
- // var list=null;
- // // 扩展API加载完毕,现在可以正常调用扩展API
- // ws=plus.webview.currentWebview();
- // ws.setPullToRefresh({support:true,
- // height:'50px',
- // range:'200px',
- // contentdown:{
- // caption:'下拉可以刷新'
- // },
- // contentover:{
- // caption:'释放立即刷新'
- // },
- // contentrefresh:{
- // caption:'正在刷新...'
- // }
- // },onRefresh);
- // plus.nativeUI.toast('下拉可以刷新')
- this.initAtPresent()
- },
- onReachBottom() {
- if (this.pattern == 2) {
- this.$refs.lifeRef.moreGoods()
- }
- },
- onShow() {
- // setTimeout(() => {
- // this.$skipWeb('http://10.46.4.212/auth/')
- // },3000)
- },
- mounted() {
- },
- methods: {
- init(e) {
- this.pattern = e
- },
- initAtPresent() {
- this.oneNetwork();
- try {
- switch (this.pattern) {
- case 1:
- this.$refs.affairTopRef.init();
- this.$refs.affairRef.init();
- this.$refs.kongKimRef_1.init();
- break;
- case 2:
- this.$refs.lifeTopRef.init();
- this.$refs.lifeRef.init();
- this.$refs.kongKimRef_2.init();
- break;
- }
- } catch (e) {
- //TODO handle the exception
- console.log('eeeeee = ', e)
- };
- setTimeout(() => {
- uni.stopPullDownRefresh();
- }, 2000)
- },
- oneNetwork() {
- getWeatherInfo_Fn().then(res => {
- this.weatherInfo = res
- })
- const keys = [this.$keys.SY_TOP_KONGKIM, this.$keys.SY_qiye_KONGKIM]
- keys.forEach(el => {
- getAPPList(el).then(res => {
- const list = res.data || []
- if (list.length > 0) {
- this.setService(list, el, keys)
- }
- }).catch(err => {
- this.setService([], el, keys)
- })
- })
- },
- setService(data, key, keys) {
- switch (key) {
- case keys[0]:
- // 首页顶金刚区
- this.topKongLimList = data || []
- break;
- case keys[1]:
- // 首页企业入口
- this.toQyKongLimList = data || []
- break;
- }
- },
- // 获取更新包
- getVersionNewest() {
- setTimeout(() => {
- // #ifdef APP
- const systemInfo = uni.getSystemInfoSync();
- let version_number = systemInfo.appVersion;
- let platform = uni.getSystemInfoSync().platform;
- let type = 0
- if (platform == 'ios') {
- type = 1
- } else if (platform == 'android') {
- type = 0
- }
- versionNewest({
- type: type
- }).then(res => {
- this.newest = res.data;
- if (version_number < this.newest.version) {
- uni.navigateTo({
- url: "/components/appUpdatePop?type=1"
- })
- } else {
- this.showSopupSwiper = true
- }
- }).catch(err => {
- this.showSopupSwiper = true
- })
- // #endif
- // #ifdef WEB
- this.showSopupSwiper = true
- // #endif
- }, 200)
- }
- }
- }
- </script>
- <style>
- page {
- /* opacity: 0.2; */
- /* rgba(75,90,255,0.2), rgba(74,181,255,0.2) 8%, */
- background: #fcfcfc;
- }
- </style>
|