C端小程序
Vous ne pouvez pas sélectionner plus de 25 sujets Les noms de sujets doivent commencer par une lettre ou un nombre, peuvent contenir des tirets ('-') et peuvent comporter jusqu'à 35 caractères.

182 lignes
4.1 KiB

  1. let config = require("../../../config/config.js");
  2. let Http = require("../../../utils/HttpBasics");
  3. const util = require("../../../utils/util");
  4. let app = getApp();
  5. const imgurl = require("../../../utils/imgurl");
  6. Page({
  7. data: {
  8. noOrdersUrl: imgurl.noOrders.url,
  9. loadingUrl: imgurl.loading.url,
  10. wmhome: imgurl.wmhome.url,
  11. wmdiscount: imgurl.wmdiscount.url,
  12. wmgive: imgurl.wmgive.url,
  13. tabs: [{
  14. key: "all",
  15. name: "全部"
  16. },
  17. {
  18. key: 0,
  19. name: "待付款"
  20. },
  21. {
  22. key: 1,
  23. name: "已完成"
  24. }
  25. ],
  26. list: [],
  27. current: "",
  28. loading: true, //"上拉加载"的变量,默认false,隐藏
  29. current_scroll: "1",
  30. allow_load: true,
  31. page: 1,
  32. content: "",
  33. },
  34. goback: function () {
  35. wx.switchTab({
  36. url: '/pages/main/index',
  37. })
  38. },
  39. onLoad(e) {
  40. this.getList(e.id, 1);
  41. this.setData({
  42. current_scroll: e.id
  43. });
  44. },
  45. /**
  46. * 砍价中的状态
  47. * 跳转到砍价详情页面
  48. */
  49. gotoDiscount:function(e){
  50. wx.navigateTo({
  51. url: `/pages/bargain/bargainDatail/bargainDatail?orderId=${e.currentTarget.dataset.id}`
  52. })
  53. },
  54. gotopay: function (e) {
  55. wx.navigateTo({
  56. url: `/pages/order/detail/index?orderId=${e.currentTarget.dataset.id}&flag='pay'`
  57. })
  58. },
  59. // gotoSpellPay(e) {
  60. // console.log(e, 333)
  61. // let data = e.currentTarget.dataset.data
  62. // wx.navigateTo({
  63. // url: `/pages/spellGroup/paySpellGroup/index?orderId=${data.orderId}&couponId=${data.couponId}&orderGroupId=${data.orderGroupId}&couponChannelId=${data.couponChannelId}`,
  64. // })
  65. // },
  66. getList(key, pageNum) {
  67. let that = this;
  68. /**
  69. * key==0
  70. * 不发送该字段
  71. */
  72. if (key == 'all') {
  73. var variable = {
  74. pageNum: pageNum,
  75. pageSize: 15,
  76. paymentType: 0
  77. };
  78. } else {
  79. var variable = {
  80. pageNum: pageNum,
  81. pageSize: 15,
  82. orderStatus: key,
  83. paymentType: 0
  84. };
  85. }
  86. if (that.data.allow_load) {
  87. that.setData({
  88. loading: true,
  89. content: '小主,我在玩命加载中...'
  90. })
  91. Http.get({
  92. url: config.api.orderList,
  93. data: variable
  94. }).then(res => {
  95. if (pageNum >= res.data.pages) {
  96. that.setData({
  97. allow_load: false
  98. });
  99. setTimeout(function () {
  100. that.setData({
  101. loading: false,
  102. })
  103. }, 1400);
  104. }
  105. setTimeout(function () {
  106. that.setData({
  107. loading: false,
  108. })
  109. }, 1400);
  110. if (pageNum == 1) {
  111. that.setData({
  112. list: []
  113. })
  114. }
  115. var tmpArr = that.data.list;
  116. tmpArr.push.apply(tmpArr, res.data.list);
  117. // 将砍价的状态过滤出来
  118. console.log(tmpArr)
  119. that.setData({
  120. list: tmpArr
  121. })
  122. for (let i = 0; i < that.data.list.length; i++) {
  123. var createDate1 = util.formatTime(that.data.list[i].createDate, "yyyy-MM-dd hh:mm:ss");
  124. /**
  125. * 修改list的endtime
  126. * 渲染到页面
  127. */
  128. var createDate = 'list[' + i + '].createDate'
  129. that.setData({
  130. [createDate]: createDate1
  131. });
  132. }
  133. })
  134. .catch(err => {
  135. wx.showModal({
  136. title: '提示',
  137. content: err.errMsg,
  138. showCancel:false
  139. })
  140. })
  141. }
  142. else {
  143. that.setData({
  144. loading: true,
  145. content: "——— 再拉裤子就掉了啦 ———"
  146. })
  147. setTimeout(function () {
  148. that.setData({
  149. loading: false,
  150. })
  151. }, 1400)
  152. }
  153. },
  154. handleChange({
  155. detail
  156. }) {
  157. this.setData({
  158. current: detail.key
  159. });
  160. },
  161. handleChangeScroll({
  162. detail
  163. }) {
  164. this.setData({
  165. list: [],
  166. allow_load: true,
  167. current_scroll: detail.key,
  168. page: 1
  169. })
  170. this.getList(detail.key, 1);
  171. },
  172. onReachBottom: function () {
  173. var that = this;
  174. that.data.page++;
  175. that.setData({
  176. page: that.data.page
  177. });
  178. that.getList(that.data.current_scroll, that.data.page);
  179. },
  180. });