欧美bbbwbbbw肥妇,免费乱码人妻系列日韩,一级黄片

vue+web端仿微信網(wǎng)頁版聊天室功能

 更新時間:2019年04月30日 08:32:21   作者:xiaoyan2017  
這篇文章主要介紹了vue+web端仿微信網(wǎng)頁版聊天室功能,非常不錯,具有一定的參考借鑒價值 ,需要的朋友可以參考下

一、項目介紹

基于Vue2.5.6+Vuex+vue-cli+vue-router+vue-gemini-scrollbar+swiper+elementUI等技術(shù)混合架構(gòu)開發(fā)的仿微信web端聊天室——vueWebChat,實現(xiàn)了發(fā)送消息、表情(動圖),圖片、視頻預(yù)覽,右鍵菜單、截屏、截圖可直接粘貼至文本框進行發(fā)送。

二、技術(shù)框架

•MVVM框架:Vue2.5.6
•狀態(tài)管理:Vuex
•頁面路由:Vue-router
•iconfont圖標(biāo):阿里巴巴字體圖標(biāo)庫
•自定義滾動條:vue-gemini-scrollbar
•彈窗組件:element-ui(餓了么前端UI庫)
•環(huán)境配置:node.js + cnpm + webpack
•高德地圖:vue-amap
•圖片預(yù)覽:vue-photo-preview

◆ 點擊右上角最大化按鈕,可以進行全屏切換

◆ 引入公共及全局組件配置components.js

/*
 引入公共及全局組件配置
*/ 
// 引入側(cè)邊欄及聯(lián)系人
import winBar from './components/winbar'
import sideBar from './components/sidebar'
import recordList from './components/recordList'
import contactList from './components/contact'
// 引入jquery
import $ from 'jquery'
// 引入wcPop彈窗插件
import wcPop from './assets/js/wcPop/wcPop'
import './assets/js/wcPop/skin/wcPop.css'
// 引入餓了么pc端UI庫
import elementUI from 'element-ui'
import 'element-ui/lib/theme-chalk/index.css'
// 引入圖片預(yù)覽插件
import photoPreview from 'vue-photo-preview'
import 'vue-photo-preview/dist/skin.css'
// 引入自定義滾動條插件
import geminiScrollbar from 'vue-gemini-scrollbar'
// 引入加載更多插件
import infiniteLoading from 'vue-infinite-scroll'
// 引入高德地圖
import vueAMap from 'vue-amap'
const install = Vue => {
 // 注冊組件
 Vue.component('win-bar', winBar)
 Vue.component('side-bar', sideBar)
 Vue.component('record-list', recordList)
 Vue.component('contact-list', contactList)
 // 應(yīng)用實例
 Vue.use(elementUI)
 Vue.use(photoPreview, {
  loop: false,
  fullscreenEl: true, //是否全屏
  arrowEl: true, //左右按鈕
 });
 Vue.use(geminiScrollbar)
 Vue.use(infiniteLoading)
 Vue.use(vueAMap)
 vueAMap.initAMapApiLoader({
  key: "e1dedc6bdd765d46693986ff7ff969f4",
  plugin: [
   "AMap.Autocomplete", //輸入提示插件
   "AMap.PlaceSearch", //POI搜索插件
   "AMap.Scale", //右下角縮略圖插件 比例尺
   "AMap.OverView", //地圖鷹眼插件
   "AMap.ToolBar", //地圖工具條
   "AMap.MapType", //類別切換控件,實現(xiàn)默認(rèn)圖層與衛(wèi)星圖、實施交通圖層之間切換的控制
   "AMap.PolyEditor", //編輯 折線多,邊形
   "AMap.CircleEditor", //圓形編輯器插件
   "AMap.Geolocation" //定位控件,用來獲取和展示用戶主機所在的經(jīng)緯度位置
  ],
  uiVersion: "1.0"
 });
}
export default install

◆ 主頁面模板

<template>
 <div id="app">
 <div class="vChat-wrapper flexbox flex-alignc">
  <div class="vChat-panel" style="background-image: url(src/assets/img/placeholder/vchat__panel-bg01.jpg);">
  <div class="vChat-inner flexbox">
   <!-- //頂部按鈕(最大、最小、關(guān)閉) -->
   <win-bar></win-bar>
   <!-- //側(cè)邊欄 -->
   <side-bar></side-bar>
   <keep-alive>
   <router-view class="flex1 flexbox"></router-view>
   </keep-alive>
  </div>
  </div>
 </div>
 </div>
