WeChat applet function
In the future, we will continue to add related functions of the WeChat Mini Program.
1. Sharing function
The user clicks on the upper right corner to repost
Monitor the behavior of the user clicking the forward button in the page (component open-type="share") or the "forward" button in the upper right menu, and customize the forward content.
Note: Only when this event handler is defined, the upper right menu will display the "Forward" button
This event needs to return an Object for custom forwarding content
.js file
onShareAppMessage() {
const promise = new Promise(resolve => {
setTimeout(() => {
resolve({
title: '自定义转发标题'
})
}, 2000)
})
return {
title: '自定义转发标题',
path: '/page/user?id=123',
promise
}
}
share button
If you want to remove the default button style in .xml
, use the interline style to overwrite the original style.
<button
open-type="share"
style="width:122rpx;
display:flex;
align-items: center;
margin: 0;
padding: 0;">分享<button/>
API for hiding sharing function
wx.hideShareMenu({
});
2. Copy text
Long press to copy
To implement the long-press copy function, you need to set the user-select attribute in the text tag
Copy pinned content to clipboard
wx.setClipboardData({
data: "复制内容",
})
After the call is successful, a toast will pop up prompting "the content has been copied" for 1.5s
If you don't use the system's toast bullet box, you can call wx.hiddenloading(), and the toast bullet box that comes with setClipboardData will no longer be displayed
wx.setClipboardData({
data: "复制订单号",
success: function () {
wx.hideLoading()
wx.showToast({
title: '复制成功',
})
}
})
3. Make a call
wx.makePhoneCall({
phoneNumber: "电话号码"
})