Files
2026-07-24 11:56:12 +08:00

222 lines
5.6 KiB
Vue

<script>
import login from "@/utils/login";
// #ifdef MP-WEIXIN
const PlayerManager = require('@/utils/playerManager')
const playletPlugin = requirePlugin('playlet-plugin')
// #endif
export default {
data() {
return {
playerManagerList: [],
}
},
globalData: {},
onLaunch: function(e) {
this.getappinfodata()
uni.getLocation({})
let that = this;
if (e.query.invite) {
uni.setStorageSync('invite_number', e.query.invite);
}
if (e.query.fxpid && e.query.fxpid > 0) {
uni.setStorageSync('fxpid', e.query.fxpid);
}
if (e.invite) {
uni.setStorageSync('invite_number', e.invite)
}
if (e.fxpid && e.fxpid > 0) {
uni.setStorageSync('fxpid', e.fxpid)
}
const extConfig = uni.getExtConfigSync ? uni.getExtConfigSync() : {};
if (extConfig.appid) {
this.$config.appId = extConfig.appid;
}
// #ifdef MP-WEIXIN
// 扫描小程序二维码使用
this.getScence(e.query.scene)
this.$nextTick(() => {
playletPlugin.onPageLoad(this.onPlayerLoad.bind(this))
})
// wx.setVisualEffectOnCapture({
// visualEffect: 'hidden',
// success: (res) => {
// console.log(res)
// },
// fail: (err) => {
// console.log(err)
// },
// complete: (res) => {
// console.log(res)
// }
// })
let info = uni.getStorageSync("userinfo");
let token = info ? info.token : '';
if (token) {
login.wxLogin();
}
// #endif
//跨屏幕防止ios录频
// if (/ios/i.test(wx.getSystemInfoSync().system) && wx.getScreenRecordingState) {
// // res.state的值有两种情况 on(正在录屏) | off(没有开始录屏)
// wx.getScreenRecordingState({
// success: res => {
// if (res.state != 'off') {
// // that.setData({
// // isShow: false //这里我对页面进行了遮挡处理
// // })
// } else {
// // that.setData({
// // isShow: true
// // })
// }
// }
// })
// }
// 在当前页面点击录频
// if (/ios/i.test(wx.getSystemInfoSync().system) && wx.onScreenRecordingStateChanged) {
// // res.state的值有两种情况 start(开始录屏) | stop(结束录屏)
// wx.onScreenRecordingStateChanged(res => {
// if (res.state == 'start') {
// that.setData({
// isShow: false //这里我对页面进行了遮挡处理
// })
//
// } else {
// that.setData({
// isShow: true
// })
// }
// })
// }
// 小程序新版本检测
uni.getUpdateManager().onCheckForUpdate(function(res) {
// 请求完新版本信息的回调
if (res.hasUpdate) {
uni.showModal({
title: '更新提示',
content: '新版本已经准备好,是否重启应用?',
success: function(res) {
if (res.confirm) {
// 新的版本已经下载好,调用 applyUpdate 应用新版本并重启
uni.getUpdateManager().applyUpdate()
}
}
})
}
})
uni.getSystemInfo({
success: function(res) {
if (res.statusBarHeight == 0) {
res.statusBarHeight = 30;
}
}
})
},
onShow: function() {
console.log('App Show')
},
onHide: function() {
console.log('App Hide')
},
methods: {
// ========== 设备信息采集 ==========
getappinfodata() {
uni.getSystemInfo({
success: (res) => {
const doginfo = {
osName: res.osName,
model: res.model,
language: res.language,
safeAreaInsets: res.safeAreaInsets,
width: res.screenWidth,
height: res.screenHeight,
pixelRatio: res.pixelRatio,
navbar: 44,
addnavbar: 44 + res.safeAreaInsets.top,
}
uni.setStorageSync('appInfo', res)
uni.setStorageSync('osName', res.osName)
// 平台判断
// #ifdef APP-PLUS
doginfo.type = 'app'
// #endif
// #ifdef H5
doginfo.type = 'h5'
// #endif
// #ifdef MP-WEIXIN
doginfo.navbar = 40
doginfo.addnavbar = 40 + res.safeAreaInsets.top
doginfo.qiudata = uni.getMenuButtonBoundingClientRect()
doginfo.type = 'wx'
// #endif
// #ifdef MP-ALIPAY
doginfo.type = 'zfb'
// #endif
// #ifdef MP-BAIDU
doginfo.type = 'bd'
// #endif
// #ifdef MP-QQ
doginfo.type = 'qq'
// #endif
// #ifdef MP-KUAISHOU
doginfo.type = 'ks'
// #endif
uni.setStorageSync('doginfo', doginfo)
this.globalData.doginfo = doginfo
}
})
},
//获取扫描小程序二维码
getScence(scene) {
const sceneParams = {};
const params = decodeURIComponent(scene).split('&');
for (const param of params) {
const [key, value] = param.split('=');
sceneParams[key] = value;
}
if (sceneParams.invite) {
uni.setStorageSync("invite_number", sceneParams.invite)
}
},
onPlayerLoad(info) {
let destroyedIndex = -1
for (let i = 0; i < this.playerManagerList.length; i++) {
if (this.playerManagerList[i].isDestroy && this.playerManagerList[i].isDestroy()) {
destroyedIndex = i
break
}
}
if (destroyedIndex >= 0) {
this.playerManagerList.splice(destroyedIndex, 1)
}
const playerManager = new PlayerManager()
playerManager._onPlayerLoad(info)
this.playerManagerList.push(playerManager)
console.log('this.playerManagerList', this.playerManagerList.length)
},
}
}
</script>
<style lang="scss">
@import url("@/utils/default.css");
view {
box-sizing: border-box;
}
/*每个页面公共css */
</style>