Home > WeChat Applet > Mini Program Development > How do we implement the WeChat mini program dialing function?

How do we implement the WeChat mini program dialing function?

王林
Release: 2020-12-30 16:44:33
forward
4132 people have browsed it

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:

How do we implement the WeChat mini program dialing function?

The code of my demo is like this

index.wxml

<view bindtap=&#39;tel&#39;>
<image class=&#39;tel&#39; mode=&#39;aspectFit&#39; src=&#39;./img/tel.png&#39;></image>
</view>
Copy after login

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; 
}
Copy after login

Directly call the call API wx.makePhoneCall(OBJECT)

The official documentation is also very clear

How do we implement the WeChat mini program dialing function?

Mainly fill in the phoneNumber, others depend on the needs.

The first method is: add

tel:function () {
  wx.makePhoneCall({
    phoneNumber: &#39;158XXXXXXXX&#39;,
  })
}
Copy after login

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: &#39;158XXXXXXXX&#39;
}
Copy after login

and then index.js adds

tel:function () {
  wx.makePhoneCall({
    phoneNumber: app.globalData.phoneNumber,
  })
}
Copy after login

and click Save

How do we implement the WeChat mini program dialing function?

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!

Related labels:
source:csdn.net
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template