微信小程序自定义一个全屏的加载中提示框

1、wxml

<view class="mask" hidden="{{flag}}">
  <view class="maskContent">
    <view class='loadContent'>
        <image class='closeImg_image' src='/images/loading.png'></image>
    </view> 
    <view class='loadtext'>视频上传中,请稍后...</view>
  </view>
</view>

2、wxss

/* 设置背景遮罩层样式 */
.mask {
  position: fixed;
  left: 0;
  top: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.5);
  display: flex;
  justify-content: center;
  align-items: center;
  flex-direction: column;
  z-index: 9999 !important;
}

/* 设置遮罩内容样式 */

.maskContent {
  width: 50%;
  background: #fff;
  border-radius: 5px;
  padding: 30rpx;
  text-align: center;
}

//是图片可以旋转
.closeImg_image {
  width: 80rpx;
  height: 80rpx;
  margin: 10rpx;
  transform: rotate(360deg);
  -ms-transform: rotate(360deg); /* IE 9 */
  -moz-transform: rotate(360deg); /* Firefox */
  -webkit-transform: rotate(360deg); /* Safari 和 Chrome */
  -o-transform: rotate(360deg); /* Opera */
  animation: rotation 3s linear infinite;
  -moz-animation: rotation 3s linear infinite;
  -webkit-animation: rotation 3s linear infinite;
  -o-animation: rotation 3s linear infinite;
}

@keyframes rotation {
  from {
    -webkit-transform: rotate(0deg);
  }

  to {
    -webkit-transform: rotate(360deg);
  }
}

.loadtext {
  font-size: 32rpx;
}

3、js  可以自定义显示位置,我这里是视频上传时显示提示框,视频上传完成关闭提示框

Page({
    data: {
        flag: true
    },
    showMask: function () {
        this.setData({ flag: false })
   },
   closeMask: function () {
        this.setData({ flag: true })
   },
addVideoTap: function () {
    var that = this
    wx.chooseVideo({
      sourceType: ['camera'],
      compressed:false,
      camera: 'back',
      success: function (res) {
        console.log(res);
        that.setData({
          videoUrl: res.tempFilePath
        });
        that.showMask();//视频上传中,显示提示框
          wx.uploadFile({
             url: romoteurl + '/upload', //开发者服务器的 url
            filePath: res.tempFilePath, // 要上传文件资源的路径 String类型!!!
            name: 'file', // 文件对应的 key ,(后台接口规定的关于图片的请求参数)
            header: {
              'content-type': 'multipart/form-data'
            }, // 设置请求的 header
            formData: {

            }, // HTTP 请求中其他额外的参数
            success: function (res) {
              that.closeMask(); //视频上传成功关闭提示框
            },
            fail: function (res) {
              console.log("图片上传失败" + res);
            }
          })      
      }
    })
  },
})

 

  • 0
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

LLL_LH

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值