微信小程序> 微信聊天图片,微信小程序实现聊天功能,带表情,拍照等功能

微信聊天图片,微信小程序实现聊天功能,带表情,拍照等功能

浏览量:731 时间: 来源:qq_28994319
微信小程序实现聊天功能,带表情,拍照等功能(后端用php的Workerman来实现),想要知道具体怎么实现的加我QQ:1346883814部分代码:
toSend:function(msgType,messageId,msgContent,fileContent,path,duration){letthat=thisletuid=that.data.userIdletcuid=that.data.currenIdif(msgType=='img'||msgType=='audio'){util.common.uploadFile(path,function(res){letmsg='{"type":"chat","target":'+uid+',"from":'+cuid+',"room_id":1,"msg":{"type":"'+msgType+'","messageId":"'+messageId+'","msg":"'+msgContent+'","fileContent":"'+res.data.url+'","path":"'+res.data.url+'","duration":"'+duration+'"}}'letmsgRecords={msg:msgContent,filePath:conf.apiImgUrl+res.data.url,msgType:msgType,duration:duration,position:"right"}varchatRecords=wx.getStorageSync('chat'+cuid+uid)if(chatRecords==""||chatRecords==undefined){wx.setStorageSync('chat'+cuid+uid,[msgRecords])}else{if(chatRecords.length=100){chatRecords.splice(0,1);}chatRecords.push(msgRecords)wx.setStorageSync('chat'+cuid+uid,chatRecords)}that.setData({msg:chatRecords})that.sendSocketMessage(msg)})}else{letmsg='{"type":"chat","target":'+uid+',"from":'+cuid+',"room_id":1,"msg":{"type":"'+msgType+'","messageId":"'+messageId+'","msg":"'+msgContent+'","fileContent":"'+fileContent+'","path":"'+path+'","duration":"'+duration+'"}}'letmsgRecords={msg:msgContent,filePath:path,msgType:msgType,duration:duration,position:"right"}varchatRecords=wx.getStorageSync('chat'+cuid+uid)if(chatRecords==""||chatRecords==undefined){wx.setStorageSync('chat'+cuid+uid,[msgRecords])}else{if(chatRecords.length=100){chatRecords.splice(0,1);}chatRecords.push(msgRecords)wx.setStorageSync('chat'+cuid+uid,chatRecords)}//console.log(JSON.parse(chatRecords[8]))that.setData({msg:chatRecords})that.sendSocketMessage(msg)}},效果图如下

版权声明

即速应用倡导尊重与保护知识产权。如发现本站文章存在版权问题,烦请提供版权疑问、身份证明、版权证明、联系方式等发邮件至197452366@qq.com ,我们将及时处理。本站文章仅作分享交流用途,作者观点不等同于即速应用观点。用户与作者的任何交易与本站无关,请知悉。

产品经理

手机 : 13312967497

擅长 : 小程序流量变现

扫码领取礼包

热门模板

  • 头条
  • 搜狐
  • 微博
  • 百家
  • 一点资讯
  • 知乎