合同小程序前端代码仓库
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 

679 lines
24 KiB

"use strict";
const common_vendor = require("../../common/vendor.js");
const api = require("../../api.js");
const common_assets = require("../../common/assets.js");
const _sfc_main = common_vendor.defineComponent({
data() {
return {
uploadConfig: new UTSJSONObject({
// 上传地址
url: "https://gpt.aiym.run/contract/miniapp/file/upload",
// 文件字段名
name: "file",
// 请求头
header: new UTSJSONObject({}),
// 附带的表单数据
formData: new UTSJSONObject({
"biz": "cert"
}),
// 是否开启实际上传
enabled: true
}),
clientInfo: new UTSJSONObject({
appOrderCarList: [
new UTSJSONObject({
buyMoney: 0,
buyTax: 0,
carModel: "",
carNo: "",
carSeries: "",
carType: "",
engineNo: "",
newCar: 0,
useType: "",
vin: ""
})
],
appOrderVoucherList: [
new UTSJSONObject({
dealerAddress: "",
firstBeneficiary: "",
packageMoney: 0,
serviceMoney: 0
})
],
carPic: "",
certBack: "",
certFront: "",
custAddress: "",
custCardNo: "",
custName: "",
custPhone: "",
custType: 0,
invoiceUrl: "",
payType: "全款",
payVoucherUrl: "",
payee: "",
productName: "自动填写所选商品服务分类",
productServiceYear: 1,
saleName: "",
salePort: "售前",
status: 0,
storeName: "自动填写所选择的门店"
}),
fileList1: [],
fileList2: [],
departments: ["售前", "售后", "二网车"],
carType: ["燃油车", "新能源"],
useType: ["非营运", "营运"],
carBrandIndex: -1,
useTypeIndex: -1,
serviceAges: ["1年", "2年", "3年"],
serviceAgeIndex: -1,
payees: [],
payeeIndex: -1,
screenHeight: 0,
curHeight: 0,
// 扫描
positiveImg: "/static/image/组件 4 – 1.png",
certFront: "",
carPic: "",
certBack: "",
// 反面身份证
reverseImg: "/static/image/组 71663.png",
// 行车驾驶证
carImg: "/static/image/组件 2 – 1.png"
//自己图片路径
};
},
onLoad(options) {
api.isToken();
this.clientInfo.storeName = getApp().storeName || "自动填写所选择的门店";
this.clientInfo.productName = getApp().productName || "自动填写所选商品服务分类";
this.clientInfo.appOrderVoucherList[0].dealerAddress = getApp().dealerAddress;
for (var index = 0; index < getApp().allMsg.length; index++) {
this.payees.push(getApp().allMsg[index].storeName);
}
this.clientInfo.payee = getApp().storeName;
this.uploadConfig.header = new UTSJSONObject({
"X-Access-Token": common_vendor.index.getStorageSync("token")
});
let clientInfo = UTS.JSON.parse(decodeURIComponent(options.clientInfo));
if (clientInfo) {
this.clientInfo = UTS.JSON.parse(decodeURIComponent(options.clientInfo));
this.certFront = getApp().certFront;
this.carPic = getApp().carPic;
this.certBack = getApp().certBack;
}
},
onUpload() {
common_vendor.index.offKeyboardHeightChange();
},
methods: {
// 凭证上传函数
deletePic(event = null) {
this[`fileList${event.name}`].splice(event.index, 1);
},
// 新增图片
afterRead(event = null) {
return common_vendor.__awaiter(this, void 0, void 0, function* () {
let lists = [].concat(event.file);
let fileListLen = this[`fileList${event.name}`].length;
lists.map((item) => {
this[`fileList${event.name}`].push(new UTSJSONObject(Object.assign(Object.assign({}, item), { status: "uploading", message: "上传中" })));
});
for (let i = 0; i < lists.length; i++) {
const result = yield this.uploadFilePromise(lists[i].url, event.name);
let item = this[`fileList${event.name}`][fileListLen];
this[`fileList${event.name}`].splice(fileListLen, 1, Object.assign(item, {
status: "success",
message: "",
url: result
}));
fileListLen++;
}
});
},
uploadFilePromise(url = null, name = null) {
let token = common_vendor.index.getStorageSync("token");
return new Promise((resolve, reject) => {
common_vendor.index.uploadFile({
url: "https://www.shengchuangyunkong.com/contract/miniapp/file/upload",
filePath: url,
name: "file",
formData: new UTSJSONObject({
biz: "test"
}),
header: new UTSJSONObject({
"X-Access-Token": token
}),
success: (res) => {
if (name == "1") {
this.clientInfo.payVoucherUrl = UTS.JSON.parse(res.data).message;
setTimeout(() => {
resolve(res.data.data);
}, 1e3);
} else {
this.clientInfo.invoiceUrl = UTS.JSON.parse(res.data).message;
setTimeout(() => {
resolve(res.data.data);
}, 1e3);
}
}
});
});
},
isEmpty(value = null) {
if (value === null || value === void 0)
return false;
if (typeof value === "string" && value.trim() === "")
return false;
if (Array.isArray(value) && value.length === 0)
return false;
if (typeof value === "object" && Object.keys(value).length === 0)
return false;
return true;
},
get_to() {
common_vendor.index.__f__("log", "at pages/index/PayPal_pinpai.uvue:418", "suss", UTS.JSON.parse(UTS.JSON.stringify(this.clientInfo)));
for (var i in this.clientInfo) {
if (typeof this.clientInfo[i] == "object") {
for (var j in this.clientInfo[i]) {
for (var k in this.clientInfo[i][j]) {
if (!this.isEmpty(this.clientInfo[i][j][k]) && k != "carNo" && k != "lender" && k != "lenderMoney" && k != "lenderYear") {
common_vendor.index.showToast({
title: "提交失败,请检查字段是否未填!",
icon: "error",
duration: 500,
success: (res) => {
},
fail: (res) => {
}
});
return false;
}
}
}
} else {
if (!this.isEmpty(this.clientInfo[i])) {
common_vendor.index.showToast({
title: "提交失败,请检查字段是否未填!",
icon: "error",
duration: 500,
success: (res) => {
},
fail: (res) => {
}
});
return false;
}
}
}
api.add(this.clientInfo).then((res = null) => {
if (res.success) {
common_vendor.index.showToast({
title: "提交成功",
icon: "success",
duration: 500,
success: (res2) => {
},
fail: (res2) => {
}
});
common_vendor.index.switchTab({ url: "/pages/index/dingdan" });
} else {
common_vendor.index.showToast({
title: "提交失败,请检查格式!",
icon: "error",
duration: 500,
success: (res2) => {
},
fail: (res2) => {
}
});
}
}).catch((err = null) => {
common_vendor.index.__f__("log", "at pages/index/PayPal_pinpai.uvue:479", "err", err);
});
},
getCar() {
getApp().flag = 1;
common_vendor.index.navigateTo({
url: "/pages/views/carOne?clientInfo=" + encodeURIComponent(UTS.JSON.stringify(this.clientInfo))
});
getApp().certFront = this.certFront;
getApp().carPic = this.carPic;
getApp().certBack = this.certBack;
},
toBack() {
common_vendor.index.navigateBack({ delta: 1 });
},
handleDepartmentChange(e = null) {
this.clientInfo.salePort = e;
},
// 修改车辆类型
bindCarBrandChanges(e = null) {
this.clientInfo.appOrderCarList[0].carType = this.carType[e.detail.value];
},
// 修改车辆类型
binduseTypeChanges(e = null) {
this.clientInfo.appOrderCarList[0].useType = this.useType[e.detail.value];
},
// 取服务年限
bindServiceAgeChange(e = null) {
this.serviceAgeIndex = e.detail.value;
if (this.serviceAges[e.detail.value] == "1年") {
this.clientInfo.productServiceYear = 1;
} else if (this.serviceAges[e.detail.value] == "2年") {
this.clientInfo.productServiceYear = 2;
} else {
this.clientInfo.productServiceYear = 3;
}
},
// 选择收款方
bindPayeeChange(e = null) {
this.payeeIndex = e.detail.value;
this.clientInfo.payee = this.payees[e.detail.value];
},
msToDate(msec = null) {
let datetime = new Date(msec);
let year = datetime.getFullYear();
let month = datetime.getMonth();
let date = datetime.getDate();
let hour = datetime.getHours();
let minute = datetime.getMinutes();
let second = datetime.getSeconds();
let result1 = year + "-" + (month + 1 >= 10 ? month + 1 : "0" + (month + 1)) + "-" + (date + 1 < 10 ? "0" + date : date) + " " + (hour + 1 < 10 ? "0" + hour : hour) + ":" + (minute + 1 < 10 ? "0" + minute : minute) + ":" + (second + 1 < 10 ? "0" + second : second);
let result2 = year + "-" + (month + 1 >= 10 ? month + 1 : "0" + (month + 1)) + "-" + (date + 1 < 10 ? "0" + date : date);
let result = new UTSJSONObject({
hasTime: result1,
withoutTime: result2
});
return result;
},
// 修改生效时间
changeEffectiveTime(e = null) {
var dateTime = new Date(e);
dateTime.setDate(dateTime.getDate() + 2);
dateTime = new Date(dateTime);
this.clientInfo.appOrderVoucherList[0].effectiveTime = this.msToDate(dateTime).withoutTime;
},
changeTime(e = null) {
common_vendor.index.__f__("log", "at pages/index/PayPal_pinpai.uvue:571", e);
if (this.clientInfo.appOrderVoucherList[0].effectiveTime) {
var dateTime = new Date(this.clientInfo.appOrderVoucherList[0].effectiveTime);
let year = Number(dateTime.getFullYear()) + Number(e.detail.value);
dateTime.setFullYear(year);
dateTime = new Date(dateTime);
this.clientInfo.appOrderVoucherList[0].endTime = this.msToDate(dateTime).withoutTime;
} else {
common_vendor.index.showToast({
title: "请先选择生效时间!",
icon: "error",
duration: 500,
success: (res) => {
},
fail: (res) => {
}
});
}
},
changebuyTax() {
this.clientInfo.appOrderCarList[0].buyTax = (this.clientInfo.appOrderCarList[0].buyMoney / 11.3).toFixed(2);
},
// 身份证正面上传
uploadPositive() {
common_vendor.index.chooseImage({
count: 1,
sizeType: ["original", "compressed"],
sourceType: ["album", "camera"],
success: (res) => {
let filePath = res.tempFilePaths[0];
let token = common_vendor.index.getStorageSync("token");
this.uploadIdentify(token, "front", filePath, "sfz");
}
});
},
// 身份证反面上传
uploadReverse() {
common_vendor.index.chooseImage({
count: 1,
sizeType: ["original", "compressed"],
sourceType: ["album", "camera"],
success: (res) => {
let filePath = res.tempFilePaths[0];
let token = common_vendor.index.getStorageSync("token");
this.uploadIdentify(token, "back", filePath, "sfz");
}
});
},
uploadCarCert() {
common_vendor.index.chooseImage({
count: 1,
sizeType: ["original", "compressed"],
sourceType: ["album", "camera"],
success: (res) => {
let filePath = res.tempFilePaths[0];
let token = common_vendor.index.getStorageSync("token");
this.uploadIdentify(token, "", filePath, "carCert");
}
});
},
// 上传识别
uploadIdentify(token = null, side = null, filePath = null, type = null) {
common_vendor.index.uploadFile({
url: "https://www.shengchuangyunkong.com/contract/miniapp/file/upload",
filePath,
name: "file",
formData: new UTSJSONObject({
"biz": "cert"
}),
header: new UTSJSONObject({
"X-Access-Token": token
}),
success: (res) => {
let image = UTS.JSON.parse(res.data).message;
if (type == "sfz") {
api.idCardInfo(new UTSJSONObject({ "side": side, "url": UTS.JSON.parse(res.data).message })).then((res2 = null) => {
if (res2.success) {
if (side == "front") {
this.clientInfo.custName = res2.result.name;
this.clientInfo.appOrderVoucherList[0].firstBeneficiary = res2.result.name;
this.clientInfo.custAddress = res2.result.address;
this.clientInfo.custCardNo = res2.result.idCard;
this.clientInfo.certFront = image;
this.certFront = filePath;
} else {
this.clientInfo.certBack = image;
this.certBack = filePath;
}
} else {
common_vendor.index.showToast({
title: "身份证识别错误,请重新上传!",
icon: "error",
duration: 500,
success: (res3) => {
},
fail: (res3) => {
}
});
}
}).catch((err = null) => {
common_vendor.index.__f__("log", "at pages/index/PayPal_pinpai.uvue:675", "catch: ", err);
});
} else if (type == "carCert") {
api.carCert(new UTSJSONObject({ "url": UTS.JSON.parse(res.data).message })).then((res2 = null) => {
if (res2.success) {
this.clientInfo.appOrderCarList[0].vin = res2.result.VinNo;
this.clientInfo.carPic = image;
this.carPic = filePath;
this.clientInfo.appOrderCarList[0].engineNo = res2.result.EngineNo;
this.clientInfo.appOrderCarList[0].carModel = res2.result.CarModel;
} else {
common_vendor.index.showToast({
title: "识别错误,请重新上传!",
icon: "error",
duration: 500,
success: (res3) => {
},
fail: (res3) => {
}
});
}
}).catch((err = null) => {
common_vendor.index.__f__("log", "at pages/index/PayPal_pinpai.uvue:702", "catch: ", err);
});
}
},
fail: (err) => {
common_vendor.index.__f__("log", "at pages/index/PayPal_pinpai.uvue:709", err);
}
});
},
onChange(e = null) {
if (e == "个人") {
this.clientInfo.custType = 0;
} else {
this.clientInfo.custType = 1;
}
},
onChanges(e = null) {
if (e == "是") {
this.clientInfo.appOrderCarList[0].newCar = 1;
} else {
this.clientInfo.appOrderCarList[0].newCar = 0;
}
}
}
});
if (!Array) {
const _easycom_uni_icons2 = common_vendor.resolveComponent("uni-icons");
const _easycom_l_radio2 = common_vendor.resolveComponent("l-radio");
const _easycom_l_radio_group2 = common_vendor.resolveComponent("l-radio-group");
const _easycom_uv_upload2 = common_vendor.resolveComponent("uv-upload");
(_easycom_uni_icons2 + _easycom_l_radio2 + _easycom_l_radio_group2 + _easycom_uv_upload2)();
}
const _easycom_uni_icons = () => "../../uni_modules/uni-icons/components/uni-icons/uni-icons.js";
const _easycom_l_radio = () => "../../uni_modules/lime-radio/components/l-radio/l-radio.js";
const _easycom_l_radio_group = () => "../../uni_modules/lime-radio/components/l-radio-group/l-radio-group.js";
const _easycom_uv_upload = () => "../../uni_modules/uv-upload/components/uv-upload/uv-upload.js";
if (!Math) {
(_easycom_uni_icons + _easycom_l_radio + _easycom_l_radio_group + _easycom_uv_upload)();
}
function _sfc_render(_ctx, _cache, $props, $setup, $data, $options) {
return common_vendor.e({
a: common_vendor.p({
type: "left",
size: "30",
color: "#c2d4de"
}),
b: common_vendor.o((...args) => $options.toBack && $options.toBack(...args)),
c: common_vendor.w(({
checked
}, s0, i0) => {
return {
a: checked,
b: !checked,
c: i0,
d: s0
};
}, {
name: "icon",
path: "c",
vueId: "2d7e3f76-1"
}),
d: common_assets._imports_0$4,
e: common_assets._imports_1$3,
f: common_vendor.p({
checked: $data.clientInfo.payType === "全款",
label: "全款",
fontSize: "1rem"
}),
g: common_vendor.w(({
checked
}, s0, i0) => {
return {
a: checked,
b: !checked,
c: i0,
d: s0
};
}, {
name: "icon",
path: "g",
vueId: "2d7e3f76-3,2d7e3f76-2"
}),
h: common_assets._imports_0$4,
i: common_assets._imports_1$3,
j: common_vendor.p({
checked: $data.clientInfo.custType == 0 ? true : false,
value: "个人",
label: "个人",
fontSize: "1rem"
}),
k: common_vendor.w(({
checked
}, s0, i0) => {
return {
a: checked,
b: !checked,
c: i0,
d: s0
};
}, {
name: "icon",
path: "k",
vueId: "2d7e3f76-4,2d7e3f76-2"
}),
l: common_assets._imports_0$4,
m: common_assets._imports_1$3,
n: common_vendor.p({
checked: $data.clientInfo.custType == 1 ? true : false,
value: "公司",
label: "公司",
fontSize: "1rem"
}),
o: common_vendor.o($options.onChange),
p: $data.clientInfo.certFront == "" ? $data.positiveImg : $data.certFront,
q: $data.certFront == "" ? true : false
}, ($data.certFront == "" ? true : false) ? {} : {}, {
r: common_vendor.o((...args) => $options.uploadPositive && $options.uploadPositive(...args)),
s: $data.clientInfo.certBack == "" ? $data.reverseImg : $data.certBack,
t: $data.certBack == "" ? true : false
}, ($data.certBack == "" ? true : false) ? {} : {}, {
v: common_vendor.o((...args) => $options.uploadReverse && $options.uploadReverse(...args)),
w: $data.clientInfo.carPic == "" ? $data.carImg : $data.carPic,
x: $data.carPic == "" ? true : false
}, ($data.carPic == "" ? true : false) ? {} : {}, {
y: common_vendor.o((...args) => $options.uploadCarCert && $options.uploadCarCert(...args)),
z: common_assets._imports_3,
A: common_vendor.t($data.clientInfo.productName),
B: common_vendor.t($data.clientInfo.storeName),
C: $data.clientInfo.custName,
D: common_vendor.o(($event) => $data.clientInfo.custName = $event.detail.value),
E: $data.clientInfo.custAddress,
F: common_vendor.o(($event) => $data.clientInfo.custAddress = $event.detail.value),
G: $data.clientInfo.custCardNo,
H: common_vendor.o(($event) => $data.clientInfo.custCardNo = $event.detail.value),
I: $data.clientInfo.custPhone,
J: common_vendor.o(($event) => $data.clientInfo.custPhone = $event.detail.value),
K: common_vendor.f($data.departments, (item, k0, i0) => {
return {
a: common_vendor.w(({
checked
}, s1, i1) => {
return {
a: checked,
b: !checked,
c: i1,
d: s1
};
}, {
name: "icon",
path: "K[" + i0 + "].a",
vueId: "2d7e3f76-6-" + i0 + ",2d7e3f76-5"
}),
b: "2d7e3f76-6-" + i0 + ",2d7e3f76-5",
c: common_vendor.p({
value: item,
checked: $data.clientInfo.salePort === item
}),
d: common_vendor.t(item),
e: item
};
}),
L: common_assets._imports_0$4,
M: common_assets._imports_1$3,
N: common_vendor.o($options.handleDepartmentChange),
O: $data.clientInfo.saleName,
P: common_vendor.o(($event) => $data.clientInfo.saleName = $event.detail.value),
Q: common_assets._imports_3,
R: common_vendor.t($data.clientInfo.appOrderCarList[0].carSeries || "请选择车辆品牌 >"),
S: common_vendor.o((...args) => $options.getCar && $options.getCar(...args)),
T: $data.clientInfo.appOrderCarList[0].carModel,
U: common_vendor.o(($event) => $data.clientInfo.appOrderCarList[0].carModel = $event.detail.value),
V: $data.clientInfo.appOrderCarList[0].vin,
W: common_vendor.o(($event) => $data.clientInfo.appOrderCarList[0].vin = $event.detail.value),
X: common_vendor.t($data.clientInfo.appOrderCarList[0].carType || "请选择车辆类型 >"),
Y: common_vendor.o((...args) => $options.bindCarBrandChanges && $options.bindCarBrandChanges(...args)),
Z: $data.carBrandIndex,
aa: $data.carType,
ab: common_vendor.t($data.clientInfo.appOrderCarList[0].useType || "请选择使用性质 >"),
ac: common_vendor.o((...args) => $options.binduseTypeChanges && $options.binduseTypeChanges(...args)),
ad: $data.useTypeIndex,
ae: $data.useType,
af: common_vendor.w(({
checked
}, s0, i0) => {
return {
a: checked,
b: !checked,
c: i0,
d: s0
};
}, {
name: "icon",
path: "af",
vueId: "2d7e3f76-8,2d7e3f76-7"
}),
ag: common_assets._imports_0$4,
ah: common_assets._imports_1$3,
ai: common_vendor.p({
checked: $data.clientInfo.appOrderCarList[0].newCar == 1 ? true : false,
value: "是",
label: "是",
fontSize: "1rem"
}),
aj: common_vendor.w(({
checked
}, s0, i0) => {
return {
a: checked,
b: !checked,
c: i0,
d: s0
};
}, {
name: "icon",
path: "aj",
vueId: "2d7e3f76-9,2d7e3f76-7"
}),
ak: common_assets._imports_0$4,
al: common_assets._imports_1$3,
am: common_vendor.p({
checked: $data.clientInfo.appOrderCarList[0].newCar == 0 ? true : false,
value: "否",
label: "否",
fontSize: "1rem"
}),
an: common_vendor.o($options.onChanges),
ao: $data.clientInfo.appOrderCarList[0].carNo,
ap: common_vendor.o(($event) => $data.clientInfo.appOrderCarList[0].carNo = $event.detail.value),
aq: $data.clientInfo.appOrderCarList[0].engineNo,
ar: common_vendor.o(($event) => $data.clientInfo.appOrderCarList[0].engineNo = $event.detail.value),
as: common_assets._imports_3,
at: common_assets._imports_6,
av: common_vendor.o($options.afterRead),
aw: common_vendor.o($options.deletePic),
ax: common_vendor.p({
fileList: $data.fileList1,
name: "1",
multiple: true,
maxCount: 1
}),
ay: common_assets._imports_6,
az: common_vendor.o($options.afterRead),
aA: common_vendor.o($options.deletePic),
aB: common_vendor.p({
fileList: $data.fileList2,
name: "2",
multiple: true,
maxCount: 1
}),
aC: common_vendor.o((...args) => $options.get_to && $options.get_to(...args)),
aD: common_vendor.sei(_ctx.virtualHostId, "view")
});
}
const MiniProgramPage = /* @__PURE__ */ common_vendor._export_sfc(_sfc_main, [["render", _sfc_render], ["__scopeId", "data-v-2d7e3f76"]]);
wx.createPage(MiniProgramPage);
//# sourceMappingURL=../../../.sourcemap/mp-weixin/pages/index/PayPal_pinpai.js.map