用户登录
用户注册

分享至

微信小程序通用方法

  • 作者: 不良君丶
  • 来源: 51数据库
  • 2021-07-09

?*?返回顶部

???*/

??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();

??},

?

软件
前端设计
程序设计
Java相关