Commit 47161e0d by chenwq

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

1 parent eec09bac
......@@ -18,4 +18,11 @@ module.exports = {
...data,
});
},
/**查询发拍单详情 */
getAuctionDetail(data) {
return api.get({
method: "/rest/audit/detail/" + data.id,
...data,
});
},
};
// packageIndex/pages/editOrder/index/index.js
import homeApi from "~/api/module/home.js";
import * as constantList from "../components/constant/constantList.js";
Page({
/**
* 页面的初始数据
*/
data: {
title: "新增申请",
optType: "add", // add | edit
step: "first", // first | second | third | fourth
currentStep: 1, // 当前步骤:1-基本信息 | 2-车辆详情 | 3-价格设置 | 4-照片上传
isEdit: true,
......@@ -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) {
let navBarHeight = e.detail.height;
......@@ -66,6 +81,61 @@ Page({
*/
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() {
this.saveOrderData("draft");
},
......@@ -84,16 +154,16 @@ Page({
if (this.data.currentStep === 1) {
this.firstStepSubmit();
return;
}
}
if (this.data.currentStep === 2) {
const secondStepComp = this.selectComponent('#SecondStep');
const secondStepComp = this.selectComponent("#SecondStep");
if (secondStepComp) {
const errorObj = secondStepComp.validate();
if (errorObj) return;
}
}
if (this.data.currentStep === 3) {
const thirdStepComp = this.selectComponent('#ThirdStep');
const thirdStepComp = this.selectComponent("#ThirdStep");
if (thirdStepComp) {
const errorObj = thirdStepComp.validate();
if (errorObj) return;
......@@ -119,7 +189,7 @@ Page({
handleSubmitOrder() {
if (this.data.currentStep === 4) {
const fourthStepComp = this.selectComponent('#FourthStep');
const fourthStepComp = this.selectComponent("#FourthStep");
if (fourthStepComp) {
const errorObj = fourthStepComp.validate();
if (errorObj) return;
......
......@@ -122,6 +122,7 @@ Page({
toggleOfflineDialog() {
this.setData({ showOfflineDialog: !this.data.showOfflineDialog });
},
// 下架车辆
offlineCar(e) {
const id =
e.detail && e.detail.id ? e.detail.id : e.currentTarget.dataset.id;
......@@ -143,17 +144,22 @@ Page({
wx.hideLoading();
});
},
// 编辑发拍单
editAuction(e) {
const 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: e.detail && e.detail.id ? e.detail.id : e.currentTarget.dataset.id,
optType: "edit",
});
},
// 重新发拍
republish(e) {
const id =
e.detail && e.detail.id ? e.detail.id : e.currentTarget.dataset.id;
const id = e.detail && e.detail.id ? e.detail.id : e.currentTarget.dataset.id;
wx.p.router.go(`/packageIndex/pages/editOrder/index/index?id=${id}`);
},
// 新增发拍单
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 @@
statusMap="{{statusMap}}"
bind:viewDetail="viewDetail"
bind:offlineCar="offlineCar"
bind:editAuction="editAuction"
bind:republish="republish"
>
</auction-card>
<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!