lists.js 818 B

1234567891011121314151617181920212223242526272829303132333435
  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, keyword) {
  6. if (utils.getSwitchToLocalStatus()) {
  7. var res = cache.getFromLocal(page, pageSize, keyword);
  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. keyword: keyword
  20. }),
  21. header: header,
  22. dataType: "json",
  23. success: function(res) {
  24. app.listSync(res.data)
  25. },
  26. fail: function(res) {
  27. app.listSync(appConfig.networkError);
  28. }
  29. });
  30. }
  31. module.exports = {
  32. pwd: lists
  33. }