</template>
<script>
export default {
 name: 'app',
 data () {
 return {
 }
 },
 methods: {
 },
}
</script>
<style>
/* 引入公共樣式 */
@import './assets/fonts/iconfont.css';
@import './assets/css/reset.css';
@import './assets/css/layout.css';
</style>

◆ vue文本框?qū)崿F(xiàn)截圖粘貼發(fā)送圖片:

// 【截圖粘貼圖片】
document.getElementById('J__wcEditor').addEventListener('paste',function(e){
 var cbd = e.clipboardData;
 var ua = window.navigator.userAgent;
 // 沒有數(shù)據(jù)
 if (!(e.clipboardData && e.clipboardData.items)) {
  return;
 }
 // Mac平臺下Chrome49版本以下 復(fù)制Finder中的文件的Bug Hack掉
 if(cbd.items && cbd.items.length === 2 && cbd.items[0].kind === "string" && cbd.items[1].kind === "file" &&
  cbd.types && cbd.types.length === 2 && cbd.types[0] === "text/plain" && cbd.types[1] === "Files" &&
  ua.match(/Macintosh/i) && Number(ua.match(/Chrome\/(\d{2})/i)[1]) < 49){
  return;
 }
 for(var i = 0; i < cbd.items.length; i++){
  var item = cbd.items[i];
  console.log(item);
  console.log(item.kind);
  if(item.kind == "file"){
   var blob = item.getAsFile();
   if(blob.size === 0){
    return;
   }
   // 插入圖片記錄
   var reader = new FileReader();
   reader.readAsDataURL(blob);
   reader.onload = function(){
    var _img = this.result;
    var _tpl = [
     '<li class="me">\
      <div class="content">\
       <p class="author">王梅(Fine)</p>\
       <div class="msg picture"><img class="img__pic" src="'+ _img + '" preview="1" /></div>\
      </div>\
      <a class="avatar" href="/contact/uinfo"><img src="src/assets/img/uimg/u__chat-img11.jpg" /></a>\
     </li>'
    ].join("");
    $("#J__chatMsgList").append(_tpl);
    setTimeout(() => {
     $("#J__geminiScrollbar .gm-scroll-view").animate({ scrollTop: $("#J__chatMsgList").height() }, 0);
     $(".fixGeminiscrollHeight").show();
     setTimeout(() => { $(".fixGeminiscrollHeight").hide();}, 300);
    }, 17);
   }
  }
 }
});

◆ 表情處理及視頻預(yù)覽:

// >>> 【表情、動圖swiper切換模塊】--------------------------
var emotionSwiper;
function setEmotionSwiper(tmpl) {
 var _tmpl = tmpl ? tmpl : $("#J__emotionFootTab ul li.cur").attr("tmpl");
 $("#J__swiperEmotion .swiper-container").attr("id", _tmpl);
 $("#J__swiperEmotion .swiper-wrapper").html($("." + _tmpl).html());
 emotionSwiper = new Swiper('#' + _tmpl, {
  // loop: true,
  // autoplay: true,
  // 分頁器
  pagination: {
   el: '.pagination-emotion', clickable: true,
  },
 });
}
// 表情模板切換
$("body").on("click", "#J__emotionFootTab ul li.swiperTmpl", function () {
 // 先銷毀swiper
 emotionSwiper && emotionSwiper.destroy(true, true);
 var _tmpl = $(this).attr("tmpl");
 $(this).addClass("cur").siblings().removeClass("cur");
 setEmotionSwiper(_tmpl);
});
// >>> 【視頻預(yù)覽模塊】--------------------------
$("body").on("click", "#J__chatMsgList li .video", function () {
 var _src = $(this).find("img").attr("videoUrl"), _video;
 var videoIdx = wcPop({
  id: 'wc__previewVideo',
  skin: 'fullscreen',
  // content: '<video id="J__videoPreview" width="100%" height="100%" controls="controls" x5-video-player-type="h5" x5-video-player-fullscreen="true" webkit-playsinline preload="auto"></video>',
  content: '<video id="J__videoPreview" width="100%" height="100%" controls="controls" preload="auto"></video>',
  shade: false,
  xclose: true,
  style: 'background: #000;padding-top:48px;',
  anim: 'scaleIn',
  show: function(){
   _video = document.getElementById("J__videoPreview");
   _video.src = _src;
   if (_video.paused) {
    _video.play();
   } else {
    _video.pause();
   }
   // 播放結(jié)束
   _video.addEventListener("ended", function(){
    _video.currentTime = 0;
   });
   // 退出全屏
   _video.addEventListener("x5videoexitfullscreen", function(){
    wcPop.close(videoIdx);
   })
  }
 });
});

