386 lines
9.7 KiB
JavaScript
386 lines
9.7 KiB
JavaScript
import _ from '../../../commons/js/commons'
|
|
const app = getApp()
|
|
Page({
|
|
data: {
|
|
o_id:'',//订单id
|
|
finance_id:'',//金融机构id
|
|
financeArray:[],//金融机构
|
|
financeIndex:-1,//金融机构索引
|
|
|
|
price_loan:'',//贷款金额
|
|
submitFlag:false,
|
|
|
|
isShowConfirm:false,//是否显示确认弹框
|
|
nums:[],//金融分期期数列表
|
|
numIndex:-1,//分期期数索引
|
|
num:'',//分期期数
|
|
|
|
},
|
|
onLoad: function (options) {
|
|
for (let key in options) {
|
|
this.setData({
|
|
[key]: options[key]
|
|
})
|
|
}
|
|
|
|
this.getAppCusorderV2()
|
|
|
|
},
|
|
onShow: function () {
|
|
|
|
},
|
|
|
|
//获取订单详情
|
|
getAppCusorderV2(){
|
|
let params = {};
|
|
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:'',
|
|
})
|
|
|
|
//匹配融机构
|
|
if(!!res.data.finance_id){
|
|
let finanparams = {};
|
|
finanparams['page'] = 1;
|
|
finanparams['size'] = 100;
|
|
_.apiQuery.getAppFinance(finanparams).then(res6 => {
|
|
if(res6.data.list.length>0){
|
|
let financeArray = []
|
|
res6.data.list.forEach((item,index) => {
|
|
if(item.id == res.data.finance_id){
|
|
this.setData({
|
|
financeIndex:index,
|
|
})
|
|
}
|
|
financeArray.push(item.title)
|
|
})
|
|
this.setData({
|
|
finance_id:res.data.finance_id,
|
|
financeArray:financeArray,
|
|
financeList:res6.data.list,
|
|
})
|
|
}
|
|
});
|
|
}else{
|
|
this.getAppFinance()
|
|
}
|
|
|
|
//匹配分期期数
|
|
if(!!res.data.num){
|
|
_.apiQuery.getAppFinanceNums().then(res1 => {
|
|
if(res1.data.list.length>0){
|
|
res1.data.list.forEach((item,index) => {
|
|
if(item == res.data.num){
|
|
this.setData({
|
|
numIndex:index,
|
|
})
|
|
}
|
|
})
|
|
this.setData({
|
|
num:res.data.num,
|
|
nums:res1.data.list,
|
|
})
|
|
}
|
|
})
|
|
}else{
|
|
this.getAppFinanceNums()
|
|
}
|
|
|
|
wx.stopPullDownRefresh()
|
|
|
|
})
|
|
},
|
|
|
|
//获取金融机构列表
|
|
getAppFinance(){
|
|
let params = {};
|
|
params['page'] = 1;
|
|
params['size'] = 100;
|
|
_.apiQuery.getAppFinance(params).then(res => {
|
|
if(res.data.list.length>0){
|
|
let financeArray = []
|
|
res.data.list.forEach(item => {
|
|
financeArray.push(item.title)
|
|
})
|
|
this.setData({
|
|
financeArray:financeArray,
|
|
financeList:res.data.list,
|
|
finance_id:'',
|
|
financeIndex:-1,
|
|
})
|
|
}
|
|
});
|
|
},
|
|
|
|
//获取金融机构列表
|
|
changeFinance(e) {
|
|
if(this.data.financeIndex != e.detail.value && e.detail.value >= 0){
|
|
let finance_id = ''
|
|
if(e.detail.value >= 0){
|
|
finance_id = this.data.financeList[e.detail.value].id
|
|
}
|
|
this.setData({
|
|
finance_id:finance_id,
|
|
financeIndex:e.detail.value,
|
|
})
|
|
}
|
|
},
|
|
|
|
//上传按揭通知函
|
|
chooseImg(e) {
|
|
let that = this
|
|
if(e.currentTarget.dataset.type=='notify'){
|
|
wx.chooseImage({
|
|
count: 1, // 默认9
|
|
sizeType: ['original', 'compressed'], // 可以指定是原图还是压缩图,默认二者都有
|
|
sourceType: ['album', 'camera'], // 可以指定来源是相册还是相机,默认二者都有
|
|
success(res) {
|
|
wx.showLoading({
|
|
title: '上传中',
|
|
})
|
|
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({
|
|
title: '上传中',
|
|
})
|
|
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
|
|
})
|
|
}
|
|
})
|
|
}
|
|
},
|
|
|
|
//修改贷款信息
|
|
putAppLoan1() {
|
|
if(this.data.finance_id == ''){
|
|
wx.showToast({
|
|
title: '请选择金融机构',
|
|
icon: 'none'
|
|
})
|
|
}
|
|
else if(!this.data.price_loan||this.data.price_loan == ''){
|
|
wx.showToast({
|
|
title: '请填写贷款金额',
|
|
icon: 'none'
|
|
})
|
|
}
|
|
else if(!this.data.notify_file_obj.src){
|
|
wx.showToast({
|
|
title: '请上传按揭通知函',
|
|
icon: 'none'
|
|
})
|
|
}
|
|
else{
|
|
if(this.data.info.edit_status==1){
|
|
this.setData({
|
|
isShowConfirm:true,
|
|
})
|
|
}else{
|
|
let that = this
|
|
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;
|
|
}
|
|
if(that.data.num){
|
|
params['num'] = that.data.num;
|
|
}
|
|
_.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,
|
|
})
|
|
});
|
|
}
|
|
}
|
|
},
|
|
|
|
//修改贷款信息
|
|
putAppLoan2() {
|
|
let that = this
|
|
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;
|
|
}
|
|
if(that.data.num){
|
|
params['num'] = that.data.num;
|
|
}
|
|
_.apiQuery.putAppLoan(params).then(res => {
|
|
|
|
that.setData({
|
|
isShowConfirm: false,
|
|
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,
|
|
})
|
|
});
|
|
},
|
|
|
|
//获取金融分期期数
|
|
getAppFinanceNums(){
|
|
_.apiQuery.getAppFinanceNums().then(res => {
|
|
if(res.data.list.length>0){
|
|
this.setData({
|
|
nums:res.data.list,
|
|
})
|
|
}
|
|
});
|
|
},
|
|
|
|
//选择金融分期期数
|
|
changeNum(e) {
|
|
if(this.data.numIndex != e.detail.value && e.detail.value >= 0){
|
|
let num = ''
|
|
if(e.detail.value >= 0){
|
|
num = this.data.nums[e.detail.value]
|
|
}
|
|
this.setData({
|
|
num,
|
|
numIndex:e.detail.value,
|
|
})
|
|
}
|
|
},
|
|
|
|
//显示隐藏意向金弹框
|
|
optConfirm(){
|
|
this.setData({
|
|
isShowConfirm:!this.data.isShowConfirm,
|
|
})
|
|
},
|
|
|
|
//查看图片
|
|
previewImage: function (e) {
|
|
if(e.currentTarget.dataset.type=='notify'){
|
|
wx.previewImage({
|
|
current:this.data.notify_file_obj.src,
|
|
urls:[notify_file_obj.src],
|
|
})
|
|
}
|
|
else if(e.currentTarget.dataset.type=='lend'){
|
|
wx.previewImage({
|
|
current:this.data.lend_file_obj.src,
|
|
urls:[this.data.lend_file_obj.src],
|
|
})
|
|
}
|
|
},
|
|
|
|
}) |