refactor: 将地址操作的点击事件替换为tap事件并添加调试日志。
This commit is contained in:
parent
6183fcaf15
commit
4249ad3954
@ -52,17 +52,17 @@
|
|||||||
|
|
||||||
<!-- 操作栏 -->
|
<!-- 操作栏 -->
|
||||||
<view class="addr-actions">
|
<view class="addr-actions">
|
||||||
<view class="action-left" @click.stop="onSetDefault(item)">
|
<view class="action-left" @tap.stop="onSetDefault(item)">
|
||||||
<view class="radio-circle" :class="{ checked: item.is_default }"></view>
|
<view class="radio-circle" :class="{ checked: item.is_default }"></view>
|
||||||
<text class="action-text">{{ item.is_default ? '默认地址' : '设为默认' }}</text>
|
<text class="action-text">{{ item.is_default ? '默认地址' : '设为默认' }}</text>
|
||||||
</view>
|
</view>
|
||||||
|
|
||||||
<view class="action-right">
|
<view class="action-right">
|
||||||
<view class="action-btn" @click.stop="toEdit(item)">
|
<view class="action-btn" @tap.stop="toEdit(item)">
|
||||||
<text class="btn-icon">✎</text>
|
<text class="btn-icon">✎</text>
|
||||||
<text>编辑</text>
|
<text>编辑</text>
|
||||||
</view>
|
</view>
|
||||||
<view class="action-btn delete" @click.stop="onDelete(item)">
|
<view class="action-btn delete" @tap.stop="onDelete(item)">
|
||||||
<text class="btn-icon">🗑</text>
|
<text class="btn-icon">🗑</text>
|
||||||
<text>删除</text>
|
<text>删除</text>
|
||||||
</view>
|
</view>
|
||||||
@ -140,13 +140,19 @@ function onDelete(item) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
async function onSetDefault(item) {
|
async function onSetDefault(item) {
|
||||||
if (item.is_default) return
|
console.log('onSetDefault called', item.id, 'is_default:', item.is_default)
|
||||||
|
if (item.is_default) {
|
||||||
|
console.log('Already default, skipping')
|
||||||
|
return
|
||||||
|
}
|
||||||
try {
|
try {
|
||||||
const user_id = uni.getStorageSync('user_id')
|
const user_id = uni.getStorageSync('user_id')
|
||||||
|
console.log('Calling setDefaultAddress API', user_id, item.id)
|
||||||
await setDefaultAddress(user_id, item.id)
|
await setDefaultAddress(user_id, item.id)
|
||||||
uni.showToast({ title: '设置成功', icon: 'none' })
|
uni.showToast({ title: '设置成功', icon: 'none' })
|
||||||
fetchList()
|
fetchList()
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
|
console.error('setDefaultAddress error', e)
|
||||||
uni.showToast({ title: '设置失败', icon: 'none' })
|
uni.showToast({ title: '设置失败', icon: 'none' })
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user