album.js 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  1. const app = getApp();
  2. const appConfig = require("../config");
  3. const utils = require("../utils/util");
  4. var album = function (_this, lastId, page, pageSize) {
  5. var header = {
  6. 'content-type': 'application/x-www-form-urlencoded',
  7. 'cookie': wx.getStorageSync(appConfig.storeKeys.sessionId)
  8. };
  9. wx.request({
  10. url: utils.getUrl("album", {lastId:lastId, page:page, pageSize: pageSize}),
  11. header: header,
  12. dataType: 'json',
  13. success: function (res) {
  14. wx.hideLoading();
  15. if (res.data.code > 0) {
  16. wx.showToast({
  17. title: res.data.msg || "获取公私钥失败",
  18. duration: appConfig.duration
  19. });
  20. return;
  21. }
  22. app.albumSync(res.data);
  23. },
  24. fail: function () {
  25. app.albumSync(appConfig.networkError);
  26. wx.hideLoading();
  27. }
  28. })
  29. }
  30. var remove = function(_this, uid, id, type) {
  31. var request = {};
  32. request.uid = uid;
  33. request.id = id;
  34. request.type = type;
  35. request.timestamp = new Date().getTime();
  36. request = utils.ksort(request);
  37. var str = utils.httpBuild(request);
  38. var sign = utils.hexSha1(str);
  39. request.sign = sign;
  40. delete request.uid;
  41. var header = {
  42. 'content-type': 'application/x-www-form-urlencoded',
  43. 'cookie': wx.getStorageSync(appConfig.storeKeys.sessionId)
  44. };
  45. wx.request({
  46. url: utils.getUrl("albumRemove", request),
  47. header: header,
  48. method: "GET",
  49. dataType: "json",
  50. success: function (req) {
  51. app.removeAlbumSync(req.data)
  52. },
  53. fail: function (req) {
  54. app.removeAlbumSync(appConfig.networkError)
  55. }
  56. })
  57. }
  58. module.exports = {
  59. lists: album,
  60. remove: remove
  61. };