orderList.js 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185
  1. let app = getApp();
  2. let host = app.globalData.servsers; // 请求的url
  3. Page({
  4. data: {
  5. host: host,
  6. isSelect: "", //默认全部
  7. dataStateArray: [{
  8. state: '0',
  9. label: "全部",
  10. },
  11. {
  12. state: '1',
  13. label: "待付款",
  14. },
  15. {
  16. state: '3',
  17. label: "待发货",
  18. },
  19. {
  20. state: '4',
  21. label: "待收货",
  22. },
  23. {
  24. state: '5',
  25. label: "待评价",
  26. }
  27. ],
  28. goodsList: [],
  29. page: 1, //默认第一页
  30. limit:10,//默认就展示10条数据
  31. requestStatic:true, //默认可以下拉请求
  32. },
  33. /**
  34. * 生命周期函数--监听页面加载
  35. */
  36. onLoad: function (options) {
  37. let that = this;
  38. if ('state' in options) {
  39. that.setData({
  40. isSelect: options.state
  41. })
  42. }
  43. that.getOrderList(that, that.data.isSelect)
  44. },
  45. /**
  46. * 生命周期函数--监听页面初次渲染完成
  47. */
  48. onReady: function () {
  49. },
  50. /**
  51. * 生命周期函数--监听页面显示
  52. */
  53. onShow: function () {
  54. },
  55. /**
  56. * 生命周期函数--监听页面隐藏
  57. */
  58. onHide: function () {
  59. },
  60. /**
  61. * 生命周期函数--监听页面卸载
  62. */
  63. onUnload: function () {
  64. },
  65. /**
  66. * 页面相关事件处理函数--监听用户下拉动作
  67. */
  68. onPullDownRefresh: function () {
  69. },
  70. /**
  71. * 页面上拉触底事件的处理函数
  72. */
  73. onReachBottom: function () {
  74. console.log("到底了")
  75. let that = this;
  76. if(that.data.requestStatic){
  77. that.setData({
  78. page:that.data.page +1
  79. })
  80. that.getOrderList(that)
  81. }
  82. },
  83. /**
  84. * 用户点击右上角分享
  85. */
  86. onShareAppMessage: function () {
  87. },
  88. tab(e) { // tab切换
  89. this.setData({
  90. isSelect: e.currentTarget.dataset.state,
  91. page:1,
  92. goodsList:[],
  93. requestStatic:true
  94. })
  95. this.getOrderList(this)
  96. },
  97. getOrderList(that) {
  98. let data = {
  99. user_id: app.globalData.user_id,
  100. status: that.data.isSelect,
  101. offset: that.data.page,
  102. limit: that.data.limit
  103. }
  104. if (wx.getStorageSync('channelIdObj').channelAccountId){
  105. data.channel_account_id = wx.getStorageSync('channelIdObj').channelAccountId;
  106. }
  107. wx.request({
  108. url: host + '/orderapi/orderlist',
  109. method: 'get',
  110. data:data,
  111. success(res) {
  112. console.log(res, "orderItem")
  113. let data = res.data,goodsList = that.data.goodsList;
  114. data.forEach(res=>{
  115. let total = 0;
  116. res.list_order_aff_data.forEach(el=>{
  117. total += el.order_Price * 1
  118. })
  119. res.com_price_total = total;
  120. })
  121. goodsList.push(...data)
  122. that.setData({
  123. goodsList: goodsList,
  124. requestStatic:res.data.length == that.data.limit
  125. })
  126. }
  127. })
  128. },
  129. orderInfor: function (e) { //之前查看详情
  130. // wx.navigateTo({
  131. // url: '/pages/confirmedList/confirmedList?goosdListnew=' + newCarts
  132. // })
  133. },
  134. uploadImg(e){
  135. // 上传支付凭证
  136. let orderId=e.currentTarget.dataset.orderid,that =this;
  137. wx.chooseImage({
  138. success(res) {
  139. const tempFilePaths = res.tempFilePaths
  140. wx.uploadFile({
  141. url: host + '/payOrderFile', // 仅为示例,非真实的接口地址
  142. filePath: tempFilePaths[0],
  143. header: {
  144. "Content-Type": "multipart/form-data"
  145. },
  146. name: 'file',
  147. formData: {
  148. file: tempFilePaths[0],
  149. orderId: orderId,
  150. },
  151. success(res) {
  152. console.log(res, '我上传完了')
  153. if(res.data == 'success'){
  154. wx.showToast({
  155. title: '支付凭证上传成功!',
  156. icon:'none'
  157. })
  158. } else {
  159. wx.showToast({
  160. title: res.data,
  161. icon: 'error'
  162. })
  163. }
  164. }
  165. })
  166. }
  167. })
  168. }
  169. })