zoukankan      html  css  js  c++  java
  • 小程序 之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);
    }
    
  • 相关阅读:
    学习 swift (1)
    Sbulime Text 2 修改选中字符串的颜色
    js string 和 json 互转
    Mac OSX sublime text2 各种快捷键
    webstorm keymap
    python http post json
    node.js async 几个函数
    python 爬图 helloworld
    合服导致 globalserver 起不来的问题
    ssh 登陆 端口转发
  • 原文地址:https://www.cnblogs.com/yang-2018/p/11772329.html
Copyright © 2011-2022 走看看