lists.js 776 B

12345678910111213141516171819202122232425262728293031323334
  1. const app = getApp();
  2. const appConfig = require("../config");
  3. const utils = require("../utils/util");
  4. const cache = require("cache");
  5. var lists = function(_this, page, pageSize) {
  6. if (utils.getSwitchToLocalStatus()) {
  7. var res = cache.getFromLocal(page, pageSize);
  8. app.listSync(res);
  9. return;
  10. }
  11. var header = {
  12. 'content-type': 'application/x-www-form-urlencoded',
  13. 'cookie': wx.getStorageSync(appConfig.storeKeys.sessionId)
  14. };
  15. wx.request({
  16. url: utils.getUrl("lists", {
  17. page: page,
  18. pageSize: pageSize
  19. }),
  20. header: header,
  21. dataType: "json",
  22. success: function(res) {
  23. app.listSync(res.data)
  24. },
  25. fail: function(res) {
  26. app.listSync(appConfig.networkError);
  27. }
  28. });
  29. }
  30. module.exports = {
  31. pwd: lists
  32. }