绿满眶商城微信小程序-uniapp
zxl
2025-09-30 883630c60e9a941d6cf721cfb4b9160ab406a7dd
商品行为分析
5个文件已修改
232 ■■■■ 已修改文件
pages/health/healthVideo.vue 63 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
pages/kitchen/KitchenVideo.vue 65 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
pages/product/goods.vue 8 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
pages/tabbar/index/home.vue 13 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
pages/video/video-goods-detail-swiper.vue 83 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
pages/health/healthVideo.vue
@@ -264,7 +264,7 @@
import { silentLogin } from "@/api/connect.js";
import { getUserInfo } from "@/api/members";
import storage from "@/utils/storage.js";
import { getSessionId, userAction } from "@/api/userAction.js";
import { getSessionId, userAction,userShare } from "@/api/userAction.js";
export default {
  components: {TopBar},
  computed: {
@@ -364,14 +364,20 @@
                pageParams:"{}",
                pageStatus:"JOIN",
                pageType:"DETAIL"
            }
            },
            shareParam:{
                pageCode:"HEALTH_VIDEO",
                shareOption:"{}",
                pageType:"DETAIL"
            },
            shareId:'',
    }
  },
  onShow() {
      getSessionId().then(res=>{
        this.pageSessionNo = res.data.data
        if(this.pageSessionNo){
        let    param = this.actionParam;
        let    param = Object.assign({}, this.actionParam);
            param.sessionId = this.pageSessionNo
            userAction(param)
        }
@@ -391,19 +397,31 @@
      }
  },
  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)
  },
  onLoad(option) {
      if(option.shareId){
        console.log('触发onLoad')
          this.actionParam.shareId = option.shareId;
          this.actionParam.joinType = 'SHARE'
          uni.setStorage({
              key: 'shareId',
              data: option.shareId,
              success: function () {
                  console.log('缓存shareId成功');
              }
          });
      }
      this.marginBottom = uni.getSystemInfoSync().safeAreaInsets.bottom
      let queryParam = this.videoQuery;
      if (option.q) {
@@ -460,11 +478,42 @@
        shareUser: userInfo.id
    }
    saveShare(data)
      return {
      // return {
      //     title: videoInfo.title,
      //     path: `/pages/tabbar/index/home?videoId=${videoInfo.id}&userId=${userInfo.id}`,
      //     imageUrl: videoInfo.coverUrl
      // }
    return new Promise((resolve) => {
                this.shareId = '';
                let shareObj ={
                    videoId:videoInfo.id,
                    userId:userInfo.id
                }
                this.shareParam.shareOption = JSON.stringify(shareObj)
                userShare(this.shareParam).then(res => {
                  this.shareId = res.data.data;
                  // 当获取到shareId后,再resolve分享配置
                  resolve({
                    title: videoInfo.title,
                    path: `/pages/tabbar/index/home?videoId=${videoInfo.id}&userId=${userInfo.id}&shareId=${this.shareId}`,
                    imageUrl: videoInfo.coverUrl,
                    success(e) {
                      console.log("分享成功", e);
                    },
                    fail(e) {
                      console.log('分享失败', e);
                    }
                  });
                }).catch(err => {
                  // 处理错误情况,例如使用默认参数
                  console.error('获取分享ID失败', err);
                  resolve({
          title: videoInfo.title,
          path: `/pages/tabbar/index/home?videoId=${videoInfo.id}&userId=${userInfo.id}`,
          imageUrl: videoInfo.coverUrl
      }
                  });
                });
    });
  },
  methods: {
      // 解析URL参数
pages/kitchen/KitchenVideo.vue
@@ -285,7 +285,7 @@
} from "@/api/collect.js";
import { saveShare, saveShareClickRecord } from "@/api/share.js";
import storage from "@/utils/storage.js";
import { getSessionId, userAction } from "@/api/userAction.js";
import { getSessionId, userAction,userShare } from "@/api/userAction.js";
export default {
  computed: {
    hasPlayTime() {
@@ -397,14 +397,21 @@
        pageParams:"{}",
        pageStatus:"JOIN",
        pageType:"LIST"
        }
        },
        shareParam:{
            pageCode:"KITCHEN_VIDEO",
            shareOption:"{}",
            pageType:"DETAIL"
        },
        shareId:'',
    }
  },
  onShow() {
      getSessionId().then(res=>{
              this.pageSessionNo = res.data.data
              if(this.pageSessionNo){
              let    param = this.actionParam;
              let param = Object.assign({}, this.actionParam);
                  param.sessionId = this.pageSessionNo
                  userAction(param)
              }
@@ -418,19 +425,31 @@
    }
  },
  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)
  },
  onLoad(option) {
      if(option.shareId){
              console.log('触发onLoad')
          this.actionParam.shareId = option.shareId;
          this.actionParam.joinType = 'SHARE'
          uni.setStorage({
              key: 'shareId',
              data: option.shareId,
              success: function () {
                  console.log('缓存shareId成功');
              }
          });
      }
        this.marginBottom = uni.getSystemInfoSync().safeAreaInsets.bottom;
        // 获取状态栏高度
        const systemInfo = uni.getSystemInfoSync();
@@ -500,11 +519,43 @@
        shareUser: userInfo.id
    }
    saveShare(data)
      return {
      // return {
      //     title: videoInfo.title,
      //     path: `/pages/tabbar/index/home?videoId=${videoInfo.id}&userId=${userInfo.id}`,
      //     imageUrl: videoInfo.coverUrl
      // }
    return new Promise((resolve) => {
                this.shareId = '';
                let shareObj ={
                    videoId:videoInfo.id,
                    userId:userInfo.id
                }
                this.shareParam.shareOption = JSON.stringify(shareObj)
                userShare(this.shareParam).then(res => {
                  this.shareId = res.data.data;
                  // 当获取到shareId后,再resolve分享配置
                  resolve({
                    title: videoInfo.title,
                    path: `/pages/tabbar/index/home?videoId=${videoInfo.id}&userId=${userInfo.id}&shareId=${this.shareId}`,
                    imageUrl: videoInfo.coverUrl,
                    success(e) {
                      console.log("分享成功", e);
                    },
                    fail(e) {
                      console.log('分享失败', e);
                    }
                  });
                }).catch(err => {
                  // 处理错误情况,例如使用默认参数
                  console.error('获取分享ID失败', err);
                  resolve({
          title: videoInfo.title,
          path: `/pages/tabbar/index/home?videoId=${videoInfo.id}&userId=${userInfo.id}`,
          imageUrl: videoInfo.coverUrl
      }
                  });
                });
    });
  },
  methods: {
      // 解析URL参数
pages/product/goods.vue
@@ -572,6 +572,13 @@
        this.actionParam.shareId = options.shareId;
        this.actionParam.joinType = 'SHARE'
        console.log('触发onLoad')
        uni.setStorage({
            key: 'shareId',
            data: options.shareId,
            success: function () {
                console.log('缓存shareId成功');
            }
        });
    }
    this.actionParam.pageParams = JSON.stringify(options)
      if(options.q){
@@ -620,6 +627,7 @@
      getSessionId().then(res=>{
          this.pageSessionNo = res.data.data
        this.actionParam.sessionId = this.pageSessionNo
        this.actionParam.sessionId = res.data.data
          if(this.pageSessionNo){
          let    param = Object.assign({}, this.actionParam);
              userAction(param)
pages/tabbar/index/home.vue
@@ -441,7 +441,18 @@
    userAction(param)
  },
    onLoad(option) {
        if(option.shareId){
            console.log('触发onLoad')
            this.actionParam.shareId = option.shareId;
            this.actionParam.joinType = 'SHARE'
            uni.setStorage({
                key: 'shareId',
                data: option.shareId,
                success: function () {
                    console.log('缓存shareId成功');
                }
            });
        }
        console.log('-----------分享出的数据---------->', option)
        //处理扫码出来的视频
        this.marginBottom = uni.getSystemInfoSync().safeAreaInsets.bottom
pages/video/video-goods-detail-swiper.vue
@@ -95,10 +95,18 @@
                                                    </span>
                                                </view>
                                                <view class="icons share" @click="shareChange()">
                                        <!--         <view class="icons share" @click="shareChange()">
                                                    <u-icon size="30" name="share-fill"></u-icon>
                                                    <view>分享</view>
                                                </view> -->
                                                <view class="icons share"  style="margin-top: -15px;">
                                                       <button open-type="share" class="custom-share-btn" plain="true" style="border: none;">
                                                            <u-icon size="30" name="share-fill" :data-obj="item"></u-icon>
                                                       </button>
                                                        <view style="margin-top: -14px;">分享</view>
                                                </view>
                                                <view class="icons" @click="clickFavorite(goodsDetail.id)">
                                                    <u-icon size="30" :color="favorite ? '#f2270c' : '#262626'"
                                                        :name="favorite ? 'heart-fill' : 'heart'"></u-icon>
@@ -293,7 +301,7 @@
import popups from "@/pages/product/popups/popups.vue"; //气泡框
import takeDownFormSaleGoods from "@/pages/product/m-take-down-sale-goods/index.vue"; //下架框
import setup from "@/pages/product/product/popup/popup.js";
import { getSessionId, userAction } from "@/api/userAction.js";
import { getSessionId, userAction,userShare } from "@/api/userAction.js";
import { getGoodsDetail } from "@/api/video.js"
import {
@@ -445,11 +453,17 @@
                    sessionId:'',
                    actionType:"PAGE",
                    joinType:"SELF",
                    pageCode:"SWIPER_GOODS",
                pageCode:"RECOMMEND_VIDEO_LEFT_GOODS",
                    pageParams:"{}",
                    pageStatus:"JOIN",
                    pageType:"DETAIL"
                }
            },
            shareParam:{
                pageCode:"RECOMMEND_VIDEO_LEFT_GOODS",
                shareOption:"{}",
                pageType:"DETAIL"
            },
            shareId:'',
        };
    },
@@ -492,6 +506,18 @@
        this.productRefHeight = windowHeight - bottomHeight + "px";
    },
    async onLoad(options) {
        if(options.shareId){
            this.actionParam.shareId = options.shareId;
            this.actionParam.joinType = 'SHARE';
            uni.setStorage({
                key: 'shareId',
                data: options.shareId,
                success: function () {
                    console.log('缓存shareId成功');
                }
            });
            console.log('触发onLoad')
        }
        this.actionParam.pageParams = JSON.stringify(options)
        this.videoId = options.videoId;
@@ -499,21 +525,21 @@
        // #ifdef MP-WEIXIN
        // 小程序默认分享
        uni.showShareMenu({
            withShareTicket: true,
            menus: ["shareAppMessage", "shareTimeline"],
        });
        // uni.showShareMenu({
        //     withShareTicket: true,
        //     menus: ["shareAppMessage", "shareTimeline"],
        // });
        // #endif
    },
  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)
