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) {
if(val.query.inviter){
storage.setInviter(val.query.inviter)

View File

@@ -342,9 +342,8 @@
<div class="notSupportFreight" v-if="notSupportFreight.length != 0">
<u-notice-bar
style="width: 100%"
:volume-icon="false"
mode="horizontal"
:list="notSupportFreightGoodsList"
icon=""
:text="notSupportFreightNoticeText"
>
</u-notice-bar>
</div>
@@ -443,7 +442,7 @@ export default {
masterWay: "", //团长信息
pintuanFlage: true, //是开团还是拼团
notSupportFreight: [], //不支持运费
notSupportFreightGoodsList: ["以下商品超出配送范围:"],
notSupportFreightNoticeText: "",
storeAddress: "",
originOrderData:"", // 原始订单数据
@@ -466,29 +465,20 @@ export default {
* 监听返回
*/
onBackPress(e) {
console.log("onBackPress", 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.navigateTo({
url: item.route,
});
}
});
console.log("curRoute.addId",curRoute.addId)
const curRoute = getCurrentPages().slice(-1)[0]?.options || {};
if (curRoute.addId) {
uni.reLaunch({
url: "/pages/tabbar/cart/cartList",
});
} else if (this.routerVal?.way === "CART") {
uni.switchTab({
url: "/pages/tabbar/cart/cartList",
});
} else {
uni.navigateBack();
}
return true; //阻止默认返回行为
return true;
}
},
@@ -500,18 +490,19 @@ export default {
uni.showLoading({
mask: true,
});
await this.getOrderList();
await this.getDistribution();
if (this.$store.state.isShowToast) {
try {
await this.getOrderList();
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();
}
if (this.routerVal.way == "PINTUAN") {
this.isAssemble = true;
this.routerVal.parentOrder = JSON.parse(
decodeURIComponent(this.routerVal.parentOrder)
);
this.pintuanWay();
}
},
mounted() {},
@@ -780,33 +771,31 @@ export default {
},
// 获取结算参数
async getOrderList() {
getOrderList() {
this.notSupportFreight = [];
// 获取结算参数
API_Trade.getCheckoutParams(this.routerVal.way).then((res) => {
this.notSupportFreightNoticeText = "";
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 (
!res.data.result.checkedSkuList ||
res.data.result.checkedSkuList.length === 0
) {
if(!this.originOrderData.checkedSkuList.length){
if (!this.originOrderData?.checkedSkuList?.length) {
uni.switchTab({
url: "/pages/tabbar/cart/cartList",
});
}
}
if (res.data.result.skuList.length <= 0) {
if(!this.originOrderData.skuList.length){
if (!this.originOrderData?.skuList?.length) {
uni.navigateTo({
url: "/pages/order/myOrder?status=0",
});
}
}
let repeatData;
@@ -849,9 +838,9 @@ export default {
res.data.result.notSupportFreight.length != 0
) {
this.notSupportFreight = res.data.result.notSupportFreight;
this.notSupportFreightNoticeText = "以下商品超出配送范围:";
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"
: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>
<scroll-view scroll-x class="scroll-x" v-if="commentImages(commItem).length">
<view class="img-list">
@@ -70,7 +70,8 @@ export default {
data() {
return {
lightColor: this.$lightColor,
commDetail: [],
commDetail: {},
readMoreInited: {},
grade: "",
params: {
pageNumber: 1,
@@ -106,18 +107,27 @@ export default {
return typeof images === "string" ? images.split(",").filter(Boolean) : images;
},
parseLoaded(index) {
initReadMore(index) {
if (this.readMoreInited[index]) return;
this.readMoreInited[index] = true;
this.$nextTick(() => {
const refs = this.$refs.uReadMore;
const target = Array.isArray(refs) ? refs[index] : refs;
target && target.init && target.init();
target?.init?.();
});
},
getGoodsCommentsMethods() {
if (!this.goodsDetail.goodsId) return;
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));
});
});
});
},