1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889 |
- const moment=require('../utils/moment-with-locales.min')
- moment.locale('zh-cn');
- // 引入全局配置的图片资源地址
- import {globalImgUrls} from "../utils/config"
- import store from '@/store'
- const tabbarPathList=['pages/activity/activity','pages/buy/buy','pages/chart/chart','pages/user/user','pages/report/report']
- module.exports = {
- watch: {
- tabbarList(){
- this.handleSetTabBarItem()
- }
- },
- computed: {
- tabbarList(){
- return store.state.user.tabbarList
- },
- userInfo(){//个人信息
- return this.$store.state.user.userInfo
- }
- },
- filters: {
- /**
- * 活动时间格式化
- * @param {2021-11-12T09:25:01+08:00} start 开始时间
- * @param 2021-11-12T09:25:01+08:00 end 结束时间
- * @returns 2020-06-04 15:30-16:30 星期一
- */
- formatActivityTime(start,end){
- const week=moment(start).format('dddd');
- const day=moment(start).format('YYYY-MM-DD');
- const startTime=moment(start).format('HH:mm');
- const endTime=moment(end).format('HH:mm');
- return `${day} ${startTime}-${endTime} ${week}`
- }
- },
- data() {
- return {
- globalImgUrls:globalImgUrls,// 图片资源
- globalBgMusic:uni.getBackgroundAudioManager()
- };
- },
- onLoad() {},
- onShow(){
- this.handleActivityListPageRefresh()
- this.$store.dispatch('getTabBar')
- this.handleSetTabBarItem()
- },
- methods: {
- // 设置tabbar的选中态
- handleSetTabBarItem(){
- const page = this.$mp&&this.$mp.page;
- const tabbarList=this.$store.state.user.tabbarList
- if(!page||tabbarList.length==0) return
-
- let selected=page.route
- // 如果用户的tabbar 改变了 并且他点击的tabbar选项正好不存在了 则重定向到第一个tabbar
- let temarr=tabbarList.map(item=>item.pagePath)
- if(tabbarPathList.includes(selected)&&!temarr.includes(selected)){
- selected=tabbarList[0].pagePath
- uni.switchTab({ url: `/${selected}` })
- }
- if(tabbarPathList.includes(page.route)){
- if (page&&typeof page.getTabBar === "function" && page.getTabBar()) {
- page.getTabBar().setData({
- selected: selected,
- list:tabbarList
- });
- }
- }
- },
- // 控制是否刷新活动列表页
- handleActivityListPageRefresh(){
- const page = this.$mp&&this.$mp.page;
- if(page&&page.route&&page.route=='pages/activity/activity') return
-
- if(page&&page.route&&tabbarPathList.includes(page.route)){
- this.$store.commit('setActivityListPageRefreshStatus', true)
- }else{
- this.$store.commit('setActivityListPageRefreshStatus', false)
- }
- },
- },
- };
|