Browse Source

Merge branch 'master' of http://116.63.33.55/git/light-application

zxy 3 years ago
parent
commit
337bb9831d

+ 19 - 1
light-application-wx/comps/chat/chat.js

@@ -62,7 +62,25 @@ Component({
         },
 
         saveSendMsg(evt) {
-            msgStorage.saveMsg(evt.detail.msg, evt.detail.type);
+            console.info(evt);
+            let msg = evt.detail.msg;
+            let users = [msg.body.from, msg.body.to];
+            WebIM.conn.fetchUserInfoById(users).then((res) => {
+                console.log(res);
+                let fromInfo = {};
+                let toInfo = {};
+                for (let k in res.data) {
+                    if (k == msg.body.from) {
+                        fromInfo = res.data[k];
+                    } else {
+                        toInfo = res.data[k];
+                    }
+                }
+                msg.body.fromInfo = fromInfo;
+                msg.body.toInfo = toInfo;
+                console.info('from and to ', fromInfo, toInfo);
+                msgStorage.saveMsg(msg, evt.detail.type);
+            });
             // this.data.__comps__.inputbar.cancelEmoji();
         },
 

+ 4 - 3
light-application-wx/comps/chat/inputbar/inputbar.wxss

@@ -1,13 +1,13 @@
 /* comps/inputbar/inputbar.wxss */
 .room_bar {
     width: 100%;
-    height: auto;
-    border-top: 1px solid #CFCFCF;
+    height: 180rpx;
+    /* border-top: 1px solid #CFCFCF; */
     position: fixed;
     bottom: 0;
     right: 0;
     z-index: 1;
-    background-color: #FFFFFF;
+    background-color: #F0F4F7;
     transform: translateZ(1000px);
 }
 
@@ -15,6 +15,7 @@
     width: 100%;
     height: 60rpx;
     display: flex;
+    margin-top: 10rpx;
 }
 
 .other_func_X {

+ 1 - 1
light-application-wx/comps/chat/inputbar/suit/main/main.wxml

@@ -1,5 +1,5 @@
 <!--comps/chat/inputbar/suit/main/main.wxml-->
-<import src="../../../toast/toast.wxml" />
+<!-- <import src="../../../toast/toast.wxml" /> -->
 <form class="text-input">
     <!-- <view class="f-row"> -->
     <input class="f news" type="text" value="{{inputMessage}}" cursor-spacing="65" confirm-type="send" bindconfirm="sendMessage" bindinput="bindMessage" bindtap="focus" bindfocus="focus" bindblur="blur" placeholder="输入新消息" placeholder-style="color:#CFCFCF; padding-left:5px;" />

+ 9 - 5
light-application-wx/comps/chat/inputbar/suit/main/main.wxss

@@ -7,21 +7,25 @@
 }
 
 .news {
+    box-sizing: border-box;
     width: 100%;
-    height: 62rpx;
+    height: 80rpx;
     font-size: 14px;
     padding: 0 32rpx;
     display: inline-block;
     margin-top: 10rpx;
-    line-height: 48rpx;
+    line-height: 80rpx;
     position: relative;
     top: 0;
+    background-color: #FFFCF5;
+    border: solid 1rpx #FFFCF5;
+    border-radius: 40rpx;
 }
 
 .send_btn {
-    width: 80rpx;
-    height: 60rpx;
-    line-height: 60rpx;
+    width: 10%;
+    height: 80rpx;
+    line-height: 80rpx;
     font-size: 17px;
     color: #000;
     padding: 0;

+ 7 - 7
light-application-wx/comps/chat/msglist/msglist.wxml

@@ -6,7 +6,7 @@
     <image class="avatar" src="{{ '../../../images/faces/' + item.data }}" style="width:25px; height:25px; margin:0 0 2px 0; float:left;" />
 </template>
 <template name="img">
-    <image class="avatar" src="{{item.msg.data}}" style="width:90px; height:90px; margin:2px auto;" mode="aspectFit" bind:tap="previewImage" data-url="{{item.msg.data}}" />
+    <image class="avatar msg-img" src="{{item.msg.data}}" mode="aspectFit" bind:tap="previewImage" data-url="{{item.msg.data}}" />
 </template>
 <template name="video">
     <video class="msg-video" bindfullscreenchange="onFullscreenchange" src="{{ item.msg.data }}" controls autoplay />
@@ -16,13 +16,13 @@
 </template>
 
 <!-- view 换成 scroll-view效果更好 用view是为了要stopPullDownRefresh -->
-<view scroll-y="true" class="{{view}} wrap {{isIPX?'scroll_view_X': ''}}" bind:tap="onTap" bindscroll="scrollmore" bindscrolltoupper="refresh" upper-threshold='-50' scroll-into-view="{{toView}}">
+<scroll-view scroll-y="true" class="{{view}} wrap {{isIPX?'scroll_view_X': ''}}" bind:tap="onTap" bindscroll="scrollmore" bindscrolltoupper="refresh" upper-threshold='-50' scroll-into-view="{{toView}}">
     <view class="message" wx:for="{{chatMsg}}" wx:key="mid" id="{{item.mid}}">
         <view class="{{item.style == 'self' ? 'row-right' : 'row-left'}}">
-            <image class="photo" src="{{imgPath}}/chat-user.png" wx:if="{{item.style != 'self'}}"></image>
+            <image class="photo" src="{{item.info.fromInfo.avatarurl || imgPath +'/chat-user.png'}}" wx:if="{{item.style != 'self'}}"></image>
             <view class="msgbox">
-                <text class="user-text" wx:if="{{item.style != 'self'}}">{{ item.yourname + ' ' + item.time}}</text>
-                <text class="user-text" wx:if="{{item.style == 'self'}}">{{ item.time + ' ' + item.yourname}}</text>
+                <text class="user-text" wx:if="{{item.style != 'self'}}">{{item.info.fromInfo.nickname + ' ' + item.time}}</text>
+                <text class="user-text" wx:if="{{item.style == 'self'}}">{{item.time + ' ' + item.info.fromInfo.nickname}}</text>
                 <view wx:if="{{ item.msg.type == 'img' || item.msg.type == 'video' }}">
                     <template is="{{ item.msg.type }}" data="{{ item }}" />
                 </view>
@@ -33,8 +33,8 @@
                     </view>
                 </view>
             </view>
-            <image class="photo" src="{{imgPath}}/chat-user.png" wx:if="{{item.style == 'self'}}"></image>
+            <image class="photo" src="{{item.info.fromInfo.avatarurl || imgPath +'/chat-user.png'}}" wx:if="{{item.style == 'self'}}"></image>
         </view>
     </view>
-</view>
+</scroll-view>
 <view style="height: 1px;"></view>

+ 24 - 21
light-application-wx/comps/chat/msglist/msglist.wxss

@@ -1,17 +1,5 @@
 /* comps/msglist/msglist.wxss */
-/*.chat-bg{
-	position:fixed;
-	width: 100%;
-	height: 100%;
-	z-index: 0;
-	top: 50px;
-}*/
-/* .wrap{
-	width: 100%;
-	height: 100%;
-	position: absolute;
-	overflow-y: scroll;
-} */
+
 .scroll_view,
 .scroll_view_change {
     /*width: 100%;
@@ -19,9 +7,12 @@
 	left: 0;
 	top: 0;
 	right: 0;
-	bottom: 150rpx;*/
+    bottom: 150rpx;*/
+    box-sizing: border-box;
+    /* height: 100%; */
     margin-bottom: 174rpx;
-    background-color: #FAFAFA;
+    /* padding-bottom: 174rpx; */
+    background-color: #F0F4F7;
 }
 
 .scroll_view_X,
@@ -35,12 +26,13 @@
 }
 
 .message {
-    width: 92%;
-    min-height: 130rpx;
+    width: 100%;
+    /* min-height: 130rpx; */
     height: auto;
     padding: 0 30rpx;
     /* position: relative; */
-    display: block;
+    /* display: block; */
+    box-sizing: border-box;
 }
 
 .time {
@@ -193,7 +185,7 @@
 }
 
 .row-left .msgbox {
-    display: inline-flex;
+    display: flex;
     flex-direction: column;
     justify-content: flex-start;
     align-items: flex-start;
@@ -201,7 +193,7 @@
 }
 
 .row-right .msgbox {
-    display: inline-flex;
+    display: flex;
     flex-direction: column;
     justify-content: flex-start;
     align-items: flex-end;
@@ -227,7 +219,7 @@
 .user-text {
     box-sizing: border-box;
     font-size: 22rpx;
-    color: #dcdcdc;
+    color: #AAAAAA;
     padding: 10rpx;
 }
 
@@ -243,4 +235,15 @@
     width: 100%;
     overflow-wrap: normal;
     word-break: break-all;
+    font-size: .8em;
+    background-color: #FFFFFF;
+    box-sizing: border-box;
+    padding: 10rpx 25rpx;
+    border-radius: 20rpx;
+}
+
+.msg-img {
+    width: 200rpx;
+    height: 200rpx;
+    /* margin: 2px auto; */
 }

