1384 lines
38 KiB
JavaScript
1384 lines
38 KiB
JavaScript
import _ from '../../../commons/js/commons'
|
|
const app = getApp()
|
|
Page({
|
|
data: {
|
|
tab:[
|
|
{
|
|
title:'车辆信息',
|
|
step:2,
|
|
},
|
|
{
|
|
title:'其他信息',
|
|
step:3,
|
|
},
|
|
],
|
|
step:2,
|
|
name:'',//姓名
|
|
mobile:'',//手机号
|
|
address:'',//地址
|
|
cardid:'',//身份证
|
|
customerIndex:-1,
|
|
customer: [],//客户列表
|
|
pageNo: 1,
|
|
noData: false,
|
|
end: false,
|
|
load: true,
|
|
loading: false,
|
|
isShowSelectCustomer:false,
|
|
|
|
brand_id:'',//品牌
|
|
brandIndex:-1,//车辆品牌索引
|
|
car_id:'',//车系id
|
|
modelIndex:-1,//车系车型索引
|
|
|
|
v_id:'',//车辆版本id
|
|
color_id:'',//车身颜色id
|
|
incolor_id:'',//内饰颜色id
|
|
b_s_id:'',//备选车型id
|
|
|
|
spareIndex:-1,//备选车型索引
|
|
colorArray:[],//车身颜色列表
|
|
levelArray:[],//车辆版本列表
|
|
interiorArray:[],//内饰颜色
|
|
colorIndex:-1,//车身颜色索引
|
|
levelIndex:-1,//车辆版本索引
|
|
interiorIndex:-1,//内饰颜色索引
|
|
priceinfo:'',//车辆价格
|
|
delry_time:'',//期望交付时间
|
|
submitFlag:false,
|
|
|
|
paymentIndex:-1,//付款方式
|
|
payment:['全款', '分期',],
|
|
mainIndex:-1,//购车主体
|
|
main:['个人', '公司',],
|
|
|
|
isPreview:false,//是否预览
|
|
isShowcheck:false,//是否显示预览核对弹框
|
|
checkCount: 2,
|
|
checktext: '3s',
|
|
isShowRemarks:false,//意向金备注
|
|
srv_total:0,//代办费用
|
|
agencyList:[],//代办数组
|
|
fine_total:0,//精品费用
|
|
|
|
//if_fine:false,//精品尊享包
|
|
|
|
fines:[],//精品赠送
|
|
|
|
business_type:0,//0未执行到商务政策 1商务政策执行中 2商务政策成功 3商务政策失败
|
|
|
|
sa:'',//特别约定
|
|
|
|
if_local_bill:0,//本地开具发票
|
|
|
|
fineArr:[],//精品选装
|
|
finedIndex:-1,//精品选装索引
|
|
|
|
packageList:[],//车辆选装包
|
|
options_ids:[],//选装包id数组
|
|
options_total:0,//选装包费用
|
|
if_zero_firstpay:0,//是否0首付
|
|
},
|
|
//生命周期函数--监听页面加载
|
|
onLoad: function (options) {
|
|
for (let key in options) {
|
|
this.setData({
|
|
[key]: options[key]
|
|
})
|
|
}
|
|
|
|
this.getAppCusorderV2()
|
|
this.getAppSeriesBrands()
|
|
this.getUserInfo()
|
|
this.getAppFine()
|
|
|
|
},
|
|
|
|
//获取订单详情
|
|
getAppCusorderV2(){
|
|
let params = {};
|
|
params['id'] = this.data.id;
|
|
_.apiQuery.getAppCusorderV2(params).then(res=>{
|
|
|
|
this.setData({
|
|
info:res.data,
|
|
delry_time:res.data.delry_time?res.data.delry_time:'',
|
|
sa:res.data.sa?res.data.sa:'',
|
|
//if_fine:res.data.if_fine==1?true:false,
|
|
if_local_bill:res.data.if_local_bill==1?1:0,
|
|
brand_id:res.data.brand_id,
|
|
car_id:res.data.car_id,
|
|
if_zero_firstpay:res.data.if_zero_firstpay,
|
|
})
|
|
|
|
/*匹配车辆信息*/
|
|
//匹配品牌
|
|
if(!!res.data.brand_id){
|
|
_.apiQuery.getAppSeriesBrands().then(res1 => {
|
|
if(res1.data.list.length>0){
|
|
let brandArray = []
|
|
res1.data.list.forEach((item,index) => {
|
|
if(item.id == res.data.brand_id){
|
|
this.setData({
|
|
brandIndex:index,
|
|
})
|
|
}
|
|
brandArray.push(item.name)
|
|
})
|
|
this.setData({
|
|
brand_id:res.data.brand_id,
|
|
brandArray:brandArray,
|
|
brandList:res1.data.list,
|
|
})
|
|
|
|
//匹配车型
|
|
if(!!res.data.car_id){
|
|
let modeparams = {};
|
|
modeparams['brand_id'] = res.data.brand_id;
|
|
_.apiQuery.getAppSeries(modeparams).then(res2 => {
|
|
if(res2.data.list.length>0){
|
|
let modelArray = []
|
|
res2.data.list.forEach((item,index) => {
|
|
if(item.id == res.data.car_id){
|
|
this.setData({
|
|
modelIndex:index,
|
|
})
|
|
}
|
|
modelArray.push(item.name)
|
|
})
|
|
this.setData({
|
|
car_id:res.data.car_id,
|
|
modelArray:modelArray,
|
|
modelList:res2.data.list,
|
|
})
|
|
|
|
//匹配车辆版本
|
|
if(!!res.data.v_id){
|
|
let levelparams = {};
|
|
levelparams['id'] = res.data.car_id;
|
|
levelparams['type'] = 0;
|
|
_.apiQuery.getAppSeriesAttrs(levelparams).then(res3 => {
|
|
if(res3.data.total>0){
|
|
let levelArray = []
|
|
res3.data.list.forEach((item,index) => {
|
|
if(item.id == res.data.v_id){
|
|
this.setData({
|
|
levelIndex:index,
|
|
})
|
|
}
|
|
levelArray.push(item.title)
|
|
})
|
|
this.setData({
|
|
v_id:res.data.v_id,
|
|
levelArray:levelArray,
|
|
levelList:res3.data.list,
|
|
})
|
|
|
|
//匹配车身颜色
|
|
if(!!res.data.color_id){
|
|
let colorparams = {};
|
|
colorparams['id'] = res.data.car_id;
|
|
colorparams['v_id'] = res.data.v_id;
|
|
colorparams['type'] = 1;
|
|
_.apiQuery.getAppSeriesAttrs(colorparams).then(res4 => {
|
|
if(res4.data.total>0){
|
|
let colorArray = []
|
|
res4.data.list.forEach((item,index) => {
|
|
if(item.id == res.data.color_id){
|
|
this.setData({
|
|
colorIndex:index,
|
|
})
|
|
}
|
|
colorArray.push(item.title)
|
|
})
|
|
this.setData({
|
|
color_id:res.data.color_id,
|
|
colorArray:colorArray,
|
|
colorList:res4.data.list,
|
|
})
|
|
|
|
//匹配车身颜色
|
|
if(!!res.data.incolor_id){
|
|
let interiorparams = {};
|
|
interiorparams['id'] = res.data.car_id;
|
|
interiorparams['v_id'] = res.data.v_id;
|
|
interiorparams['color_id'] = res.data.color_id;
|
|
interiorparams['type'] = 2;
|
|
_.apiQuery.getAppSeriesAttrs(interiorparams).then(res5 => {
|
|
if(res5.data.total>0){
|
|
let interiorArray = []
|
|
res5.data.list.forEach((item,index) => {
|
|
if(item.id == res.data.incolor_id){
|
|
this.setData({
|
|
interiorIndex:index,
|
|
})
|
|
}
|
|
interiorArray.push(item.title)
|
|
})
|
|
this.setData({
|
|
incolor_id:res.data.incolor_id,
|
|
interiorArray:interiorArray,
|
|
interiorList:res5.data.list,
|
|
})
|
|
|
|
//获取车辆价格
|
|
this.setData({
|
|
business_type:1,
|
|
})
|
|
let priceparams = {};
|
|
priceparams['main_type'] = res.data.main_type;
|
|
priceparams['car_id'] = res.data.car_id;
|
|
priceparams['v_id'] = res.data.v_id;
|
|
priceparams['color_id'] = res.data.color_id;
|
|
priceparams['incolor_id'] = res.data.incolor_id;
|
|
priceparams['oid'] = this.data.id;
|
|
_.apiQuery.getAppBusiness(priceparams).then(res10 => {
|
|
this.setData({
|
|
business_type:2,
|
|
priceinfo:res10.data,
|
|
'priceinfo.sdeposit':res.data.deposit?res.data.deposit:'',
|
|
'priceinfo.sdisc_money':res.data.disc_money?res.data.disc_money:'',
|
|
//'priceinfo.sdisc_fine_money':res.data.disc_fine_money?res.data.disc_fine_money:'',
|
|
})
|
|
}).catch(res => {
|
|
this.setData({
|
|
business_type:3,
|
|
})
|
|
});
|
|
}
|
|
});
|
|
}
|
|
}
|
|
});
|
|
}
|
|
}
|
|
});
|
|
}
|
|
}
|
|
});
|
|
}
|
|
}
|
|
});
|
|
}
|
|
/*end匹配车辆信息*/
|
|
|
|
/*匹配其他信息*/
|
|
//匹配付款方式
|
|
if(!!res.data.payway){
|
|
let paymentIndex = -1
|
|
if(res.data.payway==0){
|
|
paymentIndex = 1
|
|
}else if(res.data.payway==1){
|
|
paymentIndex = 0
|
|
}
|
|
this.setData({
|
|
paymentIndex:paymentIndex,
|
|
})
|
|
}
|
|
|
|
//匹配代办
|
|
if(res.data.srv_arr&&res.data.srv_arr.length>0){
|
|
let agencyparams = {};
|
|
agencyparams['payway'] = res.data.payway;
|
|
agencyparams['cus_id'] = res.data.cus_id;
|
|
agencyparams['car_id'] = res.data.car_id;
|
|
agencyparams['v_id'] = res.data.v_id;
|
|
agencyparams['page'] = 1;
|
|
agencyparams['size'] = 100;
|
|
agencyparams['id'] = this.data.id;
|
|
_.apiQuery.getAppServices(agencyparams).then(res7 => {
|
|
|
|
let agencyList =res7.data.list
|
|
let values = res.data.srv_arr
|
|
let srv_total = 0
|
|
agencyList.forEach(item1 => {
|
|
item1.sprice = item1.price
|
|
item1.checked = false
|
|
values.forEach(item2 => {
|
|
if(item1.id == item2.id){
|
|
item1.checked = true
|
|
item1.sprice = item2.price
|
|
if(parseFloat(item2.price)>0){
|
|
srv_total = srv_total + parseFloat(item2.price)
|
|
}
|
|
}
|
|
})
|
|
})
|
|
|
|
this.setData({
|
|
agencyList,
|
|
srv_total,
|
|
})
|
|
|
|
});
|
|
|
|
}else if(res.data.payway&&res.data.car_id&&res.data.v_id){
|
|
let agencyparams = {};
|
|
agencyparams['payway'] = res.data.payway;
|
|
agencyparams['cus_id'] = res.data.cus_id;
|
|
agencyparams['car_id'] = res.data.car_id;
|
|
agencyparams['v_id'] = res.data.v_id;
|
|
agencyparams['page'] = 1;
|
|
agencyparams['size'] = 100;
|
|
agencyparams['id'] = this.data.id;
|
|
_.apiQuery.getAppServices(agencyparams).then(res9 => {
|
|
let agencyList = res9.data.list
|
|
agencyList.forEach(item => {
|
|
item.sprice = item.price
|
|
})
|
|
this.setData({
|
|
agencyList,
|
|
})
|
|
});
|
|
}
|
|
|
|
//匹配精品赠送
|
|
if(res.data.fines&&res.data.fines.length>0){
|
|
let fine_total = 0
|
|
res.data.fines.forEach(item => {
|
|
if(parseFloat(item.price)>0){
|
|
fine_total = fine_total + parseFloat(item.price)
|
|
}
|
|
})
|
|
this.setData({
|
|
fines:res.data.fines,
|
|
fine_total,
|
|
})
|
|
}
|
|
/*end匹配精品赠送*/
|
|
|
|
//匹配车辆选装包
|
|
if(res.data.option_ids&&res.data.option_ids.length>0){
|
|
let optionparams = {};
|
|
optionparams['id'] = res.data.car_id;
|
|
_.apiQuery.getAppOptions(optionparams).then(res11 => {
|
|
if(res11.data.list.length>0){
|
|
let packageList = res11.data.list
|
|
let options_ids = res.data.option_ids
|
|
let options_total = 0
|
|
packageList.forEach(itemA => {
|
|
itemA.checked = false
|
|
options_ids.forEach(itemB => {
|
|
if(itemA.id === itemB){
|
|
itemA.checked = true
|
|
if(parseFloat(itemA.price)>0){
|
|
options_total = options_total + parseFloat(itemA.price)
|
|
}
|
|
}
|
|
})
|
|
})
|
|
this.setData({
|
|
packageList,
|
|
options_ids,
|
|
options_total,
|
|
})
|
|
}
|
|
});
|
|
}else{
|
|
//获取车辆选装包
|
|
this.getAppOptions()
|
|
}
|
|
|
|
})
|
|
},
|
|
|
|
//修改步骤
|
|
optstep(e){
|
|
this.setData({
|
|
step:e.currentTarget.dataset.step,
|
|
})
|
|
},
|
|
|
|
//下一步
|
|
nextstep(){
|
|
switch (this.data.step) {
|
|
case 1:
|
|
this.setData({
|
|
mobile:this.trimAll(this.data.mobile),
|
|
cardid:this.trimAll(this.data.cardid),
|
|
owner_mobile:this.trimAll(this.data.owner_mobile),
|
|
owner_cardid:this.trimAll(this.data.owner_cardid),
|
|
})
|
|
if (this.data.customerIndex == -1 ) {
|
|
wx.showToast({
|
|
title: '请选择客户',
|
|
icon: 'none'
|
|
})
|
|
}else if (this.data.name == '' ) {
|
|
wx.showToast({
|
|
title: '请输入客户姓名',
|
|
icon: 'none'
|
|
})
|
|
}else if (!/^1[3456789]\d{9}$/.test(this.data.mobile)){
|
|
wx.showToast({
|
|
title: '请输入客户手机号',
|
|
icon: 'none'
|
|
})
|
|
}
|
|
else if(this.data.main_type == 0&&(this.data.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.cardid))){
|
|
wx.showToast({
|
|
title: '请填写正确客户身份证',
|
|
icon: 'none'
|
|
})
|
|
}
|
|
else if(this.data.address == ''){
|
|
wx.showToast({
|
|
title: '请填写联系地址',
|
|
icon: 'none'
|
|
})
|
|
}
|
|
else 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 == 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{
|
|
this.setData({
|
|
step:2,
|
|
})
|
|
}
|
|
break;
|
|
case 2:
|
|
if(this.data.car_id == '' ){
|
|
wx.showToast({
|
|
title: '请选择车系车型',
|
|
icon: 'none'
|
|
})
|
|
}else if(this.data.v_id == '' ){
|
|
wx.showToast({
|
|
title: '请选择车辆版本',
|
|
icon: 'none'
|
|
})
|
|
}else if(this.data.color_id == '' ){
|
|
wx.showToast({
|
|
title: '请选择车身颜色',
|
|
icon: 'none'
|
|
})
|
|
}else if(this.data.incolor_id == '' ){
|
|
wx.showToast({
|
|
title: '请选择内饰颜色',
|
|
icon: 'none'
|
|
})
|
|
}else{
|
|
this.setData({
|
|
step:3,
|
|
})
|
|
}
|
|
break;
|
|
case 3:
|
|
if(this.data.paymentIndex == -1 ){
|
|
wx.showToast({
|
|
title: '请选择付款方式',
|
|
icon: 'none'
|
|
})
|
|
}
|
|
else if(this.data.delry_time == ''){
|
|
wx.showToast({
|
|
title: '请输入期望交付时间',
|
|
icon: 'none'
|
|
})
|
|
}
|
|
else if(this.data.if_zero_firstpay!=1&&(!this.data.priceinfo.sdeposit||this.data.priceinfo.sdeposit == '')){
|
|
wx.showToast({
|
|
title: '请选择定金',
|
|
icon: 'none'
|
|
})
|
|
}else{
|
|
|
|
let that = this
|
|
that.setData({
|
|
isPreview: true,
|
|
isFill:true,
|
|
})
|
|
wx.pageScrollTo({
|
|
scrollTop: 0
|
|
})
|
|
|
|
that.setData({
|
|
isShowcheck:true,
|
|
checkCount:2,
|
|
checktext: 3 + 's'
|
|
})
|
|
let interval = setInterval(res => {
|
|
if (that.data.checkCount > 0) {
|
|
that.setData({
|
|
checkCount: that.data.checkCount - 1,
|
|
checktext: that.data.checkCount + 's'
|
|
})
|
|
} else {
|
|
clearInterval(interval)
|
|
that.setData({
|
|
checkCount: 5,
|
|
checktext: '我知道了'
|
|
})
|
|
}
|
|
}, 1000)
|
|
|
|
}
|
|
break;
|
|
|
|
}
|
|
},
|
|
|
|
//获取用户信息
|
|
getUserInfo(){
|
|
_.apiQuery.getUserInfo().then(res => {
|
|
this.setData({
|
|
userInfo: res,
|
|
})
|
|
|
|
if(res.biz_name == '测试门店'){
|
|
this.setData({
|
|
address:'福建狸车科技测试门店',//地址
|
|
cardid:'350000202101010000',//身份证
|
|
})
|
|
}
|
|
|
|
});
|
|
},
|
|
|
|
|
|
|
|
//获取车型品牌
|
|
getAppSeriesBrands(){
|
|
_.apiQuery.getAppSeriesBrands().then(res => {
|
|
if(res.data.list.length>0){
|
|
let brandArray = []
|
|
res.data.list.forEach(item => {
|
|
brandArray.push(item.name)
|
|
})
|
|
this.setData({
|
|
brandArray:brandArray,
|
|
brandList:res.data.list,
|
|
})
|
|
}
|
|
});
|
|
},
|
|
|
|
//获取车系车型
|
|
getAppSeries(){
|
|
let params = {};
|
|
params['brand_id'] = this.data.brand_id;
|
|
_.apiQuery.getAppSeries(params).then(res => {
|
|
if(res.data.list.length>0){
|
|
let modelArray = []
|
|
res.data.list.forEach(item => {
|
|
modelArray.push(item.name)
|
|
})
|
|
this.setData({
|
|
modelArray:modelArray,
|
|
modelList:res.data.list,
|
|
})
|
|
}
|
|
});
|
|
},
|
|
|
|
//获取车辆版本
|
|
getAppSeriesAttrslevel(){
|
|
let params = {};
|
|
params['id'] = this.data.car_id;
|
|
params['type'] = 0;
|
|
_.apiQuery.getAppSeriesAttrs(params).then(res => {
|
|
if(res.data.total>0){
|
|
let levelArray = []
|
|
res.data.list.forEach(item => {
|
|
levelArray.push(item.title)
|
|
})
|
|
this.setData({
|
|
levelArray:levelArray,
|
|
levelList:res.data.list,
|
|
levelIndex:-1,
|
|
})
|
|
}
|
|
});
|
|
},
|
|
|
|
//获取车身颜色
|
|
getAppSeriesAttrscolor(){
|
|
let params = {};
|
|
params['id'] = this.data.car_id;
|
|
params['type'] = 1;
|
|
params['v_id'] = this.data.v_id;
|
|
_.apiQuery.getAppSeriesAttrs(params).then(res => {
|
|
if(res.data.total>0){
|
|
let colorArray = []
|
|
res.data.list.forEach(item => {
|
|
colorArray.push(item.title)
|
|
})
|
|
this.setData({
|
|
colorArray:colorArray,
|
|
colorList:res.data.list,
|
|
colorIndex:-1,
|
|
})
|
|
}
|
|
});
|
|
},
|
|
|
|
//获取车型内饰颜色
|
|
getAppSeriesAttrsinterior(){
|
|
let params = {};
|
|
params['id'] = this.data.car_id;
|
|
params['type'] = 2;
|
|
params['v_id'] = this.data.v_id;
|
|
params['color_id'] = this.data.color_id;
|
|
_.apiQuery.getAppSeriesAttrs(params).then(res => {
|
|
if(res.data.total>0){
|
|
let interiorArray = []
|
|
res.data.list.forEach(item => {
|
|
interiorArray.push(item.title)
|
|
})
|
|
this.setData({
|
|
interiorArray:interiorArray,
|
|
interiorList:res.data.list,
|
|
interiorIndex:-1,
|
|
})
|
|
}
|
|
});
|
|
},
|
|
|
|
//选择品牌
|
|
changeBrand(e) {
|
|
if(this.data.brandIndex != e.detail.value && e.detail.value >= 0){
|
|
this.setData({
|
|
brand_id:this.data.brandList[e.detail.value].id,
|
|
brandIndex:e.detail.value,
|
|
car_id:'',//车系id
|
|
packageList:[],//车辆选装包
|
|
options_ids:[],//选装包id数组
|
|
options_total:0,//选装包费用
|
|
v_id:'',//车辆版本id
|
|
color_id:'',//车身颜色id
|
|
incolor_id:'',//内饰颜色id
|
|
b_s_id:'',//备选车型id
|
|
modelIndex:-1,//车系车型索引
|
|
spareIndex:-1,//备选车型索引
|
|
colorArray:[],//车身颜色列表
|
|
levelArray:[],//车辆版本列表
|
|
interiorArray:[],//内饰颜色
|
|
colorIndex:-1,//车身颜色索引
|
|
levelIndex:-1,//车辆版本索引
|
|
interiorIndex:-1,//内饰颜色索引
|
|
priceinfo:'',
|
|
business_type:0,
|
|
})
|
|
this.getAppSeries()
|
|
}
|
|
},
|
|
|
|
//选择车系
|
|
changeModel(e) {
|
|
if(this.data.modelIndex != e.detail.value && e.detail.value >= 0){
|
|
this.setData({
|
|
car_id:this.data.modelList[e.detail.value].id,
|
|
modelIndex:e.detail.value,
|
|
v_id:'',//车辆版本id
|
|
color_id:'',//车身颜色id
|
|
incolor_id:'',//内饰颜色id
|
|
b_s_id:'',//备选车型id
|
|
spareIndex:-1,//备选车型索引
|
|
colorArray:[],//车身颜色列表
|
|
levelArray:[],//车辆版本列表
|
|
interiorArray:[],//内饰颜色
|
|
colorIndex:-1,//车身颜色索引
|
|
levelIndex:-1,//车辆版本索引
|
|
interiorIndex:-1,//内饰颜色索引
|
|
priceinfo:'',
|
|
business_type:0,
|
|
options_ids:[],//选装包id数组
|
|
options_total:0,//选装包费用
|
|
})
|
|
this.getAppSeriesAttrslevel()
|
|
//获取车辆选装包
|
|
this.getAppOptions()
|
|
}
|
|
},
|
|
|
|
//车辆版本
|
|
changeLevel(e) {
|
|
if(this.data.levelIndex != e.detail.value && e.detail.value >= 0){
|
|
this.setData({
|
|
v_id:this.data.levelList[e.detail.value].id,
|
|
levelIndex:e.detail.value,
|
|
color_id:'',//车身颜色id
|
|
incolor_id:'',//内饰颜色id
|
|
colorArray:[],//车身颜色列表
|
|
interiorArray:[],//内饰颜色
|
|
colorIndex:-1,//车身颜色索引
|
|
interiorIndex:-1,//内饰颜色索引
|
|
priceinfo:'',
|
|
business_type:0,
|
|
})
|
|
this.getAppSeriesAttrscolor()
|
|
}
|
|
},
|
|
|
|
//车身颜色
|
|
changeColor(e) {
|
|
if(this.data.colorIndex != e.detail.value && e.detail.value >= 0){
|
|
this.setData({
|
|
color_id:this.data.colorList[e.detail.value].id,
|
|
colorIndex:e.detail.value,
|
|
incolor_id:'',//内饰颜色id
|
|
interiorArray:[],//内饰颜色
|
|
interiorIndex:-1,//内饰颜色索引
|
|
priceinfo:'',
|
|
business_type:0,
|
|
})
|
|
this.getAppSeriesAttrsinterior()
|
|
}
|
|
},
|
|
|
|
//内饰颜色
|
|
changeInterior(e) {
|
|
if(this.data.interiorIndex != e.detail.value && e.detail.value >= 0){
|
|
this.setData({
|
|
incolor_id:this.data.interiorList[e.detail.value].id,
|
|
interiorIndex:e.detail.value,
|
|
business_type:0,
|
|
})
|
|
this.getAppBusiness()
|
|
}
|
|
},
|
|
|
|
//付款方式
|
|
changePayment(e) {
|
|
if(this.data.paymentIndex != e.detail.value && e.detail.value >= 0){
|
|
this.setData({
|
|
paymentIndex:e.detail.value,
|
|
})
|
|
//代办列表
|
|
this.getAppServices()
|
|
}
|
|
},
|
|
|
|
//购车主体
|
|
changeMain(e) {
|
|
this.setData({
|
|
mainIndex:e.detail.value,
|
|
})
|
|
},
|
|
|
|
//获取车辆价格
|
|
getAppBusiness(){
|
|
if(this.data.car_id != ''&&this.data.v_id != ''&&this.data.color_id != ''&&this.data.incolor_id != ''){
|
|
this.setData({
|
|
business_type:1,
|
|
})
|
|
let params = {};
|
|
params['main_type'] = this.data.info.main_type;
|
|
params['car_id'] = this.data.car_id;
|
|
params['v_id'] = this.data.v_id;
|
|
params['color_id'] = this.data.color_id;
|
|
params['incolor_id'] = this.data.incolor_id;
|
|
params['oid'] = this.data.id;
|
|
_.apiQuery.getAppBusiness(params).then(res => {
|
|
this.setData({
|
|
business_type:2,
|
|
priceinfo:res.data,
|
|
})
|
|
if(this.data.info.deposit){
|
|
this.setData({
|
|
'priceinfo.sdeposit':this.data.info.deposit,
|
|
})
|
|
}
|
|
}).catch(res => {
|
|
this.setData({
|
|
business_type:3,
|
|
})
|
|
});
|
|
}
|
|
},
|
|
|
|
//获取代办服务列表
|
|
getAppServices(){
|
|
if(this.data.paymentIndex != -1&&this.data.car_id != ''&&this.data.v_id != ''){
|
|
let params = {};
|
|
params['payway'] = this.data.paymentIndex==0?'1':'0';
|
|
params['cus_id'] = this.data.info.cus_id;
|
|
params['car_id'] = this.data.car_id;
|
|
params['v_id'] = this.data.v_id;
|
|
params['page'] = 1;
|
|
params['size'] = 100;
|
|
params['id'] = this.data.id;
|
|
_.apiQuery.getAppServices(params).then(res => {
|
|
|
|
let agencyList = res.data.list
|
|
let srv_total = 0
|
|
agencyList.forEach(item => {
|
|
item.sprice = item.price
|
|
if(this.data.userInfo.biz_type==1){
|
|
if(item.id==1||item.id==2){
|
|
item.checked = true
|
|
if(parseFloat(item.price)>0){
|
|
srv_total = srv_total + parseFloat(item.price)
|
|
}
|
|
}
|
|
}
|
|
})
|
|
this.setData({
|
|
agencyList,
|
|
srv_total,
|
|
})
|
|
|
|
});
|
|
}
|
|
},
|
|
|
|
//建卡时间
|
|
delryTime(e){
|
|
this.setData({
|
|
delry_time: e.detail.value,
|
|
})
|
|
},
|
|
|
|
//修改订单信息
|
|
putAppCusorderV2() {
|
|
let that = this
|
|
that.setData({
|
|
submitFlag: true,
|
|
})
|
|
|
|
let fines = []
|
|
that.data.fines.forEach(item => {
|
|
if(item.txt!=''){
|
|
fines.push(item)
|
|
}
|
|
});
|
|
|
|
let params = {};
|
|
params['id'] = that.data.id;
|
|
params['car_id'] = that.data.car_id;
|
|
params['v_id'] = that.data.v_id;
|
|
params['color_id'] = that.data.color_id;
|
|
params['incolor_id'] = that.data.incolor_id;
|
|
if(that.data.options_ids.length>0){
|
|
params['options_ids'] = that.data.options_ids;
|
|
}
|
|
params['price'] = that.data.priceinfo.price;
|
|
if(that.data.if_zero_firstpay!=1){
|
|
params['deposit'] = that.data.priceinfo.sdeposit;
|
|
}
|
|
params['payway'] = that.data.paymentIndex==0?'1':'0';
|
|
params['delry_time'] = that.data.delry_time;
|
|
params['business_id'] = that.data.priceinfo.id;
|
|
params['disc_money'] = that.data.priceinfo.sdisc_money?that.data.priceinfo.sdisc_money:0;
|
|
|
|
params['sa'] = that.data.sa;
|
|
|
|
if(that.data.priceinfo.show_local_bill){
|
|
params['if_local_bill'] = that.data.if_local_bill;
|
|
}
|
|
if(that.data.paymentIndex==1){
|
|
params['if_zero_firstpay'] = that.data.if_zero_firstpay;
|
|
}
|
|
|
|
let srv_arr = []
|
|
that.data.agencyList.forEach(item => {
|
|
if(item.checked){
|
|
srv_arr.push({
|
|
id:item.id,
|
|
key:item.key,
|
|
price:item.sprice,
|
|
})
|
|
}
|
|
})
|
|
params['srv_arr'] = srv_arr;
|
|
|
|
params['fines'] = fines;
|
|
//精品优惠金额
|
|
// if(that.data.priceinfo.fine_money){
|
|
// params['if_fine'] = that.data.if_fine?'1':'0';
|
|
// if(that.data.if_fine&&!!that.data.priceinfo.sdisc_fine_money&&that.data.priceinfo.sdisc_fine_money!= ''){
|
|
// params['disc_fine_money'] = that.data.priceinfo.sdisc_fine_money;
|
|
// }
|
|
// }
|
|
_.apiQuery.putAppCusorderV2(params).then(res => {
|
|
|
|
//刷新列表页
|
|
let pages = getCurrentPages();
|
|
let prevPage = null; //上一个页面
|
|
if (pages.length >= 2) {
|
|
prevPage = pages[pages.length - 2]; //上一个页面
|
|
if(prevPage.route == 'pages/order/index'){
|
|
prevPage.onPullDownRefresh()
|
|
}
|
|
}
|
|
|
|
wx.showModal({
|
|
title: '编辑成功',
|
|
content: '',
|
|
confirmText: "查看详情",
|
|
confirmColor: "#36afa2",
|
|
showCancel:false,
|
|
success() {
|
|
wx.redirectTo({
|
|
url: '/pages/order/detail/index2?id=' + that.data.id
|
|
})
|
|
}
|
|
})
|
|
}).catch(res=>{
|
|
that.setData({
|
|
submitFlag: false,
|
|
})
|
|
});
|
|
},
|
|
|
|
//显示隐藏预览
|
|
optPreview(e) {
|
|
this.setData({
|
|
isPreview:!this.data.isPreview,
|
|
})
|
|
wx.pageScrollTo({
|
|
scrollTop: 0
|
|
})
|
|
},
|
|
|
|
//显示隐藏预览提示
|
|
optShowcheck(){
|
|
this.setData({
|
|
isShowcheck:!this.data.isShowcheck,
|
|
})
|
|
},
|
|
|
|
//显示隐藏意向金备注
|
|
optShowRemarks(){
|
|
this.setData({
|
|
isShowRemarks:!this.data.isShowRemarks,
|
|
})
|
|
},
|
|
|
|
//输入
|
|
inputTx(e) {
|
|
this.setData({
|
|
[e.currentTarget.dataset.key]: e.detail.value
|
|
})
|
|
},
|
|
|
|
//选择客户
|
|
radioPicker(e){
|
|
if(e.currentTarget.dataset.index != this.data.customerIndex){
|
|
this.setData({
|
|
isSubmiting: false,
|
|
customerIndex:e.currentTarget.dataset.index,
|
|
name:this.data.customer[e.currentTarget.dataset.index].name,
|
|
mobile:this.data.customer[e.currentTarget.dataset.index].complete_mobile,
|
|
})
|
|
}
|
|
},
|
|
|
|
//显示选择客户
|
|
showSelectCustomer(){
|
|
this.setData({
|
|
isShowSelectCustomer:true,
|
|
})
|
|
},
|
|
|
|
//确认选择客户
|
|
hideSelectCustomer(){
|
|
this.setData({
|
|
isShowSelectCustomer:false,
|
|
})
|
|
},
|
|
|
|
//委托代办
|
|
changeAgency(e) {
|
|
let agencyList = this.data.agencyList
|
|
let values = e.detail.value
|
|
let srv_total = 0
|
|
agencyList.forEach(item1 => {
|
|
item1.checked = false
|
|
values.forEach(item2 => {
|
|
if(item1.id == item2){
|
|
item1.checked = true
|
|
if(parseFloat(item1.sprice)>0){
|
|
srv_total = srv_total + parseFloat(item1.sprice)
|
|
}
|
|
}
|
|
})
|
|
})
|
|
|
|
this.setData({
|
|
agencyList,
|
|
srv_total,
|
|
})
|
|
},
|
|
|
|
//精品尊享版
|
|
changeFineBag(){
|
|
this.setData({
|
|
if_fine:!this.data.if_fine,
|
|
'priceinfo.sdisc_fine_money':'',
|
|
})
|
|
},
|
|
|
|
//添加精品
|
|
addFine(){
|
|
this.data.fines.push({
|
|
txt:'',
|
|
price:'',
|
|
})
|
|
this.setData({
|
|
fines:this.data.fines,
|
|
})
|
|
},
|
|
|
|
//添加精品
|
|
inputFines(e){
|
|
if(e.currentTarget.dataset.type=='txt'){
|
|
this.setData({
|
|
['fines['+e.currentTarget.dataset.index+'].txt']:e.detail.value,
|
|
})
|
|
}
|
|
if(e.currentTarget.dataset.type=='price'){
|
|
this.setData({
|
|
['fines['+e.currentTarget.dataset.index+'].price']:e.detail.value,
|
|
})
|
|
let fine_total = 0
|
|
this.data.fines.forEach(item => {
|
|
if(parseFloat(item.price)>0){
|
|
fine_total = fine_total + parseFloat(item.price)
|
|
}
|
|
})
|
|
this.setData({
|
|
fine_total,
|
|
})
|
|
}
|
|
},
|
|
|
|
//快截输入代办价格
|
|
fillAgency(e){
|
|
this.setData({
|
|
['agencyList['+e.currentTarget.dataset.index+'].sprice']:parseFloat(e.currentTarget.dataset.sprice),
|
|
})
|
|
let srv_total = 0
|
|
this.data.agencyList.forEach(item => {
|
|
if(item.checked&&parseFloat(item.sprice)>0){
|
|
srv_total = srv_total + parseFloat(item.sprice)
|
|
}
|
|
})
|
|
this.setData({
|
|
srv_total,
|
|
})
|
|
},
|
|
|
|
//修改代办金额
|
|
inputAgency(e){
|
|
this.setData({
|
|
['agencyList['+e.currentTarget.dataset.index+'].sprice']:parseFloat(e.detail.value),
|
|
})
|
|
let srv_total = 0
|
|
this.data.agencyList.forEach(item => {
|
|
if(item.checked&&parseFloat(item.sprice)>0){
|
|
srv_total = srv_total + parseFloat(item.sprice)
|
|
}
|
|
})
|
|
this.setData({
|
|
srv_total,
|
|
})
|
|
},
|
|
|
|
//判断修改代办金额
|
|
inputBlurAgency(e){
|
|
if(!this.data.agencyList[e.currentTarget.dataset.index].sprice||this.data.agencyList[e.currentTarget.dataset.index].price>parseFloat(this.data.agencyList[e.currentTarget.dataset.index].sprice)){
|
|
wx.showToast({
|
|
title: '代办费设置过低',
|
|
icon: 'none'
|
|
})
|
|
this.setData({
|
|
['agencyList['+e.currentTarget.dataset.index+'].sprice']:this.data.agencyList[e.currentTarget.dataset.index].price,
|
|
})
|
|
let srv_total = 0
|
|
this.data.agencyList.forEach(item => {
|
|
if(item.checked&&parseFloat(item.sprice)>0){
|
|
srv_total = srv_total + parseFloat(item.sprice)
|
|
}
|
|
})
|
|
this.setData({
|
|
srv_total,
|
|
})
|
|
}
|
|
},
|
|
|
|
//选择定金
|
|
fillDeposit(e){
|
|
this.setData({
|
|
'priceinfo.sdeposit':parseFloat(e.currentTarget.dataset.deposit),
|
|
})
|
|
},
|
|
|
|
//修改定金
|
|
inputDeposit(e){
|
|
this.setData({
|
|
'priceinfo.sdeposit':parseFloat(e.detail.value),
|
|
})
|
|
},
|
|
|
|
//判断修改定金是否小于限制
|
|
inputBlurDeposit(e){
|
|
if(!this.data.priceinfo.sdeposit||this.data.priceinfo.deposit>parseFloat(this.data.priceinfo.sdeposit)){
|
|
wx.showToast({
|
|
title: '定金设置过低',
|
|
icon: 'none'
|
|
})
|
|
this.setData({
|
|
'priceinfo.sdeposit':this.data.priceinfo.deposit,
|
|
})
|
|
}
|
|
},
|
|
|
|
//选择车身优惠
|
|
fillDisc_money(e){
|
|
this.setData({
|
|
'priceinfo.sdisc_money':parseFloat(e.currentTarget.dataset.disc_money),
|
|
})
|
|
},
|
|
|
|
//修改车身优惠
|
|
inputDisc_money(e){
|
|
this.setData({
|
|
'priceinfo.sdisc_money':parseFloat(e.detail.value),
|
|
})
|
|
},
|
|
|
|
//判断修改车身优惠是否小于限制
|
|
inputBlurDisc_money(e){
|
|
if(this.data.priceinfo.dis_money<parseFloat(this.data.priceinfo.sdisc_money)){
|
|
wx.showToast({
|
|
title: '车身优惠设置过高',
|
|
icon: 'none'
|
|
})
|
|
this.setData({
|
|
'priceinfo.sdisc_money':this.data.priceinfo.dis_money,
|
|
})
|
|
}
|
|
else if(!this.data.priceinfo.sdisc_money){
|
|
this.setData({
|
|
'priceinfo.sdisc_money':'',
|
|
})
|
|
}
|
|
},
|
|
|
|
//选择精品优惠
|
|
fillDisc_fine_money(e){
|
|
this.setData({
|
|
'priceinfo.sdisc_fine_money':parseFloat(e.currentTarget.dataset.disc_fine_money),
|
|
})
|
|
},
|
|
|
|
//修改精品优惠
|
|
inputDisc_fine_money(e){
|
|
this.setData({
|
|
'priceinfo.sdisc_fine_money':parseFloat(e.detail.value),
|
|
})
|
|
},
|
|
|
|
//判断修改精品优惠是否小于限制
|
|
inputBlurDisc_fine_money(e){
|
|
if(this.data.priceinfo.dis_fine_money<parseFloat(this.data.priceinfo.sdisc_fine_money)){
|
|
wx.showToast({
|
|
title: '精品优惠设置过高',
|
|
icon: 'none'
|
|
})
|
|
this.setData({
|
|
'priceinfo.sdisc_fine_money':this.data.priceinfo.dis_fine_money,
|
|
})
|
|
}
|
|
else if(!this.data.priceinfo.sdisc_fine_money){
|
|
this.setData({
|
|
'priceinfo.sdisc_fine_money':'',
|
|
})
|
|
}
|
|
},
|
|
|
|
//需开具本地发票
|
|
switchAddrDef:function(e){
|
|
this.setData({
|
|
if_local_bill:e.detail.value ? 1 :0
|
|
})
|
|
},
|
|
|
|
//获取精品选装
|
|
getAppFine(){
|
|
let params = {};
|
|
params['limbiz'] = 1;
|
|
params['page'] = 1;
|
|
params['size'] = 100;
|
|
_.apiQuery.getAppFine(params).then(res => {
|
|
let fineList = res.data.list
|
|
let fineArr = []
|
|
fineList.forEach(item => {
|
|
fineArr.push(item.title)
|
|
item.price=''
|
|
})
|
|
fineArr.push('其他')
|
|
this.setData({
|
|
fineArr,
|
|
fineList,
|
|
})
|
|
});
|
|
},
|
|
|
|
//添加精品选装
|
|
changeFine(e) {
|
|
if(this.data.fineArr[e.detail.value]=='其他'){
|
|
this.data.fines.push({
|
|
txt:'',
|
|
price:'',
|
|
})
|
|
this.setData({
|
|
finedIndex:-1,
|
|
fines:this.data.fines,
|
|
})
|
|
}else{
|
|
let fid = this.data.fineList[e.detail.value].id
|
|
let isadd = false
|
|
this.data.fines.forEach(item => {
|
|
if(item.id == fid){
|
|
isadd = true
|
|
}
|
|
})
|
|
if(isadd){
|
|
wx.showToast({
|
|
title: '您已添加过了',
|
|
icon: 'none',
|
|
duration: 2000
|
|
})
|
|
}else{
|
|
this.data.fineList.forEach(item => {
|
|
if(item.id == fid){
|
|
this.data.fines.push({
|
|
id:item.id,
|
|
txt:item.title,
|
|
price:'',
|
|
})
|
|
this.setData({
|
|
finedIndex:-1,
|
|
fines:this.data.fines,
|
|
})
|
|
}
|
|
})
|
|
}
|
|
}
|
|
|
|
},
|
|
|
|
//删除精品选装
|
|
delFine(e){
|
|
let that = this
|
|
wx.showModal({
|
|
title: '确定删除吗?',
|
|
content: '',
|
|
confirmText: "确定删除",
|
|
confirmColor: "#36afa2",
|
|
cancelText: "取消",
|
|
cancelColor: "#666",
|
|
success(res) {
|
|
if (res.confirm) {
|
|
let fines = that.data.fines
|
|
fines.splice(e.currentTarget.dataset.index, 1)
|
|
that.setData({
|
|
fines,
|
|
})
|
|
let fine_total = 0
|
|
that.data.fines.forEach(item => {
|
|
if(parseFloat(item.price)>0){
|
|
fine_total = fine_total + parseFloat(item.price)
|
|
}
|
|
})
|
|
that.setData({
|
|
fine_total,
|
|
})
|
|
}
|
|
}
|
|
})
|
|
},
|
|
|
|
//页面相关事件处理函数--监听用户下拉动作
|
|
onPullDownRefresh(){
|
|
this.getAppCusorderV2()
|
|
},
|
|
|
|
//去除空格
|
|
trimAll(ele){
|
|
if(typeof ele === 'string'){
|
|
return ele.split(' ').join('');
|
|
}else{
|
|
console.error(`${typeof ele} is not the expected type, but the string type is expected`)
|
|
}
|
|
},
|
|
|
|
//获取车辆选装包
|
|
getAppOptions(){
|
|
let params = {};
|
|
params['id'] = this.data.car_id;
|
|
_.apiQuery.getAppOptions(params).then(res => {
|
|
if(res.data.list.length>0){
|
|
let packageList = res.data.list
|
|
packageList.forEach(item => {
|
|
item.checked = false
|
|
})
|
|
this.setData({
|
|
packageList,
|
|
})
|
|
}
|
|
});
|
|
},
|
|
|
|
//选择车辆选装包
|
|
choosePackage(e) {
|
|
let packageList = this.data.packageList
|
|
let options_ids = e.detail.value
|
|
let options_total = 0
|
|
packageList.forEach(itemA => {
|
|
itemA.checked = false
|
|
options_ids.forEach(itemB => {
|
|
if(itemA.id === itemB){
|
|
itemA.checked = true
|
|
if(parseFloat(itemA.price)>0){
|
|
options_total = options_total + parseFloat(itemA.price)
|
|
}
|
|
}
|
|
})
|
|
})
|
|
|
|
this.setData({
|
|
packageList,
|
|
options_ids,
|
|
options_total,
|
|
})
|
|
},
|
|
|
|
//是否0首付
|
|
switchZeroFirstpay:function(e){
|
|
this.setData({
|
|
if_zero_firstpay:e.detail.value ? 1 :0,
|
|
'priceinfo.sdeposit':'',
|
|
})
|
|
},
|
|
|
|
}) |