微信小程序实现聊天功能,带表情,拍照等功能(后端用php的Workerman来实现),想要知道具体怎么实现的加我QQ:1346883814
部分代码:
toSend: function (msgType, messageId, msgContent, fileContent, path, duration) {
let that = this
let uid = that.data.userId
let cuid = that.data.currenId
if (msgType == 'img' || msgType == 'audio'){
util.common.uploadFile(path, function (res) {
let msg = '{ "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 + '"}}'
let msgRecords = { msg: msgContent, filePath: conf.apiImgUrl + res.data.url, msgType: msgType, duration: duration, position: "right" }
var chatRecords = wx.getStorageSync('chat' + cuid + uid)
if (chatRecords == "" || chatRecords == undefined) {
wx.setStorageSync('chat' + cuid + uid, [msgRecords])