admin
2020-12-12 320fc6e791e418a98f2cf6b44b2a602704f8b3db
'网络请求优化'
2个文件已修改
15 ■■■■ 已修改文件
pages/mine/mine.js 4 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
util/http.js 11 ●●●● 补丁 | 查看 | 原始文档 | 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,6 +29,9 @@
      borderBottomColor: "#0080FF"
    });
    http.postApi('http://www.baidu.com', {}, function (res) { }, function (e) { }, null, true);
  },
  onGetAuthorize(res) {
util/http.js
@@ -15,6 +15,8 @@
        my.showLoading();
      }
      console.log("请求参数:"+JSON.stringify(params));
      my.request({
        url: url,
        method: 'POST',
@@ -34,10 +36,12 @@
          }
        },
        fail: function (res) {
          if (fail != null)
          fail(res);
        },
        complete: function (res) {
          my.hideLoading();
          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);
  }
};