Selaa lähdekoodia

企微聊天 发送小程序消息

Long 1 viikko sitten
vanhempi
commit
3bb2470dfb
2 muutettua tiedostoa jossa 21 lisäystä ja 48 poistoa
  1. 16 25
      src/views/qw/qwChat/qq.vue
  2. 5 23
      src/views/qw/qwChat/userDetail/index.vue

+ 16 - 25
src/views/qw/qwChat/qq.vue

@@ -43,10 +43,18 @@
             />
           </div>
         </template>
-        <template #message-title>
+        <template #message-title="contact">
 <!--          <div @click="openDrawer('right')" style="position: absolute;right: 14px;top: 10px;">-->
 <!--            <i class="el-icon-more" style="cursor: pointer"/>-->
 <!--          </div>-->
+          <div>
+            <el-button
+              type="primary"
+              size="small"
+              style="position: absolute;right: 14px;top: 10px;z-index: 1000"
+              @click="showDetail(contact.extId)"
+            >详情</el-button>
+          </div>
         </template>
       </lemon-imui>
     </div>
@@ -187,7 +195,6 @@ export default {
     },
     shareCourse(nv) {
       if (nv) {
-        console.log('shareCourse', nv)
         // 发送小程序卡片消息
         const IMUI = this.$refs.IMUI;
         const contact = IMUI.currentContact;
@@ -197,28 +204,14 @@ export default {
 
         // 创建消息对象
         let message = {
-          id: generateUUID(),
-          status: 'going',
           type: 'miniprogram',
-          sendTime: Date.now(),
-          content: {
-            appid: nv.miniprogramAppid,
-            pagepath: nv.miniprogramPage,
-            title: nv.miniprogramTitle,
-            thumbnail: nv.miniprogramPicUrl
-          },
+          content: nv,
           toContactId: contact.conversationId,
-          fromUser: {
-            id: this.qwUser.id,
-            displayName: this.qwUser.qwUserName,
-            avatar: "https://cos.his.cdwjyyh.com/fs/20241231/22a765a96da247d1b83ea94fef438a41.png"
-          },
         };
 
         this.detail.open = false
         this.$store.dispatch('qwIm/shareCourse', null)
 
-        this.appendRemoteMessage(message)
         // 使用handleSend方法发送消息
         this.handleSend(
           message,
@@ -399,7 +392,7 @@ export default {
             this.appendRemoteMessage(data)
             let conversation = IMUI.findConversation(message.toContactId);
             conversation.lastSendTime = message.sendTime;
-            conversation.lastContent = message.content;
+            conversation.lastContent = IMUI.lastContentRender(message)
             IMUI.topPopConversations(conversation);
             next();
           } else {
@@ -420,7 +413,7 @@ export default {
               if(code === 200){
                 let conversation = IMUI.findConversation(message.toContactId);
                 conversation.lastSendTime = message.sendTime;
-                conversation.lastContent = message.content;
+                conversation.lastContent = IMUI.lastContentRender(message)
                 IMUI.topPopConversations(conversation);
                 next();
               } else {
@@ -436,19 +429,17 @@ export default {
         params = {
           "sessionId": message.toContactId,
           "appKey": this.qwUser.appKey,
-          "content": JSON.stringify(message.content),
+          "content": message.content,
           "msgType": 5 // 小程序消息类型
         };
         sendMsg(params).then(response => {
-          const {code} = response
+          const {code, data} = response
           if(code === 200){
+            this.appendRemoteMessage(data)
             let conversation = IMUI.findConversation(message.toContactId);
             conversation.lastSendTime = message.sendTime;
-            conversation.lastContent = "小程序";
+            conversation.lastContent = IMUI.lastContentRender(message)
             IMUI.topPopConversations(conversation);
-            next && next();
-          } else {
-            next && next({status:'failed'})
           }
         });
       }

+ 5 - 23
src/views/qw/qwChat/userDetail/index.vue

@@ -102,8 +102,11 @@
         </div>
         <!-- 近七天看课记录 -->
         <div>
-          <div class="section-title">
-            近七天看课记录
+          <div style="display: flex;justify-content: space-between;align-items: center;flex-direction: row;background: #FFF;padding: 10px 0 20px 0">
+            <div class="section-title">
+              近七天看课记录
+            </div>
+            <el-button size="mini" round @click="courseManage">课程管理</el-button>
           </div>
           <div class="course-record-container">
             <div
@@ -125,27 +128,6 @@
         </div>
       </div>
 
-      <!-- 按钮 -->
-      <div>
-        <div style="display: flex;justify-content: space-evenly;align-items: center;flex-direction: row;background: #FFF;padding: 10px 0 20px 0">
-          <div>
-            <el-button style="width: 150px;height: 35px;background-color: #1890ff;color: #fff;border: none;
-              border-radius: 22px;
-              font-size: 12px;
-              cursor: pointer;
-              transition: background 0.2s;"
-              @click="courseManage">课程管理</el-button>
-          </div>
-          <div>
-            <el-button style="width: 150px;height: 35px;background-color: #1890ff;color: #fff;border: none;
-              border-radius: 22px;
-              font-size: 12px;
-              cursor: pointer;
-              transition: background 0.2s;"
-              @click="remindCourseManage">催课管理</el-button>
-          </div>
-        </div>
-      </div>
     </div>
 
     <!-- 修改用户信息 -->