C端小程序
Nie możesz wybrać więcej, niż 25 tematów Tematy muszą się zaczynać od litery lub cyfry, mogą zawierać myślniki ('-') i mogą mieć do 35 znaków.

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