orderCanavs.js 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134
  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. // 查看订单
  65. wx.navigateTo({
  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 == 'success') {
  89. wx.showToast({
  90. title: '支付凭证上传成功!',
  91. icon: 'none'
  92. })
  93. } else {
  94. wx.showToast({
  95. title: res.data,
  96. icon: 'none'
  97. })
  98. }
  99. }
  100. })
  101. }
  102. })
  103. },
  104. getImg(that){
  105. wx.request({
  106. url: host+'/orderapi/getOrderShareById',
  107. data:{
  108. orderId:that.data.params.orderId
  109. },
  110. method:"get",
  111. success(res){
  112. console.log(res,"内容")
  113. that.setData({
  114. orderImg:res.data
  115. })
  116. }
  117. })
  118. }
  119. })