C端小程序
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

82 lines
2.0 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. couponUrl: wx.getStorageSync('imgurl').coupon.url,
  8. gouUrl: wx.getStorageSync('imgurl').gou.url,
  9. linessUrl: wx.getStorageSync('imgurl').liness.url,
  10. loadingUrl: wx.getStorageSync('imgurl').loading.url,
  11. list: [],
  12. current: "0",
  13. current_scroll: "0",
  14. page: 1,
  15. allow_load: true
  16. },
  17. onLoad(options) {
  18. this.getList(0, 0);
  19. if (options.quanid){
  20. this.setData({
  21. quanid: options.quanid
  22. })
  23. }
  24. },
  25. /**
  26. * 选择使用的优惠券
  27. */
  28. choicecoupon: function(e) {
  29. wx.navigateBack();
  30. var pages = getCurrentPages();
  31. var prevPage = pages[pages.length - 2] //上一个页面
  32. var that = this;
  33. var quantitle = e.currentTarget.dataset.title;
  34. var quanid = e.currentTarget.dataset.id;
  35. prevPage.setData({
  36. quantitle: quantitle,
  37. quanid: quanid,
  38. });
  39. wx.setStorage({
  40. key: 'chosed',
  41. data: 'chosed',
  42. })
  43. },
  44. getList(key, pageNum) {
  45. var that = this;
  46. if (that.data.allow_load) {
  47. Http.get({
  48. url: config.api.couponOrderList + "?type=5",
  49. data: {
  50. pageNum: pageNum,
  51. pageSize: 20,
  52. couponOrderStatus: key
  53. }
  54. }).then(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. .catch(err => {
  72. wx.showToast({
  73. title: err.errMsg,
  74. icon: 'none',
  75. duration: 2000,
  76. mask: false
  77. });
  78. })
  79. }
  80. },
  81. });