C端小程序
Você não pode selecionar mais de 25 tópicos Os tópicos devem começar com uma letra ou um número, podem incluir traços ('-') e podem ter até 35 caracteres.

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