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.

183 lines
4.1 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. let that = this;
  42. wx.scanCode({
  43. success: (res) => {
  44. that.merChantId = res.result;
  45. console.log(res);
  46. wx.navigateTo({
  47. url: `/pages/scanPay/scanPay?`,
  48. })
  49. },
  50. fail: (res) => {
  51. console.log(res);
  52. }
  53. })
  54. },
  55. // gotoPayMoney:function(){
  56. // let that = this;
  57. // Http.post({
  58. // url: config.api.orderCreate,
  59. // data: {
  60. // cardId: e.currentTarget.dataset.cardid,
  61. // merchantCode: that.data.merChantId,
  62. // totalFee: "5"
  63. // }
  64. // })
  65. // .then(res => {
  66. // console.log(res)
  67. // })
  68. // .catch(err => {
  69. // wx.showModal({
  70. // title: "抱歉",
  71. // content: err.message,
  72. // showCancel: false
  73. // })
  74. // })
  75. // },
  76. //点击跳转到券详情页面
  77. gotouse: function (e) {
  78. if (this.data.mystatus == '' || this.data.mystatus == 'undefined') {
  79. var mystatus = e.currentTarget.dataset.couponorderstatus;
  80. } else {
  81. var mystatus = this.data.mystatus;
  82. }
  83. wx.navigateTo({
  84. url: `/pages/couponorder/detail/index?quancode=${
  85. e.currentTarget.dataset.quancode}&couponorderstatus=${mystatus}`
  86. });
  87. },
  88. getList(key, pageNum) {
  89. var that = this;
  90. console.log(key)
  91. if (that.data.allow_load) {
  92. that.setData({
  93. loading: true,
  94. content: "小主,我在玩命加载中...",
  95. });
  96. if(key==4){
  97. var data = {
  98. pageNum: pageNum,
  99. pageSize: 6,
  100. couponType: "7",
  101. couponOrderStatus: 4
  102. }
  103. }else if(key=='5,6,7'){
  104. var data = {
  105. pageNum: pageNum,
  106. pageSize: 6,
  107. couponType: "7",
  108. statusStr: "5,6,7"
  109. }
  110. }
  111. Http.get({
  112. url: config.api.cardorderList,
  113. data:data
  114. })
  115. .then(res => {
  116. if(res.code == 200){
  117. that.setData({
  118. showPage:true
  119. })
  120. }
  121. res.data.list.map(file => {
  122. file.expiredTime = util.fmtDate(file.expiredTime);
  123. });
  124. setTimeout(function () {
  125. that.setData({
  126. loading: false
  127. });
  128. }, 1400);
  129. if (pageNum >= res.data.pages) {
  130. that.setData({
  131. allow_load: false
  132. });
  133. }
  134. if (pageNum == 1) {
  135. that.setData({
  136. list: []
  137. })
  138. }
  139. var tmpArr = that.data.list;
  140. tmpArr.push.apply(tmpArr, res.data.list);
  141. that.setData({
  142. list: tmpArr
  143. })
  144. })
  145. .catch(err => {
  146. wx.showModal({
  147. title: '提示',
  148. content: err.errMsg,
  149. showCancel:false
  150. })
  151. })
  152. } else {
  153. that.setData({
  154. loading: true,
  155. content: "——— 再拉裤子就掉了啦 ———"
  156. });
  157. setTimeout(function () {
  158. that.setData({
  159. loading: false
  160. });
  161. }, 1400);
  162. }
  163. },
  164. handleChangeScroll({
  165. detail
  166. }) {
  167. this.setData({
  168. list: [],
  169. allow_load: true,
  170. current_scroll: detail.key,
  171. page:1,
  172. });
  173. this.getList(detail.key, 1);
  174. },
  175. onReachBottom: function () {
  176. var that = this;
  177. that.data.page++;
  178. that.setData({
  179. page: that.data.page
  180. });
  181. that.getList(that.data.current_scroll, that.data.page);
  182. }
  183. });