socket
This commit is contained in:
@@ -57,13 +57,18 @@ class webSocketUtils {
|
|||||||
// 监听连接失败,这里代码我注释掉的原因是因为如果服务器关闭后,和下面的onclose方法一起发起重连操作,这样会导致重复连接
|
// 监听连接失败,这里代码我注释掉的原因是因为如果服务器关闭后,和下面的onclose方法一起发起重连操作,这样会导致重复连接
|
||||||
uni.onSocketError((res) => {
|
uni.onSocketError((res) => {
|
||||||
console.log('网络断开,请检查!');
|
console.log('网络断开,请检查!');
|
||||||
// this.socketTask = null;
|
this.socketTask = null;
|
||||||
// this.is_open_socket = false;
|
this.is_open_socket = false;
|
||||||
this.Close()
|
// this.Close()
|
||||||
this.canReconnect = true;
|
this.canReconnect = true;
|
||||||
clearInterval(this.heartbeatInterval);
|
clearInterval(this.heartbeatInterval);
|
||||||
clearInterval(this.reconnectTimeOut);
|
clearInterval(this.reconnectTimeOut);
|
||||||
if (this.connectNum <= 10) {
|
if (this.connectNum <= 10) {
|
||||||
|
// uni.showLoading({
|
||||||
|
// title: `网络连接失败,正尝试第${this.connectNum}次连接`,
|
||||||
|
// mask: true
|
||||||
|
// })
|
||||||
|
uni.$emit('message', 1) //进行重连
|
||||||
uni.showToast({
|
uni.showToast({
|
||||||
title: `网络连接失败,正尝试第${this.connectNum}次连接`,
|
title: `网络连接失败,正尝试第${this.connectNum}次连接`,
|
||||||
icon: 'none',
|
icon: 'none',
|
||||||
@@ -78,6 +83,13 @@ class webSocketUtils {
|
|||||||
});
|
});
|
||||||
this.connectNum = 1;
|
this.connectNum = 1;
|
||||||
this.canReconnect = false;
|
this.canReconnect = false;
|
||||||
|
this.Close()
|
||||||
|
setTimeout(res => {
|
||||||
|
uni.switchTab({
|
||||||
|
url: '/pages/index/index'
|
||||||
|
})
|
||||||
|
uni.hideLoading()
|
||||||
|
}, 1000)
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
// 这里仅是事件监听【如果socket关闭了会执行】
|
// 这里仅是事件监听【如果socket关闭了会执行】
|
||||||
@@ -134,10 +146,6 @@ class webSocketUtils {
|
|||||||
clearInterval(this.heartbeatInterval);
|
clearInterval(this.heartbeatInterval);
|
||||||
//如果不是人为关闭的话,进行重连
|
//如果不是人为关闭的话,进行重连
|
||||||
if (!this.is_open_socket) {
|
if (!this.is_open_socket) {
|
||||||
uni.showLoading({
|
|
||||||
title: '加载中',
|
|
||||||
mask: true
|
|
||||||
})
|
|
||||||
console.log('进行重连');
|
console.log('进行重连');
|
||||||
this.canReconnect = true;
|
this.canReconnect = true;
|
||||||
this.reconnectTimeOut = setInterval(() => {
|
this.reconnectTimeOut = setInterval(() => {
|
||||||
|
|||||||
41
components/vastwu-barrage/readme.md
Normal file
41
components/vastwu-barrage/readme.md
Normal file
@@ -0,0 +1,41 @@
|
|||||||
|
# 测试发现h5不支持
|
||||||
|
## 如何使用
|
||||||
|
```
|
||||||
|
<template>
|
||||||
|
<view class="barrage-test">
|
||||||
|
<vastwu-barrage width="750rpx" height="1300rpx" ref="vBarrage"></vastwu-barrage>
|
||||||
|
</view>
|
||||||
|
</template>
|
||||||
|
<script>
|
||||||
|
const list = ['模拟弹幕效果','宽度如要修改请留意动画是从750rpx到-100%','高度默认100%','随机颜色','随机速度','图标可设置','图标大小可控','可自定义高度轨道','高度轨道数组多长,一屏幕就能播多少列','高度不够不会显示','欢迎使用','不会重叠']
|
||||||
|
import vastwuBarrage from '@/components/vastwu-barrage/vastwu-barrage.vue'
|
||||||
|
export default {
|
||||||
|
components:{vastwuBarrage},
|
||||||
|
data() {
|
||||||
|
return {}
|
||||||
|
},
|
||||||
|
onLoad() {
|
||||||
|
this.$refs.vBarrage.init(list)
|
||||||
|
},
|
||||||
|
methods: {}
|
||||||
|
}
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<style>
|
||||||
|
.barrage-test{
|
||||||
|
background-color: #C0C0C0
|
||||||
|
}
|
||||||
|
</style>
|
||||||
|
```
|
||||||
|
|
||||||
|
## 参数说明
|
||||||
|
|参数|类型|默认|说明|
|
||||||
|
|:-|:-:|-:|-:|
|
||||||
|
|trackList|Array|[0,100,200,300,400,500,600,700,800,900,1000]|自定义弹幕轨道,值为距离容器顶部的距离,可根据图标高度自行调整|
|
||||||
|
|icon|String||默认图标|
|
||||||
|
|iconWidth|String|62rpx|图标宽度|
|
||||||
|
|iconHeight|String|'86rpx'|图标高度|
|
||||||
|
|minTime|Number|7|最短过渡时间|
|
||||||
|
|maxTime|Number|10|最长过渡时间|
|
||||||
|
|width|String|'100%'|容器宽度|
|
||||||
|
|height|String|'100%'|容器高度|
|
||||||
@@ -44,6 +44,19 @@ function requestrequest(options) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
async function request(options) {
|
async function request(options) {
|
||||||
|
let networkType = ''
|
||||||
|
uni.getNetworkType({
|
||||||
|
success: (res) => {
|
||||||
|
networkType = res.networkType
|
||||||
|
}
|
||||||
|
});
|
||||||
|
if (networkType == 'none') {
|
||||||
|
uni.showToast({
|
||||||
|
title: '网络异常,请检查网络',
|
||||||
|
icon: 'none'
|
||||||
|
})
|
||||||
|
return false;
|
||||||
|
}
|
||||||
try {
|
try {
|
||||||
if (options.toast) {
|
if (options.toast) {
|
||||||
// #ifdef MP-WEIXIN || APP-PLUS
|
// #ifdef MP-WEIXIN || APP-PLUS
|
||||||
|
|||||||
@@ -274,26 +274,35 @@
|
|||||||
// });
|
// });
|
||||||
// return;
|
// return;
|
||||||
// }
|
// }
|
||||||
let res = await this.api.loginapplogin({
|
// #ifdef MP-WEIXIN
|
||||||
username: this.form.loginName,
|
uni.login({
|
||||||
password: this.form.password,
|
provider: 'weixin',
|
||||||
code: this.form.code
|
success: async (data) => {
|
||||||
});
|
let res = await this.api.loginapplogin({
|
||||||
console.log(res);
|
username: this.form.loginName,
|
||||||
if (res.code == 0) {
|
password: this.form.password,
|
||||||
uni.cache.set('token', res.data.token);
|
code: this.form.code,
|
||||||
uni.cache.set('miniAppOpenId', res.data.userInfo
|
opencode: data.code
|
||||||
.miniAppOpenId)
|
|
||||||
uni.cache.set('userInfo', res.data.userInfo);
|
|
||||||
if (uni.cache.get('types') == 'types') {
|
|
||||||
uni.reLaunch({
|
|
||||||
url: '/pages/order_food/order_food'
|
|
||||||
});
|
});
|
||||||
} else {
|
console.log(res);
|
||||||
uni.pro.switchTab('index/index')
|
if (res.code == 0) {
|
||||||
}
|
uni.cache.set('token', res.data.token);
|
||||||
|
uni.cache.set('miniAppOpenId', res.data.userInfo
|
||||||
|
.miniAppOpenId)
|
||||||
|
uni.cache.set('userInfo', res.data.userInfo);
|
||||||
|
if (uni.cache.get('types') == 'types') {
|
||||||
|
uni.reLaunch({
|
||||||
|
url: '/pages/order_food/order_food'
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
uni.pro.switchTab('index/index')
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
// #endif
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
},
|
},
|
||||||
// async getPhoneNumber(res) { // 获取手机号
|
// async getPhoneNumber(res) { // 获取手机号
|
||||||
|
|||||||
@@ -65,7 +65,8 @@
|
|||||||
空
|
空
|
||||||
</view>
|
</view>
|
||||||
<view class="shop-item" v-for="(item1,index1) in item.products" :key="item1.id">
|
<view class="shop-item" v-for="(item1,index1) in item.products" :key="item1.id">
|
||||||
<view class="cover langcover" style="width:180rpx; height: 180rpx;" @click.stop="clickspecifications(item1,index,index1)">
|
<view class="cover langcover" style="width:180rpx; height: 180rpx;"
|
||||||
|
@click.stop="clickspecifications(item1,index,index1)">
|
||||||
<c-image style="position: absolute;z-index:2;"
|
<c-image style="position: absolute;z-index:2;"
|
||||||
:src="`${item1.coverImg}?x-oss-process=image/resize,m_lfit,w_90,h_90`" width="180"
|
:src="`${item1.coverImg}?x-oss-process=image/resize,m_lfit,w_90,h_90`" width="180"
|
||||||
height="180"></c-image>
|
height="180"></c-image>
|
||||||
@@ -229,12 +230,7 @@
|
|||||||
</view>
|
</view>
|
||||||
</view>
|
</view>
|
||||||
</u-popup>
|
</u-popup>
|
||||||
<u-popup :show="popupshowInfo" :round="20" mode="center" @close="popupshowInfo = false"
|
<!-- <vastwu-barrage width="750rpx" height="1300rpx" ref="vBarrage"></vastwu-barrage> -->
|
||||||
:safeAreaInsetBottom='false'>
|
|
||||||
<view class="showInfo">
|
|
||||||
|
|
||||||
</view>
|
|
||||||
</u-popup>
|
|
||||||
</view>
|
</view>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
@@ -242,7 +238,9 @@
|
|||||||
import _ from 'lodash';
|
import _ from 'lodash';
|
||||||
import navbar from '../../uni_modules/uview-ui/libs/config/props/navbar';
|
import navbar from '../../uni_modules/uview-ui/libs/config/props/navbar';
|
||||||
import webSocketUtils from '@/common/js/websocket.js'
|
import webSocketUtils from '@/common/js/websocket.js'
|
||||||
|
// import vastwuBarrage from '@/components/vastwu-barrage/vastwu-barrage.vue'
|
||||||
export default {
|
export default {
|
||||||
|
// components:{vastwuBarrage},
|
||||||
data() {
|
data() {
|
||||||
return {
|
return {
|
||||||
// #ifndef MP-WEIXIN
|
// #ifndef MP-WEIXIN
|
||||||
@@ -257,7 +255,6 @@
|
|||||||
shopList: {}, //数据类型
|
shopList: {}, //数据类型
|
||||||
active: 0,
|
active: 0,
|
||||||
showShopInfo: false,
|
showShopInfo: false,
|
||||||
popupshowInfo: false,
|
|
||||||
showShopsku: false,
|
showShopsku: false,
|
||||||
titleTopNumIndex: 0,
|
titleTopNumIndex: 0,
|
||||||
titleTopNums: [],
|
titleTopNums: [],
|
||||||
@@ -299,6 +296,7 @@
|
|||||||
this.$nextTick(() => {
|
this.$nextTick(() => {
|
||||||
this.countTitleTopNum(); //导航栏
|
this.countTitleTopNum(); //导航栏
|
||||||
});
|
});
|
||||||
|
// this.$refs.vBarrage.init([123])
|
||||||
},
|
},
|
||||||
onUnload() {
|
onUnload() {
|
||||||
this.socketTicket.Close()
|
this.socketTicket.Close()
|
||||||
@@ -349,6 +347,11 @@
|
|||||||
// })
|
// })
|
||||||
// }
|
// }
|
||||||
// });
|
// });
|
||||||
|
if (msg == 1) { // 网络在连接
|
||||||
|
this.fixedtrue = true
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
this.fixedtrue = false
|
||||||
if (msg.status != 'success') {
|
if (msg.status != 'success') {
|
||||||
uni.showToast({
|
uni.showToast({
|
||||||
title: msg.msg,
|
title: msg.msg,
|
||||||
@@ -429,8 +432,12 @@
|
|||||||
},
|
},
|
||||||
// 数据处理
|
// 数据处理
|
||||||
socketSendMsg(data) {
|
socketSendMsg(data) {
|
||||||
|
console.log(data, 1111)
|
||||||
if (this.socketTicket) {
|
if (this.socketTicket) {
|
||||||
|
console.log(222)
|
||||||
this.socketTicket.send(data);
|
this.socketTicket.send(data);
|
||||||
|
} else {
|
||||||
|
console.log(333)
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
getQueryString(url, name) { //解码
|
getQueryString(url, name) { //解码
|
||||||
@@ -471,9 +478,6 @@
|
|||||||
})
|
})
|
||||||
if (res.code == 0) {
|
if (res.code == 0) {
|
||||||
this.shopList = res.data
|
this.shopList = res.data
|
||||||
setTimeout(() => {
|
|
||||||
this.fixedtrue = false
|
|
||||||
}, 1000)
|
|
||||||
this.$nextTick(() => {
|
this.$nextTick(() => {
|
||||||
this.countTitleTopNum();
|
this.countTitleTopNum();
|
||||||
});
|
});
|
||||||
@@ -515,6 +519,8 @@
|
|||||||
this.hodgepodge(item, 2)
|
this.hodgepodge(item, 2)
|
||||||
},
|
},
|
||||||
async hodgepodge(item, a, c) { //此接口去获取商品id !!!赋值库存 数量 价格等
|
async hodgepodge(item, a, c) { //此接口去获取商品id !!!赋值库存 数量 价格等
|
||||||
|
console.log(11111)
|
||||||
|
|
||||||
try {
|
try {
|
||||||
let res = await this.api.productqueryProductSku({
|
let res = await this.api.productqueryProductSku({
|
||||||
shopId: uni.cache.get('shopUser'),
|
shopId: uni.cache.get('shopUser'),
|
||||||
@@ -1158,12 +1164,6 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
.showInfo {
|
|
||||||
width: 100%;
|
|
||||||
border-radius: 20rpx;
|
|
||||||
background: #fff;
|
|
||||||
max-height: 70vh;
|
|
||||||
}
|
|
||||||
|
|
||||||
.shop-info-wrap {
|
.shop-info-wrap {
|
||||||
.info-wrap {
|
.info-wrap {
|
||||||
|
|||||||
Reference in New Issue
Block a user