欧美bbbwbbbw肥妇,免费乱码人妻系列日韩,一级黄片

微信小程序 扎金花簡單實例

 更新時間:2017年02月21日 17:34:06   投稿:lqh  
這篇文章主要介紹了微信小程序 扎金花簡單實例的相關(guān)資料,需要的朋友可以參考下

微信小程序  扎金花

實現(xiàn)效果圖:

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<newarr.length;i++){
      for(var j = i + 1;j<newarr.length;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'
  }
 }
 
 
})

  index.wxml:

<view style="text-align:center;position:fixed;top:10px;left:0;width:100%;color:green;font-weight:bolder" hidden="{{hidden}}">恭喜你得了{(lán){score}}分!</view>
<view style="clear:both;overflow:hidden;display:flex;margin-top:50px">
  <view class="container" style="background:{{b1}};" >
    <text class="text">{{num1}}</text>
    <image class="img" src="../../images/{{imgNum1}}.png" style="transform: rotate({{deg1}}deg)"></image>
    <text class="text1">{{num1}}</text>
  </view>
 
  <view class="container" style="background:{{b2}};">
    <text class="text">{{num2}}</text>
    <image class="img" src="../../images/{{imgNum2}}.png" style="transform: rotate({{deg2}}deg)"></image>
    <text class="text1">{{num2}}</text>
  </view>
  <view class="container" style="background:{{b3}};">
    <text class="text">{{num3}}</text>
    <image class="img" src="../../images/{{imgNum3}}.png" style="transform: rotate({{deg3}}deg)"></image>
    <text class="text1">{{num3}}</text>
  </view>
</view>
 
<button bindtap="start" type="{{butype}}" style="margin:20px">{{butext}}</button>
 
 
<view style="font-size:13px;padding:20px;color:gray">
  <view>1.如果三張數(shù)字相同得40分,如果三張數(shù)字是連續(xù)的得30分,如果兩個數(shù)字是相同的得10分</view>
  <view>2.如果三張花色一樣得20分,如果兩張花色一樣得10分</view>
  <view>3.三張數(shù)字之和</view>
  <view>以上所有數(shù)字的總和為總分</view>
</view>

  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)}

 1.png:

2.png:

3.png

 

4.png

 

 感謝閱讀,希望能幫助到大家,謝謝大家對本站的支持!

相關(guān)文章

  • Web?Animations?API實現(xiàn)一個精確計時的時鐘示例

    Web?Animations?API實現(xiàn)一個精確計時的時鐘示例

    這篇文章主要為大家介紹了Web?Animations?API實現(xiàn)一個精確計時的時鐘示例,有需要的朋友可以借鑒參考下,希望能夠有所幫助,祝大家多多進(jìn)步,早日升職加薪
    2022-07-07
  • JS創(chuàng)建對象的四種方式

    JS創(chuàng)建對象的四種方式

    這篇文章主要給大家分享JS創(chuàng)建對象的四種方式,分別是字面量的方式去創(chuàng)建對象、使用new字符創(chuàng)建對象、自定義構(gòu)造函數(shù)、工廠模式創(chuàng)建對象,更多詳細(xì)內(nèi)容,請參考下面文章的具體內(nèi)容
    2021-11-11
  • 前端JavaScript中的反射和代理

    前端JavaScript中的反射和代理

    這篇文章主要介紹的是前端JavaScript中的反射和代理,本文主要圍繞JavaScript中的內(nèi)置Reflect、JavaScript中的內(nèi)置Proxy、Proxy實現(xiàn)觀察者模式三個話題展開文章內(nèi)容,需要的朋友可以參一考下
    2021-10-10
  • 為輸入框加入數(shù)字js校驗代碼分享

    為輸入框加入數(shù)字js校驗代碼分享

    這篇文章主要介紹了為輸入框加入數(shù)字js校驗代碼分享,還是比較不錯的,這里分享給大家,供需要的朋友參考。
    2017-11-11
  • 微信小程序 解析網(wǎng)頁內(nèi)容詳解及實例

    微信小程序 解析網(wǎng)頁內(nèi)容詳解及實例

    這篇文章主要介紹了微信小程序 解析網(wǎng)頁內(nèi)容詳解及實例的相關(guān)資料,這里使用爬蟲對復(fù)雜的網(wǎng)頁進(jìn)行抓取,遇到些問題,這里整理下并解決,需要的朋友可以參考下
    2017-02-02
  • 微信小程序 swiper制作tab切換實現(xiàn)附源碼

    微信小程序 swiper制作tab切換實現(xiàn)附源碼

    這篇文章主要介紹了微信小程序 swiper制作tab切換實現(xiàn)代碼的相關(guān)資料,需要的朋友可以參考下
    2017-01-01
  • JS實現(xiàn)微信播音效果示例詳解

    JS實現(xiàn)微信播音效果示例詳解

    這篇文章主要為大家介紹了JS實現(xiàn)微信播音效果示例詳解,有需要的朋友可以借鑒參考下,希望能夠有所幫助,祝大家多多進(jìn)步,早日升職加薪
    2023-02-02
  • 超級強大的表單驗證

    超級強大的表單驗證

    超級強大的表單驗證...
    2006-06-06
  • javascript進(jìn)階篇深拷貝實現(xiàn)的四種方式

    javascript進(jìn)階篇深拷貝實現(xiàn)的四種方式

    這篇文章主要為大家介紹了javascript進(jìn)階篇深拷貝實現(xiàn)的四種方式詳解,有需要的朋友可以借鑒參考下,希望能夠有所幫助,祝大家多多進(jìn)步,早日升職加薪
    2022-07-07
  • Three.js引用和環(huán)境搭建過程詳解

    Three.js引用和環(huán)境搭建過程詳解

    這篇文章主要為大家介紹了Three.js引用和環(huán)境搭建過程詳解,有需要的朋友可以借鑒參考下,希望能夠有所幫助,祝大家多多進(jìn)步,早日升職加薪
    2023-05-05

最新評論