This commit is contained in:
cmxdd 2020-08-10 16:55:34 +08:00
commit 2759972de6
5 changed files with 179 additions and 9 deletions

1
.gitignore vendored
View File

@ -1,3 +1,4 @@
.vscode .vscode
node_modules node_modules
unpackage unpackage
manifest.json

View File

@ -1,6 +1,6 @@
{ {
"name" : "hdemingshangjia", "name" : "德铭阳光商家",
"appid" : "", "appid" : "__UNI__EA895BE",
"description" : "", "description" : "",
"versionName" : "1.0.0", "versionName" : "1.0.0",
"versionCode" : "100", "versionCode" : "100",
@ -17,7 +17,12 @@
"delay" : 0 "delay" : 0
}, },
/* */ /* */
"modules" : {}, "modules" : {
"Push" : {},
"OAuth" : {},
"VideoPlayer" : {},
"LivePusher" : {}
},
/* */ /* */
"distribute" : { "distribute" : {
/* android */ /* android */
@ -45,12 +50,56 @@
"<uses-feature android:name=\"android.hardware.camera\"/>", "<uses-feature android:name=\"android.hardware.camera\"/>",
"<uses-permission android:name=\"android.permission.ACCESS_FINE_LOCATION\"/>", "<uses-permission android:name=\"android.permission.ACCESS_FINE_LOCATION\"/>",
"<uses-permission android:name=\"android.permission.WRITE_SETTINGS\"/>" "<uses-permission android:name=\"android.permission.WRITE_SETTINGS\"/>"
] ],
"abiFilters" : [ "armeabi-v7a", "x86" ]
}, },
/* ios */ /* ios */
"ios" : {}, "ios" : {},
/* SDK */ /* SDK */
"sdkConfigs" : {} "sdkConfigs" : {
"ad" : {},
"push" : {},
"oauth" : {},
"maps" : {}
},
"icons" : {
"android" : {
"hdpi" : "unpackage/res/icons/72x72.png",
"xhdpi" : "unpackage/res/icons/96x96.png",
"xxhdpi" : "unpackage/res/icons/144x144.png",
"xxxhdpi" : "unpackage/res/icons/192x192.png"
},
"ios" : {
"appstore" : "unpackage/res/icons/1024x1024.png",
"ipad" : {
"app" : "unpackage/res/icons/76x76.png",
"app@2x" : "unpackage/res/icons/152x152.png",
"notification" : "unpackage/res/icons/20x20.png",
"notification@2x" : "unpackage/res/icons/40x40.png",
"proapp@2x" : "unpackage/res/icons/167x167.png",
"settings" : "unpackage/res/icons/29x29.png",
"settings@2x" : "unpackage/res/icons/58x58.png",
"spotlight" : "unpackage/res/icons/40x40.png",
"spotlight@2x" : "unpackage/res/icons/80x80.png"
},
"iphone" : {
"app@2x" : "unpackage/res/icons/120x120.png",
"app@3x" : "unpackage/res/icons/180x180.png",
"notification@2x" : "unpackage/res/icons/40x40.png",
"notification@3x" : "unpackage/res/icons/60x60.png",
"settings@2x" : "unpackage/res/icons/58x58.png",
"settings@3x" : "unpackage/res/icons/87x87.png",
"spotlight@2x" : "unpackage/res/icons/80x80.png",
"spotlight@3x" : "unpackage/res/icons/120x120.png"
}
}
},
"splashscreen" : {
"iosStyle" : "storyboard",
"ios" : {
"storyboard" : "E:/Source-code/deming/static/CustomStoryboard.zip"
}
}
} }
}, },
/* */ /* */

View File

