|
|
@@ -38,7 +38,7 @@
|
|
|
<view class="message-time">{{ message.time }}</view>
|
|
|
</view>
|
|
|
|
|
|
- <view v-if="message.messageType == 'goods'" class="message-content-wrapper">
|
|
|
+ <view v-if="message.messageType == 'goods'" class="goods-content-wrapper">
|
|
|
<view class="username align-right" v-if="isMultiUser">{{
|
|
|
message.username
|
|
|
}}</view>
|
|
|
@@ -52,19 +52,21 @@
|
|
|
<!-- <view class="sales-info">
|
|
|
<text class="delivery-time">48小时发</text>
|
|
|
</view> -->
|
|
|
- <!-- 2 是报价类型,专门为报价类型使用 -->
|
|
|
- <text v-if="message.goodsInfo.goodsPriceType == 2" class="goods-price">¥{{ message.goodsInfo.goodsPrice }}</text>
|
|
|
+ <!-- 2 是报价类型,专门为报价类型使用 -->
|
|
|
+ <text v-if="message.goodsInfo.goodsPriceType == 2" class="goods-price">¥{{ parseFloat(message.goodsInfo.goodsPrice).toFixed(2) }}</text>
|
|
|
</view>
|
|
|
</view>
|
|
|
+
|
|
|
<view class="goods-footer">
|
|
|
</view>
|
|
|
+
|
|
|
<view v-if="message.goodsInfo.goodsPriceType == 2" class="action-buttons">
|
|
|
<button class="action-btn spec-btn" @click="toBuy(message.goodsInfo)">查看商品</button>
|
|
|
<button class="action-btn buy-btn" @click="toBuy(message.goodsInfo)">去购买</button>
|
|
|
</view>
|
|
|
- <view v-else>
|
|
|
+ <view v-else class="action-buttons">
|
|
|
<button class="action-btn spec-btn" @click="toGoodsDetail(message.goodsInfo)">查看商品</button>
|
|
|
- <text>报价 {{ message.goodsInfo.goodsInfo.price }}</text>
|
|
|
+ <button v-if="message.goodsInfo.goodsPriceType == 1" class="action-btn buy-btn" @click="toBuy(message.goodsInfo)">去购买</button>
|
|
|
</view>
|
|
|
</view>
|
|
|
<view class="message-time align-right">{{ message.time }}</view>
|
|
|
@@ -74,15 +76,13 @@
|
|
|
<!-- 右侧消息(我的) -->
|
|
|
<view class="message-right" v-if="message.isMine || message.customId">
|
|
|
<view v-if="message.messageType == 'text'|| message.messageType != 'goods'" class="message-content-wrapper">
|
|
|
- <view class="username align-right" v-if="isMultiUser">{{
|
|
|
- message.username
|
|
|
- }}</view>
|
|
|
+ <view class="username align-right" v-if="isMultiUser">{{ message.username}}</view>
|
|
|
<view class="message-bubble right-bubble">
|
|
|
<text class="message-text">{{ message.message }}</text>
|
|
|
</view>
|
|
|
<view class="message-time align-right">{{ message.time }}</view>
|
|
|
</view>
|
|
|
- <view v-if="message.messageType == 'goods'" class="message-content-wrapper">
|
|
|
+ <view v-if="message.messageType == 'goods'" class="goods-content-wrapper">
|
|
|
<view class="username align-right" v-if="isMultiUser">{{
|
|
|
message.username
|
|
|
}}</view>
|
|
|
@@ -100,7 +100,7 @@
|
|
|
<view class="sales-info">
|
|
|
<!-- <text class="delivery-time">48小时发</text> -->
|
|
|
</view>
|
|
|
- <text v-if="message.goodsInfo.goodsPriceType == 1" class="goods-price">¥{{ message.goodsInfo.goodsPrice }}</text>
|
|
|
+ <text v-if="message.goodsInfo.goodsPriceType == 1" class="goods-price">¥{{ parseFloat(message.goodsInfo.goodsPrice).toFixed(2) }}</text>
|
|
|
</view>
|
|
|
</view>
|
|
|
<view class="goods-footer">
|
|
|
@@ -134,7 +134,7 @@
|
|
|
<image class="goods-image" :src="currentGoodsInfo.goodsImg" mode="aspectFill" />
|
|
|
<view class="goods-details">
|
|
|
<text class="goods-name">{{ currentGoodsInfo.goodsName }}</text>
|
|
|
- <text v-if="currentGoodsInfo.goodsPriceType == 1" class="goods-price">¥{{ currentGoodsInfo.goodsPrice }}</text>
|
|
|
+ <text v-if="currentGoodsInfo.goodsPriceType == 1" class="goods-price">¥{{ parseFloat(currentGoodsInfo.goodsPrice).toFixed(2) }}</text>
|
|
|
</view>
|
|
|
<view class="goods-actions">
|
|
|
<view class="close-icon" @click="closeGoodsCard">
|
|
|
@@ -229,7 +229,7 @@ export default {
|
|
|
};
|
|
|
},
|
|
|
onLoad(options) {
|
|
|
- console.log("---------- options: ", options);
|
|
|
+ // console.log("---------- options: ", options);
|
|
|
|
|
|
if (options.goodsId) {
|
|
|
this.currentGoodsInfo = {
|
|
|
@@ -278,7 +278,7 @@ export default {
|
|
|
this.room = "default_room";
|
|
|
}
|
|
|
|
|
|
- console.log("---------- this.room: ", this.room);
|
|
|
+ // console.log("---------- this.room: ", this.room);
|
|
|
|
|
|
// 加载聊天记录
|
|
|
this.loadChatHistory();
|
|
|
@@ -308,7 +308,6 @@ export default {
|
|
|
},
|
|
|
onUnload() {
|
|
|
// 页面卸载时关闭WebSocket连接
|
|
|
- this.isManualDisconnect = true; // 标记为主动断开
|
|
|
this.disconnectWebSocket();
|
|
|
},
|
|
|
onHide() {
|
|
|
@@ -473,7 +472,9 @@ export default {
|
|
|
// 只有在非主动断开的情况下才尝试重连
|
|
|
if (!this.isManualDisconnect && this.reconnectCount < this.maxReconnectCount) {
|
|
|
setTimeout(() => {
|
|
|
- this.reconnectWebSocket();
|
|
|
+ if (!this.isManualDisconnect) {
|
|
|
+ this.reconnectWebSocket();
|
|
|
+ }
|
|
|
}, 3000);
|
|
|
}
|
|
|
|
|
|
@@ -542,7 +543,6 @@ export default {
|
|
|
|
|
|
// 验证协议字符串的合法性
|
|
|
const isValid = this.validateProtocols(protocols);
|
|
|
- console.log("协议验证结果:", isValid);
|
|
|
if (!isValid) {
|
|
|
this.$msg("协议验证失败");
|
|
|
return;
|
|
|
@@ -575,7 +575,7 @@ export default {
|
|
|
console.error("协议长度超限:", protocol.length);
|
|
|
return false;
|
|
|
}
|
|
|
- console.log('protocal -- ', protocol, protocol.length)
|
|
|
+ // console.log('protocal -- ', protocol, protocol.length)
|
|
|
}
|
|
|
|
|
|
return true;
|
|
|
@@ -756,7 +756,7 @@ export default {
|
|
|
|
|
|
// 处理WebSocket消息
|
|
|
handleWebSocketMessage(data) {
|
|
|
- console.log("---------- data: ", data);
|
|
|
+ // console.log("---------- data: ", data);
|
|
|
try {
|
|
|
// 尝试解析JSON,如果失败则认为是纯文本消息
|
|
|
let messageData;
|
|
|
@@ -800,7 +800,7 @@ export default {
|
|
|
newMessage.goodsInfo = this.parseGoodsMessage(messageData.message, messageData.timestamp);
|
|
|
}
|
|
|
|
|
|
- console.log("收到 ---------- newMessage: ", newMessage);
|
|
|
+ // console.log("收到 ---------- newMessage: ", newMessage);
|
|
|
// 添加到消息列表
|
|
|
this.messageList.push(newMessage);
|
|
|
|
|
|
@@ -871,7 +871,7 @@ export default {
|
|
|
};
|
|
|
|
|
|
const json = JSON.stringify(messageData);
|
|
|
- console.log("send ---------- json: ", json);
|
|
|
+ // console.log("send ---------- json: ", json);
|
|
|
// 发送到WebSocket服务器
|
|
|
this.socket.send({
|
|
|
data: json,
|
|
|
@@ -930,7 +930,7 @@ export default {
|
|
|
|
|
|
// 输入框聚焦事件
|
|
|
onInputFocus() {
|
|
|
- console.log('输入框聚焦');
|
|
|
+ // console.log('输入框聚焦');
|
|
|
// 微信小程序中,聚焦时延迟滚动到底部
|
|
|
setTimeout(() => {
|
|
|
this.scrollToBottom();
|
|
|
@@ -939,7 +939,7 @@ export default {
|
|
|
|
|
|
// 输入框失焦事件
|
|
|
onInputBlur() {
|
|
|
- console.log('输入框失焦');
|
|
|
+ // console.log('输入框失焦');
|
|
|
},
|
|
|
|
|
|
// 输入内容变化事件
|
|
|
@@ -1025,7 +1025,7 @@ export default {
|
|
|
this.socket.send({
|
|
|
data: json,
|
|
|
success: () => {
|
|
|
- console.log("商品消息发送成功");
|
|
|
+ // console.log("商品消息发送成功");
|
|
|
},
|
|
|
fail: (error) => {
|
|
|
console.error("商品消息发送失败:", error);
|
|
|
@@ -1093,7 +1093,7 @@ export default {
|
|
|
if (res.code == 1) {
|
|
|
if (res.data.price != -1) {
|
|
|
parsed.goodsPriceType = 2; // 报价类型
|
|
|
- parsed.goodsPrice = res.data.price;
|
|
|
+ parsed.goodsPrice = parseFloat(res.data.price).toFixed(2);
|
|
|
}
|
|
|
}
|
|
|
}).catch(err => {
|
|
|
@@ -1117,7 +1117,7 @@ export default {
|
|
|
// 查看商品
|
|
|
toGoodsDetail(goodsInfo) {
|
|
|
this.disconnectWebSocket();
|
|
|
- console.log("---------- goodsInfo: ", goodsInfo);
|
|
|
+ // console.log("---------- goodsInfo: ", goodsInfo);
|
|
|
const goodsId = parseInt(goodsInfo.goodsId);
|
|
|
const categoryId = parseInt(goodsInfo.categoryId);
|
|
|
const hdId = parseInt(goodsInfo.hdId);
|
|
|
@@ -1143,12 +1143,12 @@ export default {
|
|
|
// 去购买
|
|
|
toBuy(goodsInfo) {
|
|
|
this.disconnectWebSocket();
|
|
|
- console.log("---------- goodsInfo: ", 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);
|
|
|
- const price = parseFloat(goodsInfo.goodsPrice);
|
|
|
+ const price = parseFloat(goodsInfo.goodsPrice).toFixed(2);
|
|
|
const priceType = goodsInfo.goodsPriceType;
|
|
|
if (isNaN(goodsId) || isNaN(categoryId) || isNaN(hdId) || isNaN(account) || isNaN(price)) {
|
|
|
this.$msg("商品数据异常");
|
|
|
@@ -1326,6 +1326,10 @@ export default {
|
|
|
min-width: 100upx;
|
|
|
}
|
|
|
|
|
|
+.goods-content-wrapper {
|
|
|
+ width: 72%;
|
|
|
+}
|
|
|
+
|
|
|
.username {
|
|
|
font-size: 24upx;
|
|
|
color: $fontColor3;
|