diff --git a/App.vue b/App.vue
index 069c1f4..ad31a1b 100644
--- a/App.vue
+++ b/App.vue
@@ -5,7 +5,7 @@
export default {
onLaunch: function() {
im.initIm('lmxuhwaglu76d')
- return;
+
//#ifdef APP-PLUS
// 获取系统版本号
getVersions({
diff --git a/apis/interfaces/im.js b/apis/interfaces/im.js
index 7e3f394..07dcddf 100644
--- a/apis/interfaces/im.js
+++ b/apis/interfaces/im.js
@@ -1,46 +1,78 @@
-
-/**
- * Web唐明明
- * 匆匆数载恍如梦,岁月迢迢华发增。
- * 碌碌无为枉半生,一朝惊醒万事空。
- * moduleName: 聊聊
- */
-
-import { request } from '../index'
-
+/**
+ * Web唐明明
+ * 匆匆数载恍如梦,岁月迢迢华发增。
+ * 碌碌无为枉半生,一朝惊醒万事空。
+ * moduleName: 聊聊
+ */
+
+import {
+ request
+} from '../index'
+
// 获取好友列表
const getFriends = () => {
return request({
url: 'im/friends',
}, true)
}
-
+
// 获取融云token
const getImToken = () => {
return request({
url: 'im/token',
}, true)
}
-
+
// 获取用户信息
const getUserInfo = (targetId) => {
return request({
url: 'im/userInfo/' + targetId,
})
}
-
-/**
- * 获取好友申请列表
- */
-const getPedings = () => {
- return request({
- url: 'im/friends/pending'
- })
+
+/**
+ * 获取好友申请列表
+ */
+const getPedings = () => {
+ return request({
+ url: 'im/friends/pending'
+ })
+}
+
+const resolveFriend = (targetId) => {
+ return request({
+ method: 'POST',
+ url: 'im/friends/accept/' + targetId
+ })
+}
+
+const rejectFriend = (targetId) => {
+ return request({
+ method: 'DELETE',
+ url: 'im/friends/accept/' + targetId
+ })
+}
+
+const searchFriend = (mobile) => {
+ return request({
+ url: 'im/search?mobile=' + mobile
+ })
+}
+
+const pedingFriend = (recipient) => {
+ return request({
+ method: 'POST',
+ url: 'im/friends/' + recipient
+ })
}
-
+
export {
getImToken,
getFriends,
- getUserInfo,
- getPedings
+ getUserInfo,
+ getPedings,
+ resolveFriend,
+ rejectFriend,
+ searchFriend,
+ pedingFriend
}
diff --git a/manifest.json b/manifest.json
index 94c26d4..73cc5f5 100644
--- a/manifest.json
+++ b/manifest.json
@@ -2,8 +2,8 @@
"name" : "ZH-HEALTH",
"appid" : "__UNI__C29473D",
"description" : "ZH-HEALTH,您手上的健康管理专家",
- "versionName" : "1.0.2",
- "versionCode" : 102,
+ "versionName" : "1.0.5",
+ "versionCode" : 105,
"transformPx" : false,
/* 5+App特有相关 */
"app-plus" : {
diff --git a/pages.json b/pages.json
index c297e34..cadb731 100644
--- a/pages.json
+++ b/pages.json
@@ -364,7 +364,7 @@
"name": "IM",
"style": {
"navigationBarTitleText": "聊聊",
- "navigationBarBackgroundColor": "#FFFFFF",
+ "navigationBarBackgroundColor": "#F3F6FB",
"app-plus": {
"titleNView": {
"buttons": [
@@ -392,7 +392,7 @@
"name": "imPrivate",
"style": {
"navigationBarTitleText": "聊天",
- "navigationBarBackgroundColor": "#FFFFFF",
+ "navigationBarBackgroundColor": "#F3F6FB",
"disableScroll": true,
"app-plus": {
"titleNView": {
@@ -440,8 +440,8 @@
"path": "pages/im/friends/pending",
"name": "imFriendsPending",
"style": {
- "navigationBarTitleText": "新的朋友",
- "navigationBarBackgroundColor":"#FFFFFF"
+ "navigationBarTitleText": "新朋友",
+ "navigationBarBackgroundColor":"#F3F6FB"
}
},
{
@@ -449,7 +449,7 @@
"name": "imFriendsInfo",
"style": {
"navigationBarTitleText": "好友资料",
- "navigationBarBackgroundColor":"#FFFFFF"
+ "navigationBarBackgroundColor":"#F3F6FB"
}
},
{
diff --git a/pages/im/friends/index.vue b/pages/im/friends/index.vue
index a06cc37..27abc38 100644
--- a/pages/im/friends/index.vue
+++ b/pages/im/friends/index.vue
@@ -7,89 +7,69 @@
-
+
我的群聊
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- {{item1.name}}
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
-
@@ -99,27 +79,30 @@
@include flex;
padding: 6px 12px;
align-items: center;
+
&__avatar {
height: 35px;
width: 35px;
border-radius: 50%;
}
+
&__user-name {
font-size: 16px;
margin-left: 10px;
color: $u-main-color;
}
}
+
&__footer {
color: $u-tips-color;
font-size: 14px;
text-align: center;
margin: 15px 0;
}
- }
-
- // 页面空
- .pages-null{
- height: 70vh;
- }
+ }
+
+ // 页面空
+ .pages-null {
+ height: 70vh;
+ }
diff --git a/pages/im/friends/info.vue b/pages/im/friends/info.vue
index 1c4bebe..49e666a 100644
--- a/pages/im/friends/info.vue
+++ b/pages/im/friends/info.vue
@@ -2,8 +2,8 @@
-
-
+
+
{{ userInfo.name }}
-
-
-
-
-
- 好友
-
- 通过
- 拒绝
-
-
-
-
-
- 空列表
-
-
-
-
-
-
-
diff --git a/pages/im/index.vue b/pages/im/index.vue
index d4234c7..a8cc868 100644
--- a/pages/im/index.vue
+++ b/pages/im/index.vue
@@ -13,7 +13,8 @@
-
+
@@ -27,11 +28,19 @@
{{ item.latestMessage.content || ' ' }}
+
+
+
+
+ {{item}}
+
+
+
@@ -59,7 +68,16 @@
isShown: true, // 当前页面显示状态
conversations: [], // 会话列表
isImToken: '', // 是否已鉴权
- connection: 0
+ connection: 0,
+ /* 窗口尺寸 */
+ winSize: {},
+ /* 显示操作弹窗 */
+ showPop: false,
+ /* 弹窗按钮列表 */
+ popButton: ['置顶聊天', '删除该聊天'],
+ /* 弹窗定位样式 */
+ popStyle: "",
+ pickedItem: {}
}
},
computed: {
@@ -111,6 +129,48 @@
}
},
methods: {
+ hidePop() {
+ this.showPop = false
+ this.pickedItem = {}
+ setTimeout(() => {
+ this.showShade = false
+ }, 250)
+ },
+ pickerMenu(e) {
+ const index = Number(e.currentTarget.dataset.index)
+
+ if (index == 0) {
+ RongIMLib.setConversationToTop(this.pickedItem.conversationType, this.pickedItem.targetId, !this
+ .pickedItem.isTop)
+ } else {
+ RongIMLib.removeConversation(this.pickedItem.conversationType, this.pickedItem.targetId)
+ }
+ this.getConversationList()
+ this.hidePop()
+ },
+ onLongPress(e) {
+ let [touches, style, item] = [e.touches[0], "", e.currentTarget.dataset.item]
+
+ if (touches.clientY > (this.winSize.height / 2)) {
+ style = `bottom:${this.winSize.height-touches.clientY}px;`
+ } else {
+ style = `top:${touches.clientY}px;`
+ }
+ if (touches.clientX > (this.winSize.witdh / 2)) {
+ style += `right:${this.winSize.witdh-touches.clientX}px`
+ } else {
+ style += `left:${touches.clientX}px`
+ }
+
+ this.popButton[0] = item.isTop ? '取消置顶' : '置顶聊天'
+ this.popStyle = style
+ this.pickedItem = item
+ this.$nextTick(() => {
+ setTimeout(() => {
+ this.showPop = true;
+ }, 10)
+ })
+ },
// 检查登录
toLogin() {
if (this.$store.state.token === '') {
@@ -120,21 +180,18 @@
}
return true
},
- getFriend(targetId) {
- return this.$store.getters.userInfo(targetId)
- },
getConversationList() {
const count = 1000
const timestamp = 0 // 会话的时间戳(获取这个时间戳之前的会话列表,0 表示从最新开始获取)会话类型
RongIMLib.getConversationList(undefined, count, timestamp, (res) => {
if (res.code === 0 && res.conversations.length > 0) {
this.conversations = res.conversations
- console.log(this.conversations);
}
})
},
// 进入聊天的详情页面,清理未读消息数量
- toDetail(item) {
+ toDetail(item) {
+ this.hidePop()
uni.navigateTo({
url: '/pages/im/private/index?targetId=' + item.targetId + '&conversationType=' + item
.conversationType
@@ -148,7 +205,6 @@
.container {
background-color: $window-color;
min-height: 100vh;
- padding-bottom: 200px;
.null-list {
height: 100vh;
@@ -172,6 +228,10 @@
background: white;
padding: 24rpx 24rpx 20rpx 24rpx;
+ &.is-top {
+ background: $window-color;
+ }
+
.avatar {
position: relative;
@@ -198,11 +258,11 @@
}
}
- .preview {
- width: 520rpx;
+ .preview {
+ width: 520rpx;
word-break: break-all;
color: $text-gray;
- font-size: 26rpx;
+ font-size: 26rpx;
@extend .nowrap;
}
}
@@ -290,4 +350,42 @@
// }
// }
}
+
+ /* 遮罩 */
+ .shade {
+
+ .pop {
+ position: fixed;
+ z-index: 101;
+ width: 200rpx;
+ box-sizing: border-box;
+ font-size: 28rpx;
+ text-align: left;
+ color: #333;
+ background-color: #fff;
+ box-shadow: 0 0 5px rgba(0, 0, 0, 0.5);
+ line-height: 80rpx;
+ transition: transform 0.15s ease-in-out 0s;
+ user-select: none;
+ -webkit-touch-callout: none;
+ transform: scale(0, 0);
+
+ &.show {
+ transform: scale(1, 1);
+ }
+
+ &>view {
+ padding: 0 20rpx;
+ overflow: hidden;
+ text-overflow: ellipsis;
+ white-space: nowrap;
+ user-select: none;
+ -webkit-touch-callout: none;
+
+ &:active {
+ background-color: #f3f3f3;
+ }
+ }
+ }
+ }
diff --git a/pages/im/private/index.vue b/pages/im/private/index.vue
index fa70f1d..ee6d370 100644
--- a/pages/im/private/index.vue
+++ b/pages/im/private/index.vue
@@ -99,7 +99,13 @@
if (e.index == 0) {
uni.navigateTo({
url: '/pages/im/private/setting?targetId=' + this.targetId +
- '&conversationType=' + this.conversationType
+ '&conversationType=' + this.conversationType,
+ events: {
+ messageClear: () => {
+ this.getMessageList()
+ console.log('聊天消息被清空');
+ }
+ }
})
}
},
diff --git a/pages/im/private/setting.vue b/pages/im/private/setting.vue
index 726bcd7..4c7353b 100644
--- a/pages/im/private/setting.vue
+++ b/pages/im/private/setting.vue
@@ -2,18 +2,18 @@
-
- {{ userInfo.name }}
+
+ {{ friend(targetId).name }}
-
+
-
-
+
+
@@ -35,22 +35,26 @@
export default {
data() {
return {
- userInfo: {},
+ eventChannel: null,
targetId: '',
conversationType: 1,
isTop: false,
- status: 0 // 0 是免打扰,1是正常通知
+ status: false // 0 是免打扰,1是正常通知
+ }
+ },
+ computed: {
+ friend() {
+ return function(targetId) {
+ return this.$store.getters.userInfo(targetId)
+ }
}
},
onLoad(e) {
+ this.eventChannel = this.$scope.eventChannel
+
this.targetId = e.targetId
this.conversationType = e.conversationType
- getUserInfo(e.targetId).then(res => {
- console.log(res);
- this.userInfo = res
- })
-
RongIMLib.getConversation(this.conversationType, this.targetId, ({
conversation
}) => {
@@ -60,29 +64,27 @@
RongIMLib.getConversationNotificationStatus(this.conversationType, this.targetId, ({
status
}) => {
- this.status = status
+ this.status = !Boolean(status)
})
},
- methods: {
- showFriend() {
- uni.navigateTo({
- url: '/pages/im/friends/info?targetId=' + this.targetId
- })
+ methods: {
+ showFriend() {
+ uni.navigateTo({
+ url: '/pages/im/friends/info?targetId=' + this.targetId
+ })
},
setStatus() {
RongIMLib.setConversationNotificationStatus(this.conversationType, this.targetId, this.status, ({
status
}) => {
- this.status = status
+ this.status = !Boolean(status)
})
},
setTop() {
- RongIMLib.setConversationToTop(this.conversationType, this.targetId, !this.isTop, (res) => {
- console.log(res);
+ RongIMLib.setConversationToTop(this.conversationType, this.targetId, this.isTop, (res) => {
RongIMLib.getConversation(this.conversationType, this.targetId, ({
conversation
}) => {
- console.log(conversation.isTop);
this.isTop = conversation.isTop
})
})
@@ -97,6 +99,7 @@
code
}) => {
if (code === 0) {
+ this.eventChannel.emit('messageClear')
uni.showToast({
title: '聊天记录已清空'
})