微信小程序 自定义d窗

微信小程序 自定义d窗,第1张

 <button bindtap="powerDrawer" type="primary" size="mini" style="width: 55%" data-statu="open">中奖记录</button>  

<!-- 中间名单d窗 -->

<view class="drawer_div">

  <view class="drawer_screen" bindtap="powerDrawer" data-statu="close" wx:if="{{showModalStatus}}"></view>

    <view animation="{{animationPrize}}" class="drawer_box" wx:if="{{showModalStatus}}">

      <view class="drawer_title">

        中奖记录

        <image src="../img/[email protected]" bindtap="powerDrawer" data-statu="close"></image>

      </view>

      <view class="drawer_content">

        <view class="top grid">

          <text>

            名称:啦啦啦啦啦啦啦啦

          </text>

          <text>

            时间:2020-02-20

          </text>

        </view>

        <view class="top grid">

          <text>

            名称:啦啦啦啦啦啦啦啦

          </text>

          <text>

            时间:2020-02-20

          </text>

        </让岩view>

    </view>

  </view>

</view>

.drawer_screen {

  width: 100%

  height: 100%

  position: fixed

  top: 0

  left: 0

  z-index: 1000

  background: #000

  opacity: 0.5

  overflow: hidden

}

/*content*/

.drawer_box {

  width: 650rpx

  overflow: hidden

  position: fixed

  top: 50%

  left: 0

  z-index: 1001

  background: #FAFAFA

  margin: -150px 50rpx 0 50rpx

  border-radius: 3px

}

.drawer_title{

  padding:30rpx 20rpx

  font-size: 36rpx

  text-align: center

  position: relative

}

.drawer_title 郑扰image{

  display: inline-block

  width: 30rpx

  height: 30rpx

  position: absolute

  right: 9px

  top: 10px

}

.drawer_content {

  height: 210px

  overflow-y: scroll /*超出父盒子高度可滚动*/

  padding: 0 20rpx

}

.top{

  display: flex

  justify-content: space-between

  border-bottom: 1px dashed #ccc

}

.top text{

  display: inline-block

  height: 60rpx

  line-height: 20rpx

}

data: {

animationPrize: {},

}

powerDrawer: function (e) {

    // console.log(e)

    let currentStatu = e.currentTarget.dataset.statu

    this.util(currentStatu)

  },

  util: function (currentStatu) {

 坦丛御   /* 动画部分 */

    // 第1步:创建动画实例

    var animation = wx.createAnimation({

      duration: 200,  //动画时长

      timingFunction: "linear", //线性

      delay: 0  //0则不延迟

    })

    // 第2步:这个动画实例赋给当前的动画实例

    this.animation = animation

    // 第3步:执行第一组动画

    animation.opacity(0).rotateX(-100).step()

    // 第4步:导出动画对象赋给数据对象储存

    this.setData({

      animationPrize: animation.export()

    })

    // 第5步:设置定时器到指定时候后,执行第二组动画

    setTimeout(function () {

      // 执行第二组动画

      animation.opacity(1).rotateX(0).step()

      // 给数据对象储存的第一组动画,更替为执行完第二组动画的动画对象

      this.setData({

        animationPrize: animation

      })

      //关闭

      if (currentStatu == "close") {

        this.setData({

          showModalStatus: false

        })

      }

    }.bind(this), 200)

    // 显示

    if (currentStatu == "open") {

      this.setData({

        showModalStatus: true

      })

    }

  },

   微信小程序的蓝牙流程按着官网的说明写就可以了,具体参看文败宏盯档: 小程序开发文档

坑列表:

    1.成对调用需要注意, wx.openBluetoothAdapter 与 wx.closeBluetoothAdapter

                                        wx.startBluetoothDevicesDiscovery 与 wx.stopBluetoothDevicesDiscovery

     2.安卓与IOS的区别:安卓可以根据蓝牙标识直接连接,IOS则必须先搜索才能进行连接;

     3.权限问题:IOS的系统不能仅仅打开系统的蓝牙权限,因为IOS新版本针对蓝牙做了应用及的限制,因此需要给微信蓝牙权限才可以使用;对于安卓系统,部分手机必须打开定位权限察和才能搜索到蓝牙设备

     4.创建连接API( wx.createBLEConnection )调用失败:

            超时报错:{"errCode":10012,"errMsg":"createBLEConnection:fail:operate time out"}

            连接超时:{"errCode":10003,"errMsg":"createBLEConnection:fail connect time out."}

            连接失败:{"errCode":10003,"errMsg":"createBLEConnection:fail:connection fail status:133"}

           基本都是安卓手机出现以上问题,针对这些报错,需编写重试连接 *** 作,很大概率能解决此问题;

     5.搜索不到任何设备,安卓手机可能是定位权限的问题造成,苹果手机基本就是设备出问题了

     6.网络请求与蓝牙请求尽量分开,因为蓝牙连接会受到影响,造成一些异常信息;

     7.所有API调用针对fail函数最好都做一次重试,因为再次重试可能就会成功;、

     8.API调用之间绝旅最好有一定毫秒数的间隔,目前怀疑api部分机型会存在延时;

总之微信的蓝牙连接就那些已知的接口,调用时多考虑异常的情况下的重试,简单总结下,以便查阅。

           

    


欢迎分享,转载请注明来源:内存溢出

原文地址: https://outofmemory.cn/yw/12560437.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2023-05-26
下一篇 2023-05-26

发表评论

登录后才能评论

评论列表(0条)

保存