C端小程序
Nevar pievienot vairāk kā 25 tēmas Tēmai ir jāsākas ar burtu vai ciparu, tā var saturēt domu zīmes ('-') un var būt līdz 35 simboliem gara.

134 rindas
3.0 KiB

  1. const util = require("../../../utils/util.js");
  2. const config = require("../../../config/config.js");
  3. const Http = require("../../../utils/HttpBasics");
  4. let app = getApp();
  5. Page({
  6. data: {
  7. tabs: [{
  8. key: 0,
  9. name: "使用中"
  10. },
  11. {
  12. key: 1,
  13. name: "已失效"
  14. }
  15. ],
  16. list: [],
  17. current: "0",
  18. current_scroll: "0",
  19. page: 1,
  20. allow_load: true,
  21. loading: true, //"上拉加载"的变量,默认false,隐藏
  22. content: "",
  23. mystatus: '',
  24. showPage:false
  25. },
  26. onLoad() {
  27. this.getList(0, 1);
  28. },
  29. onShow: function () {
  30. let that = this;
  31. wx.setStorage({
  32. key: 'couponNum',
  33. data: "couponNum1",
  34. })
  35. wx.hideTabBarRedDot({
  36. index:2
  37. })
  38. },
  39. //点击跳转到券详情页面
  40. gotouse: function (e) {
  41. if (this.data.mystatus == '' || this.data.mystatus == 'undefined') {
  42. var mystatus = e.currentTarget.dataset.couponorderstatus;
  43. } else {
  44. var mystatus = this.data.mystatus;
  45. }
  46. wx.navigateTo({
  47. url: `/pages/couponorder/detail/index?quancode=${
  48. e.currentTarget.dataset.quancode}&couponorderstatus=${mystatus}`
  49. });
  50. },
  51. getList(key, pageNum) {
  52. var that = this;
  53. if (that.data.allow_load) {
  54. that.setData({
  55. loading: true,
  56. content: "小主,我在玩命加载中...",
  57. });
  58. Http.get({
  59. url: config.api.cardorderList,
  60. data: {
  61. pageNum: pageNum,
  62. pageSize: 6,
  63. couponType:7
  64. }
  65. })
  66. .then(res => {
  67. if(res.code == 200){
  68. that.setData({
  69. showPage:true
  70. })
  71. }
  72. res.data.list.map(file => {
  73. file.expiredTime = util.fmtDate(file.expiredTime);
  74. });
  75. setTimeout(function () {
  76. that.setData({
  77. loading: false
  78. });
  79. }, 1400);
  80. if (pageNum >= res.data.pages) {
  81. that.setData({
  82. allow_load: false
  83. });
  84. }
  85. if (pageNum == 1) {
  86. that.setData({
  87. list: []
  88. })
  89. }
  90. var tmpArr = that.data.list;
  91. tmpArr.push.apply(tmpArr, res.data.list);
  92. that.setData({
  93. list: tmpArr
  94. })
  95. })
  96. .catch(err => {
  97. wx.showModal({
  98. title: '提示',
  99. content: err.errMsg,
  100. showCancel:false
  101. })
  102. })
  103. } else {
  104. that.setData({
  105. loading: true,
  106. content: "——— 再拉裤子就掉了啦 ———"
  107. });
  108. setTimeout(function () {
  109. that.setData({
  110. loading: false
  111. });
  112. }, 1400);
  113. }
  114. },
  115. handleChangeScroll({
  116. detail
  117. }) {
  118. this.setData({
  119. list: [],
  120. allow_load: true,
  121. current_scroll: detail.key,
  122. page:1,
  123. });
  124. this.getList(detail.key, 1);
  125. },
  126. onReachBottom: function () {
  127. var that = this;
  128. that.data.page++;
  129. that.setData({
  130. page: that.data.page
  131. });
  132. that.getList(that.data.current_scroll, that.data.page);
  133. }
  134. });