首页数据不刷新问题

This commit is contained in:
李彪 2025-04-30 13:33:40 +08:00
parent 3c78631953
commit 6870af63cb
2 changed files with 18 additions and 4 deletions

View File

@ -52,9 +52,16 @@ export default {
mounted() { mounted() {
uni.hideLoading() // Loading uni.hideLoading() // Loading
}, },
onLoad() {}, onLoad() {
uni.$off('reset')
uni.$on('reset', () => {
console.log('%c%s', 'color:red', 'reset')
this.getDataFn()
})
},
onShow() { onShow() {
this.getDataFn() this.getDataFn()
console.log('%c%s', 'color:red', 'onSHow')
}, },
methods: { methods: {
async getDataFn() { async getDataFn() {

View File

@ -40,13 +40,13 @@
<u-empty v-if="!sonList.length" text="数据为空" mode="list"></u-empty> <u-empty v-if="!sonList.length" text="数据为空" mode="list"></u-empty>
</scroll-view> </scroll-view>
</view> </view>
<!-- 筛选的下拉 --> <!-- 筛选的下拉 -->
<u-action-sheet :list="options" title="请选择" @click="changeFn" v-model:value="selectShow"></u-action-sheet> <u-action-sheet :list="options" title="请选择" @click="changeFn" v-model:value="selectShow"></u-action-sheet>
<!-- 弹窗 --> <!-- 弹窗 -->
<bind-dialog ref="dialogRef" :visible="showDialog" @close="showDialog = false" :currentRow="currentRow" @changeBinding="onChangeBinding" @confirm="onConfirm" @closeRes="closeResFn"></bind-dialog> <bind-dialog ref="dialogRef" :visible="showDialog" @close="showDialog = false" :currentRow="currentRow" @changeBinding="onChangeBinding" @confirm="onConfirm" @closeRes="closeResFn"></bind-dialog>
<u-tabbar :list="vuex_tabbar"></u-tabbar> <u-tabbar :list="vuex_tabbar" :before-switch="beforeSwitch"></u-tabbar>
</view> </view>
</template> </template>
<script> <script>
@ -109,8 +109,14 @@ export default {
}, },
onShow() { onShow() {
this.getDataFn() this.getDataFn()
console.log('%c%s', 'color:red', 'onSHow')
}, },
methods: { methods: {
beforeSwitch(e) {
console.log(e, 'e-')
uni.$emit('reset')
return true
},
dialogShowFn(row) { dialogShowFn(row) {
// console.log(this.vuex_userData.nfcwrite) // console.log(this.vuex_userData.nfcwrite)
// return // return
@ -168,7 +174,7 @@ export default {
const res = await GetRegionDataListApi() const res = await GetRegionDataListApi()
console.log(res, '区域数据') console.log(res, '区域数据')
this.tabsList = res.data this.tabsList = res.data
if (this.tabsList.length > 0) { if (this.tabsList?.length > 0) {
this.tabCurrentId = this.tabsList[0].id this.tabCurrentId = this.tabsList[0].id
this.getSonAreaFn() this.getSonAreaFn()
} }
@ -179,6 +185,7 @@ export default {
uni.showToast({ title: '绑定成功', icon: 'none' }) uni.showToast({ title: '绑定成功', icon: 'none' })
setTimeout(() => { setTimeout(() => {
this.getSonAreaFn() this.getSonAreaFn()
this.getDataFn()
}, 500) }, 500)
}, },
// //