Commit 47161e0d by chenwq

新增发拍单详情查询功能,优化相关页面逻辑和交互

1 parent eec09bac
...@@ -18,4 +18,11 @@ module.exports = { ...@@ -18,4 +18,11 @@ module.exports = {
...data, ...data,
}); });
}, },
/**查询发拍单详情 */
getAuctionDetail(data) {
return api.get({
method: "/rest/audit/detail/" + data.id,
...data,
});
},
}; };
// packageIndex/pages/editOrder/index/index.js // packageIndex/pages/editOrder/index/index.js
import homeApi from "~/api/module/home.js"; import homeApi from "~/api/module/home.js";
import * as constantList from "../components/constant/constantList.js";
Page({ Page({
/** /**
* 页面的初始数据 * 页面的初始数据
*/ */
data: { data: {
title: "新增申请", title: "新增申请",
optType: "add", // add | edit
step: "first", // first | second | third | fourth step: "first", // first | second | third | fourth
currentStep: 1, // 当前步骤:1-基本信息 | 2-车辆详情 | 3-价格设置 | 4-照片上传 currentStep: 1, // 当前步骤:1-基本信息 | 2-车辆详情 | 3-价格设置 | 4-照片上传
isEdit: true, isEdit: true,
...@@ -22,7 +24,20 @@ Page({ ...@@ -22,7 +24,20 @@ Page({
/** /**
* 生命周期函数--监听页面加载 * 生命周期函数--监听页面加载
*/ */
onLoad(options) {}, onLoad(options) {
console.log(constantList);
wx.p.router.getRouterParams(options).then((params) => {
console.log("路由参数:", params);
this.setData({
["formData.id"]: params.id || null, // 编辑时会有id,新增时为null
title: params.optType == "edit" ? "编辑申请" : "新增申请",
optType: params.optType || "add",
});
if (params.optType == "edit") {
this.getDetail();
}
});
},
navbarReady(e) { navbarReady(e) {
let navBarHeight = e.detail.height; let navBarHeight = e.detail.height;
...@@ -66,6 +81,61 @@ Page({ ...@@ -66,6 +81,61 @@ Page({
*/ */
onShareAppMessage() {}, onShareAppMessage() {},
dealReturnData() {
let { formData } = this.data;
const selectAttrList = [
{
name: "transmissionType",
listName: "transmissionTypeList",
},
{
name: "vehicleNature",
listName: "vehicleNatureList",
},
{
name: "fuelType",
listName: "fuelTypeList",
},
{
name: "bodyColor",
listName: "bodyColorList",
},
{
name: "interiorColor",
listName: "interiorColorList",
},
];
selectAttrList.forEach((attr) => {
if (formData[attr.name]) {
formData[`${attr.name}Name`] = constantList[attr.listName].find(
(item) => item.value == formData[attr.name]
)?.name;
}
});
formData.carCityName = formData.provinceName + " " + formData.cityName;
this.setData({
formData,
});
},
getDetail() {
const { id } = this.data.formData;
if (!id) return;
wx.showLoading({ title: "加载中...", mask: true });
homeApi
.getAuctionDetail({ id })
.then((res) => {
wx.hideLoading();
this.setData({
formData: res || {},
});
this.dealReturnData();
console.log("获取详情:", res);
})
.catch(() => {
wx.hideLoading();
});
},
handleSaveDraft() { handleSaveDraft() {
this.saveOrderData("draft"); this.saveOrderData("draft");
}, },
...@@ -84,16 +154,16 @@ Page({ ...@@ -84,16 +154,16 @@ Page({
if (this.data.currentStep === 1) { if (this.data.currentStep === 1) {
this.firstStepSubmit(); this.firstStepSubmit();
return; return;
} }
if (this.data.currentStep === 2) { if (this.data.currentStep === 2) {
const secondStepComp = this.selectComponent('#SecondStep'); const secondStepComp = this.selectComponent("#SecondStep");
if (secondStepComp) { if (secondStepComp) {
const errorObj = secondStepComp.validate(); const errorObj = secondStepComp.validate();
if (errorObj) return; if (errorObj) return;
} }
} }
if (this.data.currentStep === 3) { if (this.data.currentStep === 3) {
const thirdStepComp = this.selectComponent('#ThirdStep'); const thirdStepComp = this.selectComponent("#ThirdStep");
if (thirdStepComp) { if (thirdStepComp) {
const errorObj = thirdStepComp.validate(); const errorObj = thirdStepComp.validate();
if (errorObj) return; if (errorObj) return;
...@@ -119,7 +189,7 @@ Page({ ...@@ -119,7 +189,7 @@ Page({
handleSubmitOrder() { handleSubmitOrder() {
if (this.data.currentStep === 4) { if (this.data.currentStep === 4) {
const fourthStepComp = this.selectComponent('#FourthStep'); const fourthStepComp = this.selectComponent("#FourthStep");
if (fourthStepComp) { if (fourthStepComp) {
const errorObj = fourthStepComp.validate(); const errorObj = fourthStepComp.validate();
if (errorObj) return; if (errorObj) return;
......
...@@ -122,6 +122,7 @@ Page({ ...@@ -122,6 +122,7 @@ Page({
toggleOfflineDialog() { toggleOfflineDialog() {
this.setData({ showOfflineDialog: !this.data.showOfflineDialog }); this.setData({ showOfflineDialog: !this.data.showOfflineDialog });
}, },
// 下架车辆
offlineCar(e) { offlineCar(e) {
const id = const id =
e.detail && e.detail.id ? e.detail.id : e.currentTarget.dataset.id; e.detail && e.detail.id ? e.detail.id : e.currentTarget.dataset.id;
...@@ -143,17 +144,22 @@ Page({ ...@@ -143,17 +144,22 @@ Page({
wx.hideLoading(); wx.hideLoading();
}); });
}, },
// 编辑发拍单
editAuction(e) { editAuction(e) {
const id = wx.p.router.go(`/packageIndex/pages/editOrder/index/index`, {
e.detail && e.detail.id ? e.detail.id : e.currentTarget.dataset.id; id: e.detail && e.detail.id ? e.detail.id : e.currentTarget.dataset.id,
wx.p.router.go(`/packageIndex/pages/editOrder/index/index?id=${id}`); optType: "edit",
});
}, },
// 重新发拍
republish(e) { republish(e) {
const id = const id = e.detail && e.detail.id ? e.detail.id : e.currentTarget.dataset.id;
e.detail && e.detail.id ? e.detail.id : e.currentTarget.dataset.id;
wx.p.router.go(`/packageIndex/pages/editOrder/index/index?id=${id}`); wx.p.router.go(`/packageIndex/pages/editOrder/index/index?id=${id}`);
}, },
// 新增发拍单
addAuction() { addAuction() {
wx.p.router.go("/packageIndex/pages/editOrder/index/index"); wx.p.router.go("/packageIndex/pages/editOrder/index/index", {
optType: "add",
});
}, },
}); });
...@@ -56,6 +56,8 @@ ...@@ -56,6 +56,8 @@
statusMap="{{statusMap}}" statusMap="{{statusMap}}"
bind:viewDetail="viewDetail" bind:viewDetail="viewDetail"
bind:offlineCar="offlineCar" bind:offlineCar="offlineCar"
bind:editAuction="editAuction"
bind:republish="republish"
> >
</auction-card> </auction-card>
<view class="loading-text">{{isLastPage ? '到底了~' : '加载中...'}}</view> <view class="loading-text">{{isLastPage ? '到底了~' : '加载中...'}}</view>
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!