文章来源:网络作者:安笙々发布时间:2026-08-19 05:39:42
今天小编就带大家来共同学习如何在微信小程序上制作炸金花?希望可以帮助到有需要的小伙伴哦,下面就是详细完整的操作步骤。


app.json:
{
"pages":[
"pages/index/index"
],
"window":{
"navigationBarBackgroundColor": "#333333","navigationBarTextStyle":"white",
"navigationBarTitleText": "炸金花",
"backgroundColor":"#ffffff",
"backgroundTextStyle":"light",
"enablePullDownRefresh":false
}
}
index.js
Page({
data:{
num1:1,
num2:2,
num3:3,
imgNum1:1,
imgNum2:2,
imgNum3:3,
b1:"white",
b2:"white",
b3:"white",
flag:true,
butype:"primary",
butext:"开始",
hidden:true,
score:0
},
start:function(){
var that=this;
that.setData({
butype:"default",
butext:"停止"
})
if(this.data.flag){
this.go=setInterval(function(){
that.setData({
num1:Math.ceil(Math.random()*10),
num2:Math.ceil(Math.random()*10),
num3:Math.ceil(Math.random()*10),
imgNum1:Math.ceil(Math.random()*4),
imgNum2:Math.ceil(Math.random()*4),
imgNum3:Math.ceil(Math.random()*4),
b1:"#"+Math.floor(Math.random()*1000000),b2:"#"+Math.floor(Math.random()*1000000),b3:"#"+Math.floor(Math.random()*1000000)
})
},100)
this.setData({
flag:false,
hidden:true,
score:0
})
}else{
clearInterval(this.go)
this.setData({
flag:true,
butype:"primary",
butext:"开始",
b1:"white",
b2:"white",
b3:"white"
})
var n1=this.data.num1;
var n2=this.data.num2;
var n3=this.data.num3;
var img1=this.data.imgNum1;
var img2=this.data.imgNum2;
var img3=this.data.imgNum3;
var result=n1+n2+n3;
if(img1==img2&&img2==img3){
result+=20;
}else if(img1==img2 || img2==img3 || img1==img3){result+=10;
}
var newarr=new Array();
newarr.push(n1)
newarr.push(n2)
newarr.push(n3)
for(var i=0;i for(var j = i + 1;j if(newarr[i]>newarr[j]){ var tmp = newarr[i]; newarr[i] = newarr[j]; newarr[j] = tmp; } } } if(((newarr[2]-newarr[1])==1)&&((newarr[1]-newarr[0])==1)){result+=30; }else if(newarr[2]==newarr[1] || newarr[2]==newarr[0] || newarr[0]==newarr[1]){result+=10; }else if(newarr[2]==newarr[1]&&newarr[2]==newarr[0]){result+=40; } this.setData({ hidden:false, score:result }) } }, onShareAppMessage: function () { return { title: "大小之争", desc: \'激烈的竞技游戏\', path: \'/pages/index/index\' } } }) ndex.wxml: index.wxss: .container{width:30%;height:200px;position:relative;border:1px solid #787775;box-sizing:border-box; display: inline-block;flex:1;margin:10px;border-radius:10px;box-shadow: 5px 5px 3px #787775} .text{width:30px;height:30px;position:absolute;top:15px;left:15px;font-size: 25px;font-weight: bolder} .img{width:50px;height:50px;position:absolute;top:50%;left:50%;margin-left:-25px;margin-top:-25px} .text1{width:30px;height:30px;position:absolute;bottom:15px;right:15px;font-size: 25px;font-weight: bolder;transform: rotate(180deg)} 以上就是如何在微信小程序上制作炸金花的全部内容了,大家都学会了吗?




禁地之战(乾马金龙专属)
超变传奇996传奇
乾马金龙专属 全新三职业神器,上线领豪礼,爽玩!

王者霸业(王斩切割爆爆爆)
超变传奇
王斩切割爆爆爆 上线即送自动拾取、自动回收

烈焰之怒(骷髅超变日送10万...
超变传奇996传奇
骷髅超变日送10万 上线免费送刀刀绿毒刀刀冰冻自动回收,无条件登录就送10万充值货币!

铸兵之王(百亿直购送充爆)
超变传奇996传奇
百亿直购送充爆 自动拾取 自动回收 攻速全满 直升10000级 六大终极装备

江湖我最牛(GM狂送真充超超...
超变传奇996传奇
GM狂送真充超超变 全新超变几率触发GM手机,狂送真充红包

斗转武林(竹火百锻默爆)
超变传奇996传奇
竹火百锻默爆 上线福利:自动拾取、自动回收、更多豪礼在线相送!!

战影破穹(百亿送充神技觉醒...
超变传奇996传奇
百亿送充神技觉醒 上线即送自动回收、自动拾取等!

苍穹之剑2(帝煞古兵专属)
超变传奇996传奇
帝煞古兵专属 上线即送自动拾取、自动回收

摸金之路(无限超变天天送百...
超变传奇996传奇
无限超变天天送百万 超爽直购币白漂版本,天天送百万直购币!

国战来了(3.5折免费版)
策略
3.5折免费版 3.5折免费,每天送100限时代金券

《逆战:未来》张杰福利放送:杰...