This commit is contained in:
XGL-THINKPAD-X1\rucky
2024-01-23 19:10:52 +08:00
parent 35957f9f8d
commit ec457dc86c
7 changed files with 126 additions and 84 deletions

View File

@@ -19,7 +19,7 @@ import MyPrize from "@/components/MyPrize";
import Draw from "@/components/Draw";
import Result from "@/components/Result";
import Rule from "@/components/Rule";
import { createBGM, getQueryString, screenOrientation, isAndriod } from "@/plugins";
import { createBGM, getQueryString, screenOrientation, isAndriod,fontAdpat } from "@/plugins";
import { authorize, getUserInfo } from "@/api";
import { Toast } from "vant";
import { useMainStore } from "@/store";
@@ -77,7 +77,7 @@ const drawFn = (item) => {
}
};
const showResult = ref(false);
const showResult = ref(true);
const resultFn = (item) => {
if (item.action == "hide") {
showResult.value = false;
@@ -113,6 +113,24 @@ onMounted(() => {
createBGM();
// 开始加载组件
showLoad.value = true;
// ios自动播放音乐
document.addEventListener("DOMContentLoaded", function () {
function audioAutoPlay() {
var audio = document.getElementById("musicBtn");
audio.play();
document.addEventListener(
"WeixinJSBridgeReady",
function () {
WeixinJSBridge.invoke("getNetworkType", {}, function (e) {
audio.play();
});
},
false
);
}
audioAutoPlay();
});
return;
} else {
authorize({ scopeType: 1, redirectUri: url }).then((res) => {
@@ -184,39 +202,19 @@ onMounted(() => {
}
} else {
showLoad.value = true;
createBGM();
}
});
// 字体适配
const fontAdpat = () => {
if (
typeof WeixinJSBridge == "object" &&
typeof WeixinJSBridge.invoke == "function"
) {
handleFontSize();
} else {
if (document.addEventListener) {
document.addEventListener("WeixinJSBridgeReady", handleFontSize, false);
} else if (document.attachEvent) {
document.attachEvent("onWeixinJSBridgeReady", handleFontSize);
}
}
function handleFontSize() {
// 设置网页字体为默认大小
WeixinJSBridge.invoke("setFontSizeCallback", { fontSize: 0 });
// 重写设置网页字体大小的事件
WeixinJSBridge.on("menu:setfont", function () {
WeixinJSBridge.invoke("setFontSizeCallback", { fontSize: 0 });
});
}
};
const playMusic = () => {
if (isAndriod) {
var audio = document.getElementById("audio");
audio.play();
}
if(isAndriod){
var audioEle = document.getElementById("audio");
audioEle.play();
}
}