Home >WeChat Applet >Mini Program Development >How do we implement the WeChat mini program dialing function?
Foreword:
Since the click thing here is a picture, we need to set up a view first, and the bindtap event is used here.
(Learning video sharing: Programming video)
First of all, let’s take a look at what the official document says:
The code of my demo is like this
index.wxml
<view bindtap='tel'> <image class='tel' mode='aspectFit' src='./img/tel.png'></image> </view>
Then adjust the ss. Of course, this is just my demo. The actual application depends on the actual application.
index.wxss
.tel{ display: block; width: 70rpx; height: 70rpx; position: absolute; margin-top:-100rpx; margin-left: 200rpx; }
Directly call the call API wx.makePhoneCall(OBJECT)
The official documentation is also very clear
Mainly fill in the phoneNumber, others depend on the needs.
The first method is: add
tel:function () { wx.makePhoneCall({ phoneNumber: '158XXXXXXXX', }) }
in the Page of
index.js. There is another way Yes:
Just go to the global variable to set it, go to the globalData of the outermost app.js and add
globalData: { userInfo: null, phoneNumber: '158XXXXXXXX' }
and then index.js adds
tel:function () { wx.makePhoneCall({ phoneNumber: app.globalData.phoneNumber, }) }
and click Save
Related recommendations:小program development tutorial
The above is the detailed content of How do we implement the WeChat mini program dialing function?. For more information, please follow other related articles on the PHP Chinese website!