C端小程序
Вы не можете выбрать более 25 тем Темы должны начинаться с буквы или цифры, могут содержать дефисы(-) и должны содержать не более 35 символов.

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