C端小程序
Vous ne pouvez pas sélectionner plus de 25 sujets Les noms de sujets doivent commencer par une lettre ou un nombre, peuvent contenir des tirets ('-') et peuvent comporter jusqu'à 35 caractères.

149 lignes
3.3 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: 4,
  9. name: "使用中"
  10. },
  11. {
  12. key: 5,
  13. name: "已失效"
  14. }
  15. ],
  16. list: [],
  17. current: "4",
  18. current_scroll: "4",
  19. page: 1,
  20. allow_load: true,
  21. loading: true, //"上拉加载"的变量,默认false,隐藏
  22. content: "",
  23. mystatus: '',
  24. showPage:false
  25. },
  26. onLoad() {
  27. this.getList(4, 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. gotoPay:function(e){
  41. console.log(e.currentTarget.dataset.cardid)
  42. Http.post({
  43. url: config.api.orderCreate,
  44. data: {
  45. cardId: e.currentTarget.dataset.cardid,
  46. merchantCode: "234567451101102080",
  47. totalFee: "5"
  48. }
  49. }).then(res=>{
  50. console.log(res)
  51. })
  52. },
  53. //点击跳转到券详情页面
  54. gotouse: function (e) {
  55. if (this.data.mystatus == '' || this.data.mystatus == 'undefined') {
  56. var mystatus = e.currentTarget.dataset.couponorderstatus;
  57. } else {
  58. var mystatus = this.data.mystatus;
  59. }
  60. wx.navigateTo({
  61. url: `/pages/couponorder/detail/index?quancode=${
  62. e.currentTarget.dataset.quancode}&couponorderstatus=${mystatus}`
  63. });
  64. },
  65. getList(key, pageNum) {
  66. var that = this;
  67. if (that.data.allow_load) {
  68. that.setData({
  69. loading: true,
  70. content: "小主,我在玩命加载中...",
  71. });
  72. Http.get({
  73. url: config.api.cardorderList,
  74. data: {
  75. pageNum: pageNum,
  76. pageSize: 6,
  77. couponType:"7",
  78. couponOrderStatus: key
  79. }
  80. })
  81. .then(res => {
  82. if(res.code == 200){
  83. that.setData({
  84. showPage:true
  85. })
  86. }
  87. res.data.list.map(file => {
  88. file.expiredTime = util.fmtDate(file.expiredTime);
  89. });
  90. setTimeout(function () {
  91. that.setData({
  92. loading: false
  93. });
  94. }, 1400);
  95. if (pageNum >= res.data.pages) {
  96. that.setData({
  97. allow_load: false
  98. });
  99. }
  100. if (pageNum == 1) {
  101. that.setData({
  102. list: []
  103. })
  104. }
  105. var tmpArr = that.data.list;
  106. tmpArr.push.apply(tmpArr, res.data.list);
  107. that.setData({
  108. list: tmpArr
  109. })
  110. })
  111. .catch(err => {
  112. wx.showModal({
  113. title: '提示',
  114. content: err.errMsg,
  115. showCancel:false
  116. })
  117. })
  118. } else {
  119. that.setData({
  120. loading: true,
  121. content: "——— 再拉裤子就掉了啦 ———"
  122. });
  123. setTimeout(function () {
  124. that.setData({
  125. loading: false
  126. });
  127. }, 1400);
  128. }
  129. },
  130. handleChangeScroll({
  131. detail
  132. }) {
  133. this.setData({
  134. list: [],
  135. allow_load: true,
  136. current_scroll: detail.key,
  137. page:1,
  138. });
  139. this.getList(detail.key, 1);
  140. },
  141. onReachBottom: function () {
  142. var that = this;
  143. that.data.page++;
  144. that.setData({
  145. page: that.data.page
  146. });
  147. that.getList(that.data.current_scroll, that.data.page);
  148. }
  149. });