C端小程序
No puede seleccionar más de 25 temas Los temas deben comenzar con una letra o número, pueden incluir guiones ('-') y pueden tener hasta 35 caracteres de largo.

74 líneas
1.7 KiB

  1. const format = require("../../../utils/util.js");
  2. const config = require("../../../config/config.js");
  3. const app = getApp();
  4. const Http = require("../../../utils/HttpBasics");
  5. Page({
  6. data: {
  7. list: [],
  8. current: "0",
  9. current_scroll: "0",
  10. page: 1,
  11. allow_load: true
  12. },
  13. onLoad(options) {
  14. this.getList(0, 0);
  15. if (options.quanid){
  16. this.setData({
  17. quanid: options.quanid
  18. })
  19. }
  20. },
  21. /**
  22. * 选择使用的优惠券
  23. */
  24. choicecoupon: function(e) {
  25. wx.navigateBack();
  26. console.log(e);
  27. var pages = getCurrentPages();
  28. var prevPage = pages[pages.length - 2] //上一个页面
  29. var that = this;
  30. var quantitle = e.currentTarget.dataset.title;
  31. var quanid = e.currentTarget.dataset.id;
  32. prevPage.setData({
  33. quantitle: quantitle,
  34. quanid: quanid,
  35. });
  36. wx.setStorage({
  37. key: 'chosed',
  38. data: 'chosed',
  39. })
  40. },
  41. getList(key, pageNum) {
  42. var that = this;
  43. console.log(key);
  44. console.log(pageNum);
  45. if (that.data.allow_load) {
  46. Http.get({
  47. url: config.api.couponOrderList + "?type=5",
  48. data: {
  49. pageNum: pageNum,
  50. pageSize: 20,
  51. couponOrderStatus: key
  52. }
  53. }).then(res => {
  54. console.log(res);
  55. res.data.list.map(file => {
  56. file.expiredTime = format.formatTime(
  57. file.expiredTime,
  58. "yyyy-MM-dd hh:mm:ss"
  59. );
  60. });
  61. if (pageNum > res.data.pages) {
  62. that.setData({
  63. allow_load: false
  64. });
  65. }
  66. that.data.list = that.data.list.concat(res.data.list);
  67. that.setData({
  68. list: that.data.list
  69. });
  70. });
  71. }
  72. },
  73. });