orderCanavs.js 2.6 KB

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