微信小程序通用方法
* 返回顶部
*/
backTop: function() {
this.stickyFlag = false, wx.pageScrollTo({
scrollTop: 0,
duration: 500
});
},
//跳转
goLink: function(event) {
let url = event.currentTarget.dataset.link;
url && wx.navigateTo({ url })
},
//复制
copy: function () {
var that = this;
wx.setClipboardData({
data: that.data.goodsList[0].code,
success() {
wx.showToast({
title: '复制成功',
icon: 'success',
duration: 1000
})
}
})
},
/**
* 拨打电话
*/
callTelphone: function (e) {
var that = this;
var phoneNumber = e.currentTarget.dataset.phone;
if (phoneNumber) {
this.isCalling || (this.isCalling = true, wx.makePhoneCall({
phoneNumber: phoneNumber,
complete: function () {
that.isCalling = false;
}
}));
}
},
/**
* 搜索栏高度
*/
getScrollViewHeight: function () {
var that = this;
wx.createSelectorQuery().select(".search-bar").boundingClientRect(function (res) {
res.height && that.setData({
scrollViewHeight: wx.getSystemInfoSync().windowHeight - res.height
});
}).exec();
},
本文地址:https://blog.csdn.net/liugenrong/article/details/107352837