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.

160 line
3.6 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,6,7",
  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. console.log(key)
  68. if (that.data.allow_load) {
  69. that.setData({
  70. loading: true,
  71. content: "小主,我在玩命加载中...",
  72. });
  73. if(key==4){
  74. var data = {
  75. pageNum: pageNum,
  76. pageSize: 6,
  77. couponType: "7",
  78. couponOrderStatus: 4
  79. }
  80. }else if(key=='5,6,7'){
  81. var data = {
  82. pageNum: pageNum,
  83. pageSize: 6,
  84. couponType: "7",
  85. statusStr: "5,6,7"
  86. }
  87. }
  88. Http.get({
  89. url: config.api.cardorderList,
  90. data: data
  91. })
  92. .then(res => {
  93. if(res.code == 200){
  94. that.setData({
  95. showPage:true
  96. })
  97. }
  98. res.data.list.map(file => {
  99. file.expiredTime = util.fmtDate(file.expiredTime);
  100. });
  101. setTimeout(function () {
  102. that.setData({
  103. loading: false
  104. });
  105. }, 1400);
  106. if (pageNum >= res.data.pages) {
  107. that.setData({
  108. allow_load: false
  109. });
  110. }
  111. if (pageNum == 1) {
  112. that.setData({
  113. list: []
  114. })
  115. }
  116. var tmpArr = that.data.list;
  117. tmpArr.push.apply(tmpArr, res.data.list);
  118. that.setData({
  119. list: tmpArr
  120. })
  121. })
  122. .catch(err => {
  123. wx.showModal({
  124. title: '提示',
  125. content: err.errMsg,
  126. showCancel:false
  127. })
  128. })
  129. } else {
  130. that.setData({
  131. loading: true,
  132. content: "——— 再拉裤子就掉了啦 ———"
  133. });
  134. setTimeout(function () {
  135. that.setData({
  136. loading: false
  137. });
  138. }, 1400);
  139. }
  140. },
  141. handleChangeScroll({
  142. detail
  143. }) {
  144. this.setData({
  145. list: [],
  146. allow_load: true,
  147. current_scroll: detail.key,
  148. page:1,
  149. });
  150. this.getList(detail.key, 1);
  151. },
  152. onReachBottom: function () {
  153. var that = this;
  154. that.data.page++;
  155. that.setData({
  156. page: that.data.page
  157. });
  158. that.getList(that.data.current_scroll, that.data.page);
  159. }
  160. });