yunshangxie/pages/index/index.vue

239 lines
6.5 KiB
Vue
Raw Normal View History

2023-12-25 17:56:30 +08:00
<template>
2024-04-20 14:57:39 +08:00
<view class="index">
2023-12-25 17:56:30 +08:00
<view v-if="tabberPageLoadFlag[0]" :style="{display: currentIndex === 0 ? '' : 'none'}">
<scroll-view class="custom-tabbar-page" scroll-y enable-back-to-top @scrolltolower="tabbarPageScrollLower">
<Home ref="home"></Home>
</scroll-view>
</view>
2024-05-14 10:20:09 +08:00
<!-- <view v-if="tabberPageLoadFlag[1]" :style="{display: currentIndex === 1 ? '' : 'none'}">
2023-12-25 17:56:30 +08:00
<scroll-view class="custom-tabbar-page" scroll-y enable-back-to-top @scrolltolower="tabbarPageScrollLower">
<Service ref="service"></Service>
</scroll-view>
2024-05-14 10:20:09 +08:00
</view> -->
2024-06-04 18:04:09 +08:00
<view @touchmove="preventTouchMove" v-if=" tabberPageLoadFlag[1]"
:style="{display: currentIndex === 1 ? '' : 'none'}">
<view :class="tabShow?'custom-tabbar-page':''">
2024-05-14 10:20:09 +08:00
<Directory ref="directory"></Directory>
2024-06-04 18:04:09 +08:00
</view>
2023-12-25 17:56:30 +08:00
</view>
2024-05-14 10:20:09 +08:00
<!-- <view v-if="tabberPageLoadFlag[2]" :style="{display: currentIndex === 2 ? '' : 'none'}">
2023-12-25 17:56:30 +08:00
<scroll-view class="custom-tabbar-page" scroll-y enable-back-to-top @scrolltolower="tabbarPageScrollLower">
<Discovery ref="discovery"></Discovery>
</scroll-view>
2024-05-14 10:20:09 +08:00
</view> -->
<view v-if="tabberPageLoadFlag[2]" :style="{display: currentIndex === 2 ? '' : 'none'}">
2023-12-25 17:56:30 +08:00
<scroll-view class="custom-tabbar-page" scroll-y enable-back-to-top @scrolltolower="tabbarPageScrollLower">
<Pizz ref="pizz"></Pizz>
</scroll-view>
</view>
2024-05-14 10:20:09 +08:00
<view v-if="tabberPageLoadFlag[3]" :style="{display: currentIndex === 3 ? '' : 'none'}">
2023-12-25 17:56:30 +08:00
<scroll-view class="custom-tabbar-page" scroll-y enable-back-to-top @scrolltolower="tabbarPageScrollLower">
<User ref="user"></User>
</scroll-view>
</view>
2024-06-03 18:19:31 +08:00
<tn-tabbar :show="tabShow" :outHeight="140" :height="120" v-model="currentIndex" :list="tabbarList"
2024-06-28 08:50:34 +08:00
activeColor="#000000" inactiveColor="#AAAAAA" activeIconColor="#3377FF" inactiveIconColor="#888888"
:animation="true" :safeAreaInsetBottom="true" :thisIndex="thisIndex" @change="switchTabbar"></tn-tabbar>
2023-12-25 17:56:30 +08:00
</view>
</template>
<script>
import Home from './home.vue'
import Service from './service.vue'
import Pizz from './pizz.vue'
import User from './user.vue'
2024-05-14 10:20:09 +08:00
import Directory from './directory.vue'
2024-05-15 17:54:48 +08:00
import {
Mailcoent
} from '@/util/api.js';
import store from '@/store/index.js'
2023-12-25 17:56:30 +08:00
export default {
components: {
Home,
Service,
Pizz,
2024-05-14 10:20:09 +08:00
User,
Directory
2023-12-25 17:56:30 +08:00
},
data() {
return {
// 底部tabbar菜单数据
tabbarList: [{
title: '首页',
activeIcon: '/static/01_1.png',
2024-06-28 08:50:34 +08:00
inactiveIcon: '/static/01.png',
id: 0,
2023-12-25 17:56:30 +08:00
},
{
2024-05-14 10:20:09 +08:00
title: '通讯录',
2023-12-25 17:56:30 +08:00
activeIcon: '/static/02_2.png',
2024-06-28 08:50:34 +08:00
inactiveIcon: '/static/02.png',
id: 1,
2023-12-25 17:56:30 +08:00
},
2024-05-14 10:20:09 +08:00
// {
// // 服务、案例、品牌、合作、发现、探索
// activeIcon: '',
// inactiveIcon: '',
// iconSize: 110,
// out: true
// },
2023-12-25 17:56:30 +08:00
{
title: '发现',
activeIcon: '/static/03_3.png',
2024-06-28 08:50:34 +08:00
inactiveIcon: '/static/03.png',
id: 2,
2023-12-25 17:56:30 +08:00
},
{
title: '个人中心',
activeIcon: '/static/04_4.png',
2024-06-28 08:50:34 +08:00
inactiveIcon: '/static/04.png',
id: 3,
2023-12-25 17:56:30 +08:00
}
],
2024-06-28 08:50:34 +08:00
thisIndex: 0,
2023-12-25 17:56:30 +08:00
// tabbar当前被选中的序号
currentIndex: 0,
// 自定义底栏对应页面的加载情况
2024-04-24 17:34:38 +08:00
tabberPageLoadFlag: [],
2024-05-08 18:14:41 +08:00
apiImgUrl: this.$store.state.imgUrl,
2024-05-27 17:40:54 +08:00
icon: '',
name: '',
2024-06-03 18:19:31 +08:00
tabShow: true,
2023-12-25 17:56:30 +08:00
}
},
onLoad(options) {
const index = Number(options.index || 0)
// 根据底部tabbar菜单列表设置对应页面的加载情况
this.tabberPageLoadFlag = this.tabbarList.map((item, tabbar_index) => {
return index === tabbar_index
})
this.switchTabbar(index)
2024-04-20 14:57:39 +08:00
var that = this;
uni.$on('depId', function(data) {
that.switchTabbar(data.index);
})
2024-06-03 18:19:31 +08:00
uni.$on('showTab', function(data) {
var index = data.index;
that.tabShow = index;
})
2024-06-21 16:15:26 +08:00
if (typeof(options.scene) != 'undefined') {
let decodedParams = decodeURIComponent(options.scene);
var searchParams = this.parseQuery(decodedParams);
store.commit('$tStore', {
name: 'Gid',
value: searchParams.gid
})
uni.setStorageSync('Gid', searchParams.gid);
}
2024-04-20 14:57:39 +08:00
},
mounted() {
//this.wxshare();
},
onShareAppMessage() { // 分享到微信好友
// 更多参数配置,参考文档
return {
2024-05-27 17:40:54 +08:00
title: this.name,
2024-06-21 16:15:26 +08:00
path: '/pages/index/index?gid=' + store.state.Gid,
2024-05-27 17:40:54 +08:00
imageUrl: this.icon,
2024-04-20 14:57:39 +08:00
}
},
onShareTimeline() { // 分享到朋友圈
return {
2024-05-27 17:40:54 +08:00
title: this.name,
2024-06-21 16:15:26 +08:00
path: '/pages/index/index?gid=' + store.state.Gid,
2024-05-27 17:40:54 +08:00
imageUrl: this.icon,
2024-04-20 14:57:39 +08:00
}
2023-12-25 17:56:30 +08:00
},
methods: {
2024-06-21 16:15:26 +08:00
parseQuery(queryStr) {
let params = {};
queryStr.split('&').forEach(param => {
let [key, value] = param.split('=');
params[key] = decodeURIComponent(value);
});
return params;
2024-06-04 18:04:09 +08:00
},
2024-05-08 18:14:41 +08:00
childEvent(data) {
console.log(123);
console.log(data);
2024-05-27 17:40:54 +08:00
this.icon = this.apiImgUrl + data.icon;
this.name = data.label;
2024-05-08 18:14:41 +08:00
},
2024-04-20 14:57:39 +08:00
wxshare() {
this.$wxshare({
url: 'http://ysh.0rui.cn/#/pages/index/index',
data: {
url: window.location.href.split("#")[0],
},
share_data: {
title: '智慧云商协',
desc: '智慧云商协',
imgUrl: 'http://ysh.0rui.cn/static/ser.png',
link: window.location.href, // 分享链接,该链接域名或路径必须与当前页面对应的公众号 JS 安全域名一致
}
})
},
2023-12-25 17:56:30 +08:00
// 切换导航
switchTabbar(index) {
this._switchTabbarPage(index)
},
// 瀑布流导航页面滚动到底部
tabbarPageScrollLower(e) {
2024-04-20 14:57:39 +08:00
console.log(123);
if (this.currentIndex === 0) {
this.$refs.home.ReachBottom();
}
2024-05-14 18:14:14 +08:00
// if (this.currentIndex === 1) {
// this.$refs.service.ReachBottom();
// }
2023-12-25 17:56:30 +08:00
},
// 切换导航页面
_switchTabbarPage(index) {
2024-05-14 10:20:09 +08:00
2023-12-25 17:56:30 +08:00
const selectPageFlag = this.tabberPageLoadFlag[index]
2024-06-28 08:50:34 +08:00
this.thisIndex = this.tabbarList[index].id;
2023-12-25 17:56:30 +08:00
if (selectPageFlag === undefined) {
return
}
if (selectPageFlag === false) {
this.tabberPageLoadFlag[index] = true
}
this.currentIndex = index
2024-05-08 18:14:41 +08:00
if (index === 1) {
setTimeout(() => {
2024-05-14 10:20:09 +08:00
this.$refs.directory.onload();
2024-05-08 18:14:41 +08:00
}, 100)
}
2024-05-14 10:20:09 +08:00
// if (index === 2) {
// setTimeout(() => {
// this.$refs.discovery.getNewInfo();
// }, 100)
// }
2024-04-23 11:58:07 +08:00
2023-12-25 17:56:30 +08:00
}
}
}
</script>
<style lang="scss" scoped>
2024-04-20 14:57:39 +08:00
.index {
width: 100%;
height: 100vh;
position: relative;
.custom-tabbar-page {
width: 100%;
height: calc(100vh - 110rpx);
box-sizing: border-box;
padding-bottom: 0rpx;
padding-bottom: calc(0rpx + constant(safe-area-inset-bottom));
padding-bottom: calc(0rpx + env(safe-area-inset-bottom));
}
}
2024-05-08 18:14:41 +08:00
</style>