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.

84 regels
1.9 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. const imgurl = require("../../../utils/imgurl");
  6. Page({
  7. data: {
  8. couponUrl:imgurl.coupon.url,
  9. gouHr: imgurl.gouHr.url,
  10. gouUrl:imgurl.gou.url,
  11. linessUrl:imgurl.liness.url,
  12. loadingUrl:imgurl.loading.url,
  13. list: [],
  14. current: "0",
  15. current_scroll: "0",
  16. page: 1,
  17. allow_load: true
  18. },
  19. onLoad(options) {
  20. this.getList(0, 0);
  21. if (options.quanid){
  22. this.setData({
  23. quanid: options.quanid
  24. })
  25. }
  26. },
  27. /**
  28. * 选择使用的优惠券
  29. */
  30. choicecoupon: function(e) {
  31. wx.navigateBack();
  32. var pages = getCurrentPages();
  33. var prevPage = pages[pages.length - 2] //上一个页面
  34. var that = this;
  35. var quantitle = e.currentTarget.dataset.title;
  36. var quanid = e.currentTarget.dataset.id;
  37. prevPage.setData({
  38. quantitle: quantitle,
  39. quanid: quanid,
  40. });
  41. wx.setStorage({
  42. key: 'chosed',
  43. data: 'chosed',
  44. })
  45. },
  46. getList(key, pageNum) {
  47. var that = this;
  48. if (that.data.allow_load) {
  49. Http.get({
  50. url: config.api.couponOrderCarList,
  51. data: {
  52. pageNum: pageNum,
  53. pageSize: 20,
  54. couponOrderStatus: key
  55. }
  56. }).then(res => {
  57. res.data.list.map(file => {
  58. file.expiredTime = format.formatTime(
  59. file.expiredTime,
  60. "yyyy-MM-dd hh:mm:ss"
  61. );
  62. });
  63. if (pageNum >= res.data.pages) {
  64. that.setData({
  65. allow_load: false
  66. });
  67. }
  68. that.data.list = that.data.list.concat(res.data.list);
  69. that.setData({
  70. list: that.data.list
  71. });
  72. })
  73. .catch(err => {
  74. wx.showToast({
  75. title: err.errMsg,
  76. icon: 'none',
  77. duration: 2000,
  78. mask: false
  79. });
  80. })
  81. }
  82. },
  83. });