@@ -522,7 +548,7 @@
      getSessionId().then(res=>{
        this.pageSessionNo = res.data.data
        if(this.pageSessionNo){
        let    param = this.actionParam;
        let param = Object.assign({}, this.actionParam);
            param.sessionId = this.pageSessionNo
            userAction(param)
        }
@@ -541,7 +567,40 @@
        //     this.init(this.routerVal.id, this.routerVal.goodsId, this.routerVal.distributionId);
        // }
    },
    onShareAppMessage(e){
        console.log(e)
        return new Promise((resolve) => {
                    this.shareId = '';
                    let shareObj ={
                        id:e.id,
                        goodsId:e.goodsId
                    }
                    this.shareParam.shareOption = JSON.stringify(shareObj)
                    userShare(this.shareParam).then(res => {
                      this.shareId = res.data.data;
                      // 当获取到shareId后,再resolve分享配置
                      resolve({
                        title: this.goodsDetail.goodsName,
                        path: '/pages/product/goods' +'?id='+ e.id + '&goodsId=' + e.goodsId +'&shareId=' + this.shareId,
                        imageUrl: this.goodsDetail.goodsGalleryList[0],
                        success(e) {
                          console.log("分享成功", e);
                        },
                        fail(e) {
                          console.log('分享失败', e);
                        }
                      });
                    }).catch(err => {
                      // 处理错误情况,例如使用默认参数
                      console.error('获取分享ID失败', err);
                      resolve({
                        title: this.goodsDetail.goodsName,
                        path: '/pages/product/goods' +'?id='+ e.id+ '&goodsId=' + e.goodsId,
                        imageUrl: this.goodsDetail.goodsGalleryList[0],
                      });
                    });
        });
    },
    methods: {
        // 获取商品列表
        async getGoodsList() {