+ 2 - 10
light-application-wx/pages/chat-detail/chat-detail.js

@@ -10,15 +10,7 @@ Page({
         username: {
             your: "",
         },
-        list: [{
-            id: 1,
-            photo: 'https://gimg2.baidu.com/image_search/src=http%3A%2F%2Fup.enterdesk.com%2Fedpic_source%2Fc0%2F8e%2F28%2Fc08e28eb52da5a2b5b451ad6272a8197.jpg&refer=http%3A%2F%2Fup.enterdesk.com&app=2002&size=f9999,10000&q=a80&n=0&g=0n&fmt=auto?sec=1652429449&t=63437c824c18680ecb5e5f27d06f941b',
-            content: '你到了吗?'
-        }, {
-            id: 2,
-            photo: 'https://gimg2.baidu.com/image_search/src=http%3A%2F%2Fnimg.ws.126.net%2F%3Furl%3Dhttp%253A%252F%252Fdingyue.ws.126.net%252F2021%252F0314%252F94ad46dbj00qpy1do0021d200rs00rsg008t008t.jpg%26thumbnail%3D650x2147483647%26quality%3D80%26type%3Djpg&refer=http%3A%2F%2Fnimg.ws.126.net&app=2002&size=f9999,10000&q=a80&n=0&g=0n&fmt=auto?sec=1652429449&t=3fd0174f597633f23248e79587f76513',
-            content: '刚刚到达,已找到位置,谢谢!'
-        }]
+        list: []
     },
 
     /**
@@ -31,7 +23,7 @@ Page({
         console.log('username *****', username)
         this.setData({ username: username });
         wx.setNavigationBarTitle({
-            title: username.your
+            title: username.navigationTitle
         });
         disp.on('em.megList.refresh', function () {
             const pages = getCurrentPages();

+ 1 - 1
light-application-wx/pages/chat-detail/chat-detail.wxss

@@ -1,6 +1,6 @@
 /* pages/chat-detail/chat-detail.wxss */
 page {
-    background-color: #f0f4f7;
+    background-color: #F0F4F7;
 }
 
 .row-left {

+ 3 - 1
light-application-wx/pages/chat-group-detail/chat-group-detail.wxss

@@ -1,4 +1,6 @@
 /* pages/chat-group-detail/chat-group-detail.wxss */
 page {
-    background-color: #FAFAFA;
+    width: 100%;
+    height: 100%;
+    background-color: #F0F4F7;
 }

+ 43 - 8
light-application-wx/pages/chat-room/chat-room.js

@@ -165,9 +165,8 @@ Page({
      * 查询聊天记录(包含陌生人版本)
      */
     getChatList: function () {
-        var myName = wx.getStorageSync("myUsername");
-        var array = [];
-        const that = this
+        let myName = wx.getStorageSync("myUsername");
+        let that = this
         wx.getStorageInfo({
             success: function (res) {
                 console.info(res);
@@ -190,7 +189,7 @@ Page({
 
                 cul.call(that, newChatMsgKeys, historyChatMsgKeys);
             }
-        })
+        });
 
         function cul(newChatMsgKeys, historyChatMsgKeys) {
             let array = []
@@ -359,6 +358,9 @@ Page({
         });
     },
 
+    /**
+     * 进入聊天界面
+     */
     into_chatRoom: function (event) {
         let detail = event.currentTarget.dataset.item;
         console.info('detail:', detail);
@@ -370,19 +372,31 @@ Page({
         }
     },
 
-    //	单聊
+    /**
+     * 进入单聊
+     */
     into_singleChatRoom: function (detail) {
         var my = wx.getStorageSync("myUsername");
+        let title = '';
+        if (detail.info.from == my) {
+            title = detail.info.toInfo.nickname;
+        } else {
+            title = detail.info.fromInfo.nickname;
+        }
         var nameList = {
             myName: my,
-            your: detail.username
+            your: detail.username,
+            navigationTitle: title
         };
         wx.navigateTo({
             url: "../chat-detail/chat-detail?username=" + JSON.stringify(nameList)
         });
     },
 
-    //	群聊 和 聊天室 (两个概念)
+    /**
+     * 进入群聊
+     * 	群聊 和 聊天室 (两个概念)
+     */
     into_groupChatRoom: function (detail) {
         var my = wx.getStorageSync("myUsername");
         var nameList = {
@@ -395,6 +409,9 @@ Page({
         });
     },
 
+    /**
+     * 删除聊天
+     */
     del_chat: function (event) {
         let detail = event.currentTarget.dataset.item;
         let nameList;
@@ -431,6 +448,9 @@ Page({
         });
     },
 
+    /**
+     * 进入聊天界面(废弃)
+     */
     chatDetail: function (e) {
         let id = e.currentTarget.dataset.id;
         let name = e.currentTarget.dataset.name;
@@ -448,9 +468,10 @@ Page({
         let timeArr = chatTime.split(' ')[1].split(':');
         let nowArr = util.formatDate(null).split(' ')[0].split('-');
         let month = dateArr[1] < 10 ? '0' + dateArr[1] : dateArr[1];
+        let day = dateArr[2] < 10 ? '0' + dateArr[2] : dateArr[2];
         console.info('dateArr', dateArr);
         console.info('nowArr', nowArr);
-        if (nowArr[0] == dateArr[0] && nowArr[1] == month && nowArr[2] == dateArr[2]) {
+        if (nowArr[0] == dateArr[0] && nowArr[1] == month && nowArr[2] == day) {
             return `${timeArr[0]}:${timeArr[1]}`;
         } else {
             return `${dateArr[0]}/${dateArr[1]}/${dateArr[2]}`;
@@ -458,6 +479,20 @@ Page({
     },
 
     /**
+     * 查询环信用户属性
+     */
+    getUserShowName: function (lastChatMsg) {
+        util.post({
+            url: '/api/easemob/getUpUserAttribute/' + lastChatMsg.username,
+            success: (res) => {
+                wx.hideLoading();
+                console.info(res);
+                return res.data.data.data.nickname;
+            }
+        });
+    },
+
+    /**
      * 扫一扫加入群聊
      */
     scanJoinGroup: function () {

+ 4 - 44
light-application-wx/pages/chat-room/chat-room.wxml

@@ -1,28 +1,13 @@
 <!--pages/chat-room/chat-room.wxml-->
-<!-- <scroll-view class="chat-room">
-    <view class="otherItem" bindtap="into_groups">
-        <image src="{{imgPath}}/chat-group.png"></image>
-        <text>群组</text>
-    </view>
-    <view class="chat" wx:for="{{list}}" wx:key="i" data-id="{{item.uuid}}" data-name="{{item.username}}" bindtap="chatDetail">
-        <image class="photo" src="{{ item.photo ? item.photo : imgPath + '/chat-user.png'}}" mode="cover"></image>
-        <view class="item-row">
-            <text class="chat-name">{{item.username}}</text>
-            <text class="chat-time">{{item.time}}</text>
-            <text class="chat-content">{{item.content}}</text>
-            <text class="unread-num" wx:if="{{item.num > 0}}">{{item.num}}</text>
-        </view>
-    </view>
-</scroll-view> -->
 <scroll-view scroll-y="true" class="chat-room">
     <view class="otherItem" bindtap="into_groups">
         <image src="{{imgPath}}/chat-group.png"></image>
         <text>群组</text>
     </view>
-    <view class="chat" wx:for="{{arr}}" wx:key="i" data-item="{{item}}" catchtap="into_chatRoom">
-        <image class="photo" src="{{ (item.chatType == 'groupchat' || item.chatType == 'chatRoom') ? imgPath + '/chat-group2.png' : imgPath + '/chat-user.png'}}" mode="cover"></image>
+    <view class="chat" wx:for="{{arr}}" wx:key="i" data-item="{{item}}" catchtap="into_chatRoom" bindlongtap="del_chat">
+        <image class="photo" src="{{ (item.chatType == 'groupchat' || item.chatType == 'chatRoom') ? imgPath + '/chat-group2.png' : (item.info.from == item.username ? item.info.fromInfo.avatarurl : item.info.toInfo.avatarurl) || imgPath + '/chat-user.png'}}" mode="cover"></image>
         <view class="item-row">
-            <text class="chat-name">{{(item.chatType == 'groupchat' || item.chatType == 'chatRoom' || item.groupName) ? item.groupName : item.username}}</text>
+            <text class="chat-name">{{(item.chatType == 'groupchat' || item.chatType == 'chatRoom' || item.groupName) ? item.groupName : (item.info.from == item.username ? item.info.fromInfo.nickname : item.info.toInfo.nickname || item.username)}}</text>
             <text class="chat-time">{{item.time}}</text>
             <text class="chat-content" wx:if="{{item.msg.data[0].data}}">{{item.msg.data[0].data}}</text>
             <text class="chat-content" wx:if="{{item.msg.type == 'img'}}">[图片]</text>
@@ -31,36 +16,11 @@
             <text class="unread-num" wx:if="{{item.unReadCount > 0 || item.unReadCount == '99+'}}">{{item.unReadCount}}</text>
         </view>
     </view>
-    <!-- <view wx:for="{{ arr }}" wx:key="index" class="chat_list" data-item="{{ item }}" catchtap='del_chat'>
-        <swipe-delete>
-            <view class="tap_mask" catchtap="into_chatRoom" data-item="{{ item }}">
-                <view class="list_box">
-                    <view class="list_left" data-username="{{ item.username }}">
-                        <view class="list_pic">
-                            <view class="em-msgNum" wx:if="{{ item.unReadCount > 0 || item.unReadCount == '99+' }}">{{ item.unReadCount }}</view>
-
-                            <image src="{{(item.chatType == 'groupchat' || item.chatType == 'chatRoom')? '../../images/groupTheme.png':'../../images/theme@2x.png'}}"></image>
-                        </view>
-                        <view class="list_text">
-                            <text class="list_user">{{(item.chatType == 'groupchat' || item.chatType == 'chatRoom' || item.groupName)?item.groupName : item.username}}</text>
-                            <text class="list_word" wx:if="{{ item.msg.data[0].data }}">{{item.msg.data[0].data}}</text>
-                            <text class="list_word" wx:if="{{ item.msg.type == 'img' }}">[图片]</text>
-                            <text class="list_word" wx:if="{{ item.msg.type == 'audio' }}">[语音]</text>
-                            <text class="list_word" wx:if="{{ item.msg.type == 'video' }}">[视频]</text>
-                        </view>
-                    </view>
-                    <view class="list_right">
-                        <text data-username="{{ item.username }}">{{item.time}}</text>
-                    </view>
-                </view>
-            </view>
-        </swipe-delete>
-    </view> -->
     <view wx:if="{{arr.length == 0}}" class="chat_noChat">
         当前没有历史聊天,添加一个好友开始聊天吧
     </view>
-    <!-- </view> -->
 </scroll-view>
+
 <!-- bug: margin-bottom 不生效 需要加一个空标签-->
 <view style="height: 1px;"></view>
 

+ 6 - 6
light-application-wx/pages/chat-room/chat-room.wxss

@@ -86,16 +86,16 @@
 
 .unread-num {
     background-color: #e95543;
-    width: 40rpx;
-    height: 40rpx;
-    border-radius: 20rpx;
-    text-align: center;
+    width: 50rpx;
+    height: 50rpx;
+    border-radius: 25rpx;
     color: white;
     position: absolute;
     right: 48rpx;
     margin-top: 50rpx;
-    box-sizing: border-box;
-    font-size: .8em;
+    font-size: .5em;
+    line-height: 50rpx;
+    text-align: center;
 }
 
 

+ 41 - 1
light-application-wx/pages/light-map/light-map.js

@@ -169,7 +169,20 @@ Page({
 
     },
 
+    /**
+     * 点击地图隐藏底部用户信息块
+     */
+    mapTap: function () {
+        this.setData({
+            show: false
+        });
+    },
+
+    /**
+     * 点击其他用户定位
+     */
     markerTap: function (e) {
+        let that = this;
         console.info(e);
         let id = e.markerId;
 
@@ -178,6 +191,16 @@ Page({
             success: (res) => {
                 wx.hideLoading();
                 console.info(res);
+                if (res.data.code != 200) {
+                    util.toast(res.data.msg);
+                } else {
+                    that.setData({
+                        show: true,
+                        userPhoto: res.data.data.data.avatarurl,
+                        nickname: res.data.data.data.nickname,
+                        username: id,
+                    });
+                }
             }
         });
     },
@@ -227,7 +250,7 @@ Page({
             // 对成功的相关定义,sdk会将消息id登记到日志进行备份处理
             success: function () {
                 console.log('send room text success');
-                // disp.fire('em.chat.sendSuccess', id, 'location');
+                disp.fire('em.chat.sendSuccess', id, 'location');
             },
             // 对失败的相关定义,sdk会将消息id登记到日志进行备份处理
             fail: function () {
@@ -246,7 +269,9 @@ Page({
         let myName = wx.getStorageSync("myUsername");
         console.info(groupId, myName);
         let historyChatMsgs = wx.getStorageSync("rendered_" + groupId + myName) || [];
+        console.info('chatMsg:', historyChatMsgs);
         let chatMsg = wx.getStorageSync(groupId + myName) || [];
+        console.info('chatMsg:', chatMsg);
         chatMsg = historyChatMsgs.concat(chatMsg);
         if (!chatMsg.length) return;
         chatMsg = chatMsg.slice(-20);
@@ -271,6 +296,21 @@ Page({
                 markers: markerList,
             });
         }
+    },
+
+    /**
+     * 打开聊天
+     */
+    intoChatRoom: function () {
+        let that = this;
+        let myName = wx.getStorageSync("myUsername");
+        let nameInfo = {
+            myName: myName,
+            your: that.data.username.toString()
+        };
+        wx.navigateTo({
+            url: "../chat-detail/chat-detail?username=" + JSON.stringify(nameInfo)
+        });
     }
 
 })

+ 6 - 6
light-application-wx/pages/light-map/light-map.wxml

@@ -1,20 +1,20 @@
 <!--pages/light-map/light-map.wxml-->
-<map id="map" longitude="{{longitude}}" latitude="{{latitude}}" scale="{{scale}}" show-location="true" markers="{{markers}}" bindmarkertap="markerTap"></map>
+<map id="map" longitude="{{longitude}}" latitude="{{latitude}}" scale="{{scale}}" show-location="true" markers="{{markers}}" bindtap="mapTap" bindmarkertap="markerTap"></map>
 
 <view class="bottom-card" wx:if="{{show}}">
     <view class="left">
-        <image class="user-photo" src="{{imgPath}}/map-user2.png"></image>
+        <image class="user-photo" src="{{userPhoto}}"></image>
         <view class="user-info">
-            <text class="username">{{username}}</text>
-            <text class="user-role">{{roleName}}</text>
+            <text class="username">{{nickname}}</text>
+            <text class="user-role" wx:if="{{showRole}}">{{roleName}}</text>
         </view>
     </view>
     <view class="right">
-        <view class="video-card" style="background-image: url({{imgPath}}/map-btn-bg1.png);">
+        <view class="video-card" style="background-image: url({{imgPath}}/map-btn-bg1.png);" wx:if="{{showVideo}}">
             <image class="video" src="{{imgPath}}/map-video.png"></image>
             <text>视频</text>
         </view>
-        <view class="message-card" style="background-image: url({{imgPath}}/map-btn-bg2.png);">
+        <view class="message-card" style="background-image: url({{imgPath}}/map-btn-bg2.png);" bindtap="intoChatRoom">
             <image class="message" src="{{imgPath}}/map-message.png"></image>
             <text>发消息</text>
         </view>

+ 3 - 2
light-application-wx/pages/light-map/light-map.wxss

@@ -13,7 +13,7 @@
     border-top-right-radius: 40rpx;
     background-color: #FFFCF5;
     box-sizing: border-box;
-    padding: 30rpx;
+    padding: 30rpx 15rpx 22rpx 32rpx;
     display: inline-flex;
     flex-direction: row;
     justify-content: space-between;
@@ -30,6 +30,7 @@
     width: 86rpx;
     height: 86rpx;
     margin-right: 18rpx;
+    border-radius: 43rpx;
 }
 
 .user-info {
@@ -53,7 +54,7 @@
 }
 
 .right {
-    display: inline-flex;
+    display: flex;
     flex-direction: row;
     align-items: center;
 }

+ 0 - 2
light-application-wx/pages/login/login.js

@@ -10,8 +10,6 @@ Page({
      */
     data: {
         imgPath: app.globalData.imgPath,
-        app_title1: '重庆市城市管理局',
-        app_title2: '指挥大厅轻应用',
         phone: '',
         vCode: '',
         sendText: '发送验证码',

+ 3 - 1
light-application-wx/utils/msgpackager.js

@@ -6,7 +6,9 @@ module.exports = function (sendableMsg, type, myName) {
     var renderableMsg = {
         info: {
             from: sendableMsg.body.from,
-            to: sendableMsg.body.to
+            fromInfo: sendableMsg.body.fromInfo,
+            to: sendableMsg.body.to,
+            toInfo: sendableMsg.body.toInfo
         },
         username: sendableMsg.body.from == myName ? sendableMsg.body.to : sendableMsg.body.from,
         yourname: sendableMsg.body.from,

+ 132 - 105
light-application-wx/utils/msgstorage.js

@@ -3,133 +3,160 @@ let msgPackager = require("./msgpackager.js");
 let msgType = require("./msgtype.js");
 let msgStorage = new Disp();
 let disp = require("./broadcast.js");
+let WebIM = wx.WebIM = require("./WebIM")["default"];
+
 msgStorage.saveReceiveMsg = function (receiveMsg, type) {
+    console.info('receiveMsg', receiveMsg);
+    let users = [receiveMsg.from, receiveMsg.to];
     let sendableMsg;
-    if (type == msgType.IMAGE) {
-        sendableMsg = {
-            id: receiveMsg.id,
-            type: type,
-            body: {
+
+    WebIM.conn.fetchUserInfoById(users).then((res) => {
+        console.log(res);
+        let fromInfo = {};
+        let toInfo = {};
+        for (let k in res.data) {
+            if (k == receiveMsg.from) {
+                fromInfo = res.data[k];
+            } else {
+                toInfo = res.data[k];
+            }
+        }
+        console.info('from and to ', fromInfo, toInfo);
+
+        if (type == msgType.IMAGE) {
+            sendableMsg = {
                 id: receiveMsg.id,
-                from: receiveMsg.from,
-                to: receiveMsg.to,
-                type: receiveMsg.type,
-                ext: receiveMsg.ext,
-                chatType: receiveMsg.type,
-                toJid: "",
+                type: type,
                 body: {
-                    type: type,
-                    url: receiveMsg.url,
-                    filename: receiveMsg.filename,
-                    filetype: receiveMsg.filetype,
-                    size: {
-                        width: receiveMsg.width,
-                        height: receiveMsg.height
+                    id: receiveMsg.id,
+                    from: receiveMsg.from,
+                    fromInfo: fromInfo,
+                    to: receiveMsg.to,
+                    toInfo: toInfo,
+                    type: receiveMsg.type,
+                    ext: receiveMsg.ext,
+                    chatType: receiveMsg.type,
+                    toJid: "",
+                    body: {
+                        type: type,
+                        url: receiveMsg.url,
+                        filename: receiveMsg.filename,
+                        filetype: receiveMsg.filetype,
+                        size: {
+                            width: receiveMsg.width,
+                            height: receiveMsg.height
+                        },
                     },
                 },
-            },
-        };
-    }
-    else if (type == msgType.TEXT || type == msgType.EMOJI) {
-        sendableMsg = {
-            id: receiveMsg.id,
-            type: type,
-            body: {
+            };
+        }
+        else if (type == msgType.TEXT || type == msgType.EMOJI) {
+            sendableMsg = {
                 id: receiveMsg.id,
-                from: receiveMsg.from,
-                to: receiveMsg.to,
-                type: receiveMsg.type,
-                ext: receiveMsg.ext,
-                chatType: receiveMsg.type,
-                toJid: "",
+                type: type,
                 body: {
-                    type: type,
-                    msg: receiveMsg.data,
+                    id: receiveMsg.id,
+                    from: receiveMsg.from,
+                    fromInfo: fromInfo,
+                    to: receiveMsg.to,
+                    toInfo: toInfo,
+                    type: receiveMsg.type,
+                    ext: receiveMsg.ext,
+                    chatType: receiveMsg.type,
+                    toJid: "",
+                    body: {
+                        type: type,
+                        msg: receiveMsg.data,
+                    },
                 },
-            },
-            value: receiveMsg.data
-        };
-    }
-    else if (type == msgType.FILE) {
-        sendableMsg = {
-            id: receiveMsg.id,
-            type: type,
-            body: {
+                value: receiveMsg.data
+            };
+        }
+        else if (type == msgType.FILE) {
+            sendableMsg = {
                 id: receiveMsg.id,
-                length: receiveMsg.file_length,
-                from: receiveMsg.from,
-                to: receiveMsg.to,
-                type: receiveMsg.type,
-                ext: receiveMsg.ext,
-                chatType: receiveMsg.type,
-                toJid: "",
+                type: type,
                 body: {
-                    type: type,
-                    url: receiveMsg.url,
-                    filename: receiveMsg.filename,
-                    msg: "当前不支持此格式消息展示",
+                    id: receiveMsg.id,
+                    length: receiveMsg.file_length,
+                    from: receiveMsg.from,
+                    to: receiveMsg.to,
+                    type: receiveMsg.type,
+                    ext: receiveMsg.ext,
+                    chatType: receiveMsg.type,
+                    toJid: "",
+                    body: {
+                        type: type,
+                        url: receiveMsg.url,
+                        filename: receiveMsg.filename,
+                        msg: "当前不支持此格式消息展示",
+                    },
                 },
-            },
-            value: receiveMsg.data
-        };
-    }
-    else if (type == msgType.AUDIO) {
-        sendableMsg = {
-            id: receiveMsg.id,
-            type: type,
-            accessToken: receiveMsg.token || receiveMsg.accessToken,
-            body: {
+                value: receiveMsg.data
+            };
+        }
+        else if (type == msgType.AUDIO) {
+            sendableMsg = {
                 id: receiveMsg.id,
-                length: receiveMsg.length,
-                from: receiveMsg.from,
-                to: receiveMsg.to,
-                type: receiveMsg.type,
-                ext: receiveMsg.ext,
-                chatType: receiveMsg.type,
-                toJid: "",
+                type: type,
+                accessToken: receiveMsg.token || receiveMsg.accessToken,
                 body: {
-                    type: type,
-                    url: receiveMsg.url,
-                    filename: receiveMsg.filename,
-                    filetype: receiveMsg.filetype,
+                    id: receiveMsg.id,
+                    length: receiveMsg.length,
                     from: receiveMsg.from,
-                    to: receiveMsg.to
+                    to: receiveMsg.to,
+                    type: receiveMsg.type,
+                    ext: receiveMsg.ext,
+                    chatType: receiveMsg.type,
+                    toJid: "",
+                    body: {
+                        type: type,
+                        url: receiveMsg.url,
+                        filename: receiveMsg.filename,
+                        filetype: receiveMsg.filetype,
+                        from: receiveMsg.from,
+                        to: receiveMsg.to
+                    },
                 },
-            },
-        };
-    }
-    else if (type == msgType.VIDEO) {
-        sendableMsg = {
-            id: receiveMsg.id,
-            type: type,
-            accessToken: receiveMsg.token || receiveMsg.accessToken,
-            body: {
+            };
+        }
+        else if (type == msgType.VIDEO) {
+            sendableMsg = {
                 id: receiveMsg.id,
-                length: receiveMsg.length,
-                from: receiveMsg.from,
-                to: receiveMsg.to,
-                type: receiveMsg.type,
-                ext: receiveMsg.ext,
-                chatType: receiveMsg.type,
-                toJid: "",
+                type: type,
+                accessToken: receiveMsg.token || receiveMsg.accessToken,
                 body: {
-                    type: type,
-                    url: receiveMsg.url,
-                    filename: receiveMsg.filename,
-                    filetype: receiveMsg.filetype,
+                    id: receiveMsg.id,
+                    length: receiveMsg.length,
                     from: receiveMsg.from,
-                    to: receiveMsg.to
+                    to: receiveMsg.to,
+                    type: receiveMsg.type,
+                    ext: receiveMsg.ext,
+                    chatType: receiveMsg.type,
+                    toJid: "",
+                    body: {
+                        type: type,
+                        url: receiveMsg.url,
+                        filename: receiveMsg.filename,
+                        filetype: receiveMsg.filetype,
+                        from: receiveMsg.from,
+                        to: receiveMsg.to
+                    },
                 },
-            },
-        };
-    }
-    else {
-        return;
-    }
-    this.saveMsg(sendableMsg, type, receiveMsg);
+            };
+        }
+        else {
+            return;
+        }
+        this.saveMsg(sendableMsg, type, receiveMsg);
+
+    });
+
+
 };
+
 msgStorage.saveMsg = function (sendableMsg, type, receiveMsg) {
-    //console.log('sendableMsgsendableMsg', sendableMsg)
+    console.log('sendableMsgsendableMsg', sendableMsg)
     let me = this;
     let myName = wx.getStorageSync("myUsername");
     let sessionKey;