微信小程序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('取消选项')
            }
          })
			} 
			}
		});
  },
相关推荐
chaosama4 小时前
微信小程序带参分享、链接功能
微信小程序·小程序
胡西风_foxww5 小时前
微信小程序动态组件加载的应用场景与实现方式
微信小程序·应用·加载·动态组件
ALLSectorSorft7 小时前
上门服务小程序会员系统框架设计
小程序·apache
甜甜的资料库9 小时前
基于小程序老人监护管理系统源码数据库文档
微信小程序
说私域14 小时前
基于定制开发开源AI智能名片S2B2C商城小程序的首屏组件优化策略研究
人工智能·小程序·开源·零售
Uyker1 天前
微信小程序动态效果实战指南:从悬浮云朵到丝滑列表加载
前端·微信小程序·小程序
happyCoder1 天前
uniapp 微信小程序实现定时消息订阅提醒(前后端)
微信小程序
Uyker2 天前
从零开始制作小程序简单概述
前端·微信小程序·小程序
打小就很皮...2 天前
HBuilder 发行Android(apk包)全流程指南
前端·javascript·微信小程序
说私域2 天前
定制开发开源AI智能名片驱动下的海报工厂S2B2C商城小程序运营策略——基于社群口碑传播与子市场细分的实证研究
人工智能·小程序·开源·零售