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

195 行
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: '/index/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. if (key == undefined) {
  79. key = 'all'
  80. }
  81. /**
  82. * key==0
  83. * 不发送该字段
  84. */
  85. if (key == 'all') {
  86. var variable = {
  87. pageNum: pageNum,
  88. pageSize: 15,
  89. paymentType: 0
  90. };
  91. } else {
  92. var variable = {
  93. pageNum: pageNum,
  94. pageSize: 15,
  95. orderStatus: key,
  96. paymentType: 0
  97. };
  98. }
  99. if (that.data.allow_load) {
  100. that.setData({
  101. loading: true,
  102. content: '小主,我在玩命加载中...'
  103. })
  104. Http.get({
  105. url: config.api.orderList,
  106. data: variable
  107. }).then(res => {
  108. if (pageNum >= res.data.pages) {
  109. that.setData({
  110. allow_load: false
  111. });
  112. setTimeout(function () {
  113. that.setData({
  114. loading: false,
  115. })
  116. }, 1400);
  117. }
  118. setTimeout(function () {
  119. that.setData({
  120. loading: false,
  121. })
  122. }, 1400);
  123. if (pageNum == 1) {
  124. that.setData({
  125. list: []
  126. })
  127. }
  128. var tmpArr = that.data.list;
  129. tmpArr.push.apply(tmpArr, res.data.list);
  130. // 将砍价的状态过滤出来
  131. console.log(tmpArr)
  132. that.setData({
  133. list: tmpArr
  134. })
  135. for (let i = 0; i < that.data.list.length; i++) {
  136. var createDate1 = util.formatTime(that.data.list[i].createDate, "yyyy-MM-dd hh:mm:ss");
  137. /**
  138. * 修改list的endtime
  139. * 渲染到页面
  140. */
  141. var createDate = 'list[' + i + '].createDate'
  142. that.setData({
  143. [createDate]: createDate1
  144. });
  145. }
  146. })
  147. .catch(err => {
  148. wx.showModal({
  149. title: '提示',
  150. content: err.errMsg,
  151. showCancel:false
  152. })
  153. })
  154. }
  155. else {
  156. that.setData({
  157. loading: true,
  158. content: "——— 再拉裤子就掉了啦 ———"
  159. })
  160. setTimeout(function () {
  161. that.setData({
  162. loading: false,
  163. })
  164. }, 1400)
  165. }
  166. },
  167. handleChange({
  168. detail
  169. }) {
  170. this.setData({
  171. current: detail.key
  172. });
  173. },
  174. handleChangeScroll({
  175. detail
  176. }) {
  177. this.setData({
  178. list: [],
  179. allow_load: true,
  180. current_scroll: detail.key,
  181. page: 1
  182. })
  183. this.getList(detail.key, 1);
  184. },
  185. onReachBottom: function () {
  186. var that = this;
  187. that.data.page++;
  188. that.setData({
  189. page: that.data.page
  190. });
  191. that.getList(that.data.current_scroll, that.data.page);
  192. },
  193. });