微信小程序通用方法

button 去边框

.operation-list::after{
    border: none;
} 

* 返回顶部 */

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

  },

//图片上传

headsculpture: function (e) {

    var that = this;

    wx.chooseImage({

      count: 1, //最多可以选择的图片总数

      sizeType: ['compressed'], // 可以指定是原图还是压缩图,默认二者都有

      sourceType: ['album', 'camera'], // 可以指定来源是相册还是相机,默认二者都有

      success: function (res) {

        // 返回选定照片的本地文件路径列表,tempFilePath可以作为img标签的src属性显示图片

        var tempFilePaths = res.tempFilePaths;

        //启动上传等待中...

        wx.showToast({

          title: '正在上传...',

          icon: 'loading',

          mask: true,

          duration: 2000,

        })

        wx.uploadFile({

          url: '', //地址

          filePath: tempFilePaths[0],

          name: 'uploadfile_ant',

          formData: {},

          header: {

            "Content-Type": "multipart/form-data"

          },

          success: function (res) {

            var data = JSON.parse(res.data);

            //服务器返回格式: { "Catalog": "testFolder", "FileName": &
  • 1
    点赞
  • 3
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值