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.

192 Zeilen
4.5 KiB

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