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.
383 lines
13 KiB
383 lines
13 KiB
"use strict"; |
|
const common_vendor = require("../../../common/vendor.js"); |
|
const api_user = require("../../../api/user.js"); |
|
const utils_utils = require("../../../utils/utils.js"); |
|
require("../../../utils/request.js"); |
|
require("../../../store/index.js"); |
|
require("../../../utils/functions.js"); |
|
require("../../../utils/IDCardVerification.js"); |
|
require("../../../utils/base64.js"); |
|
require("../../../config/host.js"); |
|
require("../../../utils/md5.js"); |
|
if (!Array) { |
|
const _easycom_u_navbar2 = common_vendor.resolveComponent("u-navbar"); |
|
const _component_tiplist = common_vendor.resolveComponent("tiplist"); |
|
(_easycom_u_navbar2 + _component_tiplist)(); |
|
} |
|
const _easycom_u_navbar = () => "../../../uni_modules/uview-plus/components/u-navbar/u-navbar.js"; |
|
if (!Math) { |
|
_easycom_u_navbar(); |
|
} |
|
const _sfc_main = /* @__PURE__ */ common_vendor.defineComponent({ |
|
__name: "CustomerSign", |
|
setup(__props) { |
|
let details = common_vendor.reactive({ |
|
items: {}, |
|
id: "", |
|
datalist: [], |
|
authbuts: [], |
|
imgList: [], |
|
isChange: false, |
|
changeImageList: [], |
|
/** |
|
* 必填照片 |
|
* "photo_1": 上门照 |
|
* "photo_2": 堆码照 |
|
* "photo_5": 签收照 |
|
*/ |
|
ImagesRequiredFields: [ |
|
{ |
|
key: "photo_1", |
|
isShowTitle: false |
|
}, |
|
{ |
|
key: "photo_2", |
|
isShowTitle: false |
|
}, |
|
{ |
|
key: "photo_5", |
|
isShowTitle: false |
|
} |
|
] |
|
}); |
|
details.authbuts = common_vendor.index.getStorageSync("authbuts") || []; |
|
const tiplists = common_vendor.ref(null); |
|
common_vendor.onLoad((op) => { |
|
details.items = JSON.parse(op.item); |
|
details.id = JSON.parse(op.item).id; |
|
}); |
|
common_vendor.onShow(() => { |
|
initpage(); |
|
getconfig(); |
|
}); |
|
common_vendor.onPullDownRefresh(() => { |
|
const timer = setTimeout(async () => { |
|
await initpage(); |
|
common_vendor.index.stopPullDownRefresh(); |
|
clearTimeout(timer); |
|
}, 500); |
|
}); |
|
async function getconfig() { |
|
let res = await api_user.dictbizdictionary({ code: "photo_type" }); |
|
console.log("res1>>>>", res); |
|
const { code, data } = res; |
|
if (code === 200) { |
|
details.imgList = data.map((value) => { |
|
return { |
|
dictKey: value.dictKey, |
|
dictValue: value.dictValue, |
|
imgList: [] |
|
}; |
|
}); |
|
console.log("details.imgList :>> ", details.imgList); |
|
} |
|
} |
|
function gosetorice(item) { |
|
common_vendor.index.navigateTo({ |
|
url: "/pagesHome/pages/SetPrice/SetPrice?reservationId=" + details.id + "&item=" + JSON.stringify(item) |
|
}); |
|
} |
|
const signNub = common_vendor.computed(() => { |
|
let num = 0; |
|
details.datalist.map((item) => { |
|
if (item.signNub) { |
|
num += item.signNub; |
|
} |
|
}); |
|
return num; |
|
}); |
|
const deliveryNumber = common_vendor.computed(() => { |
|
return details.datalist.reduce((curr, item) => { |
|
if (item.reservationNum) |
|
return curr + item.reservationNum; |
|
return curr; |
|
}, 0); |
|
}); |
|
const truckLoadingNum = common_vendor.computed(() => { |
|
return details.datalist.reduce((curr, item) => { |
|
if (item.loadedNumber) |
|
return curr + item.loadedNumber; |
|
return curr; |
|
}, 0); |
|
}); |
|
async function initpage() { |
|
let data = { |
|
id: details.id |
|
}; |
|
let response = await api_user.signforcustom(data); |
|
if (response.code !== 200) |
|
return; |
|
const _arr = response.data; |
|
const _fastArr = []; |
|
const _commonArr = []; |
|
console.log("_arr :>> ", _arr); |
|
_arr.forEach((val) => { |
|
console.log("val :>> ", val); |
|
if (Number(val.isUrgent) === 2) |
|
return _fastArr.push(val); |
|
return _commonArr.push(val); |
|
}); |
|
details.datalist = [..._fastArr, ..._commonArr]; |
|
return null; |
|
} |
|
async function uplodimg(item) { |
|
let data = { |
|
reservationId: item.id |
|
}; |
|
let res = await api_user.signforprices(data); |
|
console.log("res>>>>>", res); |
|
let imglis = [], rearks = ""; |
|
if (res.code == 200) { |
|
if (Object.keys(res.data.deliverySignPictures).length !== 0 || res.data.driverRemarks) { |
|
details.isChange = true; |
|
imglis = res.data.deliverySignPictures; |
|
details.imgList.forEach((item2, index) => { |
|
item2.imgList = []; |
|
if (!imglis[item2.dictKey]) |
|
return; |
|
details.imgList[index].imgList = imglis[item2.dictKey]; |
|
}); |
|
console.log("details.imgList :>> ", details.imgList); |
|
} else { |
|
details.isChange = false; |
|
} |
|
if (res.data.driverRemarks) { |
|
rearks = res.data.driverRemarks; |
|
} |
|
} |
|
const response = await api_user.signforSignNum({ ...data, id: details.id }); |
|
console.log("response :>> ", response); |
|
console.log("tiplists :>> ", tiplists.value); |
|
tiplists.value.setdetails({ |
|
title: "请上传签收图片", |
|
isshow: true, |
|
tipstate: 3, |
|
placeholder: "请填写备注", |
|
confirmTxt: "确认", |
|
inputtext: rearks, |
|
imglist: details.imgList, |
|
maximglength: 20, |
|
isChange: details.isChange, |
|
changeImageList: details.changeImageList, |
|
ImagesRequiredFields: details.ImagesRequiredFields, |
|
success: async (detail) => { |
|
console.log("detail :>> ", detail); |
|
let data2 = { |
|
deliveryId: details.id, |
|
reservationId: item.id, |
|
map: {}, |
|
driverRemarks: detail.inputtext |
|
}; |
|
let res2 = null; |
|
let isSubmit = true; |
|
console.log("details.ImagesRequiredFields :>> ", details.ImagesRequiredFields); |
|
if (details.isChange) { |
|
const filterMap = detail.imglist.filter((item2) => details.changeImageList.includes(item2.dictKey)); |
|
isSubmit = filterMap.every((item2) => { |
|
data2.map[item2.dictKey] = item2.imgList; |
|
if (details.ImagesRequiredFields.find((val) => val.key === item2.dictKey) && item2.imgList.length < 1) |
|
return false; |
|
return true; |
|
}); |
|
if (!isSubmit) { |
|
common_vendor.index.showToast({ |
|
title: "请根据要求上传照片", |
|
icon: "none" |
|
}); |
|
utils_utils.utils.ttsspke("必传照片不足"); |
|
return; |
|
} |
|
res2 = await api_user.signforUpdatePicture(data2); |
|
} else { |
|
console.log("details.imgList :>> ", details.imgList); |
|
detail.imglist.forEach((item2) => { |
|
data2.map[item2.dictKey] = item2.imgList; |
|
console.log(2); |
|
console.log("item.imgList :>> ", item2.imgList); |
|
if (details.ImagesRequiredFields.find((val) => val.key === item2.dictKey) && item2.imgList.length < 1) |
|
isSubmit = false; |
|
else |
|
isSubmit = true; |
|
}); |
|
if (!isSubmit) { |
|
common_vendor.index.showToast({ |
|
title: "请根据要求上传照片", |
|
icon: "none" |
|
}); |
|
utils_utils.utils.ttsspke("必传照片不足"); |
|
return; |
|
} |
|
res2 = await api_user.signforsignforack(data2); |
|
} |
|
if (res2.code == 200) { |
|
initpage(); |
|
common_vendor.index.showToast({ |
|
title: res2.msg, |
|
icon: "none" |
|
}); |
|
} |
|
tiplists.value.setdetails({ isshow: false }); |
|
}, |
|
cancel: () => { |
|
tiplists.value.setdetails({ isshow: false }); |
|
}, |
|
close: () => { |
|
tiplists.value.setdetails({ isshow: false }); |
|
} |
|
}); |
|
} |
|
async function allclick(item) { |
|
tiplists.value.setdetails({ |
|
isshow: true, |
|
tipstate: 3, |
|
placeholder: "请填写备注", |
|
confirmTxt: "确认批量签收", |
|
inputtext: "", |
|
imglist: [], |
|
maximglength: 20, |
|
success: async (detail) => { |
|
try { |
|
common_vendor.index.showLoading({ |
|
title: "提交中", |
|
mask: true |
|
}); |
|
let data = { |
|
deliveryId: details.id, |
|
reservationId: item.id, |
|
deliverySignPictures: detail.imglist.join(","), |
|
driverRemarks: detail.inputtext |
|
}; |
|
let res = await api_user.signforoneclick(data); |
|
if (res.code == 200) { |
|
common_vendor.index.showToast({ |
|
title: "签收成功", |
|
icon: "none" |
|
}); |
|
initpage(); |
|
} |
|
} catch (e) { |
|
} finally { |
|
common_vendor.index.hideLoading(); |
|
tiplists.value.setdetails({ isshow: false }); |
|
} |
|
}, |
|
cancel: () => { |
|
tiplists.value.setdetails({ isshow: false }); |
|
}, |
|
close: () => { |
|
tiplists.value.setdetails({ isshow: false }); |
|
} |
|
}); |
|
} |
|
function getLocation(item) { |
|
console.log("getLocation-------"); |
|
common_vendor.index.getLocation({ |
|
type: "wgs84", |
|
geocode: true, |
|
isHighAccuracy: true, |
|
success: async function(res) { |
|
try { |
|
common_vendor.index.showLoading({ |
|
title: "打卡中", |
|
mask: true |
|
}); |
|
console.log(JSON.stringify(res)); |
|
console.log("当前位置的经度:" + res.longitude); |
|
console.log("当前位置的纬度:" + res.latitude); |
|
let data = { |
|
deliveryId: details.id, |
|
reservationId: item.id, |
|
positioning: res.longitude + "," + res.latitude, |
|
positioningAdr: "" |
|
}; |
|
let response = await api_user.signforpositioning(data); |
|
console.log(response); |
|
if (response.code == 200) { |
|
initpage(); |
|
} |
|
} catch (err) { |
|
console.log("err :>> ", err); |
|
} finally { |
|
common_vendor.index.hideLoading(); |
|
} |
|
}, |
|
fail: (err) => { |
|
common_vendor.index.showToast({ |
|
title: "定位失败", |
|
icon: "none" |
|
}); |
|
console.log(err); |
|
common_vendor.index.hideLoading(); |
|
} |
|
}); |
|
} |
|
function gosinorderscan(item) { |
|
common_vendor.index.navigateTo({ |
|
url: "/pagesHome/pages/signOrderScan/signOrderScan?item=" + JSON.stringify(item) + "&deliveryId=" + details.id |
|
}); |
|
} |
|
const { authbuts, items, datalist } = common_vendor.toRefs(details); |
|
return (_ctx, _cache) => { |
|
return { |
|
a: common_vendor.p({ |
|
title: "客户签收", |
|
bgColor: "#D3832A", |
|
leftIconColor: "#ffffff", |
|
titleStyle: "color:#ffffff", |
|
placeholder: true, |
|
autoBack: true, |
|
leftIconSize: "35" |
|
}), |
|
b: common_vendor.t(common_vendor.unref(items).type_name), |
|
c: common_vendor.t(common_vendor.unref(items).deliStatus_name), |
|
d: common_vendor.t(common_vendor.unref(items).vehicleName), |
|
e: common_vendor.t(common_vendor.unref(items).driverName), |
|
f: common_vendor.t(common_vendor.unref(items).loadingTeamName), |
|
g: common_vendor.t(common_vendor.unref(items).isstock), |
|
h: common_vendor.t(common_vendor.unref(items).customersNumber), |
|
i: common_vendor.t(common_vendor.unref(items).orderNumber), |
|
j: common_vendor.t(common_vendor.unref(deliveryNumber)), |
|
k: common_vendor.t(common_vendor.unref(truckLoadingNum)), |
|
l: common_vendor.t(common_vendor.unref(signNub)), |
|
m: common_vendor.f(common_vendor.unref(datalist), (item, k0, i0) => { |
|
return common_vendor.e({ |
|
a: common_vendor.t(item.consignee), |
|
b: common_vendor.t(item.isUrgent == "2" ? "(加急)" : ""), |
|
c: common_vendor.s(item.isUrgent == "2" ? "color: red;" : ""), |
|
d: common_vendor.t(item.deliveryStatus), |
|
e: common_vendor.t(item.ordNub), |
|
f: common_vendor.t(item.reservationNum), |
|
g: common_vendor.t(item.signNub), |
|
h: common_vendor.t(item.deliveryPhone || ""), |
|
i: common_vendor.t(item.deliveryAddress || ""), |
|
j: common_vendor.t(item.remarks), |
|
k: common_vendor.t(item.positioning == 1 ? "已打卡" : "定位打卡"), |
|
l: common_vendor.n(item.positioning == 1 ? "ydk" : ""), |
|
m: common_vendor.o(($event) => getLocation(item)), |
|
n: common_vendor.o(($event) => gosinorderscan(item)), |
|
o: common_vendor.o(($event) => uplodimg(item)), |
|
p: common_vendor.o(($event) => gosetorice(item)), |
|
q: common_vendor.unref(authbuts).findIndex((val) => val.code === "127") != -1 && item.deliveryStatus != "完成配送" |
|
}, common_vendor.unref(authbuts).findIndex((val) => val.code === "127") != -1 && item.deliveryStatus != "完成配送" ? { |
|
r: common_vendor.o(($event) => allclick(item)) |
|
} : {}); |
|
}), |
|
n: common_vendor.sr(tiplists, "1f112ba4-1", { |
|
"k": "tiplists" |
|
}) |
|
}; |
|
}; |
|
} |
|
}); |
|
const MiniProgramPage = /* @__PURE__ */ common_vendor._export_sfc(_sfc_main, [["__file", "D:/worksp/logpm/pagesHome/pages/CustomerSign/CustomerSign.vue"]]); |
|
wx.createPage(MiniProgramPage);
|
|
|