141 lines
3.7 KiB
JavaScript
141 lines
3.7 KiB
JavaScript
import _ from '../../../commons/js/commons'
|
|
const app = getApp()
|
|
Page({
|
|
data: {
|
|
main_type:'',//购车主体
|
|
owner_name:'',//车主姓名
|
|
owner_mobile:'',//车主手机号
|
|
owner_cardid:'',//车主身份证
|
|
address:'',//车主地址
|
|
company:'',//企业名称
|
|
credit:'',//企业信用代码
|
|
submitFlag:false,
|
|
},
|
|
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({
|
|
main_type:res.data.main_type,
|
|
owner_name:res.data.owner_name?res.data.owner_name:'',
|
|
owner_mobile:res.data.owner_mobile?res.data.owner_mobile:'',
|
|
owner_cardid:res.data.owner_cardid?res.data.owner_cardid:'',
|
|
address:res.data.address?res.data.address:'',
|
|
company:res.data.company?res.data.company:'',
|
|
credit:res.data.credit?res.data.credit:'',
|
|
})
|
|
|
|
wx.stopPullDownRefresh()
|
|
|
|
})
|
|
},
|
|
|
|
//修改订单基本信息
|
|
putAppCusorderV2Info() {
|
|
if(this.data.main_type == 0&&this.data.owner_name == ''){
|
|
wx.showToast({
|
|
title: '请填写车主姓名',
|
|
icon: 'none'
|
|
})
|
|
}
|
|
else if(this.data.main_type == 0&&!/^1[3456789]\d{9}$/.test(this.data.owner_mobile)){
|
|
wx.showToast({
|
|
title: '请填写车主手机号',
|
|
icon: 'none'
|
|
})
|
|
}
|
|
else if(this.data.main_type == 0&&(this.data.owner_cardid == ''|| !/^\d{6}(18|19|20)?\d{2}(0[1-9]|1[012])(0[1-9]|[12]\d|3[01])\d{3}(\d|[xX])$/.test(this.data.owner_cardid))){
|
|
wx.showToast({
|
|
title: '请填写正确车主身份证',
|
|
icon: 'none'
|
|
})
|
|
}
|
|
else if(this.data.main_type == 0&&this.data.address == ''){
|
|
wx.showToast({
|
|
title: '请填写车主地址',
|
|
icon: 'none'
|
|
})
|
|
}
|
|
else if(this.data.main_type == 1&&this.data.company == ''){
|
|
wx.showToast({
|
|
title: '请填写企业名称',
|
|
icon: 'none'
|
|
})
|
|
}
|
|
else if(this.data.main_type == 1&&this.data.credit == ''){
|
|
wx.showToast({
|
|
title: '请填写企业信用代码',
|
|
icon: 'none'
|
|
})
|
|
}
|
|
else{
|
|
let that = this
|
|
that.setData({
|
|
submitFlag: true,
|
|
})
|
|
let params = {};
|
|
params['id'] = this.data.id;
|
|
if(that.data.owner_name != ''){
|
|
params['owner_name'] = that.data.owner_name;
|
|
}
|
|
if(that.data.owner_mobile != ''){
|
|
params['owner_mobile'] = that.data.owner_mobile;
|
|
}
|
|
if(that.data.owner_cardid != ''){
|
|
params['owner_cardid'] = that.data.owner_cardid;
|
|
}
|
|
if(that.data.address != ''){
|
|
params['address'] = that.data.address;
|
|
}
|
|
if(that.data.company != ''){
|
|
params['company'] = that.data.company;
|
|
}
|
|
if(that.data.credit != ''){
|
|
params['credit'] = that.data.credit;
|
|
}
|
|
_.apiQuery.putAppCusorderV2Info(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=>{
|
|
that.setData({
|
|
submitFlag: false,
|
|
})
|
|
});
|
|
}
|
|
},
|
|
|
|
}) |