shizhongqi 11 месяцев назад
Родитель
Сommit
bebf0822d6

+ 53 - 9
hdApp/src/admin/chat/chatPage.vue

@@ -1,7 +1,7 @@
 <template>
   <view class="chat-container">
     <!-- 连接状态指示器 -->
-    <view class="connection-status" v-if="!isConnected">
+    <view class="connection-status" v-if="!isConnected && !isManualDisconnect">
       <text class="status-text">{{ '连接中...' }}</text>
     </view>
 
@@ -66,6 +66,14 @@
               <view v-else>
                 <text v-if="message.goodsInfo.goodsPriceType == 0">报价窗口期已过,无法报价</text>
               </view>
+              <!-- 报价类型显示重新报价 -->
+              <view v-if="message.goodsInfo.goodsPriceType == 2 && isExpired(message.timestamp)" class="action-buttons">
+                <form @submit.prevent="createQrotedPrice(message)">
+                  <text class="goods-price" v-if="message.goodsInfo.lastPrice || message.goodsInfo.goodsPrice">¥{{message.goodsInfo.lastPrice || message.goodsInfo.goodsPrice}}</text>
+                  <input class="price-input" type="number" v-model="message.quotedPrice" placeholder="输入价格" />
+                  <button class="action-btn buy-btn" form-type="submit">重新报价</button>
+                </form>
+              </view>
             </view>
             <view class="message-time align-right">{{ message.time }}</view>
           </view>
@@ -109,9 +117,9 @@
               </view>
               <view class="action-buttons">
                 <button class="action-btn spec-btn" @click="toGoodsDetail(message.goodsInfo)">查看商品</button>
-                <button v-if="message.goodsInfo.goodsPriceType == 1" class="action-btn buy-btn" click="toBuy">去购买</button>
+                <!-- <button v-if="message.goodsInfo.goodsPriceType == 1" class="action-btn buy-btn" @click="toBuy">去购买</button> -->
                 <!-- 报价类型显示去购买 -->
-                <button v-if="message.goodsInfo.goodsPriceType == 2" class="action-btn buy-btn" click="toBuy">去购买</button>
+                <!-- <button v-if="message.goodsInfo.goodsPriceType == 2" class="action-btn buy-btn" @click="toBuy">去购买</button> -->
               </view>
             </view>
             <view class="message-time align-right">{{ message.time }}</view>
@@ -1008,16 +1016,20 @@ export default {
         });
       }
     },
-    createQrotedPrice(goodsInfo) {
-      console.log("createPrice", goodsInfo)
+    createQrotedPrice(message) {
+      console.log("createPrice", message)
       createQuotedPrice({
-        key: goodsInfo.goodsInfo.key,
-        price: goodsInfo.quotedPrice,
+        key: message.goodsInfo.key,
+        price: message.quotedPrice,
       }).then(res => {
         console.log("createQuotedPrice", res)
         if (res.code == 1) {
           this.$msg("报价成功")
-          this.sendMessageOfGoodsPrice(goodsInfo.goodsInfo)
+          message.goodsInfo.goodsPriceType = 2;
+          message.goodsInfo.goodsPrice = message.quotedPrice;
+          message.goodsInfo.lastPrice = message.quotedPrice;
+          message.quotedPrice = '';
+          this.sendMessageOfGoodsPrice(message.goodsInfo)
         }
       }).catch(err => {
         console.log("createQuotedPrice error", err)
@@ -1030,6 +1042,32 @@ export default {
       const now = Math.floor(Date.now()/1000);
       const timeDiff = now - timestamp;
       return timeDiff < this.expireTime;
+    },
+    // 查看商品
+    toGoodsDetail(goodsInfo) {
+      // console.log("---------- goodsInfo: ", goodsInfo);
+      const goodsId = parseInt(goodsInfo.goodsId);
+      const categoryId = parseInt(goodsInfo.categoryId);
+      const hdId = parseInt(goodsInfo.hdId);
+      const account = parseInt(goodsInfo.account);
+      if (isNaN(goodsId) || isNaN(categoryId) || isNaN(hdId) || isNaN(account)) {
+        this.$msg("商品数据异常");
+        return;
+      }
+
+      this.$util.pageTo({
+        url: "/admin/goods/detail",
+        query: { // id=2020&categoryId=1402&hdId=229&account=36548&shopId=36548&name=花仙子&avatar=https://img.theflorist.cn/hhb_small.png
+          id: goodsId,
+          account: goodsInfo.account,
+          hdId: goodsInfo.hdId,
+          categoryId: categoryId,
+          shopId: goodsInfo.shopId,
+          name: goodsInfo.name,
+          avatar: goodsInfo.avatar,
+        },
+      });
+      this.disconnectWebSocket();
     }
   },
 };
@@ -1260,7 +1298,7 @@ export default {
     .price-input {
       display: inline-block;
       vertical-align: middle;
-      width: 180rpx;
+      width: 160rpx;
       height: 60rpx;
       border: 1px solid #666666;
       border-radius: 8rpx;
@@ -1289,6 +1327,12 @@ export default {
       background-color: #ff9800;
       color: white;
     }
+    .goods-price {
+      font-size: 26rpx;
+      color: #ff5050;
+      font-weight: bold;
+      margin-right: 10rpx;
+    }
   }
 }
 

+ 2 - 2
mallApp/src/pages/chat/chatPage.vue

@@ -1,7 +1,7 @@
 <template>
   <view class="chat-container">
     <!-- 连接状态指示器 -->
-    <view class="connection-status" v-if="!isConnected">
+    <view class="connection-status" v-if="!isConnected && !isManualDisconnect">
       <text class="status-text">"连接中...</text>
     </view>
 
@@ -1105,7 +1105,7 @@ export default {
         // 如果两者都不是,返回空对象
         return {};
       } catch (error) {
-        // console.error("解析商品消息失败:", error, messageStr);
+        console.error("解析商品消息失败:", error, messageStr);
         // 在解析失败时返回一个包含默认值的对象,以避免模板渲染错误
         return {
           goodsImg: "",

+ 1 - 1
mallApp/src/pages/goods/components/buy-foot.vue

@@ -19,7 +19,7 @@
         <div class="btn-right">
             <button v-if="priceType == 1" class="button-com red" @click="buy">购买</button>
             <button v-if="priceType == 2" class="button-com red" @click="buy">购买</button>
-            <button v-else class="button-com red" @click.stop="goChat">询价</button>
+            <button v-if="priceType == 0" class="button-com red" @click.stop="goChat">询价</button>
         </div>
     </view>
 </template>

+ 1 - 1
mallApp/src/pages/home/recent.vue

@@ -250,6 +250,7 @@ export default {
   onShow() {
     if (!this.$util.isEmpty(this.loginInfo)) {
       this.loginStyle = 1;
+      this.getUnReadMsgCount()
     } else {
       this.loginStyle = 0;
     }
@@ -257,7 +258,6 @@ export default {
       this.init();
       this.pageAction.refresh == 0;
     }
-    this.getUnReadMsgCount()
   },
   onPullDownRefresh() {
     this.resetList();