Files
peiwan-uniapp/App.vue
2025-01-21 01:46:34 +08:00

130 lines
3.0 KiB
Vue
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

<script setup>
import { onLaunch, onShow, onHide, onUnload, onError } from '@dcloudio/uni-app';
import { ShoproInit } from './sheep';
import { useWebSocket } from '@/sheep/hooks/useWebSocket';
import { WebSocketMessageTypeConstants } from '@/sheep/util/const';
onLaunch(() => {
// 隐藏原生导航栏 使用自定义底部导航
//uni.hideTabBar();
// 加载Shopro底层依赖
ShoproInit();
});
onError((err) => {
console.log('AppOnError:', err);
});
onShow((options) => {
// #ifdef APP-PLUS
// 获取urlSchemes参数
const args = plus.runtime.arguments;
if (args) {
}
// 获取剪贴板
uni.getClipboardData({
success: (res) => { },
});
// #endif
// #ifdef MP-WEIXIN
// 确认收货回调结果
console.log(options,'options');
// #endif
// 禁止截屏
if (wx.setVisualEffectOnCapture) {
wx.setVisualEffectOnCapture({
visualEffect: 'hidden',
complete: function(res) {}
})
}
if (wx.setVisualEffectOnCapture) {
let that = this
wx.onUserCaptureScreen(function (res) {
uni.showToast({
icon: 'none',
title: '禁止截屏!',
position: 'bottom'
})
that.flushed()
})
}
console.log('App Show')
});
onHide(() => {
if (wx.setVisualEffectOnCapture) {
wx.setVisualEffectOnCapture({
visualEffect: 'none',
complete: function(res) {}
})
}
});
onUnload(() => {
if (wx.setVisualEffectOnCapture) {
wx.setVisualEffectOnCapture({
visualEffect: 'none',
complete: function(res) {}
})
}
});
//======================= 聊天工具相关 end =======================
/* const { options } = useWebSocket({
// 连接成功
onConnected: async () => {
console.log('连接成功');
},
// 收到消息
onMessage: async (data) => {
console.log('接收消息');
const type = data.type;
if (!type) {
console.error('未知的消息类型:' + data.value);
return;
}
if (type == WebSocketMessageTypeConstants.IM_MESSAGE_READ) {
console.log('刷新消息');
setTimeout(function(){
uni.$emit(WebSocketMessageTypeConstants.IM_MESSAGE_READ, data);
},1000);
return;
}
if (type == WebSocketMessageTypeConstants.IM_MESSAGE_NEWS) {
uni.$emit(WebSocketMessageTypeConstants.IM_MESSAGE_NEWS, data);
return;
}
// 2.2 消息类型KEFU_MESSAGE_TYPE
if (type == WebSocketMessageTypeConstants.KEFU_MESSAGE_TYPE) {
console.log('刷新消息');
// 刷新消息列表
//await messageListRef.value.refreshMessageList(JSON.parse(data.content));
return;
}
// 2.3 消息类型KEFU_MESSAGE_ADMIN_READ
if (type == WebSocketMessageTypeConstants.KEFU_MESSAGE_ADMIN_READ) {
console.log('管理员已读消息');
}
},
}); */
</script>
<style lang="scss">
@import '@/sheep/scss/index.scss';
@import "@/static/css/iconfont.css";
@import "@/uni_modules/vk-uview-ui/index.scss";
::-webkit-scrollbar {
width: 0 !important;
height: 0 !important;
color: transparent !important;
display: none;
}
</style>