C端小程序
Du kannst nicht mehr als 25 Themen auswählen Themen müssen entweder mit einem Buchstaben oder einer Ziffer beginnen. Sie können Bindestriche („-“) enthalten und bis zu 35 Zeichen lang sein.

177 Zeilen
4.1 KiB

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