C端小程序
Nie możesz wybrać więcej, niż 25 tematów Tematy muszą się zaczynać od litery lub cyfry, mogą zawierać myślniki ('-') i mogą mieć do 35 znaków.

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