绿满眶商城微信小程序-uniapp
peng
11 小时以前 3fea9f0720e7751e4737ded74b3aa89db273688d
pages/prize/PrizeDetail/PrizeDetail.vue
@@ -148,7 +148,7 @@
</template>
<script>
   import bgConfig from '@/pages/prize/PrizeDetail/prize-bgConfig.js'
   import { getSessionId, userAction } from "@/api/userAction.js";
   import { getSessionId, userAction ,userShare } from "@/api/userAction.js";
   import {
      prizeInfo,
@@ -224,7 +224,13 @@
               pageParams:"{}",
               pageStatus:"JOIN",
               pageType:"DETAIL"
            }
            },
            shareParam:{
               pageCode:"PRIZE_DETAIL",
               shareOption:"{}",
               pageType:"DETAIL"
            },
            shareId:'',
         };
      },
      computed: {
@@ -234,14 +240,14 @@
         }
      },
    onUnload() {
      let   param = this.actionParam;
      let param = Object.assign({}, this.actionParam);
      if (this.sendOnShow)return
      param.pageStatus = "LEAVE"
      userAction(param)
    },
    onHide() {
      this.startHidenTime = Date.now()
      let   param = this.actionParam;
      let   param = Object.assign({}, this.actionParam);
      this.sendOnShow = true;
      param.pageStatus = "LEAVE"
      userAction(param)
@@ -249,14 +255,20 @@
      onShow() {
        getSessionId().then(res=>{
         this.pageSessionNo = res.data.data
         this.actionParam.sessionId = res.data.data
         if(this.pageSessionNo){
         let   param = this.actionParam;
         let   param = Object.assign({}, this.actionParam);
            param.sessionId = this.pageSessionNo
            userAction(param)
         }
        })   
      },
      async onLoad(option) {
         if(option.shareId){
            this.actionParam.shareId = option.shareId;
            this.actionParam.joinType = 'SHARE'
            console.log('触发onLoad')
         }
         this.actionParam.pageParams = JSON.stringify(option)
         const pages = getCurrentPages()
@@ -303,17 +315,38 @@
         // this.startAutoScroll()
      },
      onShareAppMessage() {
         return {
        // 返回一个Promise
        return new Promise((resolve) => {
         this.shareId = '';
         this.shareParam.shareOption = JSON.stringify({
            id:this.activityId
         })
         userShare(this.shareParam).then(res => {
           this.shareId = res.data.data;
           console.log('------------------1》', this.shareId);
           // 当获取到shareId后,再resolve分享配置
           resolve({
            title: this.activityName,
            path: '/pages/prize/PrizeDetail/PrizeDetail?id=' + this.activityId,
            path: '/pages/prize/PrizeDetail/PrizeDetail?id=' + this.activityId + '&shareId=' + this.shareId,
            imageUrl: this.activityCover,
            success(e) {
               console.log("分享成功", e)
              console.log("分享成功", e);
            },
            fail(e) {
               console.log('分享失败', e)
              console.log('分享失败', e);
            }
         }
           });
         }).catch(err => {
           // 处理错误情况,例如使用默认参数
           console.error('获取分享ID失败', err);
           resolve({
            title: this.activityName,
            path: '/pages/prize/PrizeDetail/PrizeDetail?id=' + this.activityId,
            imageUrl: this.activityCover
           });
         });
        });
      },
      beforeDestroy() {
         this.stopAutoScroll()