默認
發表評論 1
想開發IM:買成品怕坑?租第3方怕貴?找開源自已擼?盡量別走彎路了... 找站長給點建議
釘釘辦公h5實例|仿釘釘聊天weDingTalk
閱讀(10201) | 評論(1 收藏1 淘帖
h5高仿釘釘辦公移動端——weDingTalk微釘,最近一直研究釘釘app,覺得里面的功能模塊及效果都挺棒噠,于是也利用html5+css3+rem+wcPop+zepto等技術做了一個微釘h5項目,使用css3實現了類似QQ聊天多圖像拼合,里面很多鏈接地方使用到了Material Design效果。

項目截圖:
釘釘辦公h5實例|仿釘釘聊天weDingTalk_001360截圖20180915003708059.png 釘釘辦公h5實例|仿釘釘聊天weDingTalk_002360截圖20180915003826602.png
釘釘辦公h5實例|仿釘釘聊天weDingTalk_003360截圖20180915005347716.png 釘釘辦公h5實例|仿釘釘聊天weDingTalk_004360截圖20180915005419923.png
釘釘辦公h5實例|仿釘釘聊天weDingTalk_006360截圖20180915005901996.png 釘釘辦公h5實例|仿釘釘聊天weDingTalk_007360截圖20180915010048485.png
釘釘辦公h5實例|仿釘釘聊天weDingTalk_008360截圖20180915010335077.png 釘釘辦公h5實例|仿釘釘聊天weDingTalk_010360截圖20180915013242999.png
釘釘辦公h5實例|仿釘釘聊天weDingTalk_011360截圖20180915013303062.png 釘釘辦公h5實例|仿釘釘聊天weDingTalk_012360截圖20180915010948002.png
釘釘辦公h5實例|仿釘釘聊天weDingTalk_013360截圖20180915011004813.png 釘釘辦公h5實例|仿釘釘聊天weDingTalk_014360截圖20180915011140916.png
釘釘辦公h5實例|仿釘釘聊天weDingTalk_015360截圖20180915011705229.png 釘釘辦公h5實例|仿釘釘聊天weDingTalk_017360截圖20180915011927963.png
釘釘辦公h5實例|仿釘釘聊天weDingTalk_018360截圖20180915012046733.png 釘釘辦公h5實例|仿釘釘聊天weDingTalk_019360截圖20180915012132931.png
var $chatMsgList = $("#J__chatMsgList");
// ...處理編輯器信息
var $editor = $(".J__wdtEditor"), _editor = $editor[0];
function surrounds() {
        setTimeout(function () { //chrome
                var sel = window.getSelection();
                var anchorNode = sel.anchorNode;
                if (!anchorNode) return;
                if (sel.anchorNode === _editor ||
                        (sel.anchorNode.nodeType === 3 && sel.anchorNode.parentNode === _editor)) {

                        var range = sel.getRangeAt(0);
                        var p = document.createElement("p");
                        range.surroundContents(p);
                        range.selectNodeContents(p);
                        range.insertNode(document.createElement("br")); //chrome
                        sel.collapse(p, 0);

                        (function clearBr() {
                                var elems = [].slice.call(_editor.children);
                                for (var i = 0, len = elems.length; i < len; i++) {
                                        var el = elems[i];
                                        if (el.tagName.toLowerCase() == "br") {
                                                _editor.removeChild(el);
                                        }
                                }
                                elems.length = 0;
                        })();
                }
        }, 10);
}

// 定義光標位置
var _lastRange = null, _sel = window.getSelection && window.getSelection();
var _rng = {
        getRange: function () {
                if (_sel && _sel.rangeCount > 0) {
                        return _sel.getRangeAt(0);
                }
        },
        addRange: function () {
                if (_lastRange) {
                        _sel.removeAllRanges();
                        _sel.addRange(_lastRange);
                }
        }
}

// 格式編輯器包含標簽
_editor.addEventListener("click", function () {
        $(".wdt__choose-panel").hide();
}, true);
_editor.addEventListener("focus", function () {
        surrounds();
}, true);
_editor.addEventListener("input", function () {
        surrounds();
}, false);

// ...選擇文件
$("#J__chooseFile").on("change", function () {
        $(".wdt__choose-panel").hide();

        var file = this.files[0], fileSuffix = /\.[^\*]+/.exec(file.name).toString(), fileExt = fileSuffix.substr(fileSuffix.lastIndexOf('.') + 1, fileSuffix.length).toLowerCase();
        console.log(fileSuffix);
        console.log(fileExt);
        var fileTypeArr = ['jpg', 'jpeg', 'png', 'gif', 'txt', 'rar', 'zip', 'pdf', 'docx', 'xls'];
        if ($.inArray(fileExt, fileTypeArr) < 0) {
                wcPop({content: '附件只支持jpg、jpeg、png、gif、txt、rar、zip、pdf、docx、xls格式的文件', time: 2});
                return;
        }
        var reader = new FileReader();
        reader.readAsDataURL(file);
        reader.onload = function (e) {
                var _file = this.result;
                console.log(_file);
                var _tpl = [
                        '<li class= "me">\
                                <div class="content">\
                                        <p class="author">風鈴子</p>\
                                        <div class="msg attachment">\
                                                <div class="card flexbox flex-alignc">\
                                                        <span class="ico-bg wdt__bg01"><i class="iconfont icon-fujian"></i></span>\
                                                        <div class="file-info flex1" title="'+ file.name +'">\
                                                                <p class="name">'+ file.name +'</p><p class="size">'+ formateSize(file.size) +'</p>\
                                                        </div>\
                                                        <a class="btn-down" href="'+ _file +'" target="_blank" download="'+ file.name +'"><i class="iconfont icon-down"></i></a>\
                                                </div>\
                                        </div>\
                                </div>\
                                <a class="avatar" href="微釘-好友主頁(詳細資料).html"><img src="img/uimg/u__chat-img07.jpg" /></a>\
                        </li>'
                ].join("");
                $chatMsgList.append(_tpl);

                setTimeout(function () {wchat_ToBottom();}, 17);
        }

        /** 格式化文件大小顯示  value : file文件的大小值 */
        formateSize = function (value) {
                if (null == value || value == '') {
                        return "0 Bytes";
                }
                var unitArr = new Array("B", "KB", "MB", "GB", "TB", "PB", "EB", "ZB", "YB");
                var index = 0;
                var srcsize = parseFloat(value);
                index = Math.floor(Math.log(srcsize) / Math.log(1024));
                var size = srcsize / Math.pow(1024, index);
                size = size.toFixed(2);                //保留的小數位數
                return size + unitArr[index];
        }
});

// ...拆開紅包功能
$(".J__getRedPackets").on("click", function(){
        var getHbIdx = wcPop({
                id: 'wdtPopGetHb',
                skin: 'ios',
                content: $("#J__popupTmpl-getRedPacket").html(),
                xclose: true,
                style: 'background-color: #f3f3f3; width: 280px;',

                show: function () {
                        $("body").on("click", ".J__btnGetRedPacket", function () {
                                var that = $(this);
                                that.addClass("active");
                                setTimeout(function(){
                                        that.removeClass("active");
                                }, 1000);
                        });
                }
        });
});

/* __ 觸摸模擬(active) */
.wdt__material-cell:active{background-color: rgba(25,31,37,.1)!important; transition: all .3s;}
/* __ 模擬水波效果 */
.wdt__ripple, .wdt__ripple-fff{overflow: hidden; position: relative;}
.wdt__ripple:before, .wdt__ripple-fff:before{
	background-image: radial-gradient(circle, #191f25 10%, transparent 11%); background-repeat: no-repeat; background-position: center;
	content: ''; display: block; pointer-events: none; opacity: 0; height: 100%; width: 100%; position: absolute; left: 0; top: 0;
	transform: scale(8,8); transition: transform .5s, opacity 1s;
}
.wdt__ripple-fff:before{background-image: radial-gradient(circle, #fff 10%, transparent 11%);}
.wdt__ripple:active:before, .wdt__ripple-fff:active:before{opacity: .1; transform: scale(0,0); transition: 0s;}
.wdt__ripple.disabled, .wdt__ripple-fff.disabled{pointer-events: none;}

/* …… 微釘主布局——首頁.layout …… */
.weDingTalk__panel{-webkit-touch-callout:none; -webkit-user-select:none; -moz-user-select:none; user-select:none; -webkit-tap-highlight-color: transparent; transition: transform .3s;}
.we__dingtalk-wrapper{height: calc(100vh); position: relative;}
.wdt__container{overflow-y: auto; -webkit-overflow-scrolling: touch; width: 100%; position: relative;}

/* —— 頂部header */
.wdt__topBar .inner{/*background-image: linear-gradient(90deg,#3296fa 10%,#00d3f3);*/ background: #fff; height:1rem; width:100%; z-index:999; position:relative;}
.wdt__topBar.topfixed{padding-bottom:1rem;}
.wdt__topBar.topfixed .inner{max-width:750px; width:100%; position:fixed; top:0;}
.wdt__topBar .inner .barTit{color:#191f25; font-size:.36rem; font-family: 'Microsoft Yahei'; margin-top: -.03rem; padding-left: .25rem; position: relative;}
.wdt__topBar .inner .barTit.sm{color: #575b60; font-size: .32rem; padding-left: 0;}
.wdt__topBar .inner .barTxt{color: #191f25; font-size: .32rem; justify-content: center; align-items: center;}
.wdt__topBar .inner .barTxt .lbl{color: #9ea0a3; display: block; font-size: .2rem;}

/* —— 1、消息模塊 */
/* 消息記錄列表 */
.wdt__recordList ul li{background: #fff; font-family: 'Microsoft Yahei'; padding: .2rem .25rem; position: relative;}
.wdt__recordList ul li:after{content: ''; background-color: #dcdddd; color: #dcdddd; opacity: .56; height: 1px;width: 100%; position: absolute;left: 0;bottom: 0; transform: scaleY(.5); -webkit-transform: scaleY(.5);}
.wdt__recordList ul li:last-child:after{display: none;}
.wdt__recordList ul li .avator{margin-right: .25rem; border-radius: 50%; overflow: hidden; height: .9rem; width: .9rem; position: relative;}
.wdt__recordList ul li .avator img{border-radius: 50%; height: 100%; width: 100%; object-fit: cover; position: absolute;}
.wdt__recordList ul li .groups{background: #dcdddd;}


釘釘辦公h5實例|仿釘釘聊天weDingTalk_20180817002157557.jpg
——>>>歡迎一起交流學習  QQ:282310962    微信:xy190310

即時通訊網 - 即時通訊開發者社區! 來源: - 即時通訊開發者社區!

推薦方案
評論 1
打賞樓主 ×
使用微信打賞! 使用支付寶打賞!

返回頂部
曾氏料二肖中特