Commit 2f1176c5 authored by 小何程序员's avatar 小何程序员

何润辉第一次提交

parents
Pipeline #293 failed with stages
// app.js
App({
onLaunch() {
},
globalData: {
}
})
{
"pages":[
"pages/index/index"
],
"window":{
"backgroundTextStyle":"light",
"navigationBarBackgroundColor": "#fff",
"navigationBarTitleText": "Weixin",
"navigationBarTextStyle":"black"
},
"style": "v2",
"sitemapLocation": "sitemap.json"
}
ima/11.png

73.5 KB

ima/12.png

72.8 KB

ima/13.png

73.8 KB

ima/14.png

80.4 KB

ima/15.png

75.7 KB

ima/blue.png

280 Bytes

ima/blue2.png

170 Bytes

ima/yellow.png

170 Bytes

// index.js
// 获取应用实例
const app = getApp()
const the_first_left = 20
const side_len = 60
var bottom_timer = null
var up_timer = null
Page({
data: {
viewArr: [],
touchStartTime: 0,
// 触摸结束时间
touchEndTime: 0,
the_Bottom_SieveView_backImg: "../../ima/11.png",
Winning_numbers: [],
isOver: false,
Press_Time: 0,
Press_Range: '当前未滚动骰子'
},
onLoad() {
var arr = []
var l = 0
var t = 0
for (var i = 0; i < 54; i++) {
if (i < 50 && i > 40) {
var Cell_item = {
color: "black",
top: the_first_left + t * side_len,
left: the_first_left + l * side_len,
text: "",
backIma: "../../ima/blue.png"
}
} else if (i < 29 && i > 22) {
var Cell_item = {
color: "black",
top: the_first_left + t * side_len,
left: the_first_left + l * side_len,
text: "",
backIma: "../../ima/blue.png"
}
} else {
var Cell_item = {
color: "black",
top: the_first_left + t * side_len,
left: the_first_left + l * side_len,
text: i + "",
backIma: "../../ima/blue.png"
}
}
arr.push(Cell_item)
if (i <= 9) l++
else if (i <= 16) t++
else if (i <= 18) l--
else if (i <= 23) t--
else if (i <= 29) l--
else if (i <= 33) t++
else if (i <= 37) l++
else if (i <= 39) t++
else if (i <= 45) l--
else if (i <= 54) t--
}
this.setData({
viewArr: arr
})
},
Up_start() {
// 开始上方滚轮的滚动
var j = 0
var that = this
var model = this.data.viewArr
var len = model.length
var WinArrs = that.data.Winning_numbers
var win_len = WinArrs.length - 1
up_timer = setInterval(function () {
var str = []
for (var i = 0; i < model.length; i++) {
str.push(that.data.viewArr[i])
if (i == j) {
if (win_len != 0) {
str[i].backIma = "../../ima/yellow.png"
} else {
str[i].backIma = "../../ima/blue.png"
}
} else {
if (WinArrs.slice(win_len).indexOf(str[i].text) != -1) {
str[i].backIma = "../../ima/yellow.png"
} else {
str[i].backIma = "../../ima/blue.png"
}
}
}
that.setData({
viewArr: str
})
j++
if (--len == 0) {
j = 0
len = model.length
if (--win_len == -1) {
clearInterval(up_timer)
up_timer = null
setTimeout(function () {
that.setData({
isOver: false
})
}, 500)
}
}
}, 20)
},
Bottom_start() {
// 开始下方滚轮的滚动
var that = this
var index = 2
bottom_timer = setInterval(function () {
var len = (new Date().getTime() - that.data.touchStartTime) / 1000
that.setData({
the_Bottom_SieveView_backImg: "../../ima/1" + index + ".png",
Press_Time: len,
Press_Range: ""
})
if (++index == 6) {
index = 2
}
}, 100)
},
/// 按钮触摸开始触发的事件
touchStart: function (e) {
// 如果抽奖还没有结束提示无法重复抽奖
if (this.data.isOver == false) {
this.data.touchStartTime = new Date().getTime()
this.Bottom_start()
} else {
wx.showToast({
title: '正在抽奖中',
icon: "error",
mask: true
})
}
},
/// 按钮触摸结束触发的事件
touchEnd: function (e) {
// 如果抽奖还没有结束提示无法重复抽奖
if (this.data.isOver == false) {
this.setData({
isOver: true
})
this.data.Winning_numbers = []
this.data.touchEndTime = new Date().getTime()
var len = (this.data.touchEndTime - this.data.touchStartTime) / 1000
console.log("长按了:" + len + "秒")
clearInterval(bottom_timer)
bottom_timer = null
if ((len % 10) < 2) {
this.data.Winning_numbers = ['2', '3', '4']
this.setData({
the_Bottom_SieveView_backImg: "../../ima/12.png",
Press_Time: len,
Press_Range: "属于0~2秒范围内"
})
} else if ((len % 10) < 4) {
this.data.Winning_numbers = ['5', '6', '7']
this.setData({
the_Bottom_SieveView_backImg: "../../ima/13.png",
Press_Time: len,
Press_Range: "属于2~4秒范围内"
})
} else if ((len % 10) < 6) {
this.data.Winning_numbers = ['7', '8', '9']
this.setData({
the_Bottom_SieveView_backImg: "../../ima/14.png",
Press_Time: len,
Press_Range: "属于4~6秒范围内"
})
} else if ((len % 10) < 10) {
this.data.Winning_numbers = ['9', '10', '11', '12']
this.setData({
the_Bottom_SieveView_backImg: "../../ima/15.png",
Press_Time: len,
Press_Range: "属于6~10秒范围内"
})
}
this.Up_start()
} else {
wx.showToast({
title: '正在抽奖中',
icon: "error",
mask: true
})
}
},
})
\ No newline at end of file
{
"usingComponents": {}
}
\ No newline at end of file
<view id="box">
<image id="box_backImg" src="../../ima/background.jpg"></image>
<view id="Up_SieveView">
<image id="Up_SieveView_backIma" src="../../ima/pan1.jpg"></image>
<view wx:for="{{viewArr}}" class="cell"
style="background-color: {{item.color}};top: {{item.top + 'rpx'}};left: {{item.left + 'rpx'}}">
<image id="cellIma" src="{{item.backIma}}"></image>
<text id="cellText">{{item.text}}</text>
</view>
</view>
<view id="resView">
<text>{{'长按了' + Press_Time + '秒,' + Press_Range}}</text>
</view>
<view id="Bottom_SieveView">
<image id="Bottom_SieveView_backImg" src="{{the_Bottom_SieveView_backImg}}"></image>
<image wx:if="{{!isOver}}" id="SieveImg" src="../../ima/sieeve.png" bindtouchstart="touchStart"
bindtouchend="touchEnd"></image>
<text wx:else id="SieveImg" style="top: 140rpx">正在抽奖...</text>
</view>
</view>
#box{
width: 100vw;
height: 100vh;
}
#box_backImg{
position: absolute;
width: 100vw;
height: 100vh;
}
#Up_SieveView{
position: relative;
top: 20px;
left: 25rpx;
width: 700rpx;
height: 570rpx;
/* background-color: red; */
display: flex;
}
#Up_SieveView_backIma {
width: 700rpx;
height: 570rpx;
}
#Bottom_SieveView {
position: relative;
top: 100rpx;
left: 225rpx;
width: 350rpx;
height: 350rpx;
/* background-color: rgb(151, 148, 148); */
display: flex;
align-items: center;
justify-content: center;
}
.cell {
position: absolute;
/* background-color: black; */
width: 62rpx;
height: 62rpx;
color:black;
font-size: 40rpx;
text-align: center;
display: flex;
}
#cellIma {
position: absolute;
width: 62rpx;
height: 62rpx;
}
#cellText {
position: absolute;
width: 62rpx;
height: 62rpx;
color: green;
font-weight: bold;
}
#Bottom_SieveView_backImg{
position: absolute;
top: 30rpx;
left: 30rpx;
width: 350rpx;
height: 350rpx;
}
#SieveImg {
position: absolute;
top: 110rpx;
left: 110rpx;
width: 150rpx;
height: 150rpx;
text-align: center;
font-weight: bold;
}
#resView {
position: relative;
top: 60rpx;
left: 30rpx;
font-weight: bold;
}
{
"description": "项目配置文件",
"packOptions": {
"ignore": []
},
"setting": {
"urlCheck": true,
"es6": true,
"enhance": true,
"postcss": true,
"preloadBackgroundData": false,
"minified": true,
"newFeature": false,
"coverView": true,
"nodeModules": false,
"autoAudits": false,
"showShadowRootInWxmlPanel": true,
"scopeDataCheck": false,
"uglifyFileName": false,
"checkInvalidKey": true,
"checkSiteMap": true,
"uploadWithSourceMap": true,
"compileHotReLoad": false,
"useMultiFrameRuntime": true,
"useApiHook": true,
"useApiHostProcess": false,
"babelSetting": {
"ignore": [],
"disablePlugins": [],
"outputPath": ""
},
"enableEngineNative": false,
"useIsolateContext": true,
"useCompilerModule": true,
"userConfirmedUseCompilerModuleSwitch": false,
"userConfirmedBundleSwitch": false,
"packNpmManually": false,
"packNpmRelationList": [],
"minifyWXSS": true
},
"compileType": "miniprogram",
"libVersion": "2.17.0",
"appid": "wx7d1aac29da3aa9bd",
"projectname": "Sieve_text",
"debugOptions": {
"hidedInDevtools": []
},
"scripts": {},
"staticServerOptions": {
"baseURL": "",
"servePath": ""
},
"isGameTourist": false,
"condition": {
"search": {
"list": []
},
"conversation": {
"list": []
},
"game": {
"list": []
},
"plugin": {
"list": []
},
"gamePlugin": {
"list": []
},
"miniprogram": {
"list": []
}
}
}
\ No newline at end of file
{
"desc": "关于本文件的更多信息,请参考文档 https://developers.weixin.qq.com/miniprogram/dev/framework/sitemap.html",
"rules": [{
"action": "allow",
"page": "*"
}]
}
\ No newline at end of file
const formatTime = date => {
const year = date.getFullYear()
const month = date.getMonth() + 1
const day = date.getDate()
const hour = date.getHours()
const minute = date.getMinutes()
const second = date.getSeconds()
return `${[year, month, day].map(formatNumber).join('/')} ${[hour, minute, second].map(formatNumber).join(':')}`
}
const formatNumber = n => {
n = n.toString()
return n[1] ? n : `0${n}`
}
module.exports = {
formatTime
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment