refactor: 优化订单填写页面和评价组件的逻辑与样式

- 移除不必要的返回监听逻辑,简化页面返回处理
- 更新不支持运费提示的显示方式,使用文本替代列表
- 改进评价组件的初始化逻辑,确保更好的用户体验
- 统一数据结构,提升代码可读性
This commit is contained in:
pikachu1995@126.com
2026-07-06 14:15:06 +08:00
parent 90ee7d5b1d
commit 6198a6d244
3 changed files with 47 additions and 74 deletions

28
App.vue
View File

@@ -33,34 +33,8 @@ import {
/** /**
* 监听返回 * 监听返回(页面级 onBackPress 在 App.vue 不生效,保留空实现避免误导)
*/ */
onBackPress(e) {
console.log("onBackPress-APP", e);
if (e.from == "backbutton") {
let routes = getCurrentPages();
let curRoute = routes[routes.length - 1].options;
routes.forEach((item) => {
if (
item.route == "pages/tabbar/cart/cartList" ||
item.route.indexOf("pages/product/goods") != -1
) {
uni.redirectTo({
url: item.route,
});
}
});
if (curRoute.addId) {
uni.reLaunch({
url: "/pages/tabbar/cart/cartList",
});
} else {
uni.navigateBack();
}
return true; //阻止默认返回行为
}
},
onLaunch: function(val) { onLaunch: function(val) {
if(val.query.inviter){ if(val.query.inviter){
storage.setInviter(val.query.inviter) storage.setInviter(val.query.inviter)

View File

@@ -342,9 +342,8 @@
<div class="notSupportFreight" v-if="notSupportFreight.length != 0"> <div class="notSupportFreight" v-if="notSupportFreight.length != 0">
<u-notice-bar <u-notice-bar
style="width: 100%" style="width: 100%"
:volume-icon="false" icon=""
mode="horizontal" :text="notSupportFreightNoticeText"
:list="notSupportFreightGoodsList"
> >
</u-notice-bar> </u-notice-bar>
</div> </div>
@@ -443,7 +442,7 @@ export default {
masterWay: "", //团长信息 masterWay: "", //团长信息
pintuanFlage: true, //是开团还是拼团 pintuanFlage: true, //是开团还是拼团
notSupportFreight: [], //不支持运费 notSupportFreight: [], //不支持运费
notSupportFreightGoodsList: ["以下商品超出配送范围:"], notSupportFreightNoticeText: "",
storeAddress: "", storeAddress: "",
originOrderData:"", // 原始订单数据 originOrderData:"", // 原始订单数据
@@ -466,29 +465,20 @@ export default {
* 监听返回 * 监听返回
*/ */
onBackPress(e) { onBackPress(e) {
console.log("onBackPress", e);
if (e.from == "backbutton") { if (e.from == "backbutton") {
let routes = getCurrentPages(); const curRoute = getCurrentPages().slice(-1)[0]?.options || {};
let curRoute = routes[routes.length - 1].options;
routes.forEach((item) => {
if (
item.route == "pages/tabbar/cart/cartList" ||
item.route.indexOf("pages/product/goods") != -1
) {
uni.navigateTo({
url: item.route,
});
}
});
console.log("curRoute.addId",curRoute.addId)
if (curRoute.addId) { if (curRoute.addId) {
uni.reLaunch({ uni.reLaunch({
url: "/pages/tabbar/cart/cartList", url: "/pages/tabbar/cart/cartList",
}); });
} else if (this.routerVal?.way === "CART") {
uni.switchTab({
url: "/pages/tabbar/cart/cartList",
});
} else { } else {
uni.navigateBack(); uni.navigateBack();
} }
return true; //阻止默认返回行为 return true;
} }
}, },
@@ -500,18 +490,19 @@ export default {
uni.showLoading({ uni.showLoading({
mask: true, mask: true,
}); });
await this.getOrderList(); try {
await this.getDistribution(); await this.getOrderList();
if (this.$store.state.isShowToast) { await this.getDistribution();
if (this.routerVal.way == "PINTUAN") {
this.isAssemble = true;
this.routerVal.parentOrder = JSON.parse(
decodeURIComponent(this.routerVal.parentOrder)
);
this.pintuanWay();
}
} finally {
uni.hideLoading(); uni.hideLoading();
} }
if (this.routerVal.way == "PINTUAN") {
this.isAssemble = true;
this.routerVal.parentOrder = JSON.parse(
decodeURIComponent(this.routerVal.parentOrder)
);
this.pintuanWay();
}
}, },
mounted() {}, mounted() {},
@@ -780,33 +771,31 @@ export default {
}, },
// 获取结算参数 // 获取结算参数
async getOrderList() { getOrderList() {
this.notSupportFreight = []; this.notSupportFreight = [];
// 获取结算参数 this.notSupportFreightNoticeText = "";
API_Trade.getCheckoutParams(this.routerVal.way).then((res) => { return API_Trade.getCheckoutParams(this.routerVal.way).then((res) => {
// 获取结算参数 进行首次判断 // 获取结算参数 进行首次判断
this.originOrderData = this.orderMessage ? JSON.parse(JSON.stringify(this.orderMessage)) : "" this.originOrderData = this.orderMessage
? JSON.parse(JSON.stringify(this.orderMessage))
: null;
if ( if (
!res.data.result.checkedSkuList || !res.data.result.checkedSkuList ||
res.data.result.checkedSkuList.length === 0 res.data.result.checkedSkuList.length === 0
) { ) {
if (!this.originOrderData?.checkedSkuList?.length) {
if(!this.originOrderData.checkedSkuList.length){
uni.switchTab({ uni.switchTab({
url: "/pages/tabbar/cart/cartList", url: "/pages/tabbar/cart/cartList",
}); });
} }
} }
if (res.data.result.skuList.length <= 0) { if (res.data.result.skuList.length <= 0) {
if (!this.originOrderData?.skuList?.length) {
if(!this.originOrderData.skuList.length){
uni.navigateTo({ uni.navigateTo({
url: "/pages/order/myOrder?status=0", url: "/pages/order/myOrder?status=0",
}); });
} }
} }
let repeatData; let repeatData;
@@ -849,9 +838,9 @@ export default {
res.data.result.notSupportFreight.length != 0 res.data.result.notSupportFreight.length != 0
) { ) {
this.notSupportFreight = res.data.result.notSupportFreight; this.notSupportFreight = res.data.result.notSupportFreight;
this.notSupportFreightNoticeText = "以下商品超出配送范围:";
res.data.result.notSupportFreight.forEach((item) => { res.data.result.notSupportFreight.forEach((item) => {
this.notSupportFreightGoodsList[0] += item.goodsSku.goodsName; this.notSupportFreightNoticeText += item.goodsSku.goodsName;
}); });
} }
}); });

View File

@@ -26,7 +26,7 @@
text-indent="0" text-indent="0"
:show-height="120" :show-height="120"
> >
<rich-text @load="parseLoaded(commIndex)" :nodes="commItem.content" class="con"></rich-text> <rich-text :nodes="commItem.content" class="con"></rich-text>
</u-read-more> </u-read-more>
<scroll-view scroll-x class="scroll-x" v-if="commentImages(commItem).length"> <scroll-view scroll-x class="scroll-x" v-if="commentImages(commItem).length">
<view class="img-list"> <view class="img-list">
@@ -70,7 +70,8 @@ export default {
data() { data() {
return { return {
lightColor: this.$lightColor, lightColor: this.$lightColor,
commDetail: [], commDetail: {},
readMoreInited: {},
grade: "", grade: "",
params: { params: {
pageNumber: 1, pageNumber: 1,
@@ -106,18 +107,27 @@ export default {
return typeof images === "string" ? images.split(",").filter(Boolean) : images; return typeof images === "string" ? images.split(",").filter(Boolean) : images;
}, },
parseLoaded(index) { initReadMore(index) {
if (this.readMoreInited[index]) return;
this.readMoreInited[index] = true;
this.$nextTick(() => { this.$nextTick(() => {
const refs = this.$refs.uReadMore; const refs = this.$refs.uReadMore;
const target = Array.isArray(refs) ? refs[index] : refs; const target = Array.isArray(refs) ? refs[index] : refs;
target && target.init && target.init(); target?.init?.();
}); });
}, },
getGoodsCommentsMethods() { getGoodsCommentsMethods() {
if (!this.goodsDetail.goodsId) return; if (!this.goodsDetail.goodsId) return;
API_Members.getGoodsComments(this.goodsDetail.goodsId, this.params).then((res) => { API_Members.getGoodsComments(this.goodsDetail.goodsId, this.params).then((res) => {
this.commDetail = res.data.result; this.readMoreInited = {};
this.commDetail = res.data.result || {};
this.$nextTick(() => {
const records = this.commDetail.records || [];
records.slice(0, 2).forEach((_, index) => {
setTimeout(() => this.initReadMore(index), 50 * (index + 1));
});
});
}); });
}, },