Sfoglia il codice sorgente

修改房产聊天

suyuanyuan 2 giorni fa
parent
commit
618bf1833a

+ 7 - 4
TUIKit-House/components/TUIChat/index.vue

@@ -20,7 +20,7 @@
           @closeChat="closeChat"
         />
         <Forward />
-      
+
         <MessageList
           :address="address"
           ref="messageListRef"
@@ -136,10 +136,9 @@ onMounted(() => {
 });
 
 const initData = () => {
-
   let data = {
     shopUserId: getParamValue("shopUserId"),
-    userId: getParamValue("recruitUserId") || getParamValue("userId") ,
+    userId: getParamValue("recruitUserId") || getParamValue("userId"),
     houseId: getParamValue("houseId"),
   };
   let url = config.baseUrl + "/house/communicate/status";
@@ -155,7 +154,11 @@ const initData = () => {
     header: header,
     data: data,
     success: function (res) {
-      infoData.value = res.data.data;
+      let data = res.data.data;
+      data.isShowSeeHouseBtn = getParamValue("isShowSeeHouseBtn");
+      data.flag = getParamValue("flag");
+      infoData.value = data;
+      console.log("infoData", infoData);
     },
   });
 };

+ 5 - 2
TUIKit-House/components/TUIChat/message-list/index.vue

@@ -30,9 +30,9 @@
             <!-- 对方为用户显示预约看房按钮 -->
             <div
               @tap="sendMsgHandle('预约看房')"
-              v-if="infoData.agentId === '0' || loginType == 1"
+              v-if="(!infoData.flag && (userType === 0 || loginType == 1)) || (infoData.flag  && infoData.isShowSeeHouseBtn == 'true')"
             >
-              <!-- 电话沟通按钮状态根据是否聊过天判断,接受按钮根据是否发送面试邀请判断 -->
+              <!-- 电话沟通按钮状态根据是否聊过天判断 -->
               <template v-if="messageList && messageList.length > 0">
                 <img
                   src="https://qianzhiy-applet.oss-rg-china-mainland.aliyuncs.com/h5/images/house/icon/chat-icon5-active.png"
@@ -391,6 +391,8 @@ const messageTarget = ref<IMessageModel>();
 const scrollButtonInstanceRef = ref<InstanceType<typeof ScrollButton>>();
 const historyFirstMessageID = ref<string>("");
 let selfAddValue = 0;
+const userType = Number(uni.getStorageSync("userType"));
+console.log("userType:" + userType)
 
 // audio control
 const broadcastNewAudioSrc = ref<string>("");
@@ -429,6 +431,7 @@ const ShowDialogClose = () => {
   showDialog.value = false;
 };
 const loginType = ref(uni.getStorageSync("loginType"));
+console.log("loginType:" + loginType)
 onMounted(() => {
   // 消息列表监听
   TUIStore.watch(StoreName.CHAT, {

+ 6 - 4
TUIKit-House/components/TUIConversation/index.vue

@@ -51,17 +51,19 @@ TUIStore.watch(StoreName.CUSTOM, {
 });
 
 const handleSwitchConversation = (conversationID: string) => {
- let companyUserId =
-    conversationID[3] === 'C'
+  let companyUserId =
+    conversationID[3] === "C"
       ? conversationID.substring(4)
       : conversationID.substring(3);
-
+  //普通用户:判断会话Id第4位是不是C,带C是普通用户和商家的会话进入聊天页面不显示预约看房按钮,不带C是普通用户和普通用户的会话进入聊天页面显示预约看房按钮
+  // flag从会话列表中跳入的加一个标识
+  let isShowSeeHouseBtn = conversationID[3] === "C" ? false : true;
   TUIGlobal?.navigateTo({
     url:
       "/TUIKit-House/components/TUIChat/index?shopUserId=" +
       companyUserId +
       "&userId=" +
-      uni.getStorageSync("userId"),
+      uni.getStorageSync("userId") + "&isShowSeeHouseBtn=" + isShowSeeHouseBtn + "&flag=1",
   });
   emits("handleSwitchConversation", conversationID);
 };

+ 1 - 1
TUIKit/components/TUIChat/message-list/index.vue

@@ -384,7 +384,7 @@ const ShowDialogClose = () => {
 const loginType = ref(uni.getStorageSync("loginType"));
 onMounted(() => {
   let loginType = uni.getStorageSync("loginType");
-  if (loginType) {
+  if (loginType > 0) {
     chatFunctionList.value = [
       {
         icon: require("@/static/images/icon/chat-icon1.png"),

+ 3 - 1
loginChat.ts

@@ -24,6 +24,7 @@ export const loginChat = (loginInfo) => {
       const shopUserId = uni.getStorageSync("shopUserId");
       const userLoginType = uni.getStorageSync("userLoginType");
       const userId = uni.getStorageSync("userId"); // 修复此处错误
+      const userType = uni.getStorageSync("userType");
       // 异步保存用户信息
       uni.setStorage({
         key: "userInfo",
@@ -40,9 +41,10 @@ export const loginChat = (loginInfo) => {
         // 构建 conversationId
         // userTypeNum>0为商家向用户发  商家的IMID默认接收到的就是带ABC的ID
         // userTypeNum<=0时为用户像商家发 用户向商家发 需要进入商家的会话,商家的会话时商家的imID需要带ABCD
+        // usertype:0 此房源为普通用户身份发布, 会话id中不带C,usertype:1 此房源为商家身份发布, 会话id中带C
         const conversationMap = {
           job: `C2C${userTypeNum > 0 ? recruitUserId : "A" + companyUserId}`,
-          house: `C2C${userTypeNum > 0 ? shopUserId : "C" + shopUserId}`,
+          house: `C2C${userTypeNum > 0 ? shopUserId : userType > 0 ? "C" + shopUserId : shopUserId}`,
           homemaking: `C2C${userTypeNum > 0 ? shopUserId : "E" + shopUserId}`,
         };
 

+ 1 - 0
pages/views/login.vue

@@ -25,6 +25,7 @@ onLoad(() => {
     "refId",
     "demandId",
     "userLoginType",
+    "userType"
   ];
   // 批量获取参数并存储到storage
   const params: any = {};