绿满眶商城微信小程序-uniapp
zxl
2025-12-16 8e36cf0540a398cc48ee96cdc4e294f57300a700
pages/tabbar/index/home.vue
@@ -403,6 +403,7 @@
   onShow() {
      getSessionId().then(res=>{
         console.log('res',JSON.stringify(res))
      if (res.code === 200){
         this.pageSessionNo = res.data.data
         if(this.pageSessionNo){
         let   param = Object.assign({},this.actionParam);
@@ -410,7 +411,6 @@
         param.sessionId = this.pageSessionNo
            userAction(param)
         }
      })
    this.getONPrizeActivity()
    let showPopup = storage.getPopupShow();
    console.log(showPopup)
@@ -423,9 +423,6 @@
    if(showPopup){
      this.openActivityPopup()
    }
      if (!this.userId) {
         this.getUserId()
      }
@@ -448,18 +445,30 @@
         const duration = Date.now() - this.startHidenTime
         this.totalHidenTime += duration
      }
      }
      })
   },
  onUnload() {
    let   param = Object.assign({},this.actionParam);
    if (this.sendOnShow)return
    param.pageStatus = "LEAVE"
    // if (this.isNotEmpty(param.sessionId)){
      console.log("离开页面开始记录")
      //TODO 页面刷新 导致onshow未执行,导致sessionId未赋值
    userAction(param)
    // }
  },
  onHide() {
    this.startHidenTime = Date.now()
    let   param = Object.assign({},this.actionParam);
    this.sendOnShow = true;
    param.pageStatus = "LEAVE"
    console.log("执行onHide的userAction")
    userAction(param)
  },
   onLoad(option) {
@@ -598,6 +607,15 @@
      });
   },
   methods: {
     isNotEmpty(value) {
       if (value === null || value === undefined) {
         return false;
       }
       if (typeof value === 'string') {
         return value.trim() !== '';
       }
       return true;
     },
    getONPrizeActivity(){
      getONPrizeActivity().then(res =>{
        if(res.statusCode=== 200){