orderList.js 4.6 KB

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