// pages/orderCanvas/orderCanavs.js let app = getApp(); let host = app.globalData.servsers; // 请求的url Page({ /** * 页面的初始数据 */ data: { orderImg:null, host:host, params:null, uploadText:"上传付款凭证", orderList:[], }, /** * 生命周期函数--监听页面加载 */ onLoad: function (options) { var that = this that.setData({ params: options, }) }, /** * 生命周期函数--监听页面初次渲染完成 */ onReady: function () { }, /** * 生命周期函数--监听页面显示 */ onShow: function () { let that = this; that.getOrderList(that) // that.getImg(that) }, /** * 生命周期函数--监听页面隐藏 */ onHide: function () { }, /** * 生命周期函数--监听页面卸载 */ onUnload: function () { }, /** * 页面相关事件处理函数--监听用户下拉动作 */ onPullDownRefresh: function () { }, /** * 页面上拉触底事件的处理函数 */ onReachBottom: function () { }, /** * 用户点击右上角分享 */ onShareAppMessage() { return { // title: '', path: '/pages/orderCanvas/orderCanavs?orderId='+this.data.params.orderId +'&&static=true' } }, returnHome(){ wx.switchTab({ url: '/pages/mine/mine', }) }, uploadImg() { // 上传支付凭证 let that = this; wx.chooseImage({ success(res) { const tempFilePaths = res.tempFilePaths wx.uploadFile({ url: host + '/payOrderFile', // 仅为示例,非真实的接口地址 filePath: tempFilePaths[0], header: { "Content-Type": "multipart/form-data" }, name: 'file', formData: { file: tempFilePaths[0], orderId: wx.getStorageSync('orderId'), }, success(res) { console.log(res, '我上传完了') if (res.data) { wx.showToast({ title: '支付凭证上传成功!', icon: 'none' }) that.setData({ uploadText:'已上传付款凭证' }) } else { wx.showToast({ title: res.data, icon: 'none' }) } } }) } }) }, getOrderList(that){ wx.request({ url: host +'/orderapi/orderView', data:{ order_number: that.data.params.orderId }, method:'get', success(res){ console.log(res) that.setData({ orderList: res.data[0].list_order_aff_data }) } }) }, getImg(that){ wx.request({ url: host+'/orderapi/getOrderShareById', data:{ orderId:that.data.params.orderId }, method:"get", success(res){ console.log(res,"内容") that.setData({ orderImg:res.data }) } }) } })