This commit is contained in:
aihe 2024-07-31 01:52:23 +08:00
parent 6d9e6a2b16
commit dbf3df828f

View File

@ -49,7 +49,7 @@
<u-row custom-style="margin-top:20rpx;" justify="between">
<!-- <u-row>
<text class="pr-20 clr-sub">默认地址</text>
<u-switch v-model="item.blDefaultFlag" @change="handleDefaultSwitch(item)" activeValue="1" active-color="#B12D29" size="34"></u-switch>
<u-switch v-model="item.blDefaultFlag" @change="handleDefaultSwitch(item)" activeValue="1" inactiveValue="0" active-color="#B12D29" size="34"></u-switch>
</u-row> -->
<u-row>
<u-text @click="handleEditItem(item)" text="编辑" prefixIcon="edit-pen" size="26"></u-text>
@ -168,14 +168,17 @@
}
},
async handleDefaultSwitch(item) {
try{
await apiService.setDefaultAddressById({ id: item.id, defaultFlag: Number(!!item.blDefaultFlag), _loading: true })
this.showToast('操作成功')
this.$refs.listRef.getDataList(true) // 重置到第一页数据
}catch(e){
// 操作失败,切回按钮状态
item.blDefaultFlag = !item.blDefaultFlag
}
setTimeout(async ()=> {
let blDefaultFlag = item.blDefaultFlag
try{
await apiService.setDefaultAddressById({ id: item.id, defaultFlag: blDefaultFlag, _loading: true })
this.showToast('操作成功')
this.$refs.listRef.getDataList(true) // 重置到第一页数据
}catch(e){
// 操作失败,切回按钮状态
item.blDefaultFlag = Number(!Number(blDefaultFlag)) + ''
}
},300)
},
}
}