refactor: 统一移除局部金额格式化过滤器并全局复用
1. 移除多个页面/组件内重复的moneyFormat局部过滤器 2. 将moneyFormat方法提取到全局配置中复用 3. 调整登录弹窗跳转模式适配H5场景 4. 新增open方法调试日志方便排查
This commit is contained in:
@@ -247,6 +247,15 @@ export default {
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
* 金额格式化输出
|
||||
* @param {Object} money
|
||||
*/
|
||||
moneyFormat(money) {
|
||||
if (isNaN(parseFloat(money))) return money;
|
||||
return parseFloat(money).toFixed(2);
|
||||
},
|
||||
|
||||
/**
|
||||
* 重新定向到登录授权
|
||||
* @param {String} backUrl
|
||||
@@ -255,7 +264,11 @@ export default {
|
||||
redirectTologin(backUrl = '', params = {}) {
|
||||
setTimeout(() => {
|
||||
this.$nextTick(() => {
|
||||
this.$refs?.login?.open(backUrl, 'redirectTo');
|
||||
let mode = 'navigateTo';
|
||||
// #ifdef H5
|
||||
mode = 'redirectTo';
|
||||
// #endif
|
||||
this.$refs?.login?.open(backUrl, mode);
|
||||
});
|
||||
}, 0);
|
||||
}
|
||||
|
||||
@@ -77,7 +77,7 @@ export default {
|
||||
// 鸿蒙下 ArkUI 对 slot 内 Vue 响应式更新失效,数据加载后强制重建 slot DOM
|
||||
// 通过把 listSlotKey 自增,使 :key 变化,触发整个 slot 子树销毁重建
|
||||
const oldUpCallback = this.upCallback;
|
||||
this.upCallback = function() {
|
||||
this.upCallback = () => {
|
||||
const ret = oldUpCallback.apply(this, arguments);
|
||||
// 数据回来后 200ms 自增 key,强制 slot DOM 重建
|
||||
setTimeout(() => {
|
||||
|
||||
@@ -254,6 +254,7 @@ export default {
|
||||
|
||||
// 打开弹窗
|
||||
open(url = '', mode = 'navigateTo') {
|
||||
console.log(`------> ns-login.open`, url);
|
||||
if (url) this.url = url;
|
||||
// #ifdef MP-WEIXIN
|
||||
this.getCode(authData => {
|
||||
|
||||
@@ -576,10 +576,6 @@ export default {
|
||||
else if (disX < 0) cartIndex.edit = false;
|
||||
this.$forceUpdate();
|
||||
},
|
||||
moneyFormat(money) {
|
||||
if (isNaN(parseFloat(money))) return money;
|
||||
return parseFloat(money).toFixed(2);
|
||||
},
|
||||
refreshSkuDetail(goodsSkuDetail) {
|
||||
this.goodsSkuDetail = goodsSkuDetail;
|
||||
},
|
||||
|
||||
@@ -1065,11 +1065,5 @@ export default {
|
||||
}
|
||||
});
|
||||
}
|
||||
},
|
||||
filters: {
|
||||
// 金额格式化输出
|
||||
moneyFormat(money) {
|
||||
return parseFloat(money).toFixed(2);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -422,10 +422,6 @@ export default {
|
||||
}
|
||||
});
|
||||
},
|
||||
moneyFormat(money) {
|
||||
if (isNaN(parseFloat(money))) return money;
|
||||
return parseFloat(money).toFixed(2);
|
||||
},
|
||||
openTips(data) {
|
||||
this.tips = data.tips;
|
||||
this.$refs.tips.open();
|
||||
|
||||
@@ -283,10 +283,6 @@
|
||||
swiperChange(e) {
|
||||
this.curr = e.detail.current;
|
||||
},
|
||||
moneyFormat(money) {
|
||||
if (isNaN(parseFloat(money))) return money;
|
||||
return parseFloat(money).toFixed(2);
|
||||
},
|
||||
openTips(data) {
|
||||
this.tips = data.tips;
|
||||
this.$refs.tips.open();
|
||||
|
||||
@@ -571,11 +571,5 @@ export default {
|
||||
this.getOrderPaymentData();
|
||||
}
|
||||
}
|
||||
},
|
||||
filters: {
|
||||
// 金额格式化输出
|
||||
moneyFormat(money) {
|
||||
return parseFloat(money).toFixed(2);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -288,15 +288,6 @@ export default {
|
||||
this.getPayInfo();
|
||||
}
|
||||
}
|
||||
},
|
||||
filters: {
|
||||
/**
|
||||
* 金额格式化输出
|
||||
* @param {Object} money
|
||||
*/
|
||||
moneyFormat(money) {
|
||||
return parseFloat(money).toFixed(2);
|
||||
}
|
||||
}
|
||||
};
|
||||
</script>
|
||||
|
||||
Reference in New Issue
Block a user