總結(jié)

以上所述是小編給大家介紹的vue+web端仿微信網(wǎng)頁版聊天室功能,希望對大家有所幫助,如果大家有任何疑問請給我留言,小編會及時回復(fù)大家的。在此也非常感謝大家對腳本之家網(wǎng)站的支持!
如果你覺得本文對你有幫助,歡迎轉(zhuǎn)載,煩請注明出處,謝謝!

相關(guān)文章

  • vue中提示$index is not defined錯誤的解決方式

    vue中提示$index is not defined錯誤的解決方式

    這篇文章主要介紹了vue中提示$index is not defined錯誤的解決方式,具有很好的參考價值,希望對大家有所幫助。一起跟隨小編過來看看吧
    2020-09-09
  • vue-element-admin如何從mock數(shù)據(jù)過渡到使用后臺接口

    vue-element-admin如何從mock數(shù)據(jù)過渡到使用后臺接口

    這篇文章主要介紹了vue-element-admin如何從mock數(shù)據(jù)過渡到使用后臺接口問題,具有很好的參考價值,希望對大家有所幫助。如有錯誤或未考慮完全的地方,望不吝賜教
    2023-04-04
  • 在Vue項目中使用自定義字體的操作步驟

    在Vue項目中使用自定義字體的操作步驟

    在項目中使用自定義字體可以提升頁面的視覺效果,并確保在不同設(shè)備上的一致性,文中通過代碼示例給出了具體的操作步驟,對大家的學(xué)習(xí)或工作有一定的幫助,需要的朋友可以參考下
    2024-06-06
  • element-plus的el-table自定義表頭篩選查詢功能實現(xiàn)

    element-plus的el-table自定義表頭篩選查詢功能實現(xiàn)

    這篇文章主要介紹了element-plus的el-table自定義表頭篩選查詢功能實現(xiàn),本文給大家介紹的非常詳細(xì),對大家的學(xué)習(xí)或工作具有一定的參考借鑒價值,需要的朋友參考下吧
    2024-07-07
  • element-ui?el-upload實現(xiàn)上傳文件及簡單的上傳文件格式驗證功能

    element-ui?el-upload實現(xiàn)上傳文件及簡單的上傳文件格式驗證功能

    前端上傳文件后,后端接受文件進行處理后直接返回處理后的文件,前端直接再將文件下載下來,下面這篇文章主要給大家介紹了關(guān)于element-ui?el-upload實現(xiàn)上傳文件及簡單的上傳文件格式驗證功能的相關(guān)資料,需要的朋友可以參考下
    2022-11-11
  • 詳解Vue3.0 + TypeScript + Vite初體驗

    詳解Vue3.0 + TypeScript + Vite初體驗

    這篇文章主要介紹了詳解Vue3.0 + TypeScript + Vite初體驗,文中通過示例代碼介紹的非常詳細(xì),對大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價值,需要的朋友們下面隨著小編來一起學(xué)習(xí)學(xué)習(xí)吧
    2021-02-02
  • vue.js如何更改默認(rèn)端口號8080為指定端口的方法

    vue.js如何更改默認(rèn)端口號8080為指定端口的方法

    本篇文章主要介紹了vue.js如何更改默認(rèn)端口號8080為指定端口的方法,小編覺得挺不錯的,現(xiàn)在分享給大家,也給大家做個參考。一起跟隨小編過來看看吧
    2017-07-07
  • Vue中的動態(tài)路由匹配路由問題

    Vue中的動態(tài)路由匹配路由問題

    這篇文章主要介紹了Vue中的動態(tài)路由匹配路由問題,具有很好的參考價值,希望對大家有所幫助。如有錯誤或未考慮完全的地方,望不吝賜教
    2022-12-12
  • 詳解如何使用vue-cli腳手架搭建Vue.js項目

    詳解如何使用vue-cli腳手架搭建Vue.js項目

    這篇文章主要介紹了詳解如何使用vue-cli腳手架搭建Vue.js項目 ,小編覺得挺不錯的,現(xiàn)在分享給大家,也給大家做個參考。一起跟隨小編過來看看吧
    2017-05-05
  • 在vue中使用echarts實現(xiàn)上浮與下鉆效果

    在vue中使用echarts實現(xiàn)上浮與下鉆效果

    這篇文章主要介紹了在vue中使用echarts實現(xiàn)上浮與下鉆效果,本文分步驟給大家介紹的非常詳細(xì),具有一定的參考借鑒價值,需要的朋友可以參考下
    2019-11-11

最新評論