C端小程序
您最多选择25个主题 主题必须以字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符

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