解决新版一系列问题

1默认跳转页面是首页,如果没登陆点击后退键将直接跳转到首页
2手机端跳转页面this.$route 获取不到,老版本无此问题
3电脑浏览器没有问题,连接安卓手机测试错误
4打包成app,首页@tap事件无法使用 #7
This commit is contained in:
zhangdaiscott
2021-07-22 10:31:20 +08:00
parent 01222229f2
commit 18c764fa5b

View File

@@ -9,21 +9,7 @@
<video :src="item.url" autoplay loop muted :show-play-btn="false" :controls="false" objectFit="cover" v-if="item.type=='video'"></video> <video :src="item.url" autoplay loop muted :show-play-btn="false" :controls="false" objectFit="cover" v-if="item.type=='video'"></video>
</swiper-item> </swiper-item>
</swiper> </swiper>
<!-- 中部应用宫格 -->
<!--<view class="bg-white" :style="[{animation: 'show 0.3s 1'}]">
<view class="cu-list grid margin-bottom col-2 ">
<view
v-for="(item,index) in middleApps"
:key="index"
class="cu-item text-center"
:style="[{animation: 'show ' + ((index+1)*0.2+1) + 's 1'}]" hover-class="none">
<view class="flex align-center margin-left" @tap="goCheckPage(item.page)">
<image :src="item.icon" mode="aspectFill" class="line2-icon"></image>
<view class="text-df">{{item.title}} <br/> <span class="text-light">{{item.text}}</span></view>
</view>
</view>
</view>
</view>-->
<!-- 常用服务 --> <!-- 常用服务 -->
<view class="cu-bar bg-white solid-bottom" :style="[{animation: 'show 0.5s 1'}]"> <view class="cu-bar bg-white solid-bottom" :style="[{animation: 'show 0.5s 1'}]">
<view class="action"> <view class="action">
@@ -65,6 +51,7 @@
<script> <script>
import { us,os } from '@/common/util/work.js' import { us,os } from '@/common/util/work.js'
import socket from '@/common/js-sdk/socket/socket.js'
export default { export default {
name: 'home', name: 'home',
props:{ props:{
@@ -73,8 +60,8 @@
watch: { watch: {
cur: { cur: {
immediate: true, immediate: true,
handler() { handler:function(val,oldVal){
console.log('watch',this.cur) console.log('cur',val,oldVal)
this.initMenu() this.initMenu()
}, },
}, },
@@ -93,9 +80,6 @@
], ],
usList:us.data, usList:us.data,
osList:os.data, osList:os.data,
websock:'',
heartCheck:null,
lockReconnect:false,
msgCount:0, msgCount:0,
dot:{ dot:{
mailHome:false mailHome:false
@@ -105,7 +89,8 @@
methods: { methods: {
initMenu(){ initMenu(){
console.log("-----------home------------") console.log("-----------home------------")
this.initWebSocket(); this.onSocketOpen()
this.onSocketReceive()
this.loadCount(0); this.loadCount(0);
}, },
goPage(page){ goPage(page){
@@ -116,65 +101,27 @@
this.msgCount = 0 this.msgCount = 0
} }
this.dot[page]=false this.dot[page]=false
this.$router.push({name: page}) this.$Router.push({name: page})
}, },
initWebSocket: function () { // 启动webSocket
// WebSocket与普通的请求所用协议有所不同ws等同于httpwss等同于https onSocketOpen() {
var userId = this.$store.getters.userid; socket.init('websocket');
var url = this.$config.apiUrl.replace("https://","wss://").replace("http://","ws://")+"/websocket/"+userId;
console.log('websocket url>>'+url);
this.websock = new WebSocket(url);
this.websock.onopen = this.websocketOnopen;
this.websock.onerror = this.websocketOnerror;
this.websock.onmessage = this.websocketOnmessage;
this.websock.onclose = this.websocketOnclose;
}, },
websocketOnopen: function () { onSocketReceive() {
console.log("WebSocket连接成功"); var _this=this
//心跳检测重置 socket.acceptMessage = function(res){
//this.heartCheck.reset().start(); // console.log("页面收到的消息", res);
}, if(res.cmd == "topic"){
websocketOnerror: function () { //系统通知
console.log("WebSocket连接发生错误"); _this.loadCount('1')
this.reconnect(); }else if(res.cmd == "user"){
}, //用户消息
websocketOnmessage: function (e) { _this.loadCount('2')
console.log("-----接收消息-------",e.data); } else if(res.cmd == 'email'){
var data = eval("(" + e.data + ")"); //解析对象 //邮件消息
if(data.cmd == "topic"){ _this.loadEmailCount()
//系统通知 }
this.loadCount('1')
}else if(data.cmd == "user"){
//用户消息
this.loadCount('2')
} else if(data.cmd == 'email'){
this.loadEmailCount()
} }
//心跳检测重置
//this.heartCheck.reset().start();
},
websocketOnclose: function (e) {
console.log("connection closed (" + e.code + ")");
this.reconnect();
},
websocketSend(text) { // 数据发送
try {
this.websock.send(text);
} catch (err) {
console.log("send failed (" + err.code + ")");
}
},
reconnect() {
var that = this;
if(that.lockReconnect) return;
that.lockReconnect = true;
//没连接上会一直重连,设置延迟避免请求过多
setTimeout(function () {
console.info("尝试重连...");
that.initWebSocket();
that.lockReconnect = false;
}, 5000);
}, },
loadCount(flag){ loadCount(flag){
console.log("loadCount::flag",flag) console.log("loadCount::flag",flag)