genKeys.js 890 B

123456789101112131415161718192021222324252627282930313233343536
  1. const app = getApp();
  2. const appConfig = require("../config");
  3. const utils = require("../utils/util");
  4. var genKeys = function(that){
  5. var header = {
  6. 'content-type': 'application/x-www-form-urlencoded',
  7. 'cookie': wx.getStorageSync(appConfig.storeKeys.sessionId)
  8. };
  9. wx.showLoading({
  10. title: '正在拉取数据',
  11. });
  12. wx.request({
  13. url: utils.getUrl("requestSslKey"),
  14. header : header,
  15. dataType : 'json',
  16. success : function(res){
  17. wx.hideLoading();
  18. app.log(res)
  19. if(res.data.code > 0) {
  20. wx.showToast({
  21. title: res.data.msg || "获取公私钥失败",
  22. duration:appConfig.duration
  23. });
  24. return;
  25. }
  26. app.sslKeyRequestSync(res.data);
  27. },
  28. fail: function(){
  29. app.sslKeyRequestSync(appConfig.networkError);
  30. wx.hideLoading();
  31. }
  32. })
  33. }
  34. module.exports = genKeys