orderCanavs.js 2.5 KB

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