zhaoxiaohai 3 years ago
parent
commit
d746a7274a

+ 7 - 5
components/My_Checkbox/index.wxss

@@ -40,29 +40,31 @@
 
 /* 按钮 */
 .checkbox_but {
-    position: relative;
+    display: flex;
+    justify-content:flex-end;
     width: 100vw;
     margin: 30rpx 0 80rpx 0;
     box-sizing: border-box;
 }
 
-.checkbox_but .radio {
+/* .checkbox_but .radio {
     position: absolute;
     display: flex;
     align-items: center;
     width: 380rpx;
     height: 64rpx;
     left: 60rpx;
-}
+} */
 
 .checkbox_but .button {
-    position: absolute;
+    /* position: absolute; */
     width: 188rpx;
     height: 64rpx;
     background: #4EBFCF;
     border-radius: 14rpx;
-    right: 60rpx;
+    /* right: 60rpx; */
     overflow: hidden;
+    margin-right: 60rpx;
 }
 
 .customClass {

+ 113 - 15
pages/chatRoom/create.js

@@ -2,6 +2,7 @@ import {
     ApiModel
 } from "../../utils/api";
 const _Http = new ApiModel();
+const handleList = require("../../utils/processingData");
 Page({
 
     /**
@@ -12,7 +13,9 @@ Page({
         buddyList: [], //好友列表
         activeNames: [], //折叠面板展开项
         identity: '全部', //选择身份
-        result: []
+        result: [],
+        checkAll: false, //是否全选
+        numberOfPeople: 0, //全部人员计数
     },
 
     /**
@@ -45,6 +48,68 @@ Page({
         })
 
     },
+    /* 创建群聊 */
+    createdGroup() {
+        if (this.data.result.length == 0) {
+            wx.showToast({
+                title: '当前还未选择群聊成员',
+                icon: "none"
+            })
+        } else {
+            _Http.basic({
+                "accesstoken": wx.getStorageSync('userData').token,
+                "classname": "system.im.imdialog.imdialog",
+                "method": "insertOrModify",
+                "content": {
+                    "timdialogid": 0,
+                    "fimdialogname": (this.data.inputValue == '') ? '讨论组' : this.data.inputValue,
+                    "fimdialogtype": "话题",
+                    "ownertable": "",
+                    "ownerid": "",
+                    "users": this.data.result
+                }
+            }).then(res => {
+                console.log("创建群聊", res)
+                if (res.msg != '成功') return wx.showToast({
+                    title: res.data,
+                    icon: "none"
+                })
+                wx.showToast({
+                    title: '创建成功',
+                })
+                setTimeout(() => {
+                    wx.redirectTo({
+                        url: '/pages/chatRoom/dialogbox?id=' + res.data[0].timdialogid,
+                    })
+                }, 500)
+            })
+        }
+    },
+    /* 是否全选 */
+    allChange({
+        detail
+    }) {
+        this.setData({
+            checkAll: detail
+        })
+        if (detail) {
+            let result = [];
+            for (let i = 0; i < this.data.buddyList.length; i++) {
+                if (this.data.identity == '全部') {
+                    this.batchChange(i, true)
+                } else {
+                    result.push(this.data.buddyList[i].userList[0].tenterprise_userid.toString())
+                }
+            }
+            if (this.data.identity != '全部') this.setData({
+                result
+            })
+        } else {
+            this.setData({
+                result: []
+            })
+        }
+    },
     /* 商户成员列表 */
     query_CooperationAgentUsers(data) {
         _Http.basic({
@@ -53,18 +118,22 @@ Page({
             "method": "query_CooperationAgentUsers",
             "content": {
                 "getdatafromdbanyway": true,
-                "tagentsid": data.tcooperationagentsid
+                "tagentsid": data.tcooperationagentsid,
+                "hasAdministrator": "1"
             }
         }, false).then(res => {
+            console.log("成员列表", res)
             if (res.msg != '成功') return wx.showToast({
                 title: res.data,
                 icon: "none"
             })
-            data.userList = res.data;
+            data.userList = handleList.imageType(res.data, 'headportrait');
+            let numberOfPeople = this.data.numberOfPeople += data.userList.length; //计数
             let buddyList = this.data.buddyList;
             buddyList.push(data)
             this.setData({
-                buddyList
+                buddyList,
+                numberOfPeople
             })
         })
     },
@@ -72,9 +141,20 @@ Page({
     selectType({
         detail
     }) {
+        /* if (detail == '仅老板') {
+            let list = this.data.buddyList,
+                result = []
+            for (let index = 0; index < list.length; index++) {
+                result.push(list[index].userList[0].tenterprise_userid.toString())
+            }
+            this.setData({
+                result
+            })
+        } */
         if (this.data.identity != detail) this.setData({
-            detail
+            identity: detail
         });
+        this.isAll()
     },
     /* 编辑群名称 */
     nameInput(e) {
@@ -96,14 +176,17 @@ Page({
         this.setData({
             result: e.detail
         })
+        this.isAll();
     },
-    /* 标题选择框 */
+    /* 商户选中 */
     titleRadio(e) {
         const {
             index,
             id
         } = e.target.dataset;
-        if (!this.data.result.some((value) => value == id)) this.batchChange(index, false);
+        this.isAll()
+        if (!this.data.result.some((value) => value == id)) return this.batchChange(index, false);
+        if (this.data.identity == '全部') this.batchChange(index, true);
     },
     //批量修改
     batchChange(index, bool) {
@@ -111,7 +194,16 @@ Page({
             result = this.data.result;
         for (let index = 0; index < data.length; index++) {
             if (bool) {
-                if (!result.some((v) => v == data[index])) result.push(data[index].tenterprise_userid.toString())
+                if (!result.some((v) => v == data[index])) {
+                    result.push(data[index].tenterprise_userid.toString())
+                    result = result.reduce((pre, cur) => {
+                        if (!pre.includes(cur)) {
+                            return pre.concat(cur)
+                        } else {
+                            return pre
+                        }
+                    }, [])
+                }
             } else {
                 result = result.filter((value) => value != data[index].tenterprise_userid);
             }
@@ -119,6 +211,7 @@ Page({
         this.setData({
             result
         })
+        this.isAll();
     },
     /* 选择子账号同时选中主账号 */
     listClick(e) {
@@ -134,38 +227,43 @@ Page({
                 result
             })
         }
-
+    },
+    isAll() {
+        let checkAll = this.data.checkAll;
+        if (this.data.identity == '全部') {
+            checkAll = (this.data.numberOfPeople == this.data.result.length) ? true : false;
+        } else {
+            checkAll = (this.data.result.length == this.data.buddyList.length) ? true : false;
+        }
+        console.log("isall", checkAll)
+        this.setData({
+            checkAll
+        })
     },
     /**
      * 生命周期函数--监听页面初次渲染完成
      */
     onReady: function () {},
-
     /**
      * 生命周期函数--监听页面显示
      */
     onShow: function () {},
-
     /**
      * 生命周期函数--监听页面隐藏
      */
     onHide: function () {},
-
     /**
      * 生命周期函数--监听页面卸载
      */
     onUnload: function () {},
-
     /**
      * 页面相关事件处理函数--监听用户下拉动作
      */
     onPullDownRefresh: function () {},
-
     /**
      * 页面上拉触底事件的处理函数
      */
     onReachBottom: function () {},
-
     /**
      * 用户点击右上角分享
      */

+ 9 - 4
pages/chatRoom/create.wxml

@@ -21,7 +21,7 @@
                 <van-radio checked-color='#4DC2D4' name="仅老板" icon-size="28rpx" custom-class='group-class' label-class='van-radio-class'>仅老板</van-radio>
             </van-radio-group>
         </view>
-        <view style="flex: 1; max-height: 65vh;">
+        <view style="flex: 1; max-height: 65vh;  position: relative;">
             <scroll-view style="height: 100%; width: 100vw;" scroll-y>
                 <van-collapse custom-class="collapse-cus" value="{{ activeNames }}" bind:change="collapseChange">
                     <van-checkbox-group value="{{ result }}" bind:change="userListCheckboxChange">
@@ -29,9 +29,10 @@
                             <view slot="title" class="collapse-title">
                                 <van-checkbox name="{{item.userList[0].tenterprise_userid}}" shape='round' icon-size="14px" checked-color="#4DC2D4" data-index="{{index}}" data-id="{{item.userList[0].tenterprise_userid}}" catchtap="titleRadio"><text class="u-line-1" data-index="{{index}}" data-id="{{item.userList[0].tenterprise_userid}}" style="max-width: 400rpx;display: inline-block;">{{item.fbrand}}</text></van-checkbox>
                             </view>
-                            <van-checkbox disabled='{{index==0}}' data-index="{{index}}" data-id="{{it.tenterprise_userid}}" catchtap="listClick" id="{{item.userList[0].tenterprise_userid}}" wx:for="{{item.userList}}" wx:for-item="it" custom-class='user-list-custom' checked-color='#4DC2D4' label-class="user-list-checkbox" wx:key="index" name="{{it.tenterprise_userid}}">
+                            <van-checkbox disabled='{{index==0}}' icon-size="14px" data-index="{{index}}" data-id="{{it.tenterprise_userid}}" catchtap="listClick" id="{{item.userList[0].tenterprise_userid}}" wx:for="{{item.userList}}" wx:for-item="it" custom-class='user-list-custom' checked-color='#4DC2D4' label-class="user-list-checkbox" wx:key="index" name="{{it.tenterprise_userid}}">
                                 <view class="user-item u-line-1">
-                                    <image src="/static/changeImg.png" mode="aspectFill"></image>{{it.fname}}
+                                    <image wx:if="{{it.attinfos[0].fobsurl}}" src="{{it.attinfos[0].fobsurl}}" mode="aspectFill" />
+                                    <image wx:else src="https://bwj.obs.cn-east-2.myhuaweicloud.com/resources/WeChat/userCenter/userImg.png" mode="aspectFill" />{{it.fname}}
                                 </view>
                             </van-checkbox>
                         </van-collapse-item>
@@ -39,7 +40,11 @@
                 </van-collapse>
                 <van-empty wx:if="{{buddyList.length==0}}" description="暂无数据" />
             </scroll-view>
+            <view class="all">
+                <van-checkbox value="{{ checkAll }}" icon-size="28rpx" checked-color='#4DC2D4' bind:change="allChange" custom-class='radio-group-class group-class' label-class='van-radio-class'>全选</van-checkbox>
+            </view>
+            <view style="height: 60rpx; width: 50rpx;"></view>
         </view>
-        <van-button disabled custom-class='vanBut'>立即创建</van-button>
+        <van-button disabled='{{result.length==0}}' custom-class='vanBut' catchtap="createdGroup">立即创建</van-button>
     </view>
 </view>

+ 11 - 0
pages/chatRoom/create.wxss

@@ -172,4 +172,15 @@ page {
     height: 70rpx;
     border-radius: 50%;
     margin-right: 20rpx;
+}
+
+.all {
+    position: absolute;
+    height: 60rpx;
+    display: flex;
+    align-items: center;
+    bottom: 0;
+    left: 40rpx;
+    width: 100%;
+    background-color: #ffffff;
 }

+ 116 - 28
pages/chatRoom/dialogbox.js

@@ -23,6 +23,9 @@ Page({
         unreadCount: 0, //对方发送未读信息
         joinHands: false, //是否显示合作按钮
         ownerid: 0, //供需id
+        fimdialogtype: '话题', //对话框类型
+        fimuserid: 0, //创建者id
+        timsubjectid: 0, //话题id
     },
 
     /**
@@ -74,7 +77,9 @@ Page({
                 headerTitle,
                 ownerid: res.data[0].ownerid,
                 initiator: res.data[0].fimuserid,
-                joinHands
+                joinHands,
+                fimdialogtype: res.data[0].fimdialogtype,
+                fimuserid: res.data[0].fimuserid
             })
         })
         //群历史信息
@@ -86,6 +91,59 @@ Page({
         //获取表情包
         this.getMeme()
     },
+    /* 创建话题 */
+    createGambit(e) {
+        const {
+            type
+        } = e.currentTarget.dataset;
+        console.log(type)
+        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 => {
+                console.log(res)
+                if (res.msg != '成功') return wx.showToast({
+                    title: res.data,
+                    icon: "none"
+                })
+                this.setData({
+                    timsubjectid: res.data[0].timsubjectid
+                })
+            })
+        } 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",
+                    "content": {
+                        "tenterprise_userid": this.data.fimuserid
+                    }
+                }).then(res => {
+                    console.log("回复创建一对一聊天", res)
+                })
+            })
+        }
+    },
     /* 确认合作 */
     confirmTheCooperation() {
         _Http.basic({
@@ -193,35 +251,66 @@ Page({
         const content = this.data.sendText.trim(),
             that = this;
         if (type === 'file') {
-            console.log("发送", data)
-            app.globalData.SocketTask.send({
-                data: JSON.stringify({
-                    "classname": "message.message",
-                    "method": "sendFileMessage",
-                    "content": {
-                        "timdialogid": this.data.timdialogid,
-                        "tattachmentid": data[0].tattachmentid
-                    }
-                }),
-                success(res) {}
-            })
+            if (this.data.fimdialogtype != '话题') {
+                app.globalData.SocketTask.send({
+                    data: JSON.stringify({
+                        "classname": "message.message",
+                        "method": "sendFileMessage",
+                        "content": {
+                            "timdialogid": this.data.timdialogid,
+                            "tattachmentid": data[0].tattachmentid
+                        }
+                    }),
+                    success(res) {}
+                })
+            } else {
+                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) {}
+                })
+            }
         } else {
             if (content == '') return;
-            app.globalData.SocketTask.send({
-                data: JSON.stringify({
-                    "classname": "message.message",
-                    "method": "sendTextMessage",
-                    "content": {
-                        "timdialogid": that.data.timdialogid,
-                        "fmessage": content
+            if (this.data.fimdialogtype != '话题') {
+                app.globalData.SocketTask.send({
+                    data: JSON.stringify({
+                        "classname": "message.message",
+                        "method": "sendTextMessage",
+                        "content": {
+                            "timdialogid": that.data.timdialogid,
+                            "fmessage": content
+                        }
+                    }),
+                    success(res) {
+                        that.setData({
+                            sendText: ''
+                        })
                     }
-                }),
-                success(res) {
-                    that.setData({
-                        sendText: ''
-                    })
-                }
-            })
+                })
+            } else {
+                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) {}
+                })
+            }
         }
     },
     sendMeme(e) {
@@ -384,7 +473,6 @@ Page({
                     },
                     success(res) {
                         let file = res.data.data;
-                        console.log(res)
                         that.sendMsg('file', file)
                     }
                 })

+ 12 - 2
pages/chatRoom/dialogbox.wxml

@@ -5,10 +5,17 @@
         <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=='话题'}}">
+        <van-button custom-class='compile' catchtap="refuseToCooperate">
+            <image src="/static/icon-19.png" style="width: 16rpx;height: 20rpx;"></image>
+            编辑
+        </van-button>
+    </view>
 </view>
 <!-- 聊天   bindscrolltoupper='scrolltoupper' -->
 <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: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}}' />
     <view style="height: {{keyboardHeight}}px;"></view>
     <view id="bottom" style="height: {{iosX?'102':'85'}}px;"></view>
@@ -16,7 +23,11 @@
 <!-- 底部输入 -->
 <view class="input-box" style="bottom:{{keyboardHeight}}px;">
     <!-- {{lineCount>1?'multi-row':''}} -->
-    <textarea class="input-text " bindfocus="textareaFocus" 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'></textarea>
+    <textarea class="input-text" bindfocus="textareaFocus" 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'>
+    <view class="gambit" wx:if="{{fimdialogtype=='话题'&&timsubjectid==0}}" catchtap="createGambit" data-type="{{fimuserid==userid?'发起会话':'回复'}}">
+        {{fimuserid==userid?'发起会话':'回复'}}
+    </view>
+    </textarea>
     <view class="functionalZone" catchtap="selectionFunction">
         <image data-name='表情' mode="heightFix" src="/static/chatRoom/icon-01.png" />
         <image data-name='图片' mode="heightFix" src="/static/chatRoom/icon-02.png" />
@@ -36,5 +47,4 @@
         <view style="height: {{iosX?'34':'0'}}rpx;"></view>
     </view>
 </van-popup>
-
 <view wx:if="{{ memePopup }}" bindtap="endMemePopup" class="mask-layer"></view>

+ 31 - 0
pages/chatRoom/dialogbox.wxss

@@ -67,6 +67,7 @@ page {
 }
 
 .input-text {
+    position: relative;
     width: 710rpx;
     height: 64rpx;
     line-height: 64rpx;
@@ -129,4 +130,34 @@ page {
     top: 0;
     left: 0;
     z-index: 9;
+}
+
+/* 群聊编辑按钮 */
+.compile {
+    width: 118rpx !important;
+    height: 52rpx !important;
+    background: #FFB600 !important;
+    border-radius: 10rpx;
+    padding: 0;
+    margin-right: 20rpx;
+    font-size: 24rpx;
+    font-family: PingFangSC-Medium, PingFang SC;
+    color: #FFFFFF;
+}
+
+/* 群聊按钮 */
+.gambit {
+    position: absolute;
+    display: flex;
+    align-items: center;
+    justify-content: center;
+    width: 710rpx;
+    height: 100%;
+    background: linear-gradient(180deg, #FFFFFF 0%, #F4F4F4 100%);
+    box-shadow: 0px 0px 4rpx 0px rgba(0, 0, 0, 0.1);
+    left: 0;
+    top: 0;
+    z-index: 9999999999999;
+    font-size: 24rpx;
+    color: rgba(0, 0, 0, 0.5);
 }

+ 13 - 0
pages/chatRoom/index.js

@@ -58,6 +58,19 @@ Page({
                 title: res.data,
                 icon: "none"
             });
+            for (let i = 0; i < res.data.length; i++) {
+                let time = res.data[i].fjoindate.split(" "),
+                    date = new Date(),
+                    getMonth = (date.getMonth() + 1),
+                    Month = (getMonth < 10) ? '0' + getMonth : getMonth,
+                    now = date.getFullYear() + '-' + Month + '-' + date.getDate();
+                if (now == time[0]) {
+                    let a1 = time[1].split(".");
+                    res.data[i].fjoindate = a1[0];
+                } else {
+                    res.data[i].fjoindate = time[0];
+                }
+            }
             let relationList = [],
                 discussionGroupList = [];
             for (let i = 0; i < res.data.length; i++) {

+ 3 - 2
pages/chatRoom/index.wxml

@@ -20,7 +20,8 @@
             </view>
             <view class="borTop">
                 <view class="msgText">
-                    <view class="title u-line-1">{{item.latestnews[0].fname}}</view>
+                    <!-- latestnews[0].fname -->
+                    <view class="title u-line-1">{{item.fimdialogname}}</view>
                     <view class="msg u-line-1">{{item.latestnews[0].message.ftype=='file'?'[图片]':item.latestnews[0].message.data.fcontent}}</view>
                 </view>
                 <view class="msgCount">
@@ -44,7 +45,7 @@
             </view>
             <view class="borTop">
                 <view class="msgText">
-                    <view class="title u-line-1">{{item.latestnews[0].fname}}</view>
+                    <view class="title u-line-1">{{item.fimdialogname}}</view>
                     <view class="msg u-line-1">{{item.latestnews[0].message.ftype=='file'?'[图片]':item.latestnews[0].message.data.fcontent}}</view>
                 </view>
                 <view class="msgCount">

+ 11 - 2
pages/chatRoom/index.wxss

@@ -111,13 +111,13 @@ page {
 }
 
 .msgCount .time {
-    width: 110rpx;
+    width: 150rpx;
     height: 44rpx;
     font-size: 24rpx;
     font-weight: 400;
     color: rgba(0, 0, 0, .4);
     line-height: 44rpx;
-    text-align: right;
+    text-align: left;
 }
 
 .msgCount .count {
@@ -143,4 +143,13 @@ page {
 .borTop::after {
     content: '';
     height: 0rpx;
+}
+
+.msgText {
+    width: 430rpx;
+}
+
+.msgTime {
+    width: 150rpx;
+    text-align: center;
 }

BIN
static/icon-19.png