Browse Source

企微聊天动态表情消息接收处理

Long 2 weeks ago
parent
commit
c103652af8

+ 9 - 7
src/components/LemonUI/components/chatmsg.vue

@@ -195,7 +195,7 @@ export default {
         if (message.type == 'event'){
             // if(this.user.id == message.fromUser.id){}
             unread = 0;
-        } 
+        }
         if (messageList === undefined) {
           //console.log("qxj appendMessage messageList:"+messageList+",message"+JSON.stringify(message));
           conversation.id=message.toContactId;
@@ -208,7 +208,7 @@ export default {
           let hasMsg = messageList.some(({id})=>id == message.id);
           if (hasMsg) return;
           this._addMessage(message, message.toContactId, 1);
-          
+
           conversation.lastContent=this.lastContentRender(message);
           conversation.lastSendTime=message.sendTime;
           if (message.toContactId == this.currentContactId) {
@@ -487,6 +487,7 @@ export default {
       );
     },
     _renderSidebar(children, name, fixedtop) {
+      console.log("_renderSidebar", children)
       return (
         <div
           class="lemon-sidebar"
@@ -536,7 +537,7 @@ export default {
             </div>,
           );
       }
-      
+
       //聊天消息View
       nodes.push(
         <div
@@ -649,6 +650,7 @@ export default {
       lastContentRender[messageType] = render;
     },
     lastContentRender(message) {
+      console.log("msg", message)
       if (!isFunction(lastContentRender[message.type])) {
         console.error(
           `not found '${
@@ -703,7 +705,7 @@ export default {
         editorValue,
         lastContent,
       });
-      
+
       var tempDraft=this.CacheDraft.get(cid);
       //console.log("qxj editorValue:"+editorValue+",tempDraft:"+JSON.stringify(tempDraft)+"lastContent:"+lastContent);
 
@@ -937,7 +939,7 @@ export default {
     initConversations(data) {
       this.conversations = data;
       this.sortConversations();
-      
+
     },
 
     /**
@@ -1028,7 +1030,7 @@ export default {
      */
     updateContact(data) {
       const conversationId = data.conversationId;
-      const index = this.findConversationIndexById(conversationId);  
+      const index = this.findConversationIndexById(conversationId);
       if (index !== -1) {
         // if(isString(data.unread)) {
         //     if (unread.indexOf("+") === 0 || unread.indexOf("-") === 0) {
@@ -1044,7 +1046,7 @@ export default {
     updateContact1(data) {
       const contactId = data.id;
       delete data.id;
-      const index = this.findContactIndexById(contactId);  
+      const index = this.findContactIndexById(contactId);
       if (index !== -1) {
         const { unread } = data;
         if (isString(unread)) {

+ 4 - 1
src/components/LemonUI/components/index.vue

@@ -394,6 +394,9 @@ export default {
         [
           useScopedSlot(this.$scopedSlots["sidebar-message-top"], null, this),
           this.lastMessages.map(contact => {
+            if (contact.type !== 'text' && isFunction(lastContentRender[contact.type])) {
+              contact.lastContent =  lastContentRender[contact.type].call(this, contact);
+            }
             return this._renderContact(
               {
                 contact,
@@ -646,7 +649,7 @@ export default {
         );
         return "";
       }
-      return lastContentRender[message.type].call(this, message);
+      return lastContentRender[message.type].call(this, message.content);
     },
     /**
      * 将字符串内的 EmojiItem.name 替换为 img

+ 22 - 0
src/components/LemonUI/components/message/emotionDynamic.vue

@@ -0,0 +1,22 @@
+<script>
+export default {
+  name: 'lemonMessageEmotionDynamic',
+  inheritAttrs: false,
+  render() {
+    return (
+      <lemon-message-basic
+        class="lemon-message-emotion-dynamic"
+        props={{ ...this.$attrs }}
+        scopedSlots={{
+          content: props => <img src={props.content} />
+        }}
+      />
+    )
+  }
+}
+</script>
+
+
+<style scoped>
+
+</style>

+ 3 - 1
src/components/LemonUI/index.js

@@ -14,6 +14,7 @@ import lemonMessageFile from "./components/message/file";
 import lemonMessageEvent from "./components/message/event";
 import LemonMessageVoice from "./components/message/voice";
 import LemonMessageVideo from "./components/message/video";
+import LemonMessageEmotionDynamic from "./components/message/emotionDynamic.vue";
 
 
 import LemonIMUI from "./components/index";
@@ -39,7 +40,8 @@ const components = [
   lemonMessageEvent,
   LemonMessageVoice,
   LemonMessageVideo,
-  LemonRecords
+  LemonRecords,
+  LemonMessageEmotionDynamic
 ];
 const install = (Vue) => {
   Vue.directive("LemonContextmenu", Contextmenu);

+ 4 - 1
src/components/LemonUI/lastContentRender.js

@@ -13,9 +13,12 @@ export default {
     return "[视频]";
   },
   text(message) {
-    return this.emojiNameToImage(clearHtml(message.content));
+    return this.emojiNameToImage(clearHtml(message));
   },
   event(message){
     return '[通知]';
   },
+  emotionDynamic(message) {
+    return '[自定义表情]';
+  },
 };

+ 0 - 12
src/views/qw/qwChat/userDetail/index.vue

@@ -63,13 +63,6 @@
       </el-descriptions>
     </div>
 
-    <div class="contentx" v-if="item.userId != null" >
-      <div class="desct">
-        用户地址
-      </div>
-      <userAddDetails  ref="userAddDetail" />
-    </div>
-
     <div class="contentx" v-if="item.userId != null" >
       <div class="desct">
         用户订单
@@ -88,14 +81,12 @@
 
 <script>
 import {getUserInfoBySessionId} from "@/api/users/user";
-import userAddDetails from "@/views/qw/qwChat/userDetail/userAddDetails.vue";
 import userStorerDetails from "@/views/qw/qwChat/userDetail/userStorerDetails.vue"
 import userCourseWatchLog from "@/views/qw/qwChat/userDetail/userCourseWatchLog.vue";
 
 export default {
   name: "userDetail",
   components: {
-    userAddDetails,
     userStorerDetails,
     userCourseWatchLog
   },
@@ -119,9 +110,6 @@ export default {
       getUserInfoBySessionId(params).then(response => {
         this.item = response.data;
         if (this.item.userId != null) {
-            setTimeout(() => {
-              this.$refs.userAddDetail.getAddList(this.item.userId);
-            }, 1);
             setTimeout(() => {
               this.$refs.userDetails.getUserDetails(this.item.userId);
             }, 1);

+ 0 - 374
src/views/qw/qwChat/userDetail/userAddDetails.vue

@@ -1,374 +0,0 @@
-<template>
-  <div >
-    <el-row :gutter="10" class="mb8" style="float: right; top: -30px;">
-      <el-col :span="1.5">
-        <el-button
-          type="primary"
-          plain
-          icon="el-icon-plus"
-          size="mini"
-          @click="handleAdd"
-          v-hasPermi="['store:userAddress:add']"
-        >新增</el-button>
-      </el-col>
-    </el-row>
-
-    <el-table v-loading="loading" border="" :data="userAddressList" @selection-change="handleSelectionChange" style="top: -30px;">
-      <el-table-column label="收货人姓名" align="center" prop="realName" />
-      <el-table-column label="收货人电话" align="center" prop="phone" />
-      <el-table-column label="收货人所在省" align="center" prop="province" />
-      <el-table-column label="收货人所在市" align="center" prop="city" />
-      <el-table-column label="收货人所在区" align="center" prop="district" />
-      <el-table-column label="收货人详细地址" align="center" prop="detail" />
-      <el-table-column label="操作" align="center" class-name="small-padding fixed-width">
-        <template slot-scope="scope">
-          <el-button
-            size="mini"
-            type="text"
-            icon="el-icon-edit"
-            @click="handleUpdate(scope.row)"
-            v-hasPermi="['store:userAddress:edit']"
-          >修改</el-button>
-          <el-button
-            size="mini"
-            type="text"
-            icon="el-icon-delete"
-            @click="handleDelete(scope.row)"
-            v-hasPermi="['store:userAddress:remove']"
-          >删除</el-button>
-        </template>
-      </el-table-column>
-    </el-table>
-
-    <pagination
-      v-show="total>0"
-      :total="total"
-      :page.sync="queryParams.pageNum"
-      :limit.sync="queryParams.pageSize"
-      @pagination="getList"
-    />
-
-    <!-- 添加或修改用户地址对话框 -->
-    <el-dialog :title="title" :visible.sync="open" width="700px" append-to-body>
-      <el-form ref="form" :model="form" :rules="rules" label-width="110px">
-      <el-form-item label="智能识别" prop="address">
-        <el-input v-model="address" placeholder="输入需要识别的地址" >  <el-button slot="append" icon="el-icon-search" @click="sAddress"></el-button></el-input>
-      </el-form-item>
-        <el-form-item label="收货人姓名" prop="realName">
-          <el-input v-model="form.realName" placeholder="请输入收货人姓名" />
-        </el-form-item>
-        <el-form-item label="收货人电话" prop="phone">
-          <el-input v-model="form.phone" placeholder="请输入收货人电话" />
-        </el-form-item>
-        <el-form-item label="省市区" >
-          <el-cascader
-          ref="citySelect"
-          v-model="cityIds"
-          :options="citys"
-          @change="handleCityChange">
-          </el-cascader>
-        </el-form-item>
-        <el-form-item label="详细地址" prop="detail">
-          <el-input v-model="form.detail" placeholder="请输入收货人详细地址" />
-        </el-form-item>
-        <el-form-item label="是否默认地址" prop="isDefault">
-          <el-radio-group v-model="form.isDefault">
-            <el-radio :label="item.dictValue" v-for="item in orOptions" >{{item.dictLabel}}</el-radio>
-          </el-radio-group>
-        </el-form-item>
-      </el-form>
-      <div slot="footer" class="dialog-footer">
-        <el-button type="primary" @click="submitForm">确 定</el-button>
-        <el-button @click="cancel">取 消</el-button>
-      </div>
-    </el-dialog>
-  </div>
-</template>
-
-<script>
-import { getAddress,listUserAddress, getUserAddress, delUserAddress, addUserAddress, updateUserAddress, exportUserAddress } from "@/api/store/userAddress";
-import {getCitys} from "@/api/store/city";
-export default {
-  name: "UserAddress",
-  data() {
-    return {
-      // 遮罩层
-      loading: true,
-      // 导出遮罩层
-      exportLoading: false,
-      orOptions: [],
-      // 选中数组
-      ids: [],
-      // 非单个禁用
-      single: true,
-      // 非多个禁用
-      multiple: true,
-      // 显示搜索条件
-      showSearch: true,
-      // 总条数
-      total: 0,
-      // 用户地址表格数据
-      userAddressList: [],
-      // 弹出层标题
-      title: "",
-      // 是否显示弹出层
-      open: false,
-      cityIds:null,
-      address:null,
-      // 查询参数
-      queryParams: {
-        pageNum: 1,
-        pageSize: 10,
-        userId: null,
-        realName: null,
-        phone: null,
-        province: null,
-        city: null,
-        district: null,
-        cityIds: null,
-        detail: null,
-        postCode: null,
-        longitude: null,
-        latitude: null,
-        isDefault: null,
-        isDel: 0,
-      },
-      // 表单参数
-      form: {},
-      // 表单校验
-      rules: {
-        userId: [
-          { required: true, message: "用户id不能为空", trigger: "blur" }
-        ],
-        realName: [
-          { required: true, message: "收货人姓名不能为空", trigger: "blur" }
-        ],
-        phone: [
-          { required: true, message: "收货人电话不能为空", trigger: "blur" },
-          {
-                      pattern: /^1[3|4|5|6|7|8|9][0-9]\d{8}$/,
-                      message: "请输入正确的手机号码",
-                      trigger: "blur"
-                    }
-        ],
-        province: [
-          { required: true, message: "收货人所在省不能为空", trigger: "blur" }
-        ],
-        city: [
-          { required: true, message: "收货人所在市不能为空", trigger: "blur" }
-        ],
-        district: [
-          { required: true, message: "收货人所在区不能为空", trigger: "blur" }
-        ],
-        detail: [
-          { required: true, message: "收货人详细地址不能为空", trigger: "blur" }
-        ],
-        isDefault: [
-          { required: true, message: "是否默认不能为空", trigger: "blur" }
-        ],
-        cityIds: [
-          { required: true, message: "不能为空", trigger: "blur" }
-        ],
-      },
-      citys: []
-    };
-  },
-  created() {
-    this.getCitys();
-    this.getDicts("sys_company_or").then(response => {
-      this.orOptions = response.data;
-    });
-  },
-  methods: {
-    /** 查询用户地址列表 */
-    getList() {
-      this.loading = true;
-      listUserAddress(this.queryParams).then(response => {
-        this.userAddressList = response.rows;
-        this.total = response.total;
-        this.loading = false;
-
-      });
-    },
-    getAddList(id) {
-      this.queryParams.userId=id;
-      this.loading = true;
-      listUserAddress(this.queryParams).then(response => {
-        this.userAddressList = response.rows;
-        this.total = response.total;
-        this.loading = false;
-
-      });
-    },
-
-    // 取消按钮
-    cancel() {
-      this.open = false;
-      this.reset();
-    },
-    // 表单重置
-    reset() {
-      this.form = {
-        id: null,
-        userId: null,
-        realName: null,
-        phone: null,
-        province: null,
-        city: null,
-        district: null,
-        cityIds: null,
-        detail: null,
-        postCode: null,
-        longitude: null,
-        latitude: null,
-        isDefault: null,
-        isDel: null,
-        createTime: null,
-        updateTime: null
-      };
-      this.address=null;
-      this.cityIds=[];
-      this.resetForm("form");
-    },
-    getCitys(){
-        getCitys().then(res => {
-          this.citys=res.data;
-        })
-    },
-    /** 搜索按钮操作 */
-    handleQuery() {
-      this.queryParams.pageNum = 1;
-      this.getList();
-    },
-    /** 重置按钮操作 */
-    resetQuery() {
-      this.resetForm("queryForm");
-      this.handleQuery();
-    },
-    // 多选框选中数据
-    handleSelectionChange(selection) {
-      this.ids = selection.map(item => item.id)
-      this.single = selection.length!==1
-      this.multiple = !selection.length
-    },
-    handleCityChange(value) {
-      var nodes=this.$refs.citySelect.getCheckedNodes();
-      this.cityIds=value.toString();
-      this.form.province=nodes[0].pathLabels[0];
-      this.form.city=nodes[0].pathLabels[1];
-      this.form.district=nodes[0].pathLabels[2];
-    },
-
-    sAddress(){
-
-      getAddress(this.address).then(response => {
-
-        var addressJson = response.data;
-        this.msgSuccess(addressJson.reason);
-        this.form.province=addressJson.data.provinceName;
-        this.form.city=addressJson.data.cityName;
-        this.form.district=addressJson.data.expAreaName;
-        this.form.detail=addressJson.data.streetName+addressJson.data.address;
-        this.form.realName=addressJson.data.name;
-        this.form.phone=addressJson.data.mobile;
-
-        var province= this.citys.find(function(o) {
-           return o.label ==addressJson.data.provinceName ;
-         });
-         var city= province.children.find(function(o) {
-            return o.label == addressJson.data.cityName;
-          });
-        var district= city.children.find(function(o) {
-             return o.label == addressJson.data.expAreaName;
-           });
-        this.cityIds=[province.value,city.value,district.value]
-
-      });
-    },
-
-
-    /** 新增按钮操作 */
-    handleAdd() {
-      this.reset();
-      this.open = true;
-      this.title = "添加用户地址";
-    },
-    /** 修改按钮操作 */
-    handleUpdate(row) {
-      this.reset();
-      const addressId = row.id || this.ids
-      getUserAddress(addressId).then(response => {
-        this.form = response.data;
-        var province= this.citys.find(function(o) {
-           return o.label ==response.data.province ;
-         });
-         var city= province.children.find(function(o) {
-            return o.label == response.data.city;
-          });
-          var district= city.children.find(function(o) {
-             return o.label == response.data.district;
-           });
-        if(this.form.isDefault!=null){
-           this.form.isDefault = String(this.form.isDefault)
-        }
-        this.cityIds=[province.value,city.value,district.value]
-        this.open = true;
-        this.title = "修改用户地址";
-      });
-    },
-    /** 提交按钮 */
-    submitForm() {
-      this.$refs["form"].validate(valid => {
-        if (valid) {
-          if(this.form.city==null||this.form.province==null||this.form.district==null){
-           return this.msgSuccess("省市区不能为空");
-          }
-          if (this.form.id != null) {
-            updateUserAddress(this.form).then(response => {
-              this.msgSuccess("修改成功");
-              this.open = false;
-              this.getList();
-            });
-          } else {
-            this.form.userId=this.queryParams.userId
-            addUserAddress(this.form).then(response => {
-              this.msgSuccess("新增成功");
-              this.open = false;
-              this.getList();
-            });
-          }
-        }
-      });
-    },
-    /** 删除按钮操作 */
-    handleDelete(row) {
-      const addressIds = row.id || this.ids;
-      this.$confirm('是否确认删除用户地址编号为"' + addressIds + '"的数据项?', "警告", {
-          confirmButtonText: "确定",
-          cancelButtonText: "取消",
-          type: "warning"
-        }).then(function() {
-          return delUserAddress(addressIds);
-        }).then(() => {
-          this.getList();
-          this.msgSuccess("删除成功");
-        }).catch(() => {});
-    },
-    /** 导出按钮操作 */
-    handleExport() {
-      const queryParams = this.queryParams;
-      this.$confirm('是否确认导出所有用户地址数据项?', "警告", {
-          confirmButtonText: "确定",
-          cancelButtonText: "取消",
-          type: "warning"
-        }).then(() => {
-          this.exportLoading = true;
-          return exportUserAddress(queryParams);
-        }).then(response => {
-          this.download(response.msg);
-          this.exportLoading = false;
-        }).catch(() => {});
-    }
-  }
-};
-</script>