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.

148 rivejä
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: 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. 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. }
  79. })
  80. .then(res => {
  81. if(res.code == 200){
  82. that.setData({
  83. showPage:true
  84. })
  85. }
  86. res.data.list.map(file => {
  87. file.expiredTime = util.fmtDate(file.expiredTime);
  88. });
  89. setTimeout(function () {
  90. that.setData({
  91. loading: false
  92. });
  93. }, 1400);
  94. if (pageNum >= res.data.pages) {
  95. that.setData({
  96. allow_load: false
  97. });
  98. }
  99. if (pageNum == 1) {
  100. that.setData({
  101. list: []
  102. })
  103. }
  104. var tmpArr = that.data.list;
  105. tmpArr.push.apply(tmpArr, res.data.list);
  106. that.setData({
  107. list: tmpArr
  108. })
  109. })
  110. .catch(err => {
  111. wx.showModal({
  112. title: '提示',
  113. content: err.errMsg,
  114. showCancel:false
  115. })
  116. })
  117. } else {
  118. that.setData({
  119. loading: true,
  120. content: "——— 再拉裤子就掉了啦 ———"
  121. });
  122. setTimeout(function () {
  123. that.setData({
  124. loading: false
  125. });
  126. }, 1400);
  127. }
  128. },
  129. handleChangeScroll({
  130. detail
  131. }) {
  132. this.setData({
  133. list: [],
  134. allow_load: true,
  135. current_scroll: detail.key,
  136. page:1,
  137. });
  138. this.getList(detail.key, 1);
  139. },
  140. onReachBottom: function () {
  141. var that = this;
  142. that.data.page++;
  143. that.setData({
  144. page: that.data.page
  145. });
  146. that.getList(that.data.current_scroll, that.data.page);
  147. }
  148. });