This commit is contained in:
zpc 2025-05-22 03:59:23 +08:00
parent 8066034803
commit 0790b8c1a8
6 changed files with 97 additions and 1216 deletions

View File

@ -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();
}

View File

@ -15,7 +15,7 @@
动画结果因设备差异可能会显示异常获得赏品以恭喜获得结果为准</view>
<view class="skip-animation" @click="skipAnimation" :style="[skipButtonStyle()]">跳过动画</view>
</view>
<DetailGrandPrize ref="detailGrandPrize" @end="onLuckyEnd1" />
<!-- <DetailGrandPrize ref="detailGrandPrize" @end="onLuckyEnd1" /> -->
</view>
</template>
@ -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(() => {
// DOMplay
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;

View File

@ -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() {
//

File diff suppressed because it is too large Load Diff

View File

@ -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);
}
},

View File

@ -48,7 +48,7 @@
<!--选项卡-->
<detail-toolbar v-if="goods != null" :goods-type="goods.type" :current-tab="tabCur"
@rule-click="$refs.rulePop.getRule(pageData.danye_id, '购买说明')" @tab-change="tabChange"
@change-box="changeBox" :isWuxian="true"></detail-toolbar>
:isWuxian="true"></detail-toolbar>
<detail-wuxian-lingzhu v-if="goods != null && goods.lingzhu_is == 1" :goods-num="0" :goods="goods">
</detail-wuxian-lingzhu>
<detail-wuxian-rage v-if="pageData && pageData.goods.rage_is == 1"
@ -585,9 +585,7 @@ export default {
.goodslist_id);
return index;
});
this.$refs.detailLucky.startDrawWithResult(resultIndices, () => {
console.log("抽奖结束");
}, chaoshen);
this.$refs.detailLucky.startDrawWithResult(this, resultIndices, chaoshen);
}
},