diff --git a/.hbuilderx/launch.json b/.hbuilderx/launch.json
index 59d78d5..a97fd25 100644
--- a/.hbuilderx/launch.json
+++ b/.hbuilderx/launch.json
@@ -4,7 +4,7 @@
"configurations": [{
"app-plus" :
{
- "launchtype" : "remote"
+ "launchtype" : "local"
},
"default" :
{
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 0e9d6e6..73cc5f5 100644
--- a/manifest.json
+++ b/manifest.json
@@ -2,8 +2,8 @@
"name" : "ZH-HEALTH",
"appid" : "__UNI__C29473D",
"description" : "ZH-HEALTH,您手上的健康管理专家",
- "versionName" : "1.0.3",
- "versionCode" : 103,
+ "versionName" : "1.0.5",
+ "versionCode" : 105,
"transformPx" : false,
/* 5+App特有相关 */
"app-plus" : {
diff --git a/pages.json b/pages.json
index ceade35..19049ee 100644
--- a/pages.json
+++ b/pages.json
@@ -372,7 +372,7 @@
"name": "imPrivate",
"style": {
"navigationBarTitleText": "聊天",
- "navigationBarBackgroundColor": "#FFFFFF",
+ "navigationBarBackgroundColor": "#F3F6FB",
"disableScroll": true,
"app-plus": {
"titleNView": {
@@ -420,8 +420,8 @@
"path": "pages/im/friends/pending",
"name": "imFriendsPending",
"style": {
- "navigationBarTitleText": "新的朋友",
- "navigationBarBackgroundColor":"#FFFFFF"
+ "navigationBarTitleText": "新朋友",
+ "navigationBarBackgroundColor":"#F3F6FB"
}
},
{
@@ -429,7 +429,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..b3f2ed2 100644
--- a/pages/im/friends/index.vue
+++ b/pages/im/friends/index.vue
@@ -1,125 +1,84 @@
-
-
-
- 新的朋友
-
-
-
-
- 我的群聊
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- {{item1.name}}
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
-
diff --git a/pages/im/friends/info.vue b/pages/im/friends/info.vue
index 75a55d6..49e666a 100644
--- a/pages/im/friends/info.vue
+++ b/pages/im/friends/info.vue
@@ -1,122 +1,146 @@
-
-
-
-
-
- {{ userInfo.name }}
-
-
-
-
-
-
-
-
- 黑龙江 哈尔滨
-
-
-
-
-
+
+
+
+
+
+
+ {{ userInfo.name }}
+
+
+ {{ userInfo.address}}
+
+
+
+
+
+
-
-
diff --git a/pages/im/friends/pending.vue b/pages/im/friends/pending.vue
index 373405e..70472eb 100644
--- a/pages/im/friends/pending.vue
+++ b/pages/im/friends/pending.vue
@@ -1,69 +1,119 @@
-
-
-
-
-
-
-
-
- 好友
-
- 通过
- 拒绝
-
-
-
-
-
- 空列表
-
-
-
-
-
-
-
diff --git a/pages/im/index.vue b/pages/im/index.vue
index bc198ec..fb3b874 100644
--- a/pages/im/index.vue
+++ b/pages/im/index.vue
@@ -24,28 +24,39 @@
-
+
-
-
-
-
-
-
-
-
-
-
-
- {{ item.latestMessage.content }}
+
+
+
+
+
+
+
+
+
+
+
+ {{ item.latestMessage.content || ' ' }}
+
+
+
+
+
+
+ {{item}}
@@ -75,7 +86,16 @@
return {
isShown: true, // 当前页面显示状态
conversations: [], // 会话列表
- isImToken: '', // 是否已鉴权
+ connection: 0,
+ /* 窗口尺寸 */
+ winSize: {},
+ /* 显示操作弹窗 */
+ showPop: false,
+ /* 弹窗按钮列表 */
+ popButton: ['置顶聊天', '删除该聊天'],
+ /* 弹窗定位样式 */
+ popStyle: "",
+ pickedItem: {}
}
},
computed: {
@@ -87,16 +107,14 @@
},
onShow() {
if (this.$store.state.token !== '') {
- if (this.isImToken === '') {
- getImToken().then(res => {
- im.connect(res.token, res.userInfo)
- this.isImToken = res.token
- this.getConversationList()
+ getImToken().then(res => {
+ console.log("IMTOKEN", res);
+ im.connect(res.token, res.userInfo, () => {
+ this.getConversationList()
})
- }
- this.getConversationList()
- this.isShown = true
- }
+ })
+ }
+ this.isShown = true
},
onHide() {
this.isShown = false
@@ -108,22 +126,67 @@
icon: 'none'
})
}
- if (e.index == 1) {
- if(this.toLogin()){
- this.$Router.push({
- name: 'imFriends'
- })
- }
- }
- },
- watch: {
- '$store.getters.newMessage': function(n, o) {
- if (this.isShown) {
- this.getConversationList()
+ if (e.index == 1) {
+ if (this.toLogin()) {
+ this.$Router.push({
+ name: 'imFriends'
+ })
}
}
},
+ watch: {
+ '$store.getters.newMessage': function(n, o) {
+ if (this.isShown) {
+ this.getConversationList()
+ }
+ },
+ '$store.getters.connection': function(n, o) {
+ this.connection = n
+ }
+ },
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 === '') {
@@ -133,20 +196,19 @@
}
return true
},
- getFriend(targetId) {
- return this.$store.getters.userInfo(targetId)
- },
getConversationList() {
const count = 1000
- const timestamp = 0 // 会话的时间戳(获取这个时间戳之前的会话列表,0 表示从最新开始获取)会话类型
- RongIMLib.getConversationList(undefined, count, timestamp, (res) => {
+ const timestamp = 0
+ RongIMLib.getConversationList(undefined, count, timestamp, (res) => {
+ console.log('获取列表', res);
if (res.code === 0 && res.conversations.length > 0) {
this.conversations = res.conversations
}
- })
+ })
},
// 进入聊天的详情页面,清理未读消息数量
toDetail(item) {
+ this.hidePop()
uni.navigateTo({
url: '/pages/im/private/index?targetId=' + item.targetId + '&conversationType=' + item
.conversationType
@@ -220,62 +282,98 @@
}
}
- .mssage-box {
+ .message {
+ position: relative;
+ display: flex;
background: white;
+ padding: 24rpx 24rpx 20rpx 24rpx;
- .mssage-action {
+ &.is-top {
+ background: $window-color;
+ }
+
+ .avatar {
position: relative;
- padding: 20rpx $padding;
- &::after {
- position: absolute;
- left: $padding + 108;
- right: 0;
- bottom: 0;
- content: " ";
- height: 1rpx;
- background: $border-color;
- }
-
- &-content {
- position: absolute;
- top: 20rpx;
- height: 44px;
- left: $padding + 108;
- right: $margin;
- display: flex;
- flex-direction: column;
- justify-content: center;
-
- .mssage-header {
- display: flex;
- font-size: $title-size;
- line-height: 40rpx;
- justify-content: space-between;
-
- .header-name {
- flex: 1;
- @extend .nowrap;
- }
-
- .header-time {
- padding-left: $padding;
- font-size: $title-size-sm - 2;
- color: $text-gray;
- }
- }
-
- .mssage-msg {
- font-size: $title-size-sm - 2;
- color: $text-gray;
- @extend .nowrap;
- }
+ .u-badge {
+ z-index: 999;
}
}
- &-item:last-child {
- .mssage-action::after {
- display: none;
+ .content {
+ margin-left: 16rpx;
+ flex: 1;
+
+ .header {
+ display: flex;
+ justify-content: space-between;
+
+ .name {
+ font-size: 36rpx
+ }
+
+ .time {
+ font-size: 24rpx;
+ color: $text-gray;
+ }
+ }
+
+ .preview {
+ width: 520rpx;
+ word-break: break-all;
+ color: $text-gray;
+ font-size: 26rpx;
+ @extend .nowrap;
+ }
+ }
+ }
+
+ .message:not(:last-child) {
+ &::after {
+ position: absolute;
+ left: $padding + 108;
+ right: 0;
+ bottom: 0;
+ content: " ";
+ height: 1rpx;
+ background: $border-color;
+ }
+ }
+ }
+
+ /* 遮罩 */
+ .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 2a35f01..e0931c4 100644
--- a/pages/im/private/index.vue
+++ b/pages/im/private/index.vue
@@ -1,11 +1,9 @@
-
+
-
-
- {{ item.sentTime|timeCustomCN }}
-
+
{{ item.content.content }}
@@ -14,18 +12,22 @@
{{ item.sentStatus == 50 ? '已读': '未读'}}
-
-
-
+
+
-
+
+ {{ item.sentTime|timeCustomCN }}
+
+
@@ -85,8 +87,8 @@
RongIMLib.clearReadReceiptReceivedListener()
},
computed: {
- showSendButton() {
- return this.inputTxt.length > 0
+ disabled() {
+ return this.inputTxt.length == 0
},
friend() {
return function(targetId) {
@@ -98,7 +100,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('聊天消息被清空');
+ }
+ }
})
}
},
@@ -151,15 +159,15 @@
this.inputTxt = ''
})
},
- showFriend() {
- // uni.navigateTo({
- // url: '/pages/im/friends/info?targetId=' + this.targetId
- // })
+ showFriend(targetId) {
+ uni.navigateTo({
+ url: '/pages/im/friends/info?targetId=' + targetId
+ })
},
showMine() {
- // uni.navigateTo({
- // url: '/pages/im/friends/mine'
- // })
+ uni.navigateTo({
+ url: '/pages/im/friends/mine'
+ })
},
scrollBottom() {
this.$nextTick(function() {
@@ -310,6 +318,10 @@
font-size: $title-size-m;
font-weight: bold;
+ &[disabled] {
+ background: $uni-bg-color-grey;
+ }
+
&::after {
display: none;
}
diff --git a/pages/im/private/setting.vue b/pages/im/private/setting.vue
index d7fbb90..9de754e 100644
--- a/pages/im/private/setting.vue
+++ b/pages/im/private/setting.vue
@@ -1,46 +1,56 @@
-
-
-
-
-
- 唐明明
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+ {{ friend(targetId).name }}
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
-
diff --git a/pages/topic/details.vue b/pages/topic/details.vue
index c73c794..90137c6 100644
--- a/pages/topic/details.vue
+++ b/pages/topic/details.vue
@@ -1,282 +1,314 @@
-
-
-
-
-
-
-
- {{ topicData.name }}
-
-
- # 话题 -- {{ topicData.category.name }} #
-
-
- {{ topicData.description }}
-
-
-
- {{ topicData.clicks }} 人游览
- {{ topicData.favorites }} 人点赞
-
-
-
- {{ isFavorite ? '已赞' : '点赞' }}
-
-
-
-
-
-
-
-
- {{ topicData.author }}
-
-
- ZH大健康官方账号
-
-
-
-
-
-
-
-
- 相关商品
-
-
-
-
-
- {{ item.name }}
-
-
- ¥{{ item.price }}
-
-
-
- 查看商品
-
-
-
-
-
-
-
-
-
-
-
diff --git a/store/modules/im.js b/store/modules/im.js
index 19657d5..c9db26e 100644
--- a/store/modules/im.js
+++ b/store/modules/im.js
@@ -4,12 +4,17 @@ export default {
state: {
newMsg: {},
friends: {},
- sender: {}
+ sender: {},
+ // IM连接状态,0是正常
+ connection: 0
},
getters: {
newMessage(state) {
return state.newMsg
},
+ connection(state) {
+ return state.connection
+ },
friends(state) {
return state.friends
},
@@ -17,8 +22,8 @@ export default {
if (state.friends[targetId]) {
return state.friends[targetId]
} else {
- console.log('没找到,, 死循环了,得处理 todo', targetId);
- im.syncUserInfo(targetId)
+ console.log('没找到,死循环了,得处理 todo', targetId);
+ // im.syncUserInfo(targetId)
return {
name: '',
address: '',
@@ -43,9 +48,15 @@ export default {
},
SET_state_sender(state, userInfo) {
state.sender = userInfo
+ },
+ SET_connection_status(state, status) {
+ state.connection = status
}
},
- actions: {
+ actions: {
+ updateConnectionStatus({commit}, status) {
+ commit('SET_connection_status', status)
+ },
newMessage({
commit
}, msg) {
@@ -63,7 +74,6 @@ export default {
const model = uni.model.friendModel
model.find('userId=' + userInfo.userId, (err, user) => {
if (!err && user.length == 0) {
- console.log('哪里更新的 ', 1);
saveAvatar(userInfo, (savedFilePath) => {
model.insert({
userId: userInfo.userId,
@@ -76,7 +86,6 @@ export default {
commit('updateFriends', userInfo)
})
} else if (!err && user[0].hash != userInfo.hash) {
- console.log('哪里更新的 ', 2);
saveAvatar(userInfo, (savedFilePath) => {
model.update('userId=' + userInfo.userId, {
name: userInfo.name,
@@ -98,7 +107,7 @@ export default {
commit('updateFriends', userInfo)
})
} else {
- console.log('不需要有动作', user[0]);
+ console.log('不用操作', user[0]);
}
})
}
diff --git a/uni.scss b/uni.scss
index ba7a252..45042d6 100644
--- a/uni.scss
+++ b/uni.scss
@@ -44,7 +44,7 @@ $uni-border-color:#c8c7cc;
/* 文字尺寸 */
$uni-font-size-sm:12px;
$uni-font-size-base:14px;
-$uni-font-size-lg:16;
+$uni-font-size-lg:16px;
/* 图片尺寸 */
$uni-img-size-sm:20px;
diff --git a/utils/im/index.js b/utils/im/index.js
index a1f1534..b769da0 100644
--- a/utils/im/index.js
+++ b/utils/im/index.js
@@ -36,9 +36,11 @@ const setNotifyBadge = (count) => {
* @param {string} token token
* @param {object} userInfo {userId: string, name: string, portraitUrl: string}
*/
-const connect = (token, userInfo) => {
+const connect = (token, userInfo, callback) => {
RongIMLib.connect(token, res => {
- console.log('连接结果', res);
+ console.log('连接结果', res);
+
+ callback(res)
})
store.dispatch('setSenderInfo', userInfo)
@@ -61,7 +63,8 @@ const disconnect = () => {
const addListeners = () => {
// 添加连接状态监听函数
RongIMLib.addConnectionStatusListener((res) => {
- console.log('连接状态监', res.data.status);
+ console.log('连接状态监', res.data.status);
+ store.dispatch('updateConnectionStatus', res.data.status)
})
// 添加消息监听函数
RongIMLib.addReceiveMessageListener((res) => {