vue仿微信界面聊天室项目|vue聊天案例

基于vue开发的仿微信聊天室vue-wechatRoom实例,vue版仿微信聊天界面|仿微信聊天对话框vue版,使用了vue2.0+vuex+vue-router+webpack+wcpop等技术开发,实现了消息、表情发送,图片、视频预览等功能。

vue仿微信界面聊天室项目|vue聊天案例

vue仿微信界面聊天室项目|vue聊天案例

vue仿微信界面聊天室项目|vue聊天案例

vue仿微信界面聊天室项目|vue聊天案例

vue仿微信界面聊天室项目|vue聊天案例

vue仿微信界面聊天室项目|vue聊天案例

vue仿微信界面聊天室项目|vue聊天案例

vue仿微信界面聊天室项目|vue聊天案例

vue仿微信界面聊天室项目|vue聊天案例

vue仿微信界面聊天室项目|vue聊天案例

vue仿微信界面聊天室项目|vue聊天案例

vue仿微信界面聊天室项目|vue聊天案例

vue仿微信界面聊天室项目|vue聊天案例

<template>
  <div class="weChatIM__panel clearfix">
    <div class="we__chatIM-wrapper flexbox flex__direction-column">
      <!-- //顶部 -->
      <header-bar :class="{'topfixed': isTopFixed}"></header-bar>

      <!-- //主页面 -->
      <div class="wcim__container flex1">
        <keep-alive><router-view></router-view></keep-alive>
      </div>

      <!-- //底部tab -->
      <tab-bar></tab-bar>
    </div>
  </div>
</template>

<script>
  import headerBar from './components/header'
  import tabBar from './components/footer'
  export default {
    name: 'app',
    data () {
      return {
        isTopFixed: true
      }
    },
    components: {
      headerBar,
      tabBar
    }
  }
</script>

<style>
  /* 引入公共样式 */
  @import './assets/fonts/iconfont.css';
  @import './assets/css/reset.css';
  @import './assets/css/layout.css';

</style>

地址路由及登录、注册拦截


/*
 *  页面地址路由js
 */ 
import Vue from 'vue'
import _router from 'vue-router'
import store from '../vuex'

Vue.use(_router) //应用路由

const router = new _router({
    routes: [
        // 登录、注册
        {
            path: '/login',
            component: resolve => require(['../views/auth/login'], resolve),
        },
        {
            path: '/register',
            component: resolve => require(['../views/auth/register'], resolve),
        },

        // 首页、通讯录、我
        {
            path: '/',
            component: resolve => require(['../views/index'], resolve),
            meta: { showHeader: true, showTabBar: true, requireAuth: true }
        },
        {
            path: '/contact',
            component: resolve => require(['../views/contact'], resolve),
            meta: { showHeader: true, showTabBar: true, requireAuth: true },
        },
        {
            path: '/contact/uinfo',
            component: resolve => require(['../views/contact/uinfo'], resolve),
        },
        {
            path: '/ucenter',
            component: resolve => require(['../views/ucenter'], resolve),
            meta: { showHeader: true, showTabBar: true, requireAuth: true }
        },
        // 聊天页面
        {
            path: '/chat/group-chat',
            component: resolve => require(['../views/chat/group-chat'], resolve),
            meta: { requireAuth: true }
        },
        {
            path: '/chat/single-chat',
            component: resolve => require(['../views/chat/single-chat'], resolve),
            meta: { requireAuth: true }
        },
        {
            path: '/chat/group-info',
            component: resolve => require(['../views/chat/group-info'], resolve),
            meta: { requireAuth: true }
        }

        // ...
    ]
})

// 注册全局钩子拦截登录状态
const that = this
router.beforeEach((to, from, next) => {
    const token = store.state.token
    // 判断该路由地址是否需要登录权限
    if(to.meta.requireAuth){
        // 通过vuex state获取当前token是否存在
        if(token){
            next()
        }else{
            // console.log('还未登录授权!')
            next()
            wcPop({
                content: '还未登录授权!', style: 'background:#e03b30;color:#fff;', time: 2,
                end: function(){
                    next({ path: '/login' })
                }
            });
        }
    }else{
        next()
    }
})
export default router
上一篇:uniapp仿微信聊天室|仿微信界面


下一篇:react+redux聊天IM系统|react仿微信界面