• 小程序 之wx.request和wx.showModal简单封装


    一、request封装

    request(url, data, successCallBack = function(data) {}, completeCallBack = function(data) {}, method = "GET", header = {
        'content-type': 'application/json'
      }, dataType = 'json', responseType = 'text') {
        wx.request({
          url: url,
          data: data,
          header: header,
          method: method,
          dataType: dataType,
          responseType: responseType,
          success: function(res) {
            successCallBack(res.data);
          },
          fail: function(res) {},
          complete: function(res) {
            completeCallBack(res)
          },
        })
    }
    

      

    二、showModal封装

    tipsModal(content, successCallback = function() {}, title = '提示', showCancel = false, comfirmText = '知道了', confirmColor = '#03a9f4', hasCancel = false, cancelText = '取消', cancelColor = '#000') {
        var params = {
          title: title,
          content: content,
          showCancel: showCancel,
          confirmText: comfirmText,
          confirmColor: confirmColor,
          success: function(res) {
            if (res.confirm) {
              successCallback();
            }
          }
        }
        if (hasCancel == true) {
          params.cancelText = cancelText;
          params.cancelColor = cancelColor;
        }
        wx.showModal(params);
    }
    
  • 相关阅读:
    IOS:兼容ios6和低版本
    iOS开发~sizeClass和autolayout
    iOS开发~即时通讯工具参考的一些开源框架和教程
    移动开发网站导航
    mac工具总结
    推送总结(重要)
    IOS常用学习网站和博客
    iOS~静态库开发
    iOS~视频开发
    iOS~视频编码转换
  • 原文地址:https://www.cnblogs.com/yang-2018/p/11772329.html
Copyright © 2020-2023  润新知