let app = getApp(); let host = app.globalData.servsers; // 请求的url Page({ data: { host: host, isSelect: "", //默认全部 dataStateArray: [{ state: '0', label: "全部", }, { state: '1', label: "待付款", }, { state: '2', label: "待审核", }, { state: '3', label: "待发货", }, { state: '4', label: "待收货", }, { state: '5', label: "已完成", } ], goodsList: [], page: 1, //默认第一页 limit:10,//默认就展示10条数据 requestStatic:true, //默认可以下拉请求 }, /** * 生命周期函数--监听页面加载 */ onLoad: function (options) { let that = this; if ('state' in options) { that.setData({ isSelect: options.state }) } that.getOrderList(that, that.data.isSelect) }, /** * 生命周期函数--监听页面初次渲染完成 */ onReady: function () { }, /** * 生命周期函数--监听页面显示 */ onShow: function () { }, /** * 生命周期函数--监听页面隐藏 */ onHide: function () { }, /** * 生命周期函数--监听页面卸载 */ onUnload: function () { }, /** * 页面相关事件处理函数--监听用户下拉动作 */ onPullDownRefresh: function () { }, /** * 页面上拉触底事件的处理函数 */ onReachBottom: function () { console.log("到底了") let that = this; if(that.data.requestStatic){ that.setData({ page:that.data.page +1 }) that.getOrderList(that) } }, /** * 用户点击右上角分享 */ onShareAppMessage: function () { }, tab(e) { // tab切换 this.setData({ isSelect: e.currentTarget.dataset.state, page:1, goodsList:[], requestStatic:true }) this.getOrderList(this) }, getOrderList(that) { let data = { user_id: app.globalData.user_id, status: that.data.isSelect, offset: that.data.page, limit: that.data.limit } if (wx.getStorageSync('channelIdObj').channelAccountId){ data.channel_account_id = wx.getStorageSync('channelIdObj').channelAccountId; } wx.request({ url: host + '/orderapi/orderlist', method: 'get', data:data, success(res) { console.log(res, "orderItem") let data = res.data,goodsList = that.data.goodsList; data.forEach(res=>{ let total = 0; res.list_order_aff_data.forEach(el=>{ total += el.com_price * 1 }) res.com_price_total = total; }) goodsList.push(...data) that.setData({ goodsList: goodsList, requestStatic:res.data.length == that.data.limit }) } }) }, orderInfor: function (e) { //之前查看详情 // wx.navigateTo({ // url: '/pages/confirmedList/confirmedList?goosdListnew=' + newCarts // }) }, uploadImg(e){ // 上传支付凭证 let orderId = e.currentTarget.dataset.orderid, that = this, index = e.currentTarget.dataset.index; 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: orderId, }, success(res) { console.log(res, '我上传完了') if(res.data){ wx.showToast({ title: '支付凭证上传成功!', icon:'none' }) let goodsList = that.data.goodsList; goodsList[index].list_order_aff_data[0].pay_order = res.data that.setData({ goodsList: goodsList }) } else { wx.showToast({ title: res.data, icon: 'error' }) } } }) } }) }, seePayOrder(e){ let that = this, imgSrc =[]; if (e.currentTarget.dataset.src[0].pay_order){ imgSrc.push(host+e.currentTarget.dataset.src[0].pay_order) } if (e.currentTarget.dataset.src[0].final_payment) { imgSrc.push(host +e.currentTarget.dataset.src[0].final_payment) } console.log(imgSrc) wx.previewImage({ current: imgSrc[0], urls: imgSrc }) } })