websocket
socket文件:shop-index/common/socket.js
链接:ws://ping3.wu1949.com:22222
把git代码拉下来
连接聊天室
---
// 改变接收消息的方法
this.$socket.websock.onmessage = this.websocketonmessage;
// 连接聊天室
var obj = {};
obj.scene = 'joinChatRoom';
this.$socket.websocketsend(obj);
退出聊天室
---
// 退出聊天室
var obj = {};
obj.scene = 'exitChatRoom';
this.$socket.websocketsend(obj);
// 改变接收消息的方法
this.$socket.websock.onmessage = this.$socket.websock.websocketonmessage;
// 发送聊天室消息
---
// 发送聊天室消息
var obj = {};
obj.promotionId = 100015; // 用户推广id
obj.scene = 'sendChatRoom';
obj.msgType = 'text'; // text文字 image图片
obj.message = this.textMsg; // 发送消息 文字 图片id
this.$socket.websocketsend(obj);
接收聊天信息
---
status: 1 // 0 失败 1成功
message: "" // 提示信息
data: [
head_portrait: "/uploads/member/20201110/37b29ffc2a04388975cdecd4f892be70.png" // 用户头像
message: "叫小姐姐" // 接收到的消息
msgType: "text" // text文字 image图片
promotionId: 100015 // 用户推广id
username: "不失优雅" // 用户昵称
]
连接拍卖室
---
var _this = this;
setTimeout(function(){
// 改变接收消息的方法
_this.$socket.websock.onmessage = _this.websocketonmessage;
// 连接拍卖室 还在拍卖中的商品才连上去
var obj = {};
obj.scene = 'joinAuction';
obj.auctionId = _this.goodsInfo.id; // 拍卖id
_this.$socket.websocketsend(obj);
}, 1000)
退出拍卖室
---
// 退出拍卖室
var obj = {};
obj.scene = 'exitAuction';
this.$socket.websocketsend(obj);
// 改变接收消息的方法
this.$socket.websock.onmessage = this.$socket.websock.websocketonmessage;
// 发送出价信息
var obj = {};
obj.promotionId = _this.promotionId; // 用户推广id
obj.scene = 'sendAuction';
obj.auctionId = _this.goodsInfo.id; // 拍卖id
obj.offerId = res.data.offer.id; // 出价id
_this.$socket.websocketsend(obj);
接收出价信息
---
status: 1 // 0 失败 1成功
message: "" // 提示信息
data:[
auction: [
current_price: "62.00" // 当前出价金额
id: 6 // 竞拍id
status: 1 // 状态 1拍卖中 2拍卖结束 3已关闭
]
offer: [
head_portrait: "/uploads/setting/20200929/d0d36a0559f0b4e440ba9ac974ccf7b6.png" // 用户头像
is_photographed: 0
offer_amount: 62 // 出价金额
username: "嘿嘿嘿" // 用户昵称
]
]
1、用户出价后,其它用户收到最新的出价,显示在出价最新出价人列表,出价金额变成最新出价+1
2、出价后,出价接口返回出价人的信息,显示在出价最新出价人列表