173 lines
4.5 KiB
JavaScript
173 lines
4.5 KiB
JavaScript
import _ from '../../../commons/js/commons'
|
|
const app = getApp()
|
|
Page({
|
|
data: {
|
|
name: '', //姓名
|
|
mobile: '', //手机号
|
|
cardid: '', //身份证
|
|
main_type: '', //类型
|
|
},
|
|
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.getAppCusorderDetails(params).then(res => {
|
|
this.setData({
|
|
name: res.data.name ? res.data.name : '',
|
|
mobile: res.data.mobile ? res.data.mobile : '',
|
|
cardid: res.data.cardid ? res.data.cardid : '',
|
|
main_type: res.data.main_type ? res.data.main_type : ''
|
|
})
|
|
|
|
wx.stopPullDownRefresh()
|
|
|
|
})
|
|
},
|
|
|
|
//修改订单基本信息
|
|
putAppCusorderV2Info() {
|
|
this.setData({
|
|
name: this.trimAll(this.data.name),
|
|
cardid: this.trimAll(this.data.cardid),
|
|
})
|
|
if (this.data.main_type == 0 && this.data.name == '') {
|
|
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.main_type == 1 && this.data.name == '') {
|
|
wx.showToast({
|
|
title: '请输入企业名称',
|
|
icon: 'none'
|
|
})
|
|
} else if (this.data.main_type == 1 && this.data.cardid == '') {
|
|
wx.showToast({
|
|
title: '请输入企业信用代码',
|
|
icon: 'none'
|
|
})
|
|
} else {
|
|
let that = this
|
|
that.setData({
|
|
submitFlag: true,
|
|
})
|
|
let params = {};
|
|
params['id'] = that.data.id;
|
|
params['name'] = that.data.name;
|
|
params['cardid'] = that.data.cardid;
|
|
_.apiQuery.putAppCusorderInfo(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,
|
|
})
|
|
});
|
|
}
|
|
},
|
|
|
|
//推送链接
|
|
pushLink(e) {
|
|
if (e.currentTarget.dataset.url) {
|
|
_.$router.openUrlScheme(e.currentTarget.dataset.url)
|
|
}
|
|
},
|
|
|
|
//选择图片
|
|
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,
|
|
})
|
|
})
|
|
}
|
|
},
|
|
fail: res => {
|
|
wx.hideLoading();
|
|
}
|
|
})
|
|
},
|
|
fail: res => {
|
|
wx.showToast({
|
|
title: '文件选择失败',
|
|
icon: 'none',
|
|
duration: 2000
|
|
})
|
|
}
|
|
})
|
|
}
|
|
},
|
|
|
|
//去除空格
|
|
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`)
|
|
}
|
|
},
|
|
|
|
}) |