admin
2020-12-12 320fc6e791e418a98f2cf6b44b2a602704f8b3db
'网络请求优化'
2个文件已修改
21 ■■■■ 已修改文件
pages/mine/mine.js 6 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
util/http.js 15 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
pages/mine/mine.js
@@ -1,4 +1,5 @@
var help = require('../../util/help.js');
var http = require('../../util/http.js');
Page({
  data: {
    showLogout: true
@@ -28,10 +29,13 @@
      borderBottomColor: "#0080FF"
    });
    http.postApi('http://www.baidu.com', {}, function (res) { }, function (e) { }, null, true);
  },
  onGetAuthorize(res) {
    var that=this;
    var that = this;
    my.getOpenUserInfo({
      fail: (res) => {
      },
util/http.js
@@ -14,6 +14,8 @@
      if (showLoading) {
        my.showLoading();
      }
      console.log("请求参数:"+JSON.stringify(params));
      my.request({
        url: url,
@@ -34,11 +36,13 @@
          }
        },
        fail: function (res) {
          fail(res);
          if (fail != null)
            fail(res);
        },
        complete: function (res) {
          my.hideLoading();
          complete(res);
          if (complete != null)
            complete(res);
        }
      });
    });
@@ -80,12 +84,12 @@
  getSign(params) {
    if (params == null)
      params = {};
    params.timestamp = new Date().getMilliseconds();
    params.timestamp = new Date().getTime();
    params.appKey = getApp().appKey;
    var array = new Array();
    for (k, v in params) {
      array.push(k + "=" + v);
    for (var key in params) {
      array.push(key + "=" + params[key]);
    }
    //排序
@@ -100,6 +104,7 @@
    }
    str += SECRET;
    console.log("签名前字符串:"+str);
    return md5.md5(str);
  }
};