@ -196,7 +196,40 @@ export default {
methods: { methods: {
// //
tochat(ID){ tochat(ID){
function Friend(uuid, name, avatar,time = "", text = "",date = "") {
this.uuid = uuid;
this.name = name;
this.avatar = avatar;
this.online = false;
this.unReadMessage = 0;
this.text = text;
this.time = time;
this.date = date
}
console.log(ID) console.log(ID)
const token = uni.getStorageSync('token');
let that = this
uni.request({
url:"https://dmmall.sdbairui.com/api/Specialci/getAtwillUserInfo",
data:{
userId: ID
},
method:"POST",
header:{
"Authorization" : 'Bearer' + " " + token
},
success(res){
console.log(res)
res = res.data
let user = new Friend(res.data.member_id,res.data.member_nickname,res.data.member_avatar)
that.$u.route({
url:"/pages/messages/privateChat",
params:{
id:JSON.stringify(user)
}
})
}
})
}, },
// 退 // 退
radioGroupChange(e) { radioGroupChange(e) {

View File

@ -237,7 +237,7 @@ export default {
count: 1, count: 1,
sourceType: ['camera', 'album'], sourceType: ['camera', 'album'],
success: function(res) { success: function(res) {
self.src = res.tempFilePath; that.src = res.tempFilePath;
const tempFilePaths = res.tempFilePath; const tempFilePaths = res.tempFilePath;
uni.uploadFile({ uni.uploadFile({
url: url, // url: url, //
@ -250,6 +250,7 @@ export default {
Authorization: 'Bearer' + ' ' + uni.getStorageSync('token') Authorization: 'Bearer' + ' ' + uni.getStorageSync('token')
}, },
success: uploadFileRes => { success: uploadFileRes => {
console.log(uploadFileRes);
let obj = JSON.parse(uploadFileRes.data); let obj = JSON.parse(uploadFileRes.data);
that.videopath = obj.data.url; that.videopath = obj.data.url;
that.selectvideo = obj.data.key; that.selectvideo = obj.data.key;

View File

@ -386,7 +386,85 @@ IMService.prototype.initialIMListeners = function () {
// }) // })
}; };
IMService.prototype.sendMessagesSetStorage = function (friendId,message){
let friend = this.friends[friendId];
console.log(friend)
// return ;
let sorts = function (friends){
let paixu = function (a,b){
if(a.date > b.date){
return 0;
}else{
return 1;
}
}
friends.sort(paixu)
}
let that = this
if(!friend && friend == undefined){
const token = uni.getStorageSync('token');
console.log(token)
uni.request({
url:"https://dmmall.sdbairui.com/api/Specialci/getAtwillUserInfo",
data:{
userId:friendId
},
method:"POST",
header:{
"Authorization" : 'Bearer' + " " + token
},
success(res){
console.log(res)
that.friends[friendId] = new Friend(res.data.data.member_id, res.data.data.member_nickname, res.data.data.member_avatar);
friend = that.friends[friendId];
console.log(friend)
friend.text = message
let time = new Date()
friend.date = time.getTime()
friend.time = time.getHours() + ":" + time.getMinutes() + ":" + time.getSeconds()
console.log(that.friends)
that.friendsarr = []
for(let i in that.friends){
console.log(i)
that.friendsarr.push(that.friends[i])
}
sorts(that.friendsarr)
let arr = []
for(let i in that.friends){
arr.push([that.friends[i].uuid,that.friends[i].time,that.friends[i].text,that.friends[i].date,0])
}
console.log(arr)
uni.setStorageSync('imlist',JSON.stringify(arr))
that.onFriendListChange(that.friends);
}
})
}else{
console.log(friend)
friend.text = message
let time = new Date()
friend.date = time.getTime()
friend.time = time.getHours() + ":" + time.getMinutes() + ":" + time.getSeconds()
console.log(this.friends)
that.friendsarr = []
for(let i in this.friends){
that.friendsarr.push(this.friends[i])
}
sorts(that.friendsarr)
let arr = []
for(let i in that.friends){
arr.push([that.friends[i].uuid,that.friends[i].time,that.friends[i].text,that.friends[i].date,0])
}
console.log(arr)
uni.setStorageSync('imlist',JSON.stringify(arr))
this.onFriendListChange(this.friends);
}
}
//订阅群消息 //订阅群消息
IMService.prototype.subscribeGroupMessage = function (id) { IMService.prototype.subscribeGroupMessage = function (id) {
this.im.subscribeGroup([id]) this.im.subscribeGroup([id])
@ -462,6 +540,8 @@ IMService.prototype.sendPrivateTextMessage = function (friendId, text) {
text: text text: text
}); });
this.sendPrivateMessage(friendId, textMessage); this.sendPrivateMessage(friendId, textMessage);
this.sendMessagesSetStorage(friendId, text)
}; };
//私聊图片消息 //私聊图片消息
@ -473,6 +553,8 @@ IMService.prototype.sendPrivateImageMessage = function (friendId, imageFile) {
} }
}); });
this.sendPrivateMessage(friendId, imageMessage); this.sendPrivateMessage(friendId, imageMessage);
this.sendMessagesSetStorage(friendId, '其他消息')
}; };
//私聊视频消息 //私聊视频消息
@ -484,6 +566,8 @@ IMService.prototype.sendPrivateVideoMessage = function (friendId, videoFile) {
} }
}); });
this.sendPrivateMessage(friendId, videoMessage); this.sendPrivateMessage(friendId, videoMessage);
this.sendMessagesSetStorage(friendId, '其他消息')
}; };
IMService.prototype.sendPrivateAudioMessage = function (friendId, audiofile) { IMService.prototype.sendPrivateAudioMessage = function (friendId, audiofile) {
@ -495,6 +579,8 @@ IMService.prototype.sendPrivateAudioMessage = function (friendId, audiofile) {
}); });
this.sendPrivateMessage(friendId, audioMessage); this.sendPrivateMessage(friendId, audioMessage);
this.sendMessagesSetStorage(friendId, '其他消息')
}; };
//发送私聊消息 //发送私聊消息