request.js 515 B

12345678910111213141516171819
  1. const md5 = require('md5');
  2. function renderURL(method, data) {
  3. const version = '1.0'
  4. const secret = '017c0743819088468e590246464cc75f';
  5. const uid = 0;
  6. const token = '';
  7. const role = '';
  8. const mtime = parseInt(Date.now() / 1000);
  9. const body = JSON.stringify(data);
  10. const sign = md5('rental_' + version + token + body + method + mtime + secret);
  11. return {
  12. url: `/rental/${method}?t=${mtime}&u=${uid}&v=${version}&s=${sign}`,
  13. method: 'post',
  14. data: body
  15. }
  16. }
  17. module.exports = renderURL;