微信小程序wx.showActionSheet調用客服消息功能
官方文檔的代碼:
wx.showActionSheet({ itemList: ['A', 'B', 'C'], success (res) { console.log(res.tapIndex) }, fail (res) { console.log(res.errMsg) } })
但是客服消息功能調用,沒有api。只有按鈕。
<button open-type="contact"></button>
引用之前移除的組件action-sheet,好像也能用。。。
wxml
<view bindchange="test">顯示</view>
<action-sheet hidden="{{actionSheetHidden}}" bindchange="test" > <action-sheet-item bindtap='makephone'>電話咨詢</action-sheet-item> <action-sheet-item> <button open-type="contact">微信咨詢</button> </action-sheet-item> <action-sheet-cancel>取消</action-sheet-cancel> </action-sheet>
js
Page({ data: { actionSheetHidden: true }, test: function () { this.setData({ actionSheetHidden: !this.data.actionSheetHidden, }) }, makephone: function() { wx.makePhoneCall({ phoneNumber: '1300' }) } })
ps:不要隨便設置button的樣式,可能會出現bug。。。(如果有其他方法,請評論一下,謝謝)