javascript中l(wèi)ayim之查找好友查找群組
目前l(fā)ayui官方暫沒提供layim查找好友頁面的結(jié)構(gòu)與樣式,我個人好奇心極強(qiáng),自己弄了一套,現(xiàn)在上傳與大家分享。小生不是做前端的,有些方面不夠全面,請各位大神指點(diǎn)一二!
先呈上效果圖壓壓驚
Layim查找好友、查找群組、添加好友、加入群組:
附上源碼,積分下載
一、綁定用戶成員列表/** html代碼 */<textarea style='display:none;'>{{# layui.each(d.data, function(index, item){ }}<div class='layui-col-sm4 layui-col-md4 layui-col-lg2'> <div > <div class='avatar'> <img src='http://m.piao2010.com/bcjs/{{ item.avatar }}' /> </div> <div class='units'> <p>{{ item.userName }}({{ item.userCode }})</p> <p>{{ item.roleNames }}</p> <p> {{# if(item.isValid == 0){ }} <button userId='{{ item.userId }}' style='background-color:#7ADDD4;'> <strong>+</strong> 好友 </button> {{# } else { }} <span class='c_red'>已經(jīng)是好友</span> {{# } }} </p> </div> </div> </div> {{# }); }}</textarea>/** js代碼 */$.ajax({ type: 'get', url: '../json/friend.json', async: true, data: data, success: function (data) { var json = data; var list = json.data; if(list != null){ // 數(shù)據(jù)轉(zhuǎn)化為html格式var html = laytpl(LAY_Friend.value).render({ data: list});control.html(html); }else{ control.append(’<div style='color:#ccc; margin:150px 350px;'>沒有找到符合搜索條件的用戶</div>’); } }});二、添加好友
/** * 添加好友 */$(document).on(’click’, ’.addFriend’, function() {var myBut = $(this);var userId = myBut.attr('userId');// 彈出添加好友驗(yàn)證界面layim.add({type: ’friend’ ,username: user.username ,avatar: user.avatar ,submit: function(group, remark, index){layer.msg(’好友申請已發(fā)送,請等待對方確認(rèn)’, { icon: 1 });// 修改按鈕 myBut.parent().html(’<span class='c_red'>已經(jīng)提交申請</span>’); // 在這里插入你的推送信息代碼 } });});三、推送信息
利用socket推送添加好友申請
// 推送一個消息var msg = {type: 'addMsgbox',// 隨便定義,用于在服務(wù)端區(qū)分消息類型sendType: 1, // 隨便定義,用于在服務(wù)端區(qū)分消息類型fromId: loginUserId, // 申請者toId: user.id,// 好友編號groupId: group,// 所在分組remark: remark// 驗(yàn)證信息}websocket.send(JSON.stringify({ type: ’chatMsgbox’ // 隨便定義,用于在服務(wù)端區(qū)分消息類型 ,data: msg }));四、猜您喜歡
https://www.jb51.net/article/23188.htm
到此這篇關(guān)于javascript中l(wèi)ayim之查找好友查找群組的文章就介紹到這了,更多相關(guān)layim查找好友查找群組內(nèi)容請搜索好吧啦網(wǎng)以前的文章或繼續(xù)瀏覽下面的相關(guān)文章希望大家以后多多支持好吧啦網(wǎng)!
相關(guān)文章:
1. 基于javaweb+jsp實(shí)現(xiàn)學(xué)生宿舍管理系統(tǒng)2. 如何封裝一個Ajax函數(shù)3. 多級聯(lián)動下拉選擇框,動態(tài)獲取下一級4. ASP.NET MVC實(shí)現(xiàn)樹形導(dǎo)航菜單5. 什么是JWT超詳細(xì)講解6. python 在mysql中插入null空值的操作7. Python爬蟲基礎(chǔ)之初次使用scrapy爬蟲實(shí)例8. .NET Core中RabbitMQ使用死信隊(duì)列的實(shí)現(xiàn)9. Python如何telnet到網(wǎng)絡(luò)設(shè)備10. 關(guān)于html嵌入xml數(shù)據(jù)島如何穿過樹形結(jié)構(gòu)關(guān)系的問題
