222
This commit is contained in:
parent
8066034803
commit
0790b8c1a8
|
|
@ -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();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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(() => {
|
||||
// 确保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;
|
||||
|
|
|
|||
|
|
@ -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
|
|
@ -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);
|
||||
}
|
||||
|
||||
},
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
}
|
||||
},
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user