723 lines
20 KiB
JavaScript
723 lines
20 KiB
JavaScript
import _ from '../../../commons/js/commons'
|
|
const timer = require('../../../commons/js/lib/wxTimer');
|
|
var wxTimer = null
|
|
const app = getApp()
|
|
Page({
|
|
data: {
|
|
imgUrl: _.config.imgUrl,
|
|
submitFlag: false,
|
|
isShowOrderCode: false,
|
|
remark: '', //补充说明
|
|
carInfoList: [], //随车资料选项
|
|
ckcarInfo: [], //随车资料选中内容
|
|
carToolList: [], //随车随车工具选项
|
|
ckcarTool: [], //随车工具选中内容
|
|
|
|
pay_img: {}, //支付凭证照片
|
|
contract_img: {}, //合同图片照片
|
|
equity_ck_img: {}, //权益确认书照片
|
|
bill_img: {}, //发票照片
|
|
car_auth_img: {}, //车机实名认证
|
|
delivery_ck_img: {}, //交车确认图片
|
|
|
|
cardida: {}, //身份证正面照片
|
|
business_licence: {}, //营业执照照片
|
|
car_img: {}, //行驶证照片
|
|
isShowCK: false,
|
|
isShowBill: false,
|
|
isShowConfirm: false, //是否显示确认窗口
|
|
confirm_count_down: 3,
|
|
wxTimerList: {},
|
|
wxTimer: null,
|
|
group_id_4s: 5 //角色类型4店铺
|
|
},
|
|
onLoad: function (options) {
|
|
for (let key in options) {
|
|
this.setData({
|
|
[key]: options[key]
|
|
})
|
|
}
|
|
|
|
this.getAppCusorderV2()
|
|
this.getUserInfo()
|
|
|
|
|
|
},
|
|
onShow: function () {
|
|
this.getAppCusorderdata()
|
|
},
|
|
|
|
/**
|
|
* 生命周期函数--监听页面卸载
|
|
*/
|
|
onUnload: function () {
|
|
if (wxTimer) {
|
|
wxTimer.stop();
|
|
wxTimer = null
|
|
}
|
|
this.setData({
|
|
wxTimerList: {},
|
|
wxTimer: null,
|
|
})
|
|
},
|
|
|
|
//获取用户信息
|
|
getUserInfo() {
|
|
_.apiQuery.getUserInfo().then(res => {
|
|
this.setData({
|
|
userInfo: res
|
|
})
|
|
});
|
|
},
|
|
|
|
//获取订单详情
|
|
getAppCusorderV2() {
|
|
let params = {};
|
|
params['id'] = this.data.id;
|
|
_.apiQuery.getAppCusorderDetails(params).then(res => {
|
|
this.setData({
|
|
info: res.data,
|
|
})
|
|
|
|
wx.stopPullDownRefresh()
|
|
|
|
})
|
|
},
|
|
|
|
//获取订单图片
|
|
getAppCusorderdata() {
|
|
let params = {};
|
|
params['id'] = this.data.id;
|
|
_.apiQuery.getAppCusorderdata(params).then(res => {
|
|
this.setData({
|
|
imgInfo: res.data,
|
|
})
|
|
this.setData({
|
|
cardida: res.data.imgs.cardida.length == 0 ? {} : res.data.imgs.cardida,
|
|
business_licence: res.data.imgs.business_licence.length == 0 ? {} : res.data.imgs.business_licence,
|
|
car_img: res.data.imgs.car_img.length == 0 ? {} : res.data.imgs.car_img,
|
|
pay_img: res.data.imgs.pay_img.length == 0 ? [] : res.data.imgs.pay_img,
|
|
contract_img: res.data.imgs.contract_img.length == 0 ? [] : res.data.imgs.contract_img,
|
|
equity_ck_img: res.data.imgs.equity_ck_img.length == 0 ? [] : res.data.imgs.equity_ck_img,
|
|
bill_img: res.data.imgs.bill_img.length == 0 ? [] : res.data.imgs.bill_img,
|
|
car_auth_img: res.data.imgs.car_auth_img.length == 0 ? [] : res.data.imgs.car_auth_img,
|
|
delivery_ck_img: res.data.imgs.delivery_ck_img.length == 0 ? [] : res.data.imgs.delivery_ck_img,
|
|
|
|
})
|
|
wx.stopPullDownRefresh()
|
|
})
|
|
},
|
|
|
|
//显示短信弹框
|
|
showMessage(e) {
|
|
this.setData({
|
|
isShowMessage: true,
|
|
content: '',
|
|
})
|
|
},
|
|
|
|
//关闭短信弹框
|
|
hideMessage(e) {
|
|
this.setData({
|
|
isShowMessage: false,
|
|
})
|
|
},
|
|
|
|
// 输入
|
|
inputTx(e) {
|
|
this.setData({
|
|
[e.currentTarget.dataset.key]: e.detail.value
|
|
})
|
|
},
|
|
|
|
//发短信
|
|
postAppSmsCusorder() {
|
|
if (this.data.submitFlag) return;
|
|
if (this.data.content == '') {
|
|
wx.showToast({
|
|
title: '请填写短信内容',
|
|
icon: 'none'
|
|
})
|
|
} else {
|
|
this.setData({
|
|
submitFlag: true,
|
|
})
|
|
let params = {};
|
|
params['id'] = this.data.id;
|
|
params['content'] = this.data.content;
|
|
_.apiQuery.postAppSmsCusorder(params).then(res => {
|
|
this.setData({
|
|
isShowMessage: false,
|
|
submitFlag: false,
|
|
content: '',
|
|
})
|
|
wx.showToast({
|
|
title: res.msg,
|
|
icon: 'none'
|
|
})
|
|
|
|
})
|
|
}
|
|
},
|
|
|
|
//选择图片
|
|
chooseImg(e) {
|
|
let that = this
|
|
//上传身份证正面
|
|
if (e.currentTarget.dataset.type == 'cardida') {
|
|
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({
|
|
'cardida.value': resp.data.data.url,
|
|
'cardida.img': resp.data.data.full_url,
|
|
})
|
|
|
|
let params = {};
|
|
params['id'] = that.data.id;
|
|
params['cardida'] = resp.data.data.url;
|
|
_.apiQuery.putAppCusorderdata(params).then(res2 => {
|
|
|
|
}).catch(res2 => {
|
|
if (res2.code == 418) {
|
|
that.setData({
|
|
'cardida.err': !res2.data[0].caridA,
|
|
'cardida.errmsg': res2.data[0].errmsg,
|
|
})
|
|
}
|
|
});
|
|
}
|
|
},
|
|
})
|
|
},
|
|
fail: res => {
|
|
wx.showToast({
|
|
title: '文件选择失败',
|
|
icon: 'none',
|
|
duration: 2000
|
|
})
|
|
}
|
|
})
|
|
}
|
|
|
|
//上传营业执照
|
|
if (e.currentTarget.dataset.type == 'business_licence') {
|
|
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({
|
|
'business_licence.value': resp.data.data.url,
|
|
'business_licence.img': resp.data.data.full_url,
|
|
})
|
|
|
|
let params = {};
|
|
params['id'] = that.data.id;
|
|
params['business_licence'] = resp.data.data.url;
|
|
_.apiQuery.putAppCusorderdata(params).then(res2 => {
|
|
|
|
}).catch(res2 => {
|
|
if (res2.code == 418) {
|
|
that.setData({
|
|
'business_licence.err': !res2.data[0].business_licence,
|
|
'business_licence.errmsg': res2.data[0].errmsg,
|
|
})
|
|
}
|
|
});
|
|
}
|
|
},
|
|
})
|
|
},
|
|
fail: res => {
|
|
wx.showToast({
|
|
title: '文件选择失败',
|
|
icon: 'none',
|
|
duration: 2000
|
|
})
|
|
}
|
|
})
|
|
}
|
|
|
|
//上传行驶证
|
|
if (e.currentTarget.dataset.type == 'car_img') {
|
|
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) {
|
|
let params = {};
|
|
params['id'] = that.data.id;
|
|
params['car_img'] = resp.data.data.url;
|
|
_.apiQuery.putAppCusorderdata(params).then(res2 => {
|
|
that.setData({
|
|
'car_img.value': resp.data.data.url,
|
|
'car_img.img': resp.data.data.full_url,
|
|
})
|
|
})
|
|
}
|
|
},
|
|
})
|
|
},
|
|
fail: res => {
|
|
wx.showToast({
|
|
title: '文件选择失败',
|
|
icon: 'none',
|
|
duration: 2000
|
|
})
|
|
}
|
|
})
|
|
}
|
|
|
|
//上传保单
|
|
if (e.currentTarget.dataset.type == 'ins_img') {
|
|
wx.chooseImage({
|
|
count: 10 - that.data.ins_img.length, //
|
|
sizeType: ['original', 'compressed'], // 可以指定是原图还是压缩图,默认二者都有
|
|
sourceType: ['album', 'camera'], // 可以指定来源是相册还是相机,默认二者都有
|
|
success(res1) {
|
|
wx.showLoading({
|
|
title: '上传中',
|
|
})
|
|
let ins_img = that.data.ins_img
|
|
let k = 0
|
|
for (let i = 0; i < res1.tempFilePaths.length; i++) {
|
|
//上传图片
|
|
wx.uploadFile({
|
|
url: _.config.api.upImg,
|
|
filePath: res1.tempFilePaths[i],
|
|
name: 'img',
|
|
formData: {
|
|
'app': 'liche'
|
|
},
|
|
success: (resp) => {
|
|
k = k + 1
|
|
resp.data = JSON.parse(resp.data);
|
|
if (resp.data.code == 200) {
|
|
let imgdata = resp.data
|
|
let list = []
|
|
list.push({
|
|
value: imgdata.data.url,
|
|
img: imgdata.data.full_url,
|
|
})
|
|
ins_img = ins_img.concat(list)
|
|
if (k == res1.tempFilePaths.length) {
|
|
wx.hideLoading();
|
|
let params = {};
|
|
params['id'] = that.data.id;
|
|
let img = []
|
|
ins_img.forEach(item => {
|
|
img.push(item.value)
|
|
})
|
|
params['ins_imgs'] = img;
|
|
_.apiQuery.putAppCusorderdata(params).then(res2 => {
|
|
that.setData({
|
|
ins_img,
|
|
})
|
|
})
|
|
}
|
|
}
|
|
},
|
|
|
|
})
|
|
}
|
|
|
|
},
|
|
fail: res => {
|
|
wx.showToast({
|
|
title: '文件选择失败',
|
|
icon: 'none',
|
|
duration: 2000
|
|
})
|
|
}
|
|
})
|
|
}
|
|
|
|
//上传交车合照
|
|
if (e.currentTarget.dataset.type == 'other_img') {
|
|
wx.chooseImage({
|
|
count: 1, //
|
|
sizeType: ['original', 'compressed'], // 可以指定是原图还是压缩图,默认二者都有
|
|
sourceType: ['album', 'camera'], // 可以指定来源是相册还是相机,默认二者都有
|
|
success(res1) {
|
|
wx.showLoading({
|
|
title: '上传中',
|
|
})
|
|
let other_img = that.data.other_img
|
|
let k = 0
|
|
for (let i = 0; i < res1.tempFilePaths.length; i++) {
|
|
//上传图片
|
|
wx.uploadFile({
|
|
url: _.config.api.upImg,
|
|
filePath: res1.tempFilePaths[i],
|
|
name: 'img',
|
|
formData: {
|
|
'app': 'liche'
|
|
},
|
|
success: (resp) => {
|
|
k = k + 1
|
|
resp.data = JSON.parse(resp.data);
|
|
if (resp.data.code == 200) {
|
|
let imgdata = resp.data
|
|
let list = []
|
|
list.push({
|
|
value: imgdata.data.url,
|
|
img: imgdata.data.full_url,
|
|
})
|
|
other_img = other_img.concat(list)
|
|
if (k == res1.tempFilePaths.length) {
|
|
wx.hideLoading();
|
|
let params = {};
|
|
params['id'] = that.data.id;
|
|
let img = []
|
|
other_img.forEach(item => {
|
|
img.push(item.value)
|
|
})
|
|
params['other_imgs'] = img;
|
|
_.apiQuery.putAppCusorderdata(params).then(res2 => {
|
|
that.setData({
|
|
other_img,
|
|
})
|
|
})
|
|
}
|
|
}
|
|
},
|
|
|
|
})
|
|
}
|
|
|
|
},
|
|
fail: res => {
|
|
wx.showToast({
|
|
title: '文件选择失败',
|
|
icon: 'none',
|
|
duration: 2000
|
|
})
|
|
}
|
|
})
|
|
}
|
|
},
|
|
|
|
// 编辑页面删除图片
|
|
delImg(e) {
|
|
if (e.currentTarget.dataset.type == 'ins_img') {
|
|
let ins_img = this.data.ins_img
|
|
ins_img.splice(e.currentTarget.dataset.index, 1)
|
|
let params = {};
|
|
params['id'] = this.data.id;
|
|
let img = []
|
|
ins_img.forEach(item => {
|
|
img.push(item.value)
|
|
})
|
|
params['ins_imgs'] = img;
|
|
_.apiQuery.putAppCusorderdata(params).then(res => {
|
|
this.setData({
|
|
ins_img,
|
|
})
|
|
})
|
|
} else if (e.currentTarget.dataset.type == 'other_img') {
|
|
let other_img = this.data.other_img
|
|
other_img.splice(e.currentTarget.dataset.index, 1)
|
|
let params = {};
|
|
params['id'] = this.data.id;
|
|
let img = []
|
|
other_img.forEach(item => {
|
|
img.push(item.value)
|
|
})
|
|
params['other_imgs'] = img;
|
|
_.apiQuery.putAppCusorderdata(params).then(res => {
|
|
this.setData({
|
|
other_img,
|
|
})
|
|
})
|
|
}
|
|
},
|
|
|
|
//确认交付
|
|
putAppCusorderCkcar() {
|
|
|
|
if (this.data.ckcarInfo.length == 0) {
|
|
wx.showToast({
|
|
title: '请选择随车资料',
|
|
icon: 'none'
|
|
})
|
|
} else if (this.data.ckcarTool.length == 0) {
|
|
wx.showToast({
|
|
title: '请选择随车工具',
|
|
icon: 'none'
|
|
})
|
|
} else {
|
|
let that = this
|
|
wx.showModal({
|
|
title: '确认交付车辆?',
|
|
content: '',
|
|
success: function (res) {
|
|
if (res.confirm) {
|
|
that.setData({
|
|
submitFlag: true,
|
|
})
|
|
let params = {};
|
|
params['id'] = that.data.id;
|
|
params['info'] = that.data.ckcarInfo;
|
|
params['tool'] = that.data.ckcarTool;
|
|
params['remark'] = that.data.remark;
|
|
_.apiQuery.putAppCusorderCkcar(params).then(res => {
|
|
that.setData({
|
|
submitFlag: false,
|
|
})
|
|
that.getAppCusorderV2()
|
|
|
|
wx.showToast({
|
|
title: '确认交付车辆成功',
|
|
icon: 'success'
|
|
})
|
|
|
|
}).catch(res => {
|
|
that.setData({
|
|
submitFlag: false,
|
|
})
|
|
});
|
|
}
|
|
}
|
|
})
|
|
}
|
|
},
|
|
|
|
//订单支付码
|
|
optShowOrderCode() {
|
|
this.setData({
|
|
isShowOrderCode: !this.data.isShowOrderCode,
|
|
})
|
|
},
|
|
|
|
//查看图片
|
|
previewImage: function (e) {
|
|
if (e.currentTarget.dataset.type == 'bill_img') {
|
|
let urls = [this.data.info.bill_img]
|
|
wx.previewImage({
|
|
current: e.currentTarget.dataset.current,
|
|
urls,
|
|
})
|
|
} else if (e.currentTarget.dataset.type == 'cardida') {
|
|
wx.previewImage({
|
|
current: this.data.imgInfo.imgs.cardida.img,
|
|
urls: [this.data.imgInfo.imgs.cardida.img],
|
|
})
|
|
}else if (e.currentTarget.dataset.type == 'business_licence') {
|
|
wx.previewImage({
|
|
current: this.data.imgInfo.imgs.business_licence.img,
|
|
urls: [this.data.imgInfo.imgs.business_licence.img],
|
|
})
|
|
} else if (e.currentTarget.dataset.type == 'car_img') {
|
|
wx.previewImage({
|
|
current: this.data.imgInfo.imgs.car_img.img,
|
|
urls: [this.data.imgInfo.imgs.car_img.img],
|
|
})
|
|
} else if (e.currentTarget.dataset.type == 'insurance_img') {
|
|
wx.previewImage({
|
|
current: this.data.imgInfo.imgs.insurance_img.img,
|
|
urls: [this.data.imgInfo.imgs.insurance_img.img],
|
|
})
|
|
} else if (e.currentTarget.dataset.type == 'business_img') {
|
|
wx.previewImage({
|
|
current: this.data.imgInfo.imgs.business_img.img,
|
|
urls: [this.data.imgInfo.imgs.business_img.img],
|
|
})
|
|
} else if (e.currentTarget.dataset.type == 'accident_img') {
|
|
wx.previewImage({
|
|
current: this.data.imgInfo.imgs.accident_img.img,
|
|
urls: [this.data.imgInfo.imgs.accident_img.img],
|
|
})
|
|
} else if (e.currentTarget.dataset.type == 'other_img') {
|
|
let img = []
|
|
this.data.imgInfo.imgs.other_img.forEach(item => {
|
|
img.push(item.img)
|
|
})
|
|
wx.previewImage({
|
|
current: this.data.imgInfo.imgs.other_img[0].img,
|
|
urls: img,
|
|
})
|
|
} else if (e.currentTarget.dataset.type == 'wx_img') {
|
|
wx.previewImage({
|
|
current: this.data.imgInfo.imgs.wx_img.img,
|
|
urls: [this.data.imgInfo.imgs.wx_img.img],
|
|
})
|
|
} else if (e.currentTarget.dataset.type == 'mut_wx_img') {
|
|
wx.previewImage({
|
|
current: this.data.imgInfo.imgs.mut_wx_img.img,
|
|
urls: [this.data.imgInfo.imgs.mut_wx_img.img],
|
|
})
|
|
} else if (e.currentTarget.dataset.type == 'notify') {
|
|
let img = []
|
|
this.data.info.notify_file.forEach(item => {
|
|
img.push(item.src)
|
|
})
|
|
wx.previewImage({
|
|
current: e.currentTarget.dataset.current,
|
|
urls: img,
|
|
})
|
|
} else if (e.currentTarget.dataset.type == 'lend') {
|
|
wx.previewImage({
|
|
current: this.data.info.lend_file.src,
|
|
urls: [this.data.info.lend_file.src],
|
|
})
|
|
}
|
|
|
|
},
|
|
|
|
//推送链接
|
|
pushLink(e) {
|
|
if (e.currentTarget.dataset.url) {
|
|
_.$router.openUrlScheme(e.currentTarget.dataset.url)
|
|
}
|
|
},
|
|
|
|
//20240526 确认弹窗
|
|
bindShowConfirm() {
|
|
this.setData({
|
|
isShowConfirm: true,
|
|
submitFlag: true
|
|
}, () => {
|
|
this.getTimes(this.data.confirm_count_down)
|
|
})
|
|
},
|
|
|
|
//关闭短信弹框
|
|
hideConfirm(e) {
|
|
this.setData({
|
|
isShowConfirm: false,
|
|
})
|
|
},
|
|
|
|
//20240526 确定无误接口
|
|
postConfirmOrder() {
|
|
let params = {
|
|
'id': this.data.id,
|
|
'status': parseInt(this.data.info.status) + 1,
|
|
}
|
|
_.apiQuery.putAppCusorderStatus(params).then(res => {
|
|
_.utils.$toast(res.msg).then(res => {
|
|
this.getAppCusorderV2()
|
|
this.hideConfirm()
|
|
})
|
|
})
|
|
},
|
|
|
|
//删除订单
|
|
delAppCusorder(){
|
|
let that = this
|
|
wx.showModal({
|
|
title: '确定删除订单?',
|
|
content: '',
|
|
confirmColor: "#36afa2",
|
|
success(resW) {
|
|
if (resW.confirm) {
|
|
let params = {};
|
|
params['id'] = that.data.id;
|
|
params['status'] = -1;
|
|
_.apiQuery.putAppCusorderStatus(params).then(res => {
|
|
//刷新列表页
|
|
let pages = getCurrentPages();
|
|
pages.forEach(item => {
|
|
if(item.route == 'pages/order/index'){
|
|
item.onPullDownRefresh()
|
|
}
|
|
})
|
|
wx.showToast({
|
|
title: '删除成功',
|
|
icon: 'success',
|
|
duration: 2000
|
|
})
|
|
setTimeout(function () {
|
|
wx.navigateBack({
|
|
delta: 1
|
|
})
|
|
}, 500)
|
|
})
|
|
}
|
|
}
|
|
})
|
|
},
|
|
|
|
/**
|
|
* 生成倒计时
|
|
*/
|
|
getTimes(seconds) {
|
|
let that = this
|
|
return new Promise(function (resolve, reject) {
|
|
wxTimer = new timer({
|
|
name: 'wxTimer',
|
|
leftTime: seconds,
|
|
complete: function () {
|
|
// that.setData({
|
|
// isShow: false
|
|
// })
|
|
setTimeout(() => {
|
|
that.setData({
|
|
'submitFlag': false,
|
|
wxTimerList: {}
|
|
})
|
|
}, 1000);
|
|
// that.getAppActivityExchange()
|
|
resolve()
|
|
},
|
|
})
|
|
wxTimer.start(that);
|
|
})
|
|
},
|
|
|
|
//页面相关事件处理函数--监听用户下拉动作
|
|
onPullDownRefresh() {
|
|
this.getAppCusorderdata()
|
|
this.getAppCusorderV2()
|
|
this.setData({
|
|
wxTimerList: {},
|
|
wxTimer: null
|
|
})
|
|
},
|
|
|
|
}) |