diff --git a/pages/order/editFinance/index.js b/pages/order/editFinance/index.js index e6901e4..68c2b98 100644 --- a/pages/order/editFinance/index.js +++ b/pages/order/editFinance/index.js @@ -30,7 +30,9 @@ Page({ params['id'] = this.data.id; _.apiQuery.getAppCusorderV2(params).then(res=>{ this.setData({ + info:res.data, notify_file_obj:res.data.notify_file, + lend_file_obj:res.data.lend_file, price_loan:res.data.price_loan?res.data.price_loan:'', }) @@ -104,39 +106,76 @@ Page({ //上传按揭通知函 chooseImg(e) { let that = this - wx.chooseImage({ - count: 1, // 默认9 - sizeType: ['original', 'compressed'], // 可以指定是原图还是压缩图,默认二者都有 - sourceType: ['album', 'camera'], // 可以指定来源是相册还是相机,默认二者都有 - success(res) { - wx.showLoading(); - wx.uploadFile({ - url:_.config.api.upImg, - filePath:res.tempFilePaths[0], - name: 'img', - formData: { - 'app': 'liche' - }, - success: (resp) => { - resp.data = JSON.parse(resp.data); - wx.hideLoading(); - if (resp.data.code == 200) { - that.setData({ - 'notify_file_obj.value':resp.data.data.url, - 'notify_file_obj.src':resp.data.data.full_url, - }) - } - }, - }) - }, - fail: res => { - wx.showToast({ - title: '文件选择失败', - icon: 'none', - duration: 2000 - }) - } - }) + if(e.currentTarget.dataset.type=='notify'){ + wx.chooseImage({ + count: 1, // 默认9 + sizeType: ['original', 'compressed'], // 可以指定是原图还是压缩图,默认二者都有 + sourceType: ['album', 'camera'], // 可以指定来源是相册还是相机,默认二者都有 + success(res) { + wx.showLoading(); + wx.uploadFile({ + url:_.config.api.upImg, + filePath:res.tempFilePaths[0], + name: 'img', + formData: { + 'app': 'liche' + }, + success: (resp) => { + resp.data = JSON.parse(resp.data); + wx.hideLoading(); + if (resp.data.code == 200) { + that.setData({ + 'notify_file_obj.value':resp.data.data.url, + 'notify_file_obj.src':resp.data.data.full_url, + }) + } + }, + }) + }, + fail: res => { + wx.showToast({ + title: '文件选择失败', + icon: 'none', + duration: 2000 + }) + } + }) + } + if(e.currentTarget.dataset.type=='lend'){ + wx.chooseImage({ + count: 1, // 默认9 + sizeType: ['original', 'compressed'], // 可以指定是原图还是压缩图,默认二者都有 + sourceType: ['album', 'camera'], // 可以指定来源是相册还是相机,默认二者都有 + success(res) { + wx.showLoading(); + wx.uploadFile({ + url:_.config.api.upImg, + filePath:res.tempFilePaths[0], + name: 'img', + formData: { + 'app': 'liche' + }, + success: (resp) => { + resp.data = JSON.parse(resp.data); + wx.hideLoading(); + if (resp.data.code == 200) { + that.setData({ + 'lend_file_obj.value':resp.data.data.url, + 'lend_file_obj.src':resp.data.data.full_url, + }) + } + }, + }) + }, + fail: res => { + wx.showToast({ + title: '文件选择失败', + icon: 'none', + duration: 2000 + }) + } + }) + } }, //修改贷款信息 @@ -161,51 +200,110 @@ Page({ } else{ let that = this - wx.showModal({ - title: '确定修改按揭信息?', - content: '金融机构:'+that.data.financeArray[that.data.financeIndex]+'\r\n贷款金额:'+that.data.price_loan+' ', - confirmColor: "#36afa2", - success(resW) { - if (resW.confirm) { - that.setData({ - submitFlag: true, - }) - let params = {}; - params['o_id'] = that.data.id; - params['finance_id'] = that.data.finance_id; - params['notify_file'] = that.data.notify_file_obj.value; - params['price_loan'] = that.data.price_loan; - _.apiQuery.putAppLoan(params).then(res => { - - //刷新详情页 - let pages = getCurrentPages(); - let prevPage = null; //上一个页面 - if (pages.length >= 2) { - prevPage = pages[pages.length - 2]; //上一个页面 - if(prevPage.route == 'pages/order/detail/index2'){ - prevPage.onPullDownRefresh() - } - } - wx.showToast({ - title: '编辑成功', - icon: 'success', - duration: 2000 - }) - setTimeout(function () { - wx.navigateBack({ - delta: 1 - }) - }, 500) - - }).catch(res=>{ + if(that.data.info.edit_status==1){ + wx.showModal({ + title: '确定修改按揭信息?', + content: '金融机构:'+that.data.financeArray[that.data.financeIndex]+'\r\n贷款金额:'+that.data.price_loan+' ', + confirmColor: "#36afa2", + success(resW) { + if (resW.confirm) { that.setData({ - submitFlag: false, + submitFlag: true, }) - }); + let params = {}; + params['o_id'] = that.data.id; + params['finance_id'] = that.data.finance_id; + params['notify_file'] = that.data.notify_file_obj.value; + params['price_loan'] = that.data.price_loan; + if(that.data.lend_file_obj.value){ + params['lend_file'] = that.data.lend_file_obj.value; + } + _.apiQuery.putAppLoan(params).then(res => { + + that.setData({ + submitFlag: false, + }) + + //刷新详情页 + let pages = getCurrentPages(); + let prevPage = null; //上一个页面 + if (pages.length >= 2) { + prevPage = pages[pages.length - 2]; //上一个页面 + if(prevPage.route == 'pages/order/detail/index2'){ + prevPage.onPullDownRefresh() + } + } + wx.showToast({ + title: '编辑成功', + icon: 'success', + duration: 2000 + }) + setTimeout(function () { + wx.navigateBack({ + delta: 1 + }) + }, 500) + + }).catch(res=>{ + that.setData({ + submitFlag: false, + }) + }); + } } + }) + }else{ + that.setData({ + submitFlag: true, + }) + let params = {}; + params['o_id'] = that.data.id; + params['finance_id'] = that.data.finance_id; + params['notify_file'] = that.data.notify_file_obj.value; + params['price_loan'] = that.data.price_loan; + if(that.data.lend_file_obj.value){ + params['lend_file'] = that.data.lend_file_obj.value; } - }) + _.apiQuery.putAppLoan(params).then(res => { + + that.setData({ + submitFlag: false, + }) + //刷新详情页 + let pages = getCurrentPages(); + let prevPage = null; //上一个页面 + if (pages.length >= 2) { + prevPage = pages[pages.length - 2]; //上一个页面 + if(prevPage.route == 'pages/order/detail/index2'){ + prevPage.onPullDownRefresh() + } + } + wx.showToast({ + title: '编辑成功', + icon: 'success', + duration: 2000 + }) + setTimeout(function () { + wx.navigateBack({ + delta: 1 + }) + }, 500) + + }).catch(res=>{ + that.setData({ + submitFlag: false, + }) + }); + } } }, + //查看图片 + previewImage: function (e) { + wx.previewImage({ + current:this.data.notify_file_obj.src, + urls:[this.data.notify_file_obj.src], + }) + }, + }) \ No newline at end of file diff --git a/pages/order/editFinance/index.wxml b/pages/order/editFinance/index.wxml index bae2c1b..b5c6c8a 100644 --- a/pages/order/editFinance/index.wxml +++ b/pages/order/editFinance/index.wxml @@ -1,43 +1,87 @@ - - 金融机构* - - - 请选择 - {{financeArray[financeIndex]}} - - + + + 金融机构* + + + 请选择 + {{financeArray[financeIndex]}} + + + - - - 贷款金额* - - + + 贷款金额* + + + - + + 按揭通知函* + + + + + + + + + + + + + 上传按揭通知函 + + + + + + + + + + 金融机构 + {{financeArray[financeIndex]}} + + + 贷款金额 + {{price_loan}} + + + 按揭通知函 + + + + + + + + + + + - 按揭通知函* + 放款通知函 - - + + - + - 上传按揭通知函 + 上传放款通知函 -