diff --git a/components/detail-lucky/detail-grand-prize.vue b/components/detail-lucky/detail-grand-prize.vue
index 934058a..50bf40f 100644
--- a/components/detail-lucky/detail-grand-prize.vue
+++ b/components/detail-lucky/detail-grand-prize.vue
@@ -54,10 +54,12 @@ export default {
this.isVisible = true;
this.isFadingOut = false; // 重置淡出状态
this.webpUrl =
- "https://image.zfunbox.cn/static/image/lucky/grand.webp?v=" +
- new Date().getTime();
+ "https://image.zfunbox.cn/static/image/lucky/grand.webp?v=" + new Date().getTime();
if (this.bgmCtx && this.bgmCtx.csBgm) {
+ console.log('播放超神音乐');
+ this.bgmCtx.slotBgm.stop();
+ this.bgmCtx.csBgm.stop();
this.bgmCtx.csBgm.seek(0);
this.bgmCtx.csBgm.play();
}
diff --git a/components/detail-lucky/detail-lucky-canvas.vue b/components/detail-lucky/detail-lucky-canvas.vue
index 72a828b..b212858 100644
--- a/components/detail-lucky/detail-lucky-canvas.vue
+++ b/components/detail-lucky/detail-lucky-canvas.vue
@@ -15,7 +15,7 @@
动画结果因设备差异可能会显示异常,获得赏品以(恭喜获得)结果为准
跳过动画
-
+
@@ -140,7 +140,7 @@ export default {
onLuckyEnd1() {
// 发送中奖信息到父组件
- this.$emit("end", []);
+ this.$emit("end", false);
// 调用startDrawWithResult方法中保存的回调函数
if (this.drawResultCallback && typeof this.drawResultCallback === 'function') {
@@ -419,21 +419,20 @@ export default {
data: this.batchResults,
},
};
- this.bgmCtx.slotBgm.stop();
+ this.$emit("luckyStop", "");
if (this.chaoShenIndex != -1) {
-
// 重置批次状态
this.isBatchMode = false;
this.batchCount = 0;
this.batchResults = [];
- this.$refs.detailGrandPrize.init();
- this.$refs.detailGrandPrize.show();
+ // this.$refs.detailGrandPrize.init();
+ // this.$refs.detailGrandPrize.show();
return;
}
this.timers.drawResult = setTimeout(() => {
// 发送中奖信息到父组件
- this.$emit("end", batchResult);
+ this.$emit("end", false);
// 调用保存的批次回调
if (this.batchCallback && typeof this.batchCallback === 'function') {
@@ -451,18 +450,18 @@ export default {
return;
}
}
+ this.$emit("luckyStop", "");
- this.bgmCtx.slotBgm.stop();
if (this.chaoShenIndex != -1) {
- this.$refs.detailGrandPrize.init();
- this.$refs.detailGrandPrize.show();
+ // this.$refs.detailGrandPrize.init();
+ // this.$refs.detailGrandPrize.show();
return;
}
this.timers.drawResult = setTimeout(() => {
// 发送中奖信息到父组件
- this.$emit("end", result);
+ this.$emit("end", false);
// 调用startDrawWithResult方法中保存的回调函数
if (this.drawResultCallback && typeof this.drawResultCallback === 'function') {
@@ -505,10 +504,8 @@ export default {
console.error("抽奖特效尚未初始化,请先调用init方法");
return this;
}
- if (this.bgmCtx && this.bgmCtx.slotBgm) {
- this.bgmCtx.slotBgm.stop();
- }
+ this.$emit("luckyStop", "");
console.log("[跳过动画] 批次模式:", this.isBatchMode, "当前模式:", this.internalMode, "批次计数:", this.batchCount);
this.hide();
@@ -526,7 +523,7 @@ export default {
// 调用stop方法停止旋转
this.$refs.myLucky.stop(stopIndex);
// 发送事件到父组件
- this.$emit("end", []);
+ this.$emit("end", true);
return this; // 返回this以支持链式调用
},
@@ -544,82 +541,7 @@ export default {
},
- // 开始抽奖方法
- startDraw(callback) {
- // 检查是否已初始化
- if (!this.isInitialized) {
- console.error("抽奖特效尚未初始化,请先调用init方法");
- return this;
- }
- if (this.isSkip) {
- this.isSkip = false;
- }
- // 保存回调函数
- this.drawResultCallback = typeof callback === 'function' ? callback : null;
-
- // 重置跳过按钮透明度
- this.skipButtonOpacity = 0;
-
- // 如果是模式10,启用批次模式
- if (this.internalMode === 10) {
- console.log("[批次抽奖] 检测到模式10,启用批次模式");
- this.isBatchMode = true;
- this.batchCount = 0;
- this.batchResults = [];
- this.batchCallback = this.drawResultCallback; // 保存批次回调
- this.drawResultCallback = null; // 清空普通回调
-
- // 为批次模式生成随机索引
- this.batchIndices = [];
- for (let i = 0; i < 10; i++) {
- this.batchIndices.push(Math.floor(Math.random() * this.prizes.length));
- }
- console.log("[批次抽奖] 生成随机索引:", this.batchIndices);
- }
-
- // 显示抽奖特效
- this.show();
-
- setTimeout(() => {
- // 确保DOM已渲染完成后再调用play方法
- this.$nextTick(() => {
- // 检查组件是否已初始化
- if (this.$refs.myLucky) {
- // 开始旋转
- this.$refs.myLucky.play();
- if (this.bgmCtx && this.bgmCtx.slotBgm) {
- this.bgmCtx.slotBgm.seek(0);
- this.bgmCtx.slotBgm.play();
- }
-
- // 渐显跳过按钮
- this.timers.skipButton = setTimeout(() => {
- this.skipButtonOpacity = 1;
- }, 1000);
-
- // 批次模式下自动停止第一批次
- if (this.isBatchMode && this.internalMode === 10) {
- console.log("[批次抽奖] 设置2秒后自动停止第一批次");
- this.timers.firstBatch = setTimeout(() => {
- // 使用前5个索引作为第一批次结果
- const firstBatchIndices = this.batchIndices.slice(0, 5);
- console.log("[批次抽奖] 停止第一批次抽奖,使用索引:", firstBatchIndices);
- this.stopDraw(firstBatchIndices);
- }, 2000);
- }
-
- if (typeof callback === "function" && !this.isBatchMode) {
- callback();
- }
- } else {
- console.error("抽奖特效组件未初始化");
- }
- });
- }, 100);
-
- return this; // 返回this以支持链式调用
- },
// 停止抽奖并指定中奖索引
stopDraw(prizeIndices) {
@@ -759,16 +681,7 @@ export default {
console.log("[批次抽奖] 开始第一批次抽奖");
// 开始第一批次抽奖
this.$refs.myLucky.play();
-
- // 播放抽奖音乐
- if (that.bgmCtx && that.bgmCtx.slotBgm) {
- console.log("[批次抽奖] 播放第一批次抽奖音乐");
- that.bgmCtx.slotBgm.seek(0);
- that.bgmCtx.slotBgm.play();
- } else {
- console.log("[批次抽奖] 未找到音乐上下文,无法播放音乐");
- }
-
+ this.$emit("luckyPlay", "")
// 渐显跳过按钮
this.timers.skipButton = setTimeout(() => {
this.skipButtonOpacity = 1;
@@ -815,15 +728,7 @@ export default {
if (this.$refs.myLucky) {
// 开始旋转
this.$refs.myLucky.play();
-
- // 播放抽奖音乐
- if (this.bgmCtx && this.bgmCtx.slotBgm) {
- console.log("播放抽奖音乐");
- this.bgmCtx.slotBgm.seek(0);
- this.bgmCtx.slotBgm.play();
- } else {
- console.log("未找到音乐上下文,无法播放音乐");
- }
+ this.$emit("luckyPlay", "")
// 渐显跳过按钮
this.timers.skipButton = setTimeout(() => {
@@ -856,15 +761,7 @@ export default {
if (this.$refs.myLucky) {
// 开始旋转
this.$refs.myLucky.play();
-
- // 播放抽奖音乐
- if (this.bgmCtx && this.bgmCtx.slotBgm) {
- console.log("播放抽奖音乐");
- this.bgmCtx.slotBgm.seek(0);
- this.bgmCtx.slotBgm.play();
- } else {
- console.log("未找到音乐上下文,无法播放音乐");
- }
+ this.$emit("luckyPlay", "")
// 渐显跳过按钮
this.timers.skipButton = setTimeout(() => {
@@ -938,16 +835,8 @@ export default {
// 开始第二批次抽奖
console.log("[批次抽奖] 调用play方法开始第二批次");
this.$refs.myLucky.play();
-
- // 播放抽奖音乐
- if (this.bgmCtx && this.bgmCtx.slotBgm) {
- console.log("[批次抽奖] 播放第二批次抽奖音乐");
- this.bgmCtx.slotBgm.seek(0);
- this.bgmCtx.slotBgm.play();
- } else {
- console.log("[批次抽奖] 未找到音乐上下文,无法播放音乐");
- }
-
+ //开始抽奖回调
+ this.$emit("luckyPlay", "");
// 渐显跳过按钮
this.timers.skipButton = setTimeout(() => {
this.skipButtonOpacity = 1;
diff --git a/components/detail-lucky/detail-lucky-web.vue b/components/detail-lucky/detail-lucky-web.vue
index f0352fd..f79b478 100644
--- a/components/detail-lucky/detail-lucky-web.vue
+++ b/components/detail-lucky/detail-lucky-web.vue
@@ -13,22 +13,17 @@ export default {
data() {
const sysinfo = uni.getSystemInfoSync();
return {
- hideviewStyles: {
- height: "0px",
- width: "0px",
- },
webviewStyles: {
height: sysinfo.windowHeight + "px",
width: sysinfo.windowWidth + "px",
},
isWebView: false,
- webviewObj: null,
status: "init",
lotteryResult: null,
page: null,
prize: [],
- // webUrl: 'https://zfunbox.cn/m/chou-box-luck.html',
- webUrl: "http://192.168.1.26:5501/%E5%85%AC%E5%8F%B8/%E5%B7%A5%E4%BD%9C/%E5%8F%8B%E8%BE%BE/%E8%90%BD%E5%9C%B0%E9%A1%B5/chou-box-luck.html",
+ webUrl: 'https://zfunbox.cn/m/chou-box-luck.html',
+ // webUrl: "http://192.168.1.26:5501/%E5%85%AC%E5%8F%B8/%E5%B7%A5%E4%BD%9C/%E5%8F%8B%E8%BE%BE/%E8%90%BD%E5%9C%B0%E9%A1%B5/chou-box-luck.html",
};
},
@@ -76,12 +71,13 @@ export default {
data = JSON.stringify(data);
}
let str = 'OnMessage("' + action + '","' + data + '");';
- console.log("OnMessage", str);
+ // console.log("OnMessage", str);
webview.evalJS('OnMessage("' + action + '",\'' + data + '\');');
},
onMessage(event) {
console.log("收到网页消息:", event);
const data = event.detail.data[0];
+
if (data.action === "load") {
// //跳过动画
// uni.showToast({
@@ -106,13 +102,17 @@ export default {
} else if (data.action == "addLotteryCountSuccess") {
this.setWebviewAction("startLottery",
{
- stopSleep: 3000,
+ stopSleep: 2000,
lotteryResult: this.lotteryResult
});
} else if (data.action == "stopLottery") {
this.isWebView = false;
- this.$emit("end", [])
+ if (data.msg == "跳过动画") {
+ this.$emit("end", true)
+ } else {
+ this.$emit("end", false)
+ }
} else if (data.action == "luckyStop") {
this.$emit("luckyStop", "")
} else if (data.action == "luckyPlay") {
@@ -125,15 +125,7 @@ export default {
icon: "none",
});
}
- },
- evalJs() {
- const webview = this.getWebview(); // 获取第一个子 webview
- if (webview) {
-
- } else {
- console.error("未找到子 WebView");
- }
- },
+ }
},
mounted() {
// 不再自动初始化
diff --git a/components/detail-lucky/detail-lucky.vue b/components/detail-lucky/detail-lucky.vue
index e6e3083..d3abfe1 100644
--- a/components/detail-lucky/detail-lucky.vue
+++ b/components/detail-lucky/detail-lucky.vue
@@ -1,1114 +1,117 @@
-
-
-
-
-
-
-
-
-
-
-
- 动画结果因设备差异可能会显示异常,获得赏品以(恭喜获得)结果为准
- 跳过动画
-
-
-
+
+
+
+
-
\ No newline at end of file
+
\ No newline at end of file
diff --git a/pages/shouye/detail.vue b/pages/shouye/detail.vue
index 6a8604f..d67c637 100644
--- a/pages/shouye/detail.vue
+++ b/pages/shouye/detail.vue
@@ -457,10 +457,7 @@ export default {
const index = this.getGoodList.findIndex(item => item.id == it.goodslist_id);
return index;
});
- this.$refs.detailLucky.startDrawWithResult(resultIndices, () => {
- console.log("抽奖结束");
- }, chaoshen);
-
+ this.$refs.detailLucky.startDrawWithResult(this,resultIndices,chaoshen);
}
},
diff --git a/pages/shouye/detail_wuxian.vue b/pages/shouye/detail_wuxian.vue
index 91aa6a2..e9ff323 100644
--- a/pages/shouye/detail_wuxian.vue
+++ b/pages/shouye/detail_wuxian.vue
@@ -48,7 +48,7 @@
+ :isWuxian="true">
{
- console.log("抽奖结束");
- }, chaoshen);
+ this.$refs.detailLucky.startDrawWithResult(this, resultIndices, chaoshen);
}
},