zhaoxiaohai пре 3 година
родитељ
комит
210184d727

+ 45 - 2
pages/chatRoom/GambitMsgBubble/index.js

@@ -1,4 +1,7 @@
-// pages/chatRoom/GambitMsgBubble/index.js
+import {
+    ApiModel
+} from "../../../utils/api";
+const _Http = new ApiModel();
 Component({
     /**
      * 组件的属性列表
@@ -11,6 +14,11 @@ Component({
         //创建者id
         role: {
             type: Boolean
+        },
+        //是否显示底部
+        isShowBottom: {
+            type: Boolean,
+            value: true
         }
     },
 
@@ -30,7 +38,6 @@ Component({
         },
         //浏览图片
         preViewImage(e) {
-            console.log(e)
             const {
                 type,
                 url
@@ -51,5 +58,41 @@ Component({
                 url: '/pages/chatRoom/stats?type=' + type + '&timsubjectid=' + this.data.itemData.timsubjectid + '&timdialogid=' + this.data.itemData.timdialogid,
             })
         },
+        //回复话题
+        writBack() {
+            // return console.log(this.data.itemData)
+            _Http.basic({
+                "accesstoken": wx.getStorageSync('userData').token,
+                "classname": "system.im.imdialog.imdialog",
+                "method": "subjectAnswer",
+                "content": {
+                    "timsubjectid": this.data.itemData.timsubjectid
+                }
+            }).then(res => {
+                console.log("回复话题", res)
+                if (res.msg != '成功') return wx.showToast({
+                    title: res.data,
+                    icon: "none"
+                });
+                _Http.basic({
+                    "accesstoken": wx.getStorageSync('userData').token,
+                    "classname": "system.im.imdialog.imdialog",
+                    "method": "quickcontact",
+                    "content": {
+                        "tenterprise_userid": this.data.itemData.sendfrom.userid,
+                        "message": this.data.itemData
+                    }
+                }).then(res => {
+                    console.log("回复创建一对一聊天", res)
+                    if (res.msg != '成功') return wx.showToast({
+                        title: res.data,
+                        icon: "none"
+                    });
+                    wx.navigateTo({
+                        url: '/pages/chatRoom/dialogbox?id=' + res.data[0].timdialogid,
+                    })
+                })
+            })
+        }
     }
 })

+ 11 - 5
pages/chatRoom/GambitMsgBubble/index.wxml

@@ -10,12 +10,15 @@
                 <image class="{{it.ftype=='emoji'?'emoji':'image'}}" data-type="{{it.ftype}}" data-url="{{it.fobsurl}}" catchtap="preViewImage" src="{{it.fobsurl}}" mode="widthFix" />
             </view>
         </block>
-        <block wx:if="{{role}}">
+        <block wx:if="{{isShowBottom}}">
             <view class="hr"></view>
-            <view class="bottom" bindtap="toStats">
+            <view class="bottom" wx:if="{{role}}" bindtap="toStats">
                 <text data-type='回复'>查看回复详情</text>
                 <text data-type='已读' style="margin-left: 40rpx;">查看已读/未读详情</text>
             </view>
+            <view wx:else class="bot-button">
+                <van-button custom-class="call" catchtap="writBack">回复</van-button>
+            </view>
         </block>
         <view class="time">
             {{itemData.closedate}}
@@ -24,17 +27,20 @@
     <!-- 透明度为0,结构和上方一直 用来撑盒子高度 -->
     <view class="contents-box" style="position: relative; left: 0; opacity: 0; pointer-events: none;">
         <block wx:for="{{itemData.imsubjectcontent}}" wx:key="index">
-            <view class="msg-bubble">{{item.fcontent}}</view>
+            <view class="msg-bubble" wx:if="{{item.fcontent!=''}}">{{item.fcontent}}</view>
             <view class="msg-file" wx:if="{{item.attinfos.length>=1}}" wx:for="{{item.attinfos}}" wx:for-index="i" wx:for-item="it" wx:key="i">
                 <image class="{{it.ftype=='emoji'?'emoji':'image'}}" data-type="{{it.ftype}}" data-url="{{it.fobsurl}}" catchtap="preViewImage" src="{{it.fobsurl}}" mode="widthFix" />
             </view>
         </block>
-        <block wx:if="{{role}}">
+        <block wx:if="{{isShowBottom}}">
             <view class="hr"></view>
-            <view class="bottom" bindtap="toStats">
+            <view class="bottom" wx:if="{{role}}" bindtap="toStats">
                 <text data-type='回复'>查看回复详情</text>
                 <text data-type='已读' style="margin-left: 40rpx;">查看已读/未读详情</text>
             </view>
+            <view wx:else class="bot-button">
+                <van-button custom-class="call" catchtap="writBack">回复</van-button>
+            </view>
         </block>
         <view class="time">
             {{itemData.closedate}}

+ 22 - 0
pages/chatRoom/GambitMsgBubble/index.wxss

@@ -99,6 +99,7 @@
     padding-left: -10rpx;
 }
 
+/* 查看数据 */
 .bottom {
     width: 100vw;
     height: 34rpx;
@@ -123,4 +124,25 @@
     right: 20rpx;
     bottom: -40rpx;
     opacity: .39;
+}
+
+/* 回复 */
+.bot-button {
+    width: 100%;
+    margin-top: 14rpx;
+    margin-bottom: 16rpx;
+    text-align: right;
+}
+
+.call {
+    width: 108rpx !important;
+    height: 50rpx !important;
+    background: #4DC2D4 !important;
+    box-shadow: 0px 0px 12rpx 0px rgba(0, 0, 0, 0.1) !important;
+    border-radius: 8rpx !important;
+    font-size: 24rpx !important;
+    font-family: PingFangSC-Medium, PingFang SC !important;
+    color: #FFFFFF;
+    text-shadow: 0px 0px 12rpx rgba(0, 0, 0, 0.1) !important;
+    padding: 0 !important;
 }

+ 7 - 1
pages/chatRoom/MsgBubble/index.js

@@ -22,6 +22,12 @@ Component({
         },
         fobsurl: {
             type: String
+        },
+        isGroup: {
+            type: Boolean //是否群聊
+        },
+        groupData: {
+            type: Object
         }
     },
 
@@ -40,7 +46,7 @@ Component({
             let urls = [];
             urls.push(this.data.fobsurl)
             wx.previewImage({
-                urls:urls
+                urls: urls
             })
         }
     }

+ 3 - 1
pages/chatRoom/MsgBubble/index.json

@@ -1,4 +1,6 @@
 {
     "component": true,
-    "usingComponents": {}
+    "usingComponents": {
+        "GambitMsgBubble": "../GambitMsgBubble/index"
+    }
 }

+ 29 - 24
pages/chatRoom/MsgBubble/index.wxml

@@ -1,26 +1,31 @@
-<!-- 对方 -->
-<view wx:if="{{role=='you'}}" class='opposite-side'>
-    <image wx:if="{{userImg}}" class="userImg" src="{{userImg}}"></image>
-    <image wx:else class="userImg" src="https://bwj.obs.cn-east-2.myhuaweicloud.com/resources/WeChat/userCenter/userImg.png"></image>
-    <view class="content" style="background: {{type=='text'?'':'#fff'}}; padding: {{type=='text'?'':'20rpx 0 0 0'}};">
-        <block wx:if="{{type=='text'}}">
-            {{content}}</block>
-        <block wx:else>
-            <image style="width: 320rpx;" mode="widthFix" src="{{fobsurl}}" catchtap="viewImage"></image>
-        </block>
-        <view class="msg-time">{{time}}</view>
-    </view>
+<view wx:if="{{isGroup}}" style="margin-bottom: 40rpx;">
+    <GambitMsgBubble itemData='{{groupData}}' role="{{false}}" isShowBottom="false" isShowBottom='{{false}}' />
 </view>
-<!-- 自己 -->
-<view wx:if="{{role=='my'}}" class='my-msg'>
-    <view class="content" style="background: {{type=='text'?'':'#fff'}}; padding: {{type=='text'?'':'0rpx'}};">
-        <block wx:if="{{type=='text'}}">
-            {{content}}</block>
-        <block wx:else>
-            <image style="width: 320rpx;" mode="widthFix" src="{{fobsurl}}" catchtap="viewImage"></image>
-        </block>
-        <view class="msg-time">{{time}}</view>
+<block wx:else="">
+    <!-- 对方 -->
+    <view wx:if="{{role=='you'}}" class='opposite-side'>
+        <image wx:if="{{userImg}}" class="userImg" src="{{userImg}}"></image>
+        <image wx:else class="userImg" src="https://bwj.obs.cn-east-2.myhuaweicloud.com/resources/WeChat/userCenter/userImg.png"></image>
+        <view class="content" style="background: {{type=='text'?'':'#fff'}}; padding: {{type=='text'?'':'20rpx 0 0 0'}};">
+            <block wx:if="{{type=='text'}}">
+                {{content}}</block>
+            <block wx:else>
+                <image style="width: 320rpx;" mode="widthFix" src="{{fobsurl}}" catchtap="viewImage"></image>
+            </block>
+            <view class="msg-time">{{time}}</view>
+        </view>
+    </view>
+    <!-- 自己 -->
+    <view wx:if="{{role=='my'}}" class='my-msg'>
+        <view class="content" style="background: {{type=='text'?'':'#fff'}}; padding: {{type=='text'?'':'0rpx'}};">
+            <block wx:if="{{type=='text'}}">
+                {{content}}</block>
+            <block wx:else>
+                <image style="width: 320rpx;" mode="widthFix" src="{{fobsurl}}" catchtap="viewImage"></image>
+            </block>
+            <view class="msg-time">{{time}}</view>
+        </view>
+        <image wx:if="{{userImg}}" class="userImg" src="{{userImg}}"></image>
+        <image wx:else class="userImg" src="https://bwj.obs.cn-east-2.myhuaweicloud.com/resources/WeChat/userCenter/userImg.png"></image>
     </view>
-    <image wx:if="{{userImg}}" class="userImg" src="{{userImg}}"></image>
-    <image wx:else class="userImg" src="https://bwj.obs.cn-east-2.myhuaweicloud.com/resources/WeChat/userCenter/userImg.png"></image>
-</view>
+</block>

+ 35 - 65
pages/chatRoom/dialogbox.js

@@ -121,73 +121,43 @@ Page({
         this.getMeme()
     },
     /* 创建话题,回复话题 */
-    createGambit(e) {
-        const {
-            type
-        } = e.currentTarget.dataset;
-        if (type == '发起会话') {
-            _Http.basic({
-                "accesstoken": wx.getStorageSync('userData').token,
-                "classname": "system.im.imdialog.imdialog",
-                "method": "createSubject",
-                "content": {
-                    "timdialogid": this.data.timdialogid,
-                    "timsubjectid": this.data.timsubjectid,
-                    "fcontent": ""
-                }
-            }).then(res => {
-                if (res.msg != '成功') return wx.showToast({
-                    title: res.data,
-                    icon: "none"
-                })
-                let gambitList = this.data.gambitList;
-                gambitList.push(res.data[0]);
-                this.setData({
-                    timsubjectid: res.data[0].timsubjectid,
-                    gambitList
-                })
-                app.globalData.SocketTask.send({
-                    data: JSON.stringify({
-                        "classname": "message.message",
-                        "method": "sendDataMessage",
-                        "content": {
-                            "timdialogid": this.data.timdialogid,
-                            "ownertable": "timsubject",
-                            "ownerid": this.data.timsubjectid,
-                            "ftype": "话题",
-                        }
-                    }),
-                    success(res) {
-                        console.log("sddf", res)
-                    }
-                })
+    createGambit() {
+        _Http.basic({
+            "accesstoken": wx.getStorageSync('userData').token,
+            "classname": "system.im.imdialog.imdialog",
+            "method": "createSubject",
+            "content": {
+                "timdialogid": this.data.timdialogid,
+                "timsubjectid": this.data.timsubjectid,
+                "fcontent": ""
+            }
+        }).then(res => {
+            if (res.msg != '成功') return wx.showToast({
+                title: res.data,
+                icon: "none"
             })
-        } else {
-            _Http.basic({
-                "accesstoken": wx.getStorageSync('userData').token,
-                "classname": "system.im.imdialog.imdialog",
-                "method": "subjectAnswer",
-                "content": {
-                    "timsubjectid": this.data.timsubjectid
-                }
-            }).then(res => {
-                console.log("回复话题", res)
-                if (res.msg != '成功') return wx.showToast({
-                    title: res.data,
-                    icon: "none"
-                });
-                _Http.basic({
-                    "accesstoken": wx.getStorageSync('userData').token,
-                    "classname": "system.im.imdialog.imdialog",
-                    "method": "quickcontact",
+            let gambitList = this.data.gambitList;
+            gambitList.push(res.data[0]);
+            this.setData({
+                timsubjectid: res.data[0].timsubjectid,
+                gambitList
+            })
+            app.globalData.SocketTask.send({
+                data: JSON.stringify({
+                    "classname": "message.message",
+                    "method": "sendDataMessage",
                     "content": {
-                        "tenterprise_userid": this.data.fimuserid
+                        "timdialogid": this.data.timdialogid,
+                        "ownertable": "timsubject",
+                        "ownerid": this.data.timsubjectid,
+                        "ftype": "话题",
                     }
-                }).then(res => {
-                    console.log("回复创建一对一聊天", res)
-                })
+                }),
+                success(res) {
+                    console.log("sddf", res)
+                }
             })
-        }
+        })
     },
     /* 结束话题 */
     endGambit(isGetList) {
@@ -376,6 +346,7 @@ Page({
     },
     /* 根据话题ID查询详情 */
     async querySubject(array) {
+        console.log("列表", array)
         let list = [];
         for (let index = 0; index < array.length; index++) {
             await _Http.basic({
@@ -386,7 +357,7 @@ Page({
                     "timsubjectid": array[index].message.data.ownerid
                 }
             }, false).then(res => {
-                if (res.data[0].imsubjectcontent.length != 0) {
+                if (res.data.length != 0 && res.data[0].imsubjectcontent.length != 0) {
                     res.data[0].sendfrom = array[index].message.sendfrom;
                     res.data[0].timdialogid = array[index].message.timdialogid;
                     if (res.data[0].closedate != null) {
@@ -401,7 +372,6 @@ Page({
                 }
             })
         }
-        console.log("群聊话题详情", list);
         return list;
     },
     /* 加载分页 */

+ 6 - 6
pages/chatRoom/dialogbox.wxml

@@ -5,7 +5,7 @@
         <van-button custom-class='head-bot-class head-bot-l' catchtap="refuseToCooperate">暂不合作</van-button>
         <van-button custom-class='head-bot-class head-bot-r' catchtap="confirmTheCooperation">确认合作</van-button>
     </view>
-    <view class="header_botton" wx:if="{{fimdialogtype=='话题'}}">
+    <view class="header_botton" wx:if="{{fimdialogtype=='话题'&&fimuserid==userid}}">
         <van-button custom-class='compile' catchtap="a54564">
             <image src="/static/icon-19.png" style="width: 16rpx;height: 20rpx;"></image>
             编辑
@@ -16,22 +16,22 @@
 <scroll-view class="chatFrame" refresher-default-style='none' refresher-enabled bindrefresherrefresh='scrolltoupper' refresher-triggered='{{triggered}}' scroll-y scroll-into-view="{{toView}}">
     <view style="height: 110rpx;"></view>
     <!-- 个人聊天 -->
-    <MsgBubble wx:if="{{fimdialogtype!='话题'}}" wx:for="{{socketMsgQueue}}" wx:key="index" id="item{{index}}" type='{{item.message.ftype}}' fobsurl='{{item.message.data[0].fobsurl}}' role="{{userid==item.message.sendfrom.userid?'my':'you'}}" userImg='{{item.message.sendfrom.headpic}}' content='{{item.message.data.fcontent}}' time='{{item.message.fdatetime}}' />
+    <MsgBubble wx:if="{{fimdialogtype!='话题'}}" wx:for="{{socketMsgQueue}}" isGroup='{{item.message.timsubjectid}}' groupData="{{item.message}}" wx:key="index" id="item{{index}}" type='{{item.message.ftype}}' fobsurl='{{item.message.data[0].fobsurl}}' role="{{userid==item.message.sendfrom.userid?'my':'you'}}" userImg='{{item.message.sendfrom.headpic}}' content='{{item.message.data.fcontent}}' time='{{item.message.fdatetime}}' />
     <!-- 群聊聊天 -->
     <GambitMsgBubble wx:if="{{fimdialogtype=='话题'}}" wx:for="{{gambitList}}" wx:if="{{item.imsubjectcontent.length!=0}}" itemData='{{item}}' wx:key="index" id="item{{index}}" fimuserid='{{fimuserid}}' role="{{userid==fimuserid?true:false}}" />
     <view style="height: {{keyboardHeight}}px;"></view>
     <view id="bottom" style="height: {{iosX?'102':'85'}}px;"></view>
 </scroll-view>
 <!-- 底部输入 -->
-<view class="input-box" style="bottom:{{keyboardHeight}}px;">
+<view class="input-box" style="bottom:{{keyboardHeight}}px;" wx:if="{{fimuserid==userid}}">
     <!-- 普通输入框 -->
     <textarea class="input-text" bindfocus="textareaFocus" bindblur="sendMsg" adjust-position='{{false}}' bindconfirm='sendMsg' show-confirm-bar='{{false}}' confirm-type='send' confirm-hold='true' cursor-spacing='45' bindinput='sendInput' value='{{sendText}}' maxlength='-1' fixed='true' type="text" bindlinechange='linechange' bindkeyboardheightchange='keyboardheightchange'>
     <!-- 话题 -->
     <block wx:if="{{fimdialogtype=='话题'}}">
-        <view class="gambit" wx:if="{{timsubjectid==0&&fimuserid==userid}}" catchtap="createGambit" data-type="{{fimuserid==userid?'发起会话':'回复'}}">
-            {{fimuserid==userid?'发起会话':'回复'}}
+        <view class="gambit" wx:if="{{timsubjectid==0}}" catchtap="createGambit">
+            发起会话
         </view>
-        <navigator url='#' class="gambit-end" catchtap="endGambit" wx:else>
+        <navigator wx:else url='#' class="gambit-end" catchtap="endGambit">
             <image src="/static/icon-20.png" mode="aspectFill"></image>
         </navigator>
     </block>

+ 1 - 0
pages/chatRoom/dialogbox.wxss

@@ -14,6 +14,7 @@ page {
     height: 92rpx;
     background-color: #f6f7f8;
     z-index: 99;
+    box-shadow: 0px -4rpx 16rpx 0px rgba(0, 0, 0, 0.05);
 }
 
 .header_title {

+ 2 - 1
pages/chatRoom/history.wxml

@@ -1 +1,2 @@
-<MsgBubble wx:for="{{socketMsgQueue}}" id="item{{index}}" type='{{item.message.ftype}}' fobsurl='{{item.message.data[0].fobsurl}}' role="{{userid==item.message.sendfrom.userid?'my':'you'}}" userImg='{{item.message.sendfrom.headpic}}' content='{{item.message.data.fcontent}}' time='{{item.message.fdatetime}}' />
+<!-- <MsgBubble wx:for="{{socketMsgQueue}}" id="item{{index}}" type='{{item.message.ftype}}' fobsurl='{{item.message.data[0].fobsurl}}' role="{{userid==item.message.sendfrom.userid?'my':'you'}}" userImg='{{item.message.sendfrom.headpic}}' content='{{item.message.data.fcontent}}' time='{{item.message.fdatetime}}' /> -->
+<MsgBubble wx:for="{{socketMsgQueue}}" isGroup='{{item.message.timsubjectid}}' groupData="{{item.message}}" wx:key="index" id="item{{index}}" type='{{item.message.ftype}}' fobsurl='{{item.message.data[0].fobsurl}}' role="{{userid==item.message.sendfrom.userid?'my':'you'}}" userImg='{{item.message.sendfrom.headpic}}' content='{{item.message.data.fcontent}}' time='{{item.message.fdatetime}}' />

+ 7 - 4
pages/tabbar-pages/home/index.js

@@ -151,10 +151,13 @@ Page({
                 }
                 return;
             }
-            const data = handleList.getYTD(res.data);
-            this.setData({
-                productList: data
-            });
+            console.log("res.data", res.data)
+            if (res.data.length >= 1) {
+                const data = handleList.getYTD(res.data);
+                this.setData({
+                    productList: data
+                });
+            }
             // 获取到二维码原始链接内容
             if (query.q) {
                 //有登录态直接加入

+ 7 - 3
utils/processingData.js

@@ -46,9 +46,13 @@ function annunciateCheckdate(list) {
 /* 截取时间 只取年月日 */
 function getYTD(data) {
     for (let i = 0; i < data.length; i++) {
-        let checkdate = data[i].checkdate;
-        const YTD = checkdate.split(' ');
-        data[i].checkdate = YTD[0];
+        if (data[i].checkdate) {
+            let checkdate = data[i].checkdate;
+            const YTD = checkdate.split(' ');
+            data[i].checkdate = YTD[0];
+        } else {
+            data[i].checkdate = '';
+        }
     }
     return data;
 }