更改动态导航栏
This commit is contained in:
397
common/js/api.js
Normal file
397
common/js/api.js
Normal file
@@ -0,0 +1,397 @@
|
||||
export default {
|
||||
userwxlogin(data) { //登录
|
||||
return uni.api.post("/login/auth/custom/login", data);
|
||||
},
|
||||
loginwxuserInfo(data) { //获取用户详情
|
||||
return uni.api.get("/login/userInfo", data,false);
|
||||
},
|
||||
userwxlogins(data) { // 获取手机号
|
||||
console.log(data)
|
||||
return uni.api.post("/login/getPhoneNumber", data);
|
||||
},
|
||||
getShopExtend(data) { //获取图片 通过shopId和autokey
|
||||
return uni.api.post("/common/shopExtend", data,false);
|
||||
},
|
||||
// 获取弹窗广告列表
|
||||
getPopUpAd(data) {
|
||||
return uni.api.get("/tbShopAd/list", data,false);
|
||||
},
|
||||
logincreateCardNo(data) { //获取会员码
|
||||
return uni.api.get("/login/createCardNo", data);
|
||||
},
|
||||
productqueryShop(data) { //通过桌码获取店铺信息
|
||||
return uni.api.get("/product/queryShop", data);
|
||||
},
|
||||
productChoseCount(data) { //就餐人数选择
|
||||
return uni.api.post("/product/choseCount", data,false);
|
||||
},
|
||||
productqueryProduct(data) { //获取商品信息
|
||||
return uni.api.post("/product/queryProduct", data, false);
|
||||
},
|
||||
productquerySpec(data) { //获取已上架商品规格
|
||||
return uni.api.post("/product/querySpec", data, false);
|
||||
},
|
||||
cartAdd(data) { //添加到购物车
|
||||
return uni.api.post("/product/addCart", data);
|
||||
},
|
||||
cleanCart(data) { //清空购物车
|
||||
return uni.api.post("/product/cleanCart", data);
|
||||
},
|
||||
// 下单详情
|
||||
getproductorderConfirm(data) {
|
||||
return uni.api.get("/product/orderConfirm", data);
|
||||
},
|
||||
// 下单详情
|
||||
getproductorderConfirm(data) {
|
||||
return uni.api.get("/product/orderConfirm", data);
|
||||
},
|
||||
|
||||
choseEatModel(data) { //就餐模式选择
|
||||
return uni.api.post("/product/choseEatModel", data, false);
|
||||
},
|
||||
|
||||
// 支付
|
||||
payOrderPay(data) {
|
||||
return uni.api.post("/pay/groupOrderPay", data);
|
||||
},
|
||||
// 会员支付
|
||||
accountPay(data) {
|
||||
return uni.api.get("/pay/accountPay", data);
|
||||
},
|
||||
orderPay(data) { //订单支付
|
||||
return uni.api.post("/pay/orderPay", data);
|
||||
},
|
||||
cancelOrderPay(data) { //订单支付
|
||||
return uni.api.post("/notify/cancel", data);
|
||||
},
|
||||
|
||||
paymodfiyOrderInfo(data) { //查询订单支付状态
|
||||
return uni.api.post("/pay/modfiyOrderInfo", data);
|
||||
},
|
||||
paymemeberIn(data) { //充值
|
||||
return uni.api.post("/pay/memeberIn", data);
|
||||
},
|
||||
|
||||
|
||||
orderorderList(data) { //订单列表
|
||||
return uni.api.get("/order/orderList", data);
|
||||
},
|
||||
orderorderInfo(data) { //订单回显
|
||||
return uni.api.get("/order/orderInfo", data ,false);
|
||||
},
|
||||
removeOrder(data) { //删除订单
|
||||
return uni.api.post("/order/rmOrder", data);
|
||||
},
|
||||
creatOrder(data) { //创建订单
|
||||
return uni.api.post("/order/creatOrder", data);
|
||||
},
|
||||
useCoupon(data) { //订单选择优惠券
|
||||
return uni.api.post("/order/useCoupon", data);
|
||||
},
|
||||
|
||||
|
||||
// 团购订单列表
|
||||
groupOrderInfo(data) { //订单列表
|
||||
return uni.api.get("/groupOrderInfo/list", data);
|
||||
},
|
||||
|
||||
groupOrderInfoDetail(data) { //订单回显
|
||||
return uni.api.get("/groupOrderInfo/get", data);
|
||||
},
|
||||
// 下单
|
||||
creatGroupOrder(data) {
|
||||
return uni.api.post("/groupOrderInfo/creatGroupOrder", data);
|
||||
},
|
||||
|
||||
|
||||
|
||||
// 获取店铺会员信息
|
||||
shopUserInfo(data) {
|
||||
return uni.api.get("/user/shopUserInfo", data,false);
|
||||
},
|
||||
// 注册会员
|
||||
openMember(data) {
|
||||
return uni.api.post("/user/openMember", data);
|
||||
},
|
||||
// 会员填充手机号
|
||||
upVipPhont(data) {
|
||||
return uni.api.post("/user/upVipPhont", data);
|
||||
},
|
||||
|
||||
|
||||
// 优惠券数量
|
||||
userCoupon(data) {
|
||||
return uni.api.get("/user/userCoupon", data);
|
||||
},
|
||||
// 优惠加倍
|
||||
yhqDouble(data) { //查询订单支付状态
|
||||
return uni.api.post("/order/yhqDouble", data);
|
||||
},
|
||||
// 优惠卷详情
|
||||
getYhqDouble(data) { //通过选中的商品规格查询价格
|
||||
return uni.api.get("/order/getYhqDouble", data);
|
||||
},
|
||||
productqueryProductSku(data) { //通过选中的商品规格查询价格
|
||||
return uni.api.get("/product/queryProductSku", data, false);
|
||||
},
|
||||
logingetPhoneNumber(data) { //小程序获取手机号
|
||||
return uni.api.post("/login/getPhoneNumber", data);
|
||||
},
|
||||
cashierServiceloginregister(data) { //用户注册
|
||||
return uni.api.post("/cashierService/login/register", data);
|
||||
},
|
||||
cashierServiceloginregister(data) { //APP登录
|
||||
return uni.api.post("/login/app/login", data);
|
||||
},
|
||||
phoneValidateCode(data) { //验证码
|
||||
return uni.api.get("/phoneValidateCode", data);
|
||||
},
|
||||
homehomePageUp(data) { //首页上半部分
|
||||
return uni.api.post("/home/homePageUp", data);
|
||||
},
|
||||
home(data) { //首页上半部分
|
||||
return uni.api.post("/home", data, false);
|
||||
},
|
||||
locationdistrict(data) { //获取行政区域(区,街道)
|
||||
return uni.api.get("/location/district", data);
|
||||
},
|
||||
queryMemberAccount(data) { //获取余额明细
|
||||
return uni.api.get("/pay/queryMemberAccount", data);
|
||||
},
|
||||
queryMemberPointsLog(data) { //获取余额明细
|
||||
return uni.api.get("/api/points/member-points-log/page", data);
|
||||
},
|
||||
ordermineCoupons(data) { //我的优惠券
|
||||
return uni.api.get("/order/mineCoupons", data, false);
|
||||
},
|
||||
getUserConpons(data) { //我的优惠券
|
||||
return uni.api.post("/userConpons/find", data);
|
||||
},
|
||||
conponList(data) { //获取优惠券
|
||||
return uni.api.post("/coupon/find", data);
|
||||
},
|
||||
ordergetYhqPara(data) { //获取优惠券参数列表
|
||||
return uni.api.get("/order/getYhqPara", data);
|
||||
},
|
||||
orderfindCoupons(data) { //系统优惠券
|
||||
return uni.api.get("/order/findCoupons", data);
|
||||
},
|
||||
tbPlatformDict(data) { //获取菜单
|
||||
return uni.api.get("/tbPlatformDict", data);
|
||||
},
|
||||
distirictsubShopList(data) { //预约到店(店铺列表)
|
||||
return uni.api.get("/distirict/subShopList", data);
|
||||
},
|
||||
distiricttopCommon(data) { //获取top部分(店铺列表)
|
||||
return uni.api.get("/distirict/topCommon", data);
|
||||
},
|
||||
orderfindWiningUser(data) { //获取免单订单
|
||||
return uni.api.get("/order/findWiningUser", data);
|
||||
},
|
||||
// 获取自己的免单订单
|
||||
ordermineWinner(data) {
|
||||
return uni.api.get("/order/mineWinner", data);
|
||||
},
|
||||
indexlist(data) { //商品列表(今日上新/热榜/咖啡饮品)
|
||||
return uni.api.get("/distirict/productCate", data, false);
|
||||
},
|
||||
productproductInfo(data) { //商品详情
|
||||
return uni.api.get("/product/productInfo", data);
|
||||
},
|
||||
distirictcomShopList(data) { //通用门店列表
|
||||
return uni.api.get("/distirict/comShopList", data);
|
||||
},
|
||||
loginOut(data) { //退出登录
|
||||
return uni.api.post("/login/loginOut", data);
|
||||
},
|
||||
productqueryShopIdByTableCode(data) { //通过桌码获取shopId
|
||||
return uni.api.get("/product/queryShopIdByTableCode", data);
|
||||
},
|
||||
geocodelocation(data) { //根据经纬度获取信息
|
||||
return uni.api.get("/location/geocode", data, false);
|
||||
},
|
||||
// 修改头像和昵称
|
||||
upUserInfo(data) {
|
||||
return uni.api.post("/login/upUserInfo", data);
|
||||
},
|
||||
loginresetPwd(data) { // 重置资金密码
|
||||
return uni.api.post("/login/resetPwd", data);
|
||||
},
|
||||
paygetActive(data) { // 获取充值活动
|
||||
return uni.api.get("/pay/getActive", data);
|
||||
},
|
||||
paygetShopByMember(data) { // 获取会员店铺信息
|
||||
return uni.api.get("/pay/getShopByMember", data, false);
|
||||
},
|
||||
loginmpdifyPwd(data) { // 修改资金密码
|
||||
return uni.api.get("/login/mpdifyPwd", data);
|
||||
},
|
||||
cashierServicesong(data) { // 获取所有歌曲,支持搜索及分页
|
||||
return uni.api.get("/song", data, false);
|
||||
},
|
||||
cashierServicerecord(data) { // 点歌记录
|
||||
return uni.api.get("/song/record", data);
|
||||
},
|
||||
cashierServicesongpost(data) { // 点歌
|
||||
return uni.api.post("/song", data);
|
||||
},
|
||||
businessopenId(data) { // 获取openId
|
||||
return uni.api.get("/login/wx/business/openId", data);
|
||||
},
|
||||
songsinging(data) { // 获取正在演唱的歌曲
|
||||
return uni.api.get("/song/singing", data, false);
|
||||
},
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* 获取排号信息
|
||||
* @param {Object} param
|
||||
*/
|
||||
getQueueUpList(param) {
|
||||
return uni.api.get("/callTable/queue", param);
|
||||
},
|
||||
|
||||
/**
|
||||
* 获取桌型列表
|
||||
* @param {Object} param
|
||||
*/
|
||||
getQueueUpTablList(param) {
|
||||
return uni.api.get("/callTable", param);
|
||||
},
|
||||
|
||||
/**
|
||||
* 获取排号状态
|
||||
* @param {Object} param
|
||||
*/
|
||||
getQueueUpState(param) {
|
||||
return uni.api.get("/callTable/state", param);
|
||||
},
|
||||
|
||||
/**
|
||||
* 获取订阅
|
||||
* @param {Object} data
|
||||
*/
|
||||
setSubMsg(data) {
|
||||
return uni.api.post("/callTable/subMsg", data,false);
|
||||
},
|
||||
|
||||
/**
|
||||
* 取号
|
||||
* @param {Object} data
|
||||
*/
|
||||
getTakeNumber(data) {
|
||||
return uni.api.post("/callTable/takeNumber", data, false);
|
||||
},
|
||||
|
||||
/**
|
||||
* 取消排号
|
||||
* @param {Object} data
|
||||
*/
|
||||
cancelTakeNumber(data) {
|
||||
return uni.api.post("/callTable/cancel", data, false);
|
||||
},
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* 积分-基本设置-获取店铺设置
|
||||
* @param {Object} param
|
||||
*/
|
||||
shopSettingInfo(shopId) {
|
||||
return uni.api.get(`/api/points/basic-setting/${shopId}`);
|
||||
},
|
||||
|
||||
/**
|
||||
* 积分-兑换商品列表
|
||||
* @param {Object} param
|
||||
*/
|
||||
pointsGoodsList(param) {
|
||||
return uni.api.get("/api/points/goods-setting/page", param);
|
||||
},
|
||||
|
||||
/**
|
||||
* 积分-生成订单
|
||||
* @param {Object} data
|
||||
*/
|
||||
pointsCreateOrder(data) {
|
||||
return uni.api.post("/api/points/exchange-record/create", data);
|
||||
},
|
||||
/**
|
||||
* 积分-支付订单
|
||||
* @param {Object} data
|
||||
*/
|
||||
pointsPayOrder(data) {
|
||||
return uni.api.post("/api/points/exchange-record/pay", data);
|
||||
},
|
||||
/**
|
||||
* 积分-取消订单
|
||||
* @param {Object} data
|
||||
*/
|
||||
pointsCancelOrder(data) {
|
||||
return uni.api.post("/api/points/exchange-record/cancel", data);
|
||||
},
|
||||
/**
|
||||
* 积分-001-会员积分账户信息
|
||||
* @param {Object} param
|
||||
*/
|
||||
memberPointsInfo(memberId) {
|
||||
return uni.api.get(`/api/points/member-points/${memberId}`, );
|
||||
},
|
||||
|
||||
/**
|
||||
* 积分-明细列表
|
||||
* @param {Object} param
|
||||
*/
|
||||
memberPointsLogList(param) {
|
||||
return uni.api.get("/api/points/member-points-log/page", param);
|
||||
},
|
||||
|
||||
/**
|
||||
* 积分-兑换记录-列表
|
||||
* @param {Object} param
|
||||
*/
|
||||
exchangeRecordList(param) {
|
||||
return uni.api.get("/api/points/exchange-record/page", param);
|
||||
},
|
||||
|
||||
/**
|
||||
* 积分-获取订单可用积分及抵扣金额
|
||||
* @param {Object} param
|
||||
*/
|
||||
calcUsablePoints(param) {
|
||||
return uni.api.get("/api/points/member-points/calc-usable-points", param);
|
||||
},
|
||||
|
||||
/**
|
||||
* 分享-获取邀请页数据
|
||||
* @param {Object} param
|
||||
*/
|
||||
getByShopId(param) {
|
||||
return uni.api.get("/tbShopShare/getByShopId", param);
|
||||
},
|
||||
|
||||
/**
|
||||
* 分享-邀请记录
|
||||
* @param {Object} param
|
||||
*/
|
||||
shareRecord(param) {
|
||||
return uni.api.get("/tbShopShare/record", param);
|
||||
},
|
||||
|
||||
/**
|
||||
* 分享-被邀请人进入页面时使用
|
||||
* @param {Object} param
|
||||
*/
|
||||
shareHeOpen(param) {
|
||||
return uni.api.post("/tbShopShare/open", param);
|
||||
},
|
||||
|
||||
/**
|
||||
* 分享-被邀请人领取优惠券时使用
|
||||
* @param {Object} param
|
||||
*/
|
||||
shareReceive(param) {
|
||||
return uni.api.post("/tbShopShare/receive", param);
|
||||
},
|
||||
}
|
||||
34
common/js/api/queueUp.js
Normal file
34
common/js/api/queueUp.js
Normal file
@@ -0,0 +1,34 @@
|
||||
export default {
|
||||
|
||||
/**
|
||||
* 获取排号信息
|
||||
* @param {Object} param
|
||||
*/
|
||||
getQueueUpList(param) {
|
||||
return uni.api.get("/callTable/queue", param);
|
||||
},
|
||||
|
||||
/**
|
||||
* 获取桌型列表
|
||||
* @param {Object} param
|
||||
*/
|
||||
getQueueUpTablList(param) {
|
||||
return uni.api.get("/callTable", param);
|
||||
},
|
||||
|
||||
/**
|
||||
* 取号
|
||||
* @param {Object} data
|
||||
*/
|
||||
getTakeNumber(data) {
|
||||
return uni.api.post("/callTable/takeNumber", data, false);
|
||||
},
|
||||
|
||||
/**
|
||||
* 取消排号
|
||||
* @param {Object} data
|
||||
*/
|
||||
cancelTakeNumber(data) {
|
||||
return uni.api.post("/callTable", data, false);
|
||||
},
|
||||
}
|
||||
15879
common/js/city.json
Normal file
15879
common/js/city.json
Normal file
File diff suppressed because it is too large
Load Diff
1437
common/js/uqrCode.js
Normal file
1437
common/js/uqrCode.js
Normal file
File diff suppressed because it is too large
Load Diff
231
common/js/websocket.js
Normal file
231
common/js/websocket.js
Normal file
@@ -0,0 +1,231 @@
|
||||
class webSocketUtils {
|
||||
constructor(url, time, params) {
|
||||
this.socketTask = null;
|
||||
this.is_open_socket = false; //避免重复连接
|
||||
this.url = url;
|
||||
this.params = params ? params : null; ////是否初始化请求
|
||||
this.connectNum = 1; // 重连次数
|
||||
//这个参数是防止重连失败之后onClose方法会重复执行reconnect方法,导致重连定时器出问题
|
||||
//连接并打开之后可重连,且只执行重连方法一次
|
||||
this.canReconnect = false; // 是否可以重连
|
||||
//心跳检测
|
||||
this.timeout = time ? time : 5000; //多少秒执行检测
|
||||
this.heartbeatInterval = null; //检测服务器端是否还活着
|
||||
this.reconnectTimeOut = null; //重连之后多久再次重连
|
||||
try {
|
||||
|
||||
return this.connectSocketInit({
|
||||
data: this.params,
|
||||
type: 'connectSocketInit',
|
||||
});
|
||||
} catch (e) {
|
||||
// console.log('catch');
|
||||
this.reconnect();
|
||||
}
|
||||
}
|
||||
// 进入这个页面的时候创建websocket连接【整个页面随时使用】
|
||||
connectSocketInit(data) {
|
||||
let _this = this;
|
||||
this.data = data;
|
||||
// #ifdef MP-WEIXIN
|
||||
this.socketTask = uni.connectSocket({
|
||||
// #endif
|
||||
// #ifdef MP-ALIPAY
|
||||
my.connectSocket({
|
||||
// #endif
|
||||
url: this.url,
|
||||
success: (res) => {
|
||||
console.log('创建websocketc成功...');
|
||||
// uni.hideLoading();
|
||||
// 返回实例
|
||||
return this.socketTask;
|
||||
},
|
||||
fail: (res) => {
|
||||
}
|
||||
});
|
||||
|
||||
// #ifdef MP-WEIXIN
|
||||
this.socketTask.onOpen((res) => {
|
||||
// #endif
|
||||
// #ifdef MP-ALIPAY
|
||||
my.onSocketOpen((res) => {
|
||||
// #endif
|
||||
uni.hideLoading()
|
||||
this.connectNum = 1;
|
||||
console.log('WebSocket连接正常!==',res);
|
||||
if (this.params) { //是否初始化请求
|
||||
this.send(this.params);
|
||||
}
|
||||
clearInterval(this.reconnectTimeOut);
|
||||
clearInterval(this.heartbeatInterval);
|
||||
this.is_open_socket = true;
|
||||
this.canReconnect = true;
|
||||
this.start();
|
||||
// 注:只有连接正常打开中 ,才能正常收到消息
|
||||
// #ifdef MP-WEIXIN
|
||||
this.socketTask.onMessage((e) => {
|
||||
// #endif
|
||||
// #ifdef MP-ALIPAY
|
||||
my.onSocketMessage((e)=>{
|
||||
// #endif
|
||||
// 字符串转json
|
||||
let res = JSON.parse(e.data);
|
||||
uni.$emit('message', res)
|
||||
// 普通socket信息处理 TODO
|
||||
});
|
||||
});
|
||||
|
||||
// 监听连接失败,这里代码我注释掉的原因是因为如果服务器关闭后,和下面的onclose方法一起发起重连操作,这样会导致重复连接
|
||||
// #ifdef MP-WEIXIN
|
||||
uni.onSocketError((res) => {
|
||||
// #endif
|
||||
// #ifdef MP-ALIPAY
|
||||
my.onSocketError((res) => {
|
||||
// #endif
|
||||
console.log('网络断开,请检查!');
|
||||
this.socketTask = null;
|
||||
this.is_open_socket = false;
|
||||
// this.Close()
|
||||
this.canReconnect = true;
|
||||
clearInterval(this.heartbeatInterval);
|
||||
clearInterval(this.reconnectTimeOut);
|
||||
try {
|
||||
if (this.connectNum <= 10) {
|
||||
// uni.showLoading({
|
||||
// title: `网络连接失败,正尝试第${this.connectNum}次连接`,
|
||||
// mask: true
|
||||
// })
|
||||
uni.$emit('message', 1) //进行重连
|
||||
uni.showToast({
|
||||
title: `网络连接失败,正尝试第${this.connectNum}次连接`,
|
||||
icon: 'none',
|
||||
});
|
||||
this.reconnect();
|
||||
this.connectNum += 1;
|
||||
} else {
|
||||
// uni.$emit('connectError');
|
||||
uni.showToast({
|
||||
title: `网络连接失败,请检查网络!`,
|
||||
icon: 'none',
|
||||
});
|
||||
this.connectNum = 1;
|
||||
this.canReconnect = false;
|
||||
this.Close()
|
||||
setTimeout(res => {
|
||||
uni.switchTab({
|
||||
url: '/pages/index/index'
|
||||
})
|
||||
uni.hideLoading()
|
||||
}, 1000)
|
||||
}
|
||||
} catch (e) {
|
||||
//TODO handle the exception
|
||||
}
|
||||
});
|
||||
// 这里仅是事件监听【如果socket关闭了会执行】
|
||||
// #ifdef MP-WEIXIN
|
||||
this.socketTask.onClose(() => {
|
||||
// #endif
|
||||
// #ifdef MP-ALIPAY
|
||||
my.onSocketClose((res) => {
|
||||
// #endif
|
||||
console.log("socket关闭了")
|
||||
this.socketTask = null;
|
||||
clearInterval(this.heartbeatInterval);
|
||||
clearInterval(this.reconnectTimeOut);
|
||||
// #ifdef MP-ALIPAY
|
||||
// 支付宝小程序的ws连接问题,关闭连接时需关闭对于接受,防止关闭失败
|
||||
my.offSocketMessage();
|
||||
my.offSocketError();
|
||||
my.offSocketOpen();
|
||||
my.offSocketClose();
|
||||
// #endif
|
||||
this.is_open_socket = false;
|
||||
if (this.canReconnect) {
|
||||
this.reconnect();
|
||||
this.canReconnect = false;
|
||||
}
|
||||
});
|
||||
}
|
||||
// 主动关闭socket连接
|
||||
Close() {
|
||||
this.is_open_socket = true;
|
||||
this.canReconnect = false;
|
||||
|
||||
// #ifdef MP-WEIXIN
|
||||
if (this.socketTask) {
|
||||
this.socketTask.close({
|
||||
success(res) {
|
||||
console.log('手动关闭成功');
|
||||
},
|
||||
});
|
||||
}
|
||||
// #endif
|
||||
// #ifdef MP-ALIPAY
|
||||
my.closeSocket({
|
||||
success(res) {
|
||||
console.log('手动关闭成功');
|
||||
// #ifdef MP-ALIPAY
|
||||
// 支付宝小程序的ws连接问题,关闭连接时需关闭对于接受,防止关闭失败
|
||||
my.offSocketMessage();
|
||||
my.offSocketError();
|
||||
my.offSocketOpen();
|
||||
my.offSocketClose();
|
||||
// #endif
|
||||
|
||||
},
|
||||
fail: (res) => {
|
||||
console.log('手动关闭失败==',res);
|
||||
}
|
||||
});
|
||||
// #endif
|
||||
}
|
||||
//发送消息
|
||||
send(data) {
|
||||
// console.log("发送消息---------->", data);
|
||||
// 注:只有连接正常打开中 ,才能正常成功发送消息
|
||||
|
||||
// #ifdef MP-WEIXIN
|
||||
if (this.socketTask) {
|
||||
this.socketTask.send({
|
||||
data: JSON.stringify(data),
|
||||
async success() {
|
||||
// console.log("消息发送成功");
|
||||
},
|
||||
});
|
||||
}
|
||||
// #endif
|
||||
// #ifdef MP-ALIPAY
|
||||
my.sendSocketMessage({
|
||||
data: JSON.stringify(data),
|
||||
success(res) {
|
||||
// console.log("消息发送成功");
|
||||
},
|
||||
});
|
||||
// #endif
|
||||
}
|
||||
//开启心跳检测
|
||||
start(data) {
|
||||
// console.log('开启心跳检测', data)
|
||||
this.heartbeatInterval = setInterval(() => {
|
||||
this.send({
|
||||
data: '心跳检测',
|
||||
type: 'heartbeat',
|
||||
});
|
||||
}, this.timeout);
|
||||
}
|
||||
//重新连接
|
||||
reconnect() {
|
||||
//停止发送心跳
|
||||
clearInterval(this.heartbeatInterval);
|
||||
//如果不是人为关闭的话,进行重连
|
||||
if (!this.is_open_socket) {
|
||||
console.log('进行重连');
|
||||
this.canReconnect = true;
|
||||
this.reconnectTimeOut = setInterval(() => {
|
||||
this.connectSocketInit(this.data);
|
||||
}, this.timeout);
|
||||
}
|
||||
}
|
||||
}
|
||||
module.exports = webSocketUtils;
|
||||
Reference in New Issue
Block a user