Files
lichebao/pages/order/register/index.js
T
2023-02-23 12:00:41 +08:00

1401 lines
36 KiB
JavaScript

import _ from '../../../commons/js/commons'
const app = getApp()
Page({
data: {
tab:[
{
title:'客户信息',
step:1,
},
{
title:'车辆信息',
step:2,
},
{
title:'其他信息',
step:3,
},
],
step:1,
name:'',//姓名
mobile:'',//手机号
cardid:'',//身份证
address:'',//地址
owner_name:'',//车主姓名
owner_mobile:'',//车主手机号
owner_cardid:'',//车主身份证
company:'',//企业名称
credit:'',//企业信用代码
brand_id:'',//品牌
car_id:'',//车系id
v_id:'',//车辆版本id
color_id:'',//车身颜色id
incolor_id:'',//内饰颜色id
b_s_id:'',//备选车型id
buy_time:'',//预计购车时间
brandIndex:-1,//车辆品牌索引
modelIndex:-1,//车系车型索引
spareIndex:-1,//备选车型索引
colorArray:[],//车身颜色列表
levelArray:[],//车辆版本列表
interiorArray:[],//内饰颜色
colorIndex:-1,//车身颜色索引
levelIndex:-1,//车辆版本索引
interiorIndex:-1,//内饰颜色索引
priceinfo:'',//车辆价格
delry_time:'',//期望交付时间
inten_money:'',//意向金
submitFlag:false,
paymentIndex:-1,//付款方式
payment:['全款', '分期',],
main_type:0,//购车主体
main:[
{
title:'个人',
value:0,
},
{
title:'公司',
value:1,
},
],
isPreview:false,//是否预览
isFill:false,//是否已填完成
isShowcheck:false,//是否显示预览核对弹框
checkCount: 2,
checktext: '3s',
srv_total:0,//代办费用
agencyList:[],//代办数组
fine_total:0,//精品费用
isShowSuccess:false,//是否显示成功提示
isShowContract:false,//是否显示生成合同
//if_fine:false,//精品尊享包
fines:[],//精品赠送
business_type:0,//0未执行到商务政策 1商务政策执行中 2商务政策成功 3商务政策失败
isShowIntenMoney:false,//是否显示意向金弹框
isShowAddress:false,//是否显示地址弹框
//region: ['福建省', '', ''],
c_city_id:'',
oncardArray:[],//上牌城市
oncardIndex:-1,//上牌城市索引
sa:'',//特别约定
if_local_bill:0,//本地开具发票
customer_cardidpic:'',//客户身份证正面照
owner_cardidpic:'',//车主身份证正面照
fineArr:[],//精品选装
finedIndex:-1,//精品选装索引
addressFocus:false,
customer_address:'',
},
//生命周期函数--监听页面加载
onLoad: function (options) {
for (let key in options) {
this.setData({
[key]: options[key]
})
}
this.getAppSeriesBrands()
this.getUserInfo()
this.getAppCityOncard()
this.getAppFine()
},
//修改步骤
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.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.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.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 if(this.data.c_city_id == ''){
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.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({
cardid:'350000202101010000',//身份证
})
}
});
},
//获取上牌城市
getAppCityOncard(){
_.apiQuery.getAppCityOncard().then(res => {
if(res.data.list.length>0){
let oncardArray = []
res.data.list.forEach(item => {
oncardArray.push(item.name)
})
this.setData({
oncardArray,
oncardList:res.data.list,
})
}
});
},
//获取车型品牌
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
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,
})
this.getAppSeriesAttrslevel()
}
},
//车辆版本
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({
main_type:e.detail.value,
owner_name:'',
owner_mobile:'',
owner_cardid:'',
company:'',
credit:'',
address:'',
})
},
//获取车辆价格
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.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;
_.apiQuery.getAppBusiness(params).then(res => {
this.setData({
business_type:2,
priceinfo:res.data,
})
}).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.cus_id;
params['car_id'] = this.data.car_id;
params['v_id'] = this.data.v_id;
params['page'] = 1;
params['size'] = 100;
_.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,
})
},
//一件同步购车人信息
synchroCustomer(e){
this.setData({
owner_name:this.data.name,
owner_mobile:this.data.mobile,
owner_cardid:this.data.cardid,
owner_cardidpic:this.data.customer_cardidpic,
address:this.data.customer_address?this.data.customer_address:this.data.address,
})
},
//新建订单
postAppCusorderV2() {
let that = this
that.setData({
submitFlag: true,
})
let fines = []
that.data.fines.forEach(item => {
if(item.txt!=''){
fines.push(item)
}
});
let params = {};
params['main_type'] = that.data.main_type;
params['cus_id'] = that.data.cus_id;
params['name'] = that.data.name;
params['mobile'] = that.data.mobile;
params['c_city_id'] = that.data.c_city_id;
if(that.data.address != ''){
//params['pro'] = that.data.region;
params['address'] = that.data.address;
}
params['cardid'] = that.data.cardid;
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;
params['price'] = that.data.priceinfo.price;
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;
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.company != ''){
params['company'] = that.data.company;
}
if(that.data.credit != ''){
params['credit'] = that.data.credit;
}
if(!!that.data.priceinfo.sdisc_money && that.data.priceinfo.sdisc_money != '' ){
params['disc_money'] = that.data.priceinfo.sdisc_money;
}
if(that.data.sa != ''){
params['sa'] = that.data.sa;
}
if(that.data.priceinfo.show_local_bill){
params['if_local_bill'] = that.data.if_local_bill;
}
let srv_arr = []
that.data.agencyList.forEach(item => {
if(item.checked){
srv_arr.push({
id:item.id,
key:item.key,
price:item.sprice,
})
}
})
if(srv_arr.length>0){
params['srv_arr'] = srv_arr;
}
if(fines.length>0){
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.postAppCusorderV2(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()
}
}
that.setData({
isShowSuccess:true,//是否显示成功提示
details:res.data,
})
if(that.data.owner_cardidpic != ''){
let oparams = {};
oparams['id'] = res.data.id;
oparams['cardida'] = that.data.owner_cardidpic;
_.apiQuery.putAppCusorderdata(oparams).then(res2 => {
})
}
// wx.showModal({
// title: '登记成功',
// content: '',
// confirmText: "查看详情",
// confirmColor: "#36afa2",
// showCancel:false,
// success() {
// wx.redirectTo({
// url: '/pages/order/detail/index?id=' + res.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,
})
},
//点击收取意向金
createV2Inten() {
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.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.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.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 if(this.data.c_city_id == ''){
wx.showToast({
title: '请选择上牌城市',
icon: 'none'
})
}
else{
this.setData({
isShowIntenMoney:true,
})
}
},
//显示隐藏意向金弹框
optIntenMoney(){
this.setData({
isShowIntenMoney:!this.data.isShowIntenMoney,
})
},
//收取意向金新建订单
postAppCusorderV2Inten() {
if(this.data.inten_money == ''){
wx.showToast({
title: '请输入意向金',
icon: 'none'
})
}else{
let that = this
wx.showModal({
title: '确定创建订单,收取意向金?',
content: '',
confirmColor: "#36afa2",
success(resW) {
if (resW.confirm) {
that.setData({
submitFlag: true,
})
let params = {};
params['main_type'] = that.data.main_type;
params['cus_id'] = that.data.cus_id;
params['name'] = that.data.name;
params['mobile'] = that.data.mobile;
params['inten_money'] = that.data.inten_money;
params['c_city_id'] = that.data.c_city_id;
if(that.data.address != ''){
//params['pro'] = that.data.region;
params['address'] = that.data.address;
}
params['cardid'] = that.data.cardid;
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.company != ''){
params['company'] = that.data.company;
}
if(that.data.credit != ''){
params['credit'] = that.data.credit;
}
_.apiQuery.postAppCusorderV2Inten(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()
}
}
that.setData({
isShowIntenMoney:false,//关闭意向金弹框
isShowSuccess:true,//是否显示成功提示
details:res.data,
})
if(that.data.owner_cardidpic != ''){
let oparams = {};
oparams['id'] = res.data.id;
oparams['cardida'] = that.data.owner_cardidpic;
_.apiQuery.putAppCusorderdata(oparams).then(res2 => {
})
}
}).catch(res=>{
that.setData({
submitFlag: 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':'',
})
},
//推送链接
viewDetails(e){
wx.redirectTo({
url: '/pages/order/detail/index2?id=' + this.data.details.id
})
},
//修改步骤
optShowContract(e){
this.setData({
isShowSuccess:false,
isShowContract:!this.data.isShowContract,
})
},
//修改成功
optShowSuccess(e){
this.setData({
isShowSuccess:!this.data.isShowSuccess,
})
},
//添加精品
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':'',
})
}
},
//推送链接
pushLink(e){
if(e.currentTarget.dataset.url){
_.$router.openUrlScheme(e.currentTarget.dataset.url)
}
},
//选择城市
// bindRegionChange(e) {
// this.setData({
// region: e.detail.value
// })
// },
//显示隐藏修改地址
optAddress(){
this.setData({
isShowAddress:!this.data.isShowAddress,
})
},
//选择上牌城市
changeOncard(e) {
if(this.data.oncardIndex != e.detail.value && e.detail.value >= 0){
this.setData({
c_city_id:this.data.oncardList[e.detail.value].city_id,
oncardIndex:e.detail.value,
})
}
},
//需开具本地发票
switchAddrDef:function(e){
this.setData({
if_local_bill:e.detail.value ? 1 :0
})
},
//选择图片
chooseImg(e) {
let that = this
//上传身份证正面-客户身份证
if(e.currentTarget.dataset.type=='customer'){
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);
if (resp.data.code == 200) {
let params = {};
params['img'] = resp.data.data.url;
_.apiQuery.getAppIdcardInfo(params).then(res2 => {
wx.hideLoading();
that.setData({
cardid:res2.data.IdNum,
name:res2.data.Name,
customer_address:res2.data.Address,
customer_cardidpic:resp.data.data.url,
})
})
}
},
fail: res => {
wx.hideLoading();
}
})
},
fail: res => {
wx.showToast({
title: '文件选择失败',
icon: 'none',
duration: 2000
})
}
})
}
//上传身份证正面-车主身份证
if(e.currentTarget.dataset.type=='owner'){
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);
if (resp.data.code == 200) {
let params = {};
params['img'] = resp.data.data.url;
_.apiQuery.getAppIdcardInfo(params).then(res2 => {
wx.hideLoading();
that.setData({
owner_cardid:res2.data.IdNum,
owner_name:res2.data.Name,
address:res2.data.Address,
owner_cardidpic:resp.data.data.url,
})
})
}
},
fail: res => {
wx.hideLoading();
}
})
},
fail: res => {
wx.showToast({
title: '文件选择失败',
icon: 'none',
duration: 2000
})
}
})
}
},
//获取精品选装
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,
})
}
}
})
},
//去除空格
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`)
}
},
focusAddress(){
this.setData({
addressFocus:true,
})
},
blurAddress(){
this.setData({
addressFocus:false,
})
},
})