123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167 |
- const dayjs=require('../utils/dayjs.min.js')
- dayjs.locale('zh-cn')
- import {globalImgUrls} from "../utils/config"
- import store from '@/store'
- import {defaultTabBarListConfig} from '@/utils/config.js'
- const tabbarPathList=defaultTabBarListConfig.map(item=>item.pagePath)
- module.exports = {
- watch: {
- tabbarList(){
- this.handleSetTabBarItem()
- }
- },
- computed: {
- tabbarList(){
- return store.state.user.tabbarList
- },
- userInfo(){
- return this.$store.state.user.userInfo
- }
- },
- filters: {
-
- formatActivityTime(start,end){
- const week=dayjs(start).format('dddd');
- const day=dayjs(start).format('YYYY-MM-DD');
- const startTime=dayjs(start).format('HH:mm');
- const endTime=dayjs(end).format('HH:mm');
- return `${day} ${startTime}-${endTime} ${week}`
- },
-
- formatVoiceTime(e){
- let minus=parseInt(e/60)
- let sec=parseInt(e%60)
- return `${minus>9?minus:'0'+minus}分${sec>9?sec:'0'+sec}秒`
- },
-
- formatReportTime(e){
- return dayjs(e).format('YYYY-MM-DD')
- }
- },
- data() {
- return {
- globalImgUrls:globalImgUrls,
- globalBgMusic:uni.getBackgroundAudioManager(),
- globalRecorder:uni.getRecorderManager(),
- };
- },
- onLoad(options) {
- console.log('mixin onLoad',options);
- const page = this.$mp&&this.$mp.page
- console.log('当前页面路由',page.route);
- uni.getSystemInfo({
- success: function (res) {
- console.log('宽度:',res.windowWidth);
- console.log('设备:',res.platform);
- if(page.route=='pages/login'||page.route=='pages/pc') return
- if (res.windowWidth > 750||['windows','mac'].includes(res.platform)) {
- const params=options
- let paramsStr=`xcxPath=${decodeURIComponent(page.route)}`
- for(const key in params){
- paramsStr=`${paramsStr}&${key}=${params[key]}`
- }
- console.log('进入pc');
- uni.reLaunch({
- url: `/pages/pc?${paramsStr}`,
- });
- }
- },
- fail:function(res){
- }
- })
- },
- onShow(){
- this.handleActivityListPageRefresh()
- const page = this.$mp&&this.$mp.page;
- if(page&&tabbarPathList.includes(page.route)){
- this.$store.dispatch('getTabBar')
- }
- this.handleSetTabBarItem()
- },
- methods: {
-
- 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
-
- 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)
- }
- },
-
- checkUserIsBind(){
- return new Promise((resovle,reject)=>{
- if(store.state.user.userInfo.is_bind===0){
- wx.showModal({
- title: '温馨提示',
- content: '为了优化您的用户体验,\n 请登录后查看更多信息!',
- confirmText:'去登录',
- cancelColor:'#666',
- confirmColor:'#E6B77D',
- success: function (res) {
- if (res.confirm) {
- console.log('用户点击确定');
- uni.reLaunch({
- url:'/pages/login'
- })
- } else if (res.cancel) {
- console.log('用户点击取消');
- }
- }
- });
- reject()
- }else{
- resovle('不用登录')
- }
- })
- }
- },
- };
|