美文网首页
2021-11-25、阶段小制作——喝酒小游戏

2021-11-25、阶段小制作——喝酒小游戏

作者: 疋瓞 | 来源:发表于2021-12-04 14:14 被阅读0次

    tabBar项目素材:

    tabBar炸弹选中后.png tabBar炸弹选中前.png tabBar转盘结果选中后.png tabBar转盘结果选中前.png 一战到底.png 一战到底.png tabBar开发中选中后.png tabBar开发中选中前.png

    声音和图片

    声音和图片.png
    • 注意图片和声音可以自己在网上找然后下载下来,按照上面图片中的备注名称修改就好了。代码中就不用修改了。

    结果展示

    封面.png

    排雷页面:

    wxml

    <!--pages/zhaDan_game_xiugai/zhaDan_game.wxml-->
    <image src="{{title_image}}" mode="scaleToFill" class="title_image">
    </image>
    
    <view hidden="{{hidden_zhaDan}}" class="all_zhaDan">
        <view class="zhaDan_hang">
            <image id="0" src="{{zhaDan_0}}" class="zhaDan_style" bindtap="tap_image"></image>
            <image id="1" src="{{zhaDan_1}}" class="zhaDan_style" bindtap="tap_image"></image>
            <image id="2" src="{{zhaDan_2}} " class="zhaDan_style" bindtap="tap_image"></image>
            
        </view>
    
        <view class="zhaDan_hang">
            <image id="3" src="{{zhaDan_3}}" class="zhaDan_style" bindtap="tap_image"></image>
            <image id="4" src="{{zhaDan_4}}" class="zhaDan_style" bindtap="tap_image"></image>
            <image id="5" src="{{zhaDan_5}}" class="zhaDan_style" bindtap="tap_image"></image>
            
        </view>
    
        <view class="zhaDan_hang">
            <image id="6" src="{{zhaDan_6}}" class="zhaDan_style" bindtap="tap_image"></image>
            <image id="7" src="{{zhaDan_7}}" class="zhaDan_style" bindtap="tap_image"></image>
            <image id="8" src="{{zhaDan_8}}" class="zhaDan_style" bindtap="tap_image"></image>
        </view>
    </view>
    
    <view class="button_style">
        <button type="primary" bindtap="star_again" class="button_shuaXin">刷新</button>
    </view>
    

    wxss

    /* pages/zhaDan_game_xiugai/zhaDan_game.wxss */
    page {
        background-color:rgb(246, 246, 246);
    }
    .title_image{
        height: 100px;
        width: 100%;
    }
    .all_zhaDan{
        background-color: black;
        padding: 30px;
        margin-top: 10px;
    }
    .zhaDan_hang{
        display: flex;
        flex-direction: row;
        flex-wrap: nowrap;
        align-items: center;
        justify-content: center;
    }
    .zhaDan_style{
        height: 100px;
        width: 100px;
        border: 3px solid yellow;
    }
    
    .button_style{
        margin-top: 10px;
        width: 100%;  
    }
    .button_shuaXin{
        width:50%
    }
    

    js

    // pages/zhaDan_game_xiugai/zhaDan_game.js
    var yeMian_zhaDan = "https://img.haomeiwen.com/i14216764/b1623e81f9b453a2.jpeg?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240";
    var yeMian_kongBai = "https://img.haomeiwen.com/i14216764/463e903b71754a79.jpeg?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240";
    var yeMian_baoZha = "https://img.haomeiwen.com/i14216764/b0dd99eb06ebe148.jpeg?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240";
    
    var title_image = "https://img.haomeiwen.com/i14216764/7b48dc701fc98b02.jpeg?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240";
    
    var zhaDan_0 = "";
    var zhaDan_1 = "";
    var zhaDan_2 = "";
    var zhaDan_3 = "";
    var zhaDan_4 = "";
    var zhaDan_5 = "";
    var zhaDan_6 = "";
    var zhaDan_7 = "";
    var zhaDan_8 = "";
    
    var hidden_zhaDan = false;
    var random_allVar = 0;
    
    function random_number(){
        var random = Math.floor(Math.random()*9);
        return random;
    }
    
    Page({
    
        /**
         * 页面的初始数据
         */
        data: {
            hidden_zhaDan : hidden_zhaDan,
            title_image : title_image,
            zhaDan_0 : yeMian_zhaDan,
            zhaDan_1 : yeMian_zhaDan,
            zhaDan_2 : yeMian_zhaDan,
            zhaDan_3 : yeMian_zhaDan,
            zhaDan_4 : yeMian_zhaDan,
            zhaDan_5 : yeMian_zhaDan,
            zhaDan_6 : yeMian_zhaDan,
            zhaDan_7 : yeMian_zhaDan,
            zhaDan_8 : yeMian_zhaDan  
        },
     /**
         * 生命周期函数--监听页面加载
         */
        onLoad: function (options) {
            random_allVar = random_number();
            console.log(random_allVar);
        },
    
        tap_image:function(e){
            
            var num = parseInt(e.currentTarget.id);
            var random_result = random_allVar;
            console.log(random_result)
    
            if(num == random_result){
                let a1 = wx.createInnerAudioContext(); 
                a1.src = "/audio/baoZha.wav";
                a1.play();
    
                if(num == 0){
                    this.setData({
                        zhaDan_0 : yeMian_baoZha
                    })
                }
                else if(num == 1){
                    this.setData({
                        zhaDan_1 : yeMian_baoZha
                    })
                }
                else if(num == 2){
                    this.setData({
                        zhaDan_2 : yeMian_baoZha
                    })
                }
                else if(num == 3){
                    this.setData({
                        zhaDan_3 : yeMian_baoZha
                    })
                }
                else if(num == 4){
                    this.setData({
                        zhaDan_4 : yeMian_baoZha
                    })
                }
                else if(num == 5){
                    this.setData({
                        zhaDan_5 : yeMian_baoZha
                    })
                }
                else if(num == 6){
                    this.setData({
                        zhaDan_6 : yeMian_baoZha
                    })
                }
                else if(num == 7){
                    this.setData({
                        zhaDan_7 : yeMian_baoZha
                    })
                }
                else if(num == 8){
                    this.setData({
                        zhaDan_8 : yeMian_baoZha
                    })
                }
                else{
                    return null;
                }
                
            }
            else{
    
                let a2 = wx.createInnerAudioContext(); 
                a2.src = "/audio/fangPi.wav";
                a2.play();
    
                if(num == 0){
                    this.setData({
                        zhaDan_0 : yeMian_kongBai
                    })
                }
                else if(num == 1){
                    this.setData({
                        zhaDan_1 : yeMian_kongBai
                    })
                }
                else if(num == 2){
                    this.setData({
                        zhaDan_2 : yeMian_kongBai
                    })
                }
                else if(num == 3){
                    this.setData({
                        zhaDan_3 : yeMian_kongBai
                    })
                }
                else if(num == 4){
                    this.setData({
                        zhaDan_4 : yeMian_kongBai
                    })
                }
                else if(num == 5){
                    this.setData({
                        zhaDan_5 : yeMian_kongBai
                    })
                }
                else if(num == 6){
                    this.setData({
                        zhaDan_6 : yeMian_kongBai
                    })
                }
                else if(num == 7){
                    this.setData({
                        zhaDan_7 : yeMian_kongBai
                    })
                }
                else if(num == 8){
                    this.setData({
                        zhaDan_8 : yeMian_kongBai
                    })
                }
                else{
                    return null;
                }
                
            }
            
        },
       
        star_again: function(){
            this.setData({
                zhaDan_0 : yeMian_zhaDan,
                zhaDan_1 : yeMian_zhaDan,
                zhaDan_2 : yeMian_zhaDan,
                zhaDan_3 : yeMian_zhaDan,
                zhaDan_4 : yeMian_zhaDan,
                zhaDan_5 : yeMian_zhaDan,
                zhaDan_6 : yeMian_zhaDan,
                zhaDan_7 : yeMian_zhaDan,
                zhaDan_8 : yeMian_zhaDan
            });
            random_allVar = random_number();
            console.log('shuxin');
            console.log(random_allVar)
        },
        /**
         * 生命周期函数--监听页面初次渲染完成
         */
        onReady: function () {
    
        },
    
        /**
         * 生命周期函数--监听页面显示
         */
        onShow: function () {
    
        },
    
        /**
         * 生命周期函数--监听页面隐藏
         */
        onHide: function () {
    
        },
    
        /**
         * 生命周期函数--监听页面卸载
         */
        onUnload: function () {
    
        },
    
        /**
         * 页面相关事件处理函数--监听用户下拉动作
         */
        onPullDownRefresh: function () {
    
        },
    
        /**
         * 页面上拉触底事件的处理函数
         */
        onReachBottom: function () {
    
        },
    
        /**
         * 用户点击右上角分享
         */
        onShareAppMessage: function () {
    
        }
    })
    

    吹牛摇筛子页面:

    wxml

    <!--pages/zhuanPan_game/zhuanPan_game.wxml-->
    <image src="{{title_image}}" mode="scaleToFill" class="title_image">
    </image>
    <view>
        <view class="biaoTi">
            <text class="biaoTi_text">规则说明:通过摇手机产生五个不同的骰子数</text>
        </view>
        <view class="all_shaiZi">
            <view class="diYiPai_3ge">
                <image class="shaiZi" src="{{diYiPai_01}}"></image>
                <image class="shaiZi" src="{{diYiPai_02}}"></image>
                <image class="shaiZi" src="{{diYiPai_03}}"></image>
            </view>
            <view class="diErPai_2ge">
                <image class="shaiZi" src="{{diErPai_01}}"></image>
                <image class="shaiZi" src="{{diErPai_02}}"></image>
            </view>
            
        </view>
        <view class="all_button">
            <button class="button_1" type="primary" bindtap="show">显示</button>
            <button bindtap="hide" class="button_2" type="primary">隐藏</button>
        </view>
    </view>
    

    wxss

    /* pages/zhuanPan_game/zhuanPan_game.wxss */
    .title_image{
        height: 100px;
        width: 100%;
    }
    .biaoTi{
        display: flex;
        justify-content: center;
        border: 2px solid rgb(252, 206, 2);
        margin: 5px 0px;
        text-align: center;
        background-color: rgb(184, 250, 2);
        width: 100%;
    }
    .biaoTi_text{
        display: flex;
        justify-content: center;
        margin: 10px 0px;
        font-weight: bold;
    }
    .all_shaiZi{
        border: 5px solid rgb(7, 240, 248);
    }
    .shaiZi{
        height: 80px;
        width: 80px;
        margin: 5px 5px;
    }
    .diYiPai_3ge{
        margin-top: 60px;
        display: flex;
        flex-direction: row;
        flex-wrap: nowrap;
        justify-content: center;
    }
    .diErPai_2ge{
        margin-bottom: 60px;
        display: flex;
        flex-direction: row;
        flex-wrap: nowrap;
        justify-content: center;
    }
    .all_button{
        display: flex;
        flex-direction: row;
        justify-content: space-evenly;
        align-items: center;
        height: 120px;
    }
    .button_1{
        width: 40%;
    }
    .button_2{
        width: 40%;
    }
    

    js

    // pages/zhuanPan_game/zhuanPan_game.js
    var title_image = "https://img.haomeiwen.com/i14216764/b6d44c9192c1b1d2.jpeg?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240"
    var zheGai = "https://img.haomeiwen.com/i14216764/0b7aee1c83519e0d.jpeg?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240";
    
    var show = false;
    
    var image_src = [
             "https://img.haomeiwen.com/i14216764/11807092416a8e69.jpg?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240",
        
      
            "https://img.haomeiwen.com/i14216764/0c0866bf4529b974.jpg?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240",
    
    
            "https://img.haomeiwen.com/i14216764/07098125f1672b36.jpg?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240",
    
     
            "https://img.haomeiwen.com/i14216764/684be0368bb9c645.jpg?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240",
    
      
            "https://img.haomeiwen.com/i14216764/99eb3fdfc6fd4242.jpg?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240",
      
       
            "https://img.haomeiwen.com/i14216764/dfccc2844eb2c79d.jpg?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240"
    
    ]
    
    var cun_fang = ['','','','',''];
    
    var diYiPai_01 = image_src[0];
    var diYiPai_02 = image_src[1]
    var diYiPai_03 = image_src[2]
    var diErPai_01 = image_src[3]
    var diErPai_02 = image_src[4]
    
    Page({
    
        /**
         * 页面的初始数据
         */
        data: {
            title_image : title_image,
            //测试
            diYiPai_01 : zheGai,
                diYiPai_02 : zheGai,
                diYiPai_03 : zheGai,
                diErPai_01 : zheGai,
                diErPai_02 : zheGai,
                
        },
        random_index:function(){
            var r_num = Math.floor(Math.random()*6);
            return r_num;
        },
        show:function(){
            console.log("show");
            console.log(cun_fang);
            this.setData({
                diYiPai_01 : cun_fang[0],
                diYiPai_02 : cun_fang[1],
                diYiPai_03 : cun_fang[2],
                diErPai_01 : cun_fang[3],
                diErPai_02 : cun_fang[4] 
            })
        },
        hide:function(){
            this.setData({
                diYiPai_01 : zheGai,
                diYiPai_02 : zheGai,
                diYiPai_03 : zheGai,
                diErPai_01 : zheGai,
                diErPai_02 : zheGai 
            })
        },
        /**
         * 生命周期函数--监听页面加载
         */
        onLoad: function (options) {
           
        },
    
        /**
         * 生命周期函数--监听页面初次渲染完成
         */
        onReady: function () {
            
        },
    
        /**
         * 生命周期函数--监听页面显示
         */
        onShow: function () {
          var that = this;
          show = true;
          wx.onAccelerometerChange((res) => {
              if(res.x > 0.7 && res.y > 0.7 && show){
    
                  let ad = wx.createInnerAudioContext(); 
                  ad.src = "/audio/shaiZi.wav";
                  ad.play();
    
                  var index = 0;
                  for(var i = 0; i<5; i++){
                    index = that.random_index();
                    console.log(index); 
                    cun_fang[i] =  image_src[index]; 
                  }
    
                //   var index = that.random_index();
                //   cun_fang[0] =  image_src[index]; 
                //   var index = that.random_index();
                //   cun_fang[1] =  image_src[index]; 
                //   var index = that.random_index();
                //   cun_fang[2] =  image_src[index]; 
                //   var index = that.random_index();
                //   cun_fang[3] =  image_src[index]; 
                //   var index = that.random_index();
                //   cun_fang[4] =  image_src[index]; 
                  this.setData({
                    diYiPai_01 : cun_fang[0],
                    diYiPai_02 : cun_fang[1],
                    diYiPai_03 : cun_fang[2],
                    diErPai_01 : cun_fang[3],
                    diErPai_02 : cun_fang[4] 
                }) 
                console.log("yaoyiyao");
                console.log(cun_fang); 
                  wx.showToast({
                      title:'摇一摇成功',
                      icon:'success',
                      duration:1000,
                  })
                       
              }
          })
        },
    
        /**
         * 生命周期函数--监听页面隐藏
         */
        onHide: function () {
            show = false;
        },
    
        /**
         * 生命周期函数--监听页面卸载
         */
        onUnload: function () {
    
        },
    
        /**
         * 页面相关事件处理函数--监听用户下拉动作
         */
        onPullDownRefresh: function () {
    
        },
    
        /**
         * 页面上拉触底事件的处理函数
         */
        onReachBottom: function () {
    
        },
    
        /**
         * 用户点击右上角分享
         */
        onShareAppMessage: function () {
    
        }
    })
    

    一战到底页面:

    wxml

    <!--pages/yiZhanDaoDi_game/yiZhanDaoDi_game.wxml-->
    <image
        src="https://img.haomeiwen.com/i14216764/3152ca9703910e11.jpeg?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240"
        class="biaoTi_image" bindtap="zuoBi"></image>
    <view class="biaoTi">
       <text class="biaoTi_text">规则说明:从点数为1的第一层开始,每层两个方块,任选一个,顺利到第3层,通关,失败则重来。酒量差不建议挑战!</text>
    </view>
    
    <view class="button_shuaXin">
     <button type="primary" bindtap="reset_button" class="button_item">刷新</button>
    </view>
    
    <view class="all_image" >
        <view class="image_group">
            <image style="height: 150rpx;width: 150rpx;margin: 5rpx 5rpx;border:3px solid {{img_border20}};" src="{{image2_0}}" bindtap="tap20"></image>
            <image style="height: 150rpx;width: 150rpx;margin: 5rpx 5rpx;border:3px solid {{img_border21}};" src="{{image2_1}}" bindtap="tap21"></image>
        </view>
        <view class="image_group">
            <image style="height: 150rpx;width: 150rpx;margin: 5rpx 5rpx;border:3px solid {{img_border10}};" src="{{image1_0}}" bindtap="tap10"></image>
            <image style="height: 150rpx;width: 150rpx;margin: 5rpx 5rpx;border:3px solid {{img_border11}};" src="{{image1_1}}"
            bindtap="tap11"></image>
        </view>
        <view class="image_group">
            <image style="height: 150rpx;width: 150rpx;margin: 5rpx 5rpx;border:3px solid {{img_border00}};" src="{{image0_0}}" bindtap="tap00"></image>
            <image style="height: 150rpx;width: 150rpx;margin: 5rpx 5rpx;border:3px solid {{img_border01}};" src="{{image0_1}}" bindtap="tap01"></image>
        </view>
    </view>
    <view style="background-color: {{bottom_color}};color: yellow;font-size: 30rpx;text-align: center;font-weight: bold;margin-top: 10px;">你要喝:{{hejiu_num}}杯酒</view>
    
    <view hidden="{{bottom_hide}}" class="qingZhu">恭喜通关,截图保存!</view>
    

    wxss

    /* pages/yiZhanDaoDi_game/yiZhanDaoDi_game.wxss */
    page{
        background-color: black;
    }
    
    .biaoTi_image{
        height: 100rpx;
        width: 100%;
    }
    .biaoTi{
        display: flex;
        flex-direction: row;
        justify-content:space-around;
        align-items: center;
        width: 100%;
    }
    .biaoTi_text{
        border: 2px solid rgb(252, 52, 2);
        background-color: rgb(12, 12, 12);
        font-weight: bold;
        font-size:20px;
        text-align: center;
        color: yellow;
        font-weight: bold;
        width: 90%;
        height: auto;
    }
    
    .button_shuaXin{
        height: 50px;
        width: 100%;
        display: flex;
        flex-direction: row;
        justify-content: center;
    }
    .button_item{
        width: 50%;
        margin: 5px auto;
    }
    
    .all_image{
        display: flex;
        flex-direction: column;
        justify-content: center;
        margin-top: 5px;
        
    }
    .image_group{
        display: flex;
        flex-direction: row;
        justify-content: center;
    }
    
    .qingZhu{
        background-color: black;
        color: yellow;
        font-size: 20px;
        text-align: center;
        font-weight: bolder;
        margin-top: 10px;
    }
    
    

    js

    // pages/yiZhanDaoDi_game/yiZhanDaoDi_game.js
    var image_src = [
        "https://img.haomeiwen.com/i14216764/11807092416a8e69.jpg?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240",
    
    
       "https://img.haomeiwen.com/i14216764/0c0866bf4529b974.jpg?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240",
    
    
       "https://img.haomeiwen.com/i14216764/07098125f1672b36.jpg?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240",
    
    
       "https://img.haomeiwen.com/i14216764/684be0368bb9c645.jpg?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240",
    
    
       "https://img.haomeiwen.com/i14216764/99eb3fdfc6fd4242.jpg?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240",
    
    
       "https://img.haomeiwen.com/i14216764/dfccc2844eb2c79d.jpg?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240"
    
    ]
    
    
    var tap_result = [
        "https://img.haomeiwen.com/i14216764/fae66258495e7789.jpeg?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240",
    
        "https://img.haomeiwen.com/i14216764/432bbb2d259fc029.jpeg?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240"
    ]
    
    
    var image0_0 = "";
    var image0_1 = "";
    var image1_0 = "";
    var image1_1 = "";
    var image2_0 = "";
    var image2_1 = "";
    
    //选中前图片绑定颜色 
    var img_border00 = "black";
    var img_border01 = "black";
    var img_border10 = "black";
    var img_border11 = "black";
    var img_border20 = "black";
    var img_border21 = "black";
    
    var bottom_color = "";
    var hejiu_num = 0;
    
    var num_1lie = [];
    var num_2lie = [];
    
    /**
    * 标记互锁变量,等于0可以通行,等于1不能通行
    */
    var i_0 = 0;
    var i_1 = 1;
    var i_2 = 1;
    
    
    var bottom_hide = true;
    
    
    
    Page({
    
        /**
         * 页面的初始数据
         */
        data: {
            image0_0 : image_src[0],
            image0_1 : image_src[0],
            image1_0 : image_src[1],  
            image1_1 : image_src[1],
            image2_0 : image_src[2],
            image2_1 : image_src[2],
           
            img_border00 : "black",
            img_border01 : "black",
            img_border10 : "black",
            img_border11 : "black",
            img_border20 : "black",
            img_border21 : "black",
    
            bottom_color : "black",
            hejiu_num : 0,
            bottom_hide : true
        },
    
        zuoBi:function(){
    
            num_1lie[0] = 1;
            num_1lie[1] = 0;
            num_1lie[2] = 1;
    
            console.log("num_1lie");
            console.log(num_1lie);
            for(var j = 0; j < 3; j++){
                if(num_1lie[j] == 1){
                    num_2lie[j] = 0;
                }
                else{
                    num_2lie[j] = 1;
                }
            }
            console.log("num_2lie");
            console.log(num_2lie);
        },
    
        /**
         * 刷新
         */
        reset_button:function(){
            console.log("reset");
            i_0 = 0;
            i_1 = 1;
            i_2 = 1;
            hejiu_num = 0;
           
            this.setData({
                image0_0 : image_src[0],
                image0_1 : image_src[0],
                image1_0 : image_src[1],  
                image1_1 : image_src[1],
                image2_0 : image_src[2],
                image2_1 : image_src[2],
            
                bottom_hide : true,
                hejiu_num : 0,
    
                img_border00 : "black",
                img_border01 : "black",
                img_border10 : "black",
                img_border11 : "black",
                img_border20 : "black",
                img_border21 : "black"
            })
            this.random_shuZu();
    
        },
        /**
         * 重置函数
         */
        reset:function(){
            console.log("reset");
            i_0 = 0;
            i_1 = 1;
            i_2 = 1;
    
           
            this.setData({
                image0_0 : image_src[0],
                image0_1 : image_src[0],
                image1_0 : image_src[1],  
                image1_1 : image_src[1],
                image2_0 : image_src[2],
                image2_1 : image_src[2],
            
                bottom_hide : true,
    
                img_border00 : "black",
                img_border01 : "black",
                img_border10 : "black",
                img_border11 : "black",
                img_border20 : "black",
                img_border21 : "black"
            })
            this.random_shuZu();
           
        },
    
        audio_paly_tongguan:function(){
            let a010 = wx.createInnerAudioContext(); 
            a010.src = "/audio/tongguan.wav";
            a010.play();
        },
        audio_paly_shibai:function(){
            let a010 = wx.createInnerAudioContext(); 
            a010.src = "/audio/shibai.wav";
            a010.play();
        },
    
         /**
         * 先随机产生路线
         */
        random_shuZu:function(){
            for(var i = 0; i < 3; i++){
                num_1lie[i] = Math.floor(Math.random()*2);
            }
            console.log("num_1lie");
            console.log(num_1lie);
            for(var j = 0; j < 3; j++){
                if(num_1lie[j] == 1){
                    num_2lie[j] = 0;
                }
                else{
                    num_2lie[j] = 1;
                }
            }
            console.log("num_2lie");
            console.log(num_2lie);
        },
        onLoad: function (options) {
           this.random_shuZu();
        },
        tap00:function(){
            if(i_0 == 0){
                this.setData({
                    image0_0 : tap_result[num_1lie[0]],
                    img_border00 : 'red'
                })
                if(num_1lie[0] == 1){
                    
                    this.audio_paly_shibai();
    
                    hejiu_num = hejiu_num + 1;
                    this.setData({
                        hejiu_num : hejiu_num
                    })
                    setTimeout(()=>{
                        this.reset();
                    },1500)
                }
                else{
                    
                    this.audio_paly_tongguan();
    
                    i_1 = 0;
                }
            }
        },
        tap01:function(){
            if(i_0 == 0){
                this.setData({
                    image0_1 : tap_result[num_2lie[0]],
                    img_border01 : 'red'
                })
                if(num_2lie[0] == 1){
                    
                    this.audio_paly_shibai();
    
                    hejiu_num = hejiu_num + 1;
                    this.setData({
                        hejiu_num : hejiu_num
                    })
                    setTimeout(()=>{
                        this.reset();
                    },1500)
                }
                else{
    
                    this.audio_paly_tongguan();
    
                    i_1 = 0;
                }
            }
        },
    
        tap10:function(){
            if(i_1 == 0){
                this.setData({
                    image1_0 : tap_result[num_1lie[1]],
                    img_border10 : 'red'
                })
                if(num_1lie[1] == 1){
                    
                    this.audio_paly_shibai();
    
                    hejiu_num = hejiu_num + 1;
                    this.setData({
                        hejiu_num : hejiu_num
                    })
                    setTimeout(()=>{
                        this.reset();
                    },1500)
                }
                else{
    
                    this.audio_paly_tongguan();
    
                    i_2 = 0;
                }
            }
        },
        tap11:function(){
            if(i_1 == 0){
                this.setData({
                    image1_1 : tap_result[num_2lie[1]],
                    img_border11 : 'red'
                })
                if(num_2lie[1] == 1){
                    
                    this.audio_paly_shibai();
    
                    hejiu_num = hejiu_num + 1;
                    this.setData({
                        hejiu_num : hejiu_num
                    })
                    setTimeout(()=>{
                        this.reset();
                    },1500)
                }
                else{
    
                    this.audio_paly_tongguan();
    
                    i_2 = 0;
                }
            }
        },
    
        tap20:function(){
            if(i_2 == 0){
                this.setData({
                    image2_0 : tap_result[num_1lie[2]],
                    img_border20 : 'red'
                })
                if(num_1lie[2] == 1){
                    
                    this.audio_paly_shibai();
    
                    hejiu_num = hejiu_num + 1;
                    this.setData({
                        hejiu_num : hejiu_num
                    })
                    setTimeout(()=>{
                        this.reset();
                    },1500)
                }
                else{
    
                    this.audio_paly_tongguan();
                    this.setData({
                        bottom_hide : false,
                        image0_0 : image_src[5],
                        image0_1 : image_src[5],
                        image1_0 : image_src[5],  
                        image1_1 : image_src[5],
                        image2_0 : image_src[5],
                        image2_1 : image_src[5],
    
                        img_border00 : "yellow",
                        img_border01 : "yellow",
                        img_border10 : "yellow",
                        img_border11 : "yellow",
                        img_border20 : "yellow",
                        img_border21 : "yellow"
                    })
                    console.log("img_border20")
                    console.log(img_border20)
                }
            }
        },
        tap21:function(){
            if(i_2 == 0){
                this.setData({
                    image2_1 : tap_result[num_2lie[2]],
                    img_border21 : 'red'
                })
                if(num_2lie[2] == 1){
                    this.audio_paly_shibai();
                    hejiu_num = hejiu_num + 1;
                    this.setData({
                        hejiu_num : hejiu_num
                    })
                    setTimeout(()=>{
                        this.reset();
                    },1500)
                }
                else{
                    this.audio_paly_tongguan();
                    this.setData({
                        bottom_hide : false,
                        image0_0 : image_src[5],
                        image0_1 : image_src[5],
                        image1_0 : image_src[5],  
                        image1_1 : image_src[5],
                        image2_0 : image_src[5],
                        image2_1 : image_src[5],
    
                        img_border00 : "yellow",
                        img_border01 : "yellow",
                        img_border10 : "yellow",
                        img_border11 : "yellow",
                        img_border20 : "yellow",
                        img_border21 : "yellow"
                    })
                    console.log("img_border21")
                    console.log(img_border21)
    
                }
            }
        },
    
    
        /**
         * 生命周期函数--监听页面初次渲染完成
         */
        onReady: function () {
    
        },
    
        /**
         * 生命周期函数--监听页面显示
         */
        onShow: function () {
    
        },
    
        /**
         * 生命周期函数--监听页面隐藏
         */
        onHide: function () {
    
        },
    
        /**
         * 生命周期函数--监听页面卸载
         */
        onUnload: function () {
    
        },
    
        /**
         * 页面相关事件处理函数--监听用户下拉动作
         */
        onPullDownRefresh: function () {
    
        },
    
        /**
         * 页面上拉触底事件的处理函数
         */
        onReachBottom: function () {
    
        },
    
        /**
         * 用户点击右上角分享
         */
        onShareAppMessage: function () {
    
        }
    })
    

    相关文章

      网友评论

          本文标题:2021-11-25、阶段小制作——喝酒小游戏

          本文链接:https://www.haomeiwen.com/subject/uguztrtx.html