orderCanavs.js 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154
  1. // pages/orderCanvas/orderCanavs.js
  2. let app = getApp();
  3. let host = app.globalData.servsers; // 请求的url
  4. Page({
  5. /**
  6. * 页面的初始数据
  7. */
  8. data: {
  9. orderImg:null,
  10. host:host,
  11. params:null,
  12. uploadText:"上传付款凭证",
  13. orderList:[],
  14. },
  15. /**
  16. * 生命周期函数--监听页面加载
  17. */
  18. onLoad: function (options) {
  19. var that = this
  20. that.setData({
  21. params: options,
  22. })
  23. },
  24. /**
  25. * 生命周期函数--监听页面初次渲染完成
  26. */
  27. onReady: function () {
  28. },
  29. /**
  30. * 生命周期函数--监听页面显示
  31. */
  32. onShow: function () {
  33. let that = this;
  34. that.getOrderList(that)
  35. // that.getImg(that)
  36. },
  37. /**
  38. * 生命周期函数--监听页面隐藏
  39. */
  40. onHide: function () {
  41. },
  42. /**
  43. * 生命周期函数--监听页面卸载
  44. */
  45. onUnload: function () {
  46. },
  47. /**
  48. * 页面相关事件处理函数--监听用户下拉动作
  49. */
  50. onPullDownRefresh: function () {
  51. },
  52. /**
  53. * 页面上拉触底事件的处理函数
  54. */
  55. onReachBottom: function () {
  56. },
  57. /**
  58. * 用户点击右上角分享
  59. */
  60. onShareAppMessage() {
  61. return {
  62. // title: '',
  63. path: '/pages/orderCanvas/orderCanavs?orderId='+this.data.params.orderId +'&&static=true'
  64. }
  65. },
  66. returnHome(){
  67. wx.switchTab({
  68. url: '/pages/mine/mine',
  69. })
  70. },
  71. uploadImg() {
  72. // 上传支付凭证
  73. let that = this;
  74. wx.chooseImage({
  75. success(res) {
  76. const tempFilePaths = res.tempFilePaths
  77. wx.uploadFile({
  78. url: host + '/payOrderFile', // 仅为示例,非真实的接口地址
  79. filePath: tempFilePaths[0],
  80. header: {
  81. "Content-Type": "multipart/form-data"
  82. },
  83. name: 'file',
  84. formData: {
  85. file: tempFilePaths[0],
  86. orderId: wx.getStorageSync('orderId'),
  87. },
  88. success(res) {
  89. console.log(res, '我上传完了')
  90. if (res.data) {
  91. wx.showToast({
  92. title: '支付凭证上传成功!',
  93. icon: 'none'
  94. })
  95. that.setData({
  96. uploadText:'已上传付款凭证'
  97. })
  98. } else {
  99. wx.showToast({
  100. title: res.data,
  101. icon: 'none'
  102. })
  103. }
  104. }
  105. })
  106. }
  107. })
  108. },
  109. getOrderList(that){
  110. wx.request({
  111. url: host +'/orderapi/orderView',
  112. data:{
  113. order_number: that.data.params.orderId
  114. },
  115. method:'get',
  116. success(res){
  117. console.log(res)
  118. that.setData({
  119. orderList: res.data[0].list_order_aff_data
  120. })
  121. }
  122. })
  123. },
  124. getImg(that){
  125. wx.request({
  126. url: host+'/orderapi/getOrderShareById',
  127. data:{
  128. orderId:that.data.params.orderId
  129. },
  130. method:"get",
  131. success(res){
  132. console.log(res,"内容")
  133. that.setData({
  134. orderImg:res.data
  135. })
  136. }
  137. })
  138. }
  139. })