Browse Source

fix(frontend): 修复 team.vue 模板未闭合导致编译失败 + onLoad/onShow 双重调用

liaoxg 1 day ago
parent
commit
2b2f4223fa
1 changed files with 13 additions and 2 deletions
  1. 13 2
      cfc-frontend/pages/promotion/team.vue

+ 13 - 2
cfc-frontend/pages/promotion/team.vue

@@ -108,6 +108,7 @@
       </view>
     </view>
   </view>
+</template>
 
 <script>
 import { getCfRate, getTeamList } from '../../utils/api.js'
@@ -128,11 +129,21 @@ export default {
   onLoad() {
     this.loadTeamStats()
     this.loadList()
+    // 小程序首次进入时 onLoad 与 onShow 都会触发,此标记让随后的首次 onShow
+    // 跳过 loadTeamStats/loadList,避免同一接口一次冷启动被请求两遍
+    this._onLoadFired = true
   },
   onShow() {
+    // loadCurveData 只在 onShow 调用(onLoad 不含),每次进入都需刷新,保持无条件执行
     this.loadCurveData()
-    this.loadTeamStats()
-    this.loadList()
+    if (this._onLoadFired) {
+      // 首次进入:onLoad 刚加载完,跳过避免双发
+      this._onLoadFired = false
+    } else {
+      // 切 Tab 返回 / 从子页面返回:刷新
+      this.loadTeamStats()
+      this.loadList()
+    }
   },
   onReachBottom() {
     if (this.hasMore && !this.loading) {