From b8de15da6882d0c752df50d47683d676c0a5aeb4 Mon Sep 17 00:00:00 2001
From: peng <peng.com>
Date: 星期三, 15 十月 2025 09:26:36 +0800
Subject: [PATCH] 定制商品
---
pages/tabbar/index/home.vue | 166 +++++++++++++++++++++++++++++++++++++++++++------------
1 files changed, 129 insertions(+), 37 deletions(-)
diff --git a/pages/tabbar/index/home.vue b/pages/tabbar/index/home.vue
index b827c82..054c85e 100644
--- a/pages/tabbar/index/home.vue
+++ b/pages/tabbar/index/home.vue
@@ -15,13 +15,12 @@
mode="aspectFit"></image>
</view>
<video v-if="index >= currentIndex - videoLiveOffset && index <= currentIndex + videoLiveOffset"
- :id="'video' + index" :ref="'video' + index" :src="item.videoUrl"
- :autoplay="index === currentIndex" :controls="isControls" :loop="true"
- :object-fit="item.videoFit" :enable-progress-gesture="false" :show-center-play-btn="false"
- :show-progress="false" :show-fullscreen-btn="isControls" :show-play-btn="isControls"
- :show-mute-btn="false" class="video-item" @fullscreenchange="onFullscreenChange"
- @play="onPlay(item.id, index)" @pause="onPause(index)" @ended="onEnded(index)"
- @click="togglePlay(index)" @timeupdate="onTimeUpdate($event)"
+ :id="'video' + index" :ref="'video' + index" :src="item.videoUrl" :autoplay="index === currentIndex"
+ :controls="isControls" :loop="true" :object-fit="item.videoFit" :enable-progress-gesture="false"
+ :show-center-play-btn="false" :show-progress="false" :show-fullscreen-btn="isControls"
+ :show-play-btn="isControls" :show-mute-btn="false" class="video-item"
+ @fullscreenchange="onFullscreenChange" @play="onPlay(item.id, index)" @pause="onPause(index)"
+ @ended="onEnded(index)" @click="togglePlay(index)" @timeupdate="onTimeUpdate($event)"
@loadedmetadata="onLoadedMetadata($event)" @waiting="videoWaiting(index)"></video>
<view class="fullscreen-btn">
<image class="fullscreen-icon" :src="isFullScreen ? off_screen : on_screen" mode="aspectFit"
@@ -62,7 +61,7 @@
<!-- 鎮寕鍟嗗搧閾炬帴灞� -->
- <view class="goods-link-warp" v-if="item.goodsList.length > 0">
+ <view class="goods-link-warp" :style="{ bottom: marginBottom + 55 + 'px' }" v-if="item.goodsList.length > 0">
<view class="goods-link">
<swiper @change="goodsChange" :autoplay="true" :interval="4000" style="height: 120rpx;">
<swiper-item v-for="goods in item.goodsList" :key="goods.goodsId">
@@ -75,8 +74,8 @@
<text class="goods-name">{{ goods.goodsName }}</text>
<view class="price-section">
<text class="current-price">楼{{ goods.price }}</text>
- <text class="original-price" v-if="goods.originalPrice">楼{{
- goods.originalPrice }}</text>
+ <text class="original-price"
+ v-if="goods.originalPrice">楼{{ goods.originalPrice }}</text>
</view>
</view>
</view>
@@ -88,14 +87,15 @@
<!-- 瑙嗛淇℃伅灞� -->
<view class="video-info" :style="{ bottom: marginBottom + 20 + 'px' }">
- <view style="width: 100%; position: relative;" @click="jumpToSearch">
+ <view style="width: 100%; position: relative;">
<text class="video-author">@{{ item.authorName }}</text>
- <text class="iconfont" style="position: absolute;right: 42px;bottom: 50rpx;"></text>
+ <text class="iconfont" @click="jumpToSearch"
+ style="position: absolute;right: 42px;bottom: 50rpx;"></text>
</view>
<view style="width: 100%;word-wrap: break-word;white-space: normal;overflow-wrap: break-word;">
<text class="video-title">{{ item.title }}</text>
- <text class="video-tag" v-for="(tag, index) in item.tagList" :key="tag.id">#{{ tag.tagName
- }}</text>
+ <text class="video-tag" v-for="(tag, index) in item.tagList"
+ :key="tag.id">#{{ tag.tagName }}</text>
</view>
</view>
@@ -171,12 +171,12 @@
<text @click="openReply(comment)" class="reply-btu time">鍥炲</text>
<text v-if="!comment.hasThumbsUp" class="thumbs-up time iconfont"
@click="thubmsUp(comment.id, index, null)"><text
- v-show="comment.thumbsUpNum > 0" class="thumbs-num">{{ comment.thumbsUpNum
- }}</text></text>
+ v-show="comment.thumbsUpNum > 0"
+ class="thumbs-num">{{ comment.thumbsUpNum }}</text></text>
<text v-else class="thumbs-up time iconfont"
@click="cancelThumbsUp(comment.id, index, null)"><text
- v-show="comment.thumbsUpNum > 0" class="thumbs-num">{{ comment.thumbsUpNum
- }}</text></text>
+ v-show="comment.thumbsUpNum > 0"
+ class="thumbs-num">{{ comment.thumbsUpNum }}</text></text>
</view>
</view>
</view>
@@ -200,12 +200,12 @@
<text @click="openReply(comment, reply)" class="reply-btu time">鍥炲</text>
<text v-if="!reply.hasThumbsUp" class="thumbs-up time iconfont"
@click="thubmsUp(reply.id, index, replyIndex)"><text
- v-show="reply.thumbsUpNum > 0" class="thumbs-num">{{ reply.thumbsUpNum
- }}</text></text>
+ v-show="reply.thumbsUpNum > 0"
+ class="thumbs-num">{{ reply.thumbsUpNum }}</text></text>
<text v-else class="thumbs-up time iconfont"
@click="cancelThumbsUp(reply.id, index, replyIndex)"><text
- v-show="reply.thumbsUpNum > 0" class="thumbs-num">{{ reply.thumbsUpNum
- }}</text></text>
+ v-show="reply.thumbsUpNum > 0"
+ class="thumbs-num">{{ reply.thumbsUpNum }}</text></text>
</view>
</view>
</view>
@@ -265,13 +265,15 @@
import { mapState, mapMutations } from 'vuex'
import { setPopupRedisTime, getPopupAcitivty } from '@/api/popup.js'
import { changeCollect } from "@/api/collect.js";
-import { saveShare, saveShareClickRecord } from "@/api/share.js";
+import { saveShare, saveShareClickRecord} from "@/api/share.js";
+import { getSessionId, userAction,userShare } from "@/api/userAction.js";
import { silentLogin } from "@/api/connect.js";
import { getUserInfo } from "@/api/members";
import storage from "@/utils/storage.js";
import TopBar from "@/components/TopBar.vue";
import { nextTick } from "vue";
import { getVideoCover } from "@/api/common.js"
+import {addPrizeNum} from '@/api/prize.js'
export default {
components: { TopBar, ActivityPopup },
computed: {
@@ -368,10 +370,36 @@
similarlyNomore: false, // 鏄惁杩樻湁鏇村鐩镐技瑙嗛
similaryVideoIndex: 0, // 鐩镐技瑙嗛鐨勬挱鏀句綅缃�
similarlyLoading: false, // 鐩镐技瑙嗛鍔犺浇
- marginBottom: 0 // 搴曢儴瀹夊叏鍖哄煙
+ marginBottom: 0 ,// 搴曢儴瀹夊叏鍖哄煙
+ pageSessionNo:"",
+ shareId:"",
+ actionParam:{
+ sessionId:'',
+ actionType:"PAGE",
+ joinType:"SELF",
+ pageCode:"RECOMMEND_VIDEO",
+ pageParams:"{}",
+ pageStatus:"JOIN",
+ pageType:"LIST"
+ },
+ shareParam:{
+ pageCode:"RECOMMEND_VIDEO",
+ shareOption:"{}",
+ pageType:"LIST"
+ },
}
},
onShow() {
+ getSessionId().then(res=>{
+ console.log('res',JSON.stringify(res))
+ this.pageSessionNo = res.data.data
+ if(this.pageSessionNo){
+ let param = Object.assign({},this.actionParam);
+ this.actionParam.sessionId = this.pageSessionNo
+ param.sessionId = this.pageSessionNo
+ userAction(param)
+ }
+ })
this.openActivityPopup()
@@ -399,11 +427,32 @@
this.totalHidenTime += duration
}
},
- onHide() {
- this.startHidenTime = Date.now()
- },
+ onUnload() {
+ let param = Object.assign({},this.actionParam);
+ if (this.sendOnShow)return
+ param.pageStatus = "LEAVE"
+ userAction(param)
+ },
+ onHide() {
+ this.startHidenTime = Date.now()
+ 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鎴愬姛');
+ }
+ });
+ }
console.log('-----------鍒嗕韩鍑虹殑鏁版嵁---------->', option)
//澶勭悊鎵爜鍑烘潵鐨勮棰�
this.marginBottom = uni.getSystemInfoSync().safeAreaInsets.bottom
@@ -419,6 +468,9 @@
const shareType = params.shareType;
const videoId = params.videoId;
queryParam.videoId = videoId
+ this.actionParam.joinType = "SCAN";
+ this.actionParam.pageParams = JSON.stringify(params);
+
console.log('瑙f瀽鍙傛暟:', { shareType, videoId });
}
const token = storage.getAccessToken();
@@ -426,6 +478,8 @@
this.wxSilentLogin(() => {
// 鍒ゆ柇鏄笉鏄偣鍑诲垎浜摼鎺ヨ繘鏉ョ殑
if (option.userId && option.videoId) {
+ this.actionParam.joinType = "SHARE";
+ this.actionParam.pageParams = JSON.stringify(option);
queryParam.videoId = option.videoId
// 淇濆瓨鍒嗕韩鐐瑰嚮璁板綍
saveShareClickRecord({ refId: option.videoId, shareUserId: option.userId })
@@ -469,13 +523,47 @@
// }
// })
- console.log(videoInfo)
- return {
- title: videoInfo.title,
- path: `/pages/tabbar/index/home?videoId=${videoInfo.id}&userId=${userInfo.id}`,
- imageUrl: videoInfo.coverUrl
- }
// 淇濆瓨鍒嗕韩璁板綍
+
+ // 杩斿洖涓�涓狿romise
+ 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;
+ let param = {
+ addType:"SHARE_GOODS_VIDEO",
+ extend:"",
+ }
+ let extend = {shareId:this.shareId}
+ param.extend = JSON.stringify(extend)
+ addPrizeNum(param);
+ // 褰撹幏鍙栧埌shareId鍚庯紝鍐峳esolve鍒嗕韩閰嶇疆
+ 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: {
async openActivityPopup() {
@@ -984,7 +1072,9 @@
this.videoNoMore = true;
return;
}
- this.videoQuery.pageNumber++;
+ if (res.data.code === 200) {
+ this.videoQuery.pageNumber++;
+ }
})
} else {
@@ -1012,7 +1102,9 @@
this.videoNoMore = true;
return;
}
- this.videoQuery.pageNumber++;
+ if (res.data.code === 200) {
+ this.videoQuery.pageNumber++;
+ }
})
}
@@ -1472,7 +1564,7 @@
/* 鍟嗗搧閾炬帴鎮寕灞傛牱寮� */
.goods-link-warp {
position: absolute;
- bottom: 160px;
+ bottom: 100px;
left: 20px;
color: #f8f8f8;
z-index: 10;
--
Gitblit v1.8.0