增加新模块
This commit is contained in:
@@ -0,0 +1,132 @@
|
||||
"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;
|
||||
common_vendor.index.__f__("log", "at pages/turntable/turntable.vue:73", "areaNumber", areaNumber);
|
||||
const singleAngle = 360 / areaNumber;
|
||||
common_vendor.index.__f__("log", "at pages/turntable/turntable.vue:75", "singleAngle", singleAngle);
|
||||
this.singleAngle = singleAngle;
|
||||
let index = Math.floor(Math.random() * 6 + 1);
|
||||
this.award = index;
|
||||
common_vendor.index.__f__("log", "at pages/turntable/turntable.vue:79", "index", index);
|
||||
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;
|
||||
common_vendor.index.__f__("log", "at pages/turntable/turntable.vue:91", "awardNumer", awardNumer);
|
||||
common_vendor.index.__f__("log", "at pages/turntable/turntable.vue:92", "singleAngle", singleAngle);
|
||||
endAddAngle = 360 - ((awardNumer - 1) * singleAngle + singleAngle / 2);
|
||||
const rangeAngle = (Math.floor(Math.random() * 4) + 4) * 360;
|
||||
common_vendor.index.__f__("log", "at pages/turntable/turntable.vue:97", endAddAngle);
|
||||
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);
|
||||
},
|
||||
// 用户点击开始抽奖
|
||||
// turntableStart() {
|
||||
// let index = Math.floor(Math.random() * 6 + 1) //前端随机数,这里应该后台返回中奖结果
|
||||
// this.award = index
|
||||
// this.$refs.turntable.begin(this.award);
|
||||
// },
|
||||
// 抽奖完成后操作
|
||||
turntableSuccess() {
|
||||
const index = this.award - 1;
|
||||
common_vendor.index.__f__("log", "at pages/turntable/turntable.vue:131", "bind:success", this.awardList[index]);
|
||||
common_vendor.index.showToast({
|
||||
title: `恭喜你获得${this.awardList[index].title}`,
|
||||
icon: "none"
|
||||
});
|
||||
}
|
||||
}
|
||||
};
|
||||
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,
|
||||
f: common_vendor.o((...args) => $options.start && $options.start(...args))
|
||||
};
|
||||
}
|
||||
const MiniProgramPage = /* @__PURE__ */ common_vendor._export_sfc(_sfc_main, [["render", _sfc_render]]);
|
||||
wx.createPage(MiniProgramPage);
|
||||
//# sourceMappingURL=../../../.sourcemap/mp-weixin/pages/turntable/turntable.js.map
|
||||
@@ -0,0 +1,6 @@
|
||||
{
|
||||
"navigationStyle": "custom",
|
||||
"usingComponents": {
|
||||
"up-image": "../../uni_modules/uview-plus/components/u-image/u-image"
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1 @@
|
||||
<view class="turntable_warp"><view class="turntable_header_warp"><view class="header_title_warp"><up-image wx:if="{{b}}" bindclick="{{a}}" u-i="42dcd262-0" bind:__l="__l" u-p="{{b}}"></up-image><view class="title_">幸运转盘百亿补贴</view></view><view class="turntable_content_warp"><view class="frequency_warp"><view class="turntable_wp sol-class"><image src="{{c}}" style="{{d}}"></image><view class="turntable_pointer" bindtap="{{f}}"><image src="{{e}}"></image></view></view></view></view></view></view>
|
||||
File diff suppressed because one or more lines are too long
Reference in New Issue
Block a user