Commit 623ecf2c by chenwq

refactor(storeCredit): 优化异步请求处理并添加加载状态

在created钩子中将async/await改为Promise链式调用,并添加loading状态管理
在handleConfirm方法中增加loading状态检查防止重复提交
移除调试用的console.log语句
1 parent cf957e42
...@@ -364,18 +364,19 @@ export default { ...@@ -364,18 +364,19 @@ export default {
} }
} }
}, },
async created() { created() {
/** loginpath:标识系统 /** loginpath:标识系统
* 门店版:/login * 门店版:/login
* 1、默认带出商户,“选择商户”按钮置灰 * 1、默认带出商户,“选择商户”按钮置灰
* 2、导入充值人群,去掉“管理层” * 2、导入充值人群,去掉“管理层”
* 运营版:/oss * 运营版:/oss
*/ */
if(this.$globalState.session.loginpath == '/login') { if (this.$globalState.session.loginpath == '/login') {
this.baseData.personTypeList.splice(1, 1) this.baseData.personTypeList.splice(1, 1)
this.configForm.merchantId = this.$globalState.session.merchantId this.configForm.merchantId = this.$globalState.session.merchantId
this.configForm.merchantName = this.$globalState.session.merchantName this.configForm.merchantName = this.$globalState.session.merchantName
const res = await this.$apis.points.getMerchantCharge({ merchantId: this.configForm.merchantId }) this.loading = true
this.$apis.points.getMerchantCharge({ merchantId: this.configForm.merchantId }).then(res => {
if (res) { if (res) {
this.totalFormData.map(e => { this.totalFormData.map(e => {
if (['gasCardServiceCharge', 'passageServiceCharge'].includes(e.name)) { if (['gasCardServiceCharge', 'passageServiceCharge'].includes(e.name)) {
...@@ -385,6 +386,9 @@ export default { ...@@ -385,6 +386,9 @@ export default {
} }
}) })
} }
}).finally(() => {
this.loading = false
})
} }
}, },
mounted() { mounted() {
...@@ -436,7 +440,7 @@ export default { ...@@ -436,7 +440,7 @@ export default {
handleConfirm() { handleConfirm() {
const { disabled, id } = this.pageObject const { disabled, id } = this.pageObject
if (disabled) return this.$router.go(-1) if (disabled) return this.$router.go(-1)
if(this.loading) { if (this.loading) {
return true return true
} }
this.$refs.fromRef.$refs.formRef.validate(async valid => { this.$refs.fromRef.$refs.formRef.validate(async valid => {
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!