saveClientPublicKey.js 896 B

1234567891011121314151617181920212223242526272829303132333435
  1. const app = getApp();
  2. const appConfig = require("../config");
  3. const utils = require("../utils/util");
  4. var saveClientPublicKey = function (_this, publicKey, privateKey) {
  5. var header = {
  6. 'content-type': 'application/x-www-form-urlencoded',
  7. 'cookie': wx.getStorageSync(appConfig.storeKeys.sessionId)
  8. };
  9. var data = {
  10. 'publicKey': publicKey,
  11. };
  12. wx.request({
  13. url: utils.getUrl("savePublicKeyClient"),
  14. data: data,
  15. header: header,
  16. method: 'POST',
  17. dataType: 'json',
  18. success: function (res) {
  19. if(res && res.data){
  20. if(!res.data.data) {
  21. res.data.data = {};
  22. }
  23. res.data.data.publicKey = publicKey;
  24. res.data.data.privateKey = privateKey;
  25. }
  26. app.sslKeySaveSync(res.data);
  27. },
  28. fail: function (res) {
  29. app.sslKeySaveSync(appConfig.networkError);
  30. }
  31. })
  32. }
  33. module.exports = saveClientPublicKey