微信小程序4种弹框

1、wx.showModal 确认弹框

javascript 复制代码
 delete(){
    wx.showModal({
      title: '',
      content: '是否确认删除',
      success(res) {
        if (res.confirm) {
          console.log('用户点击确定')
        } else if (res.cancel) {
          console.log('用户点击取消')
        }
      }
    })
  }

2、wx.showToast 提示弹框

|---------|--------|
| success | 显示成功图标 |
| error | 显示失败图标 |
| loading | 显示加载图标 |
| none | 不显示图标 |

|---|---|
| | |

javascript 复制代码
wx.showToast({
  title: '成功',
  icon: 'success',
  duration: 2000
})

3、wx.showLoading loading弹框

javascript 复制代码
wx.showLoading({
  title: '加载中',
})

setTimeout(function () {
  wx.hideLoading()
}, 2000)

4、wx.showActionSheet 操作弹框

javascript 复制代码
wx.showActionSheet({
  itemList: ['A', 'B', 'C'],
  success (res) {
    console.log(res.tapIndex)
  },
  fail (res) {
    console.log(res.errMsg)
  }
})

customer.wxml

XML 复制代码
<button class="fixed-service"  bindtap="getPhone">

  <text class="iconfont icon-kefu"></text>

  <view>客服</view>

</button>

customer.css

css 复制代码
/* 联系客服 */

.fixed-service {
  display: inline-block;
  bottom: 13%;
  right: 30rpx;
  width: 80rpx;
  height: 80rpx;
  position: fixed;
  background: rgba(0, 0, 0, 0.5);
  border-radius: 50%;
  text-align: center;
  color: #fff;
  box-sizing: border-box;
  font-size: 20rpx;
  padding: 10rpx;
  line-height: 1.2;
  z-index: 100;
}
.fixed-share .iconfont {
  font-size: 30rpx;
}

customer.js

javascript 复制代码
  getPhone:function (params) {
    var that=this;
    let arr=[];
		wx.request({
			url: newurl.getKfPhone,
			method: 'post',
			success (res) {
				if (res.data.status == 200) {
					console.log(res.data.data);
					that.setData({
							kfphone: res.data.data,
          });
          wx.showActionSheet({
            itemList:['拨打客服电话1','拨打客服电话2'], //文字数组
            success: (ress) => {
              switch(ress.tapIndex) {
                case 0:
                  console.log(res.data.data.kfphone1)
                  wx.makePhoneCall({
                    phoneNumber: res.data.data.kfphone1
                  });
                  break;
                case 1:
                  wx.makePhoneCall({
                    phoneNumber: res.data.data.kfphone2
                  });
                  console.log(res.data.data.kfphone2)
                  break;	
              };
            
            },
            fail (ress) {
              console.log('取消选项')
            }
          })
			} 
			}
		});
  },
相关推荐
天空原海1 小时前
微信小程序 调色板
微信小程序·小程序
六月的雨__4 小时前
二手物品交易小程序的设计
java·sql·学习·小程序
彭世瑜4 小时前
微信小程序/uniapp:class和style不生效的问题
微信小程序·小程序·uni-app
缘月叙文4 小时前
uniapp+vue3+echarts编写微信小程序
微信小程序·uni-app·echarts
xiaofang201511 小时前
notepad++ 中文乱码 出现小方格
notepad++
革斤要加油12 小时前
C++系统编程篇——Linux第一个小程序--进度条
linux·c++·小程序
六月的雨__12 小时前
基于weixin小程序农场驿站系统的设计
java·sql·学习·小程序
工业互联网专业12 小时前
基于springboot+vue+uniapp的语言课学习系统小程序
vue.js·spring boot·小程序·uni-app·毕业设计·源码
2401_8441394412 小时前
Java聚合跑腿系统对接云洋聚合跑腿系统源码低价快递小程序APP公众号源码
开发语言·微信·微信小程序·小程序
lylsalt13 小时前
微信小程序的开发
微信小程序·小程序