Files
frontend-app/unpackage/dist/dev/mp-weixin/pages/turntable/turntable.js
T

150 lines
4.7 KiB
JavaScript
Raw Normal View History

2025-03-20 08:46:07 +08:00
"use strict";
const common_vendor = require("../../common/vendor.js");
const common_assets = require("../../common/assets.js");
const _sfc_main = {
data() {
return {
deg: 0,
singleAngle: "",
// 每片扇形的角度
isStart: false,
areaNumber: 6,
speed: 16,
award: 1,
awardList: [
{
title: "特等奖"
},
{
title: "一等奖"
},
{
title: "二等奖"
},
{
title: "三等奖"
},
{
title: "四等奖"
},
{
title: "啥也没有"
}
]
// 顺时针对应每个奖项
};
},
methods: {
jumpMine() {
common_vendor.index.switchTab({
url: "/pages/mine/mine"
});
},
init() {
},
// 点击开始抽奖
start() {
let { areaNumber } = this;
2025-03-23 20:36:06 +08:00
common_vendor.index.__f__("log", "at pages/turntable/turntable.vue:92", "areaNumber", areaNumber);
2025-03-20 08:46:07 +08:00
const singleAngle = 360 / areaNumber;
2025-03-23 20:36:06 +08:00
common_vendor.index.__f__("log", "at pages/turntable/turntable.vue:94", "singleAngle", singleAngle);
2025-03-20 08:46:07 +08:00
this.singleAngle = singleAngle;
let index = Math.floor(Math.random() * 6 + 1);
this.award = index;
2025-03-23 20:36:06 +08:00
common_vendor.index.__f__("log", "at pages/turntable/turntable.vue:98", "index", index);
2025-03-20 08:46:07 +08:00
this.begin(index);
},
begin(awardNumer) {
var deg = this.deg;
var singleAngle = this.singleAngle;
var speed = this.speed;
var isStart = this.isStart;
if (isStart)
return;
this.isStart = true;
let endAddAngle = 0;
2025-03-23 20:36:06 +08:00
common_vendor.index.__f__("log", "at pages/turntable/turntable.vue:110", "awardNumer", awardNumer);
common_vendor.index.__f__("log", "at pages/turntable/turntable.vue:111", "singleAngle", singleAngle);
2025-03-20 08:46:07 +08:00
endAddAngle = 360 - ((awardNumer - 1) * singleAngle + singleAngle / 2);
const rangeAngle = (Math.floor(Math.random() * 4) + 4) * 360;
2025-03-23 20:36:06 +08:00
common_vendor.index.__f__("log", "at pages/turntable/turntable.vue:116", endAddAngle);
2025-03-20 08:46:07 +08:00
let cAngle;
deg = 0;
this.timer = setInterval(() => {
if (deg < rangeAngle) {
deg += speed;
} else {
cAngle = (endAddAngle + rangeAngle - deg) / speed;
cAngle = cAngle > speed ? speed : cAngle < 1 ? 1 : cAngle;
deg += cAngle;
if (deg >= endAddAngle + rangeAngle) {
deg = endAddAngle + rangeAngle;
this.isStart = false;
clearInterval(this.timer);
this.turntableSuccess();
}
}
this.deg = deg;
}, 1e3 / 60);
},
// 抽奖完成后操作
turntableSuccess() {
const index = this.award - 1;
2025-03-23 20:36:06 +08:00
common_vendor.index.__f__("log", "at pages/turntable/turntable.vue:144", "bind:success", this.awardList[index]);
2025-03-20 08:46:07 +08:00
common_vendor.index.showToast({
title: `恭喜你获得${this.awardList[index].title}`,
icon: "none"
});
2025-03-23 20:36:06 +08:00
},
/**
* 开始多次抽奖
*/
drawsFun(count) {
common_vendor.index.__f__("log", "at pages/turntable/turntable.vue:154", "开始多次抽奖。。count", count);
this.start();
},
/**
* 跳转到中奖记录
*/
jumpWinningRecord() {
2025-03-20 08:46:07 +08:00
}
}
};
if (!Array) {
const _easycom_up_image2 = common_vendor.resolveComponent("up-image");
_easycom_up_image2();
}
const _easycom_up_image = () => "../../uni_modules/uview-plus/components/u-image/u-image.js";
if (!Math) {
_easycom_up_image();
}
function _sfc_render(_ctx, _cache, $props, $setup, $data, $options) {
return {
a: common_vendor.o($options.jumpMine),
b: common_vendor.p({
src: "/static/common/left_b.png",
width: "22",
height: "22",
bgColor: "#f1f6ff00"
}),
c: common_assets._imports_0,
d: common_vendor.s("-webkit-transform:rotate(" + $data.deg + "deg) translateZ(0);transform:rotate(" + $data.deg + "deg) translateZ(0)"),
e: common_assets._imports_1,
2025-03-23 20:36:06 +08:00
f: common_vendor.o((...args) => $options.start && $options.start(...args)),
g: common_vendor.o(($event) => $options.drawsFun(1)),
h: common_vendor.o(($event) => $options.drawsFun(10)),
i: common_vendor.o(($event) => $options.drawsFun(100)),
j: common_vendor.o(($event) => $options.drawsFun(365)),
k: common_vendor.o($options.jumpWinningRecord),
l: common_vendor.p({
src: "/static/turntable/record.png",
width: "14",
height: "14",
bgColor: "#f1f6ff00"
})
2025-03-20 08:46:07 +08:00
};
}
const MiniProgramPage = /* @__PURE__ */ common_vendor._export_sfc(_sfc_main, [["render", _sfc_render]]);
wx.createPage(MiniProgramPage);
//# sourceMappingURL=../../../.sourcemap/mp-weixin/pages/turntable/turntable.js.map