绿满眶商城微信小程序-uniapp
peng
2025-07-09 c22e91296d532873b70cb51bf5510bf7738f3f1a
pages/mine/myTracks.vue
@@ -30,23 +30,26 @@
         v-for="(item, index) in videoHistory" 
         :key="index" 
         class="video-item"
         @click="goToVideoDetail(item)"
         @click="goToVideoPlay(item, index)"
        >
           <u-swipe-action style="width: 100%;" :show="item.show" :index="index" :key="item.id"
            @click="delTracks" @open="open" :options="options">
            <image class="video-cover" :src="item.coverUrl" mode="aspectFill"></image>
            <view class="video-info">
              <view class="video-title">{{item.title}}</view>
              <view class="video-author">{{item.authorName}}</view>
              <view class="video-meta">
               <text>播放至: {{formatPlayTime(item.playAt)}}</text>
               <text class="separator">|</text>
               <text>{{formatDate(item.playTime)}}</text>
              </view>
            @click="deleteVideoView(item.id)" @open="open" :options="options">
            <view style="display: flex;" @click="goToVideoPlay(item, index)">
               <image class="video-cover" :src="item.coverUrl" mode="aspectFill"></image>
               <view class="video-info">
                 <view class="video-title">{{item.title}}</view>
                 <view class="video-author">{{item.authorName}}</view>
                 <view class="video-meta">
                  <text>播放至: {{formatPlayTime(item.playAt)}}</text>
                  <text class="separator">|</text>
                  <text>{{formatDate(item.playTime)}}</text>
                 </view>
               </view>
            </view>
           </u-swipe-action>
        </view>
        <div @click="handleClickDeleteSelected" v-if="isEdit" class="submit">
        <div @click="deleteVideoView(item.id)" v-if="isEdit" class="submit">
           删除所选
        </div>
        <view v-if="videoHistory.length === 0" class="empty-tip">
@@ -83,11 +86,11 @@
            </view>
            <view class="myTracks-divider"></view>
            <div @click="handleClickDeleteSelected(item.id)" v-if="isEdit" class="submit">
               删除所选
            </div>
         </view>
         <div @click="handleClickDeleteSelected" v-if="isEdit" class="submit">
            删除所选
         </div>
         <view v-if="trackList.length === 0" class="empty-tip">
                  暂无商品浏览记录
         </view>
@@ -104,6 +107,7 @@
      deleteHistoryListId,
      myVideoHistory
   } from "@/api/members.js";
import storage from '@/utils/storage';
   export default {
      data() {
@@ -152,17 +156,25 @@
         },
         
         // 跳转到视频详情页
         goToVideoDetail(item) {
           uni.navigateTo({
            url: `/pages/video-detail/video-detail?id=${item.id}`
           })
         goToVideoPlay(item, index) {
            const playInfo = {
               videoList: this.videoHistory,
               nomore: true,
               pageNumber: this.params.pageNumber,
               playIndex: index
            }
            uni.setStorageSync("playInfo", playInfo)
             uni.navigateTo({
              url: `/pages/video/video-play?authorId=${storage.getUserInfo().id}&videoFrom=history`
             })
         },
         
         // 格式化播放时间 (秒 -> 分:秒)
         formatPlayTime(seconds) {
           const mins = Math.floor(seconds / 60)
           const secs = seconds % 60
           return `${mins}:${secs < 10 ? '0' + secs : secs}`
            const secsInt = Math.floor(seconds); // 去掉小数部分
             const mins = Math.floor(secsInt / 60)
             const secs = secsInt % 60
             return `${mins}:${secs < 10 ? '0' + secs : secs}`
         },
         
         // 格式化日期
@@ -191,6 +203,22 @@
         },
         checkboxChangeDP(val){
            console.log(val)
         },
         // 删除视频浏览记录
         deleteVideoView(id) {
            deleteHistoryListId([id], 'video').then((res) => {
               if (res.data.code == 200) {
                  this.videoHistory = [];
                  this.params.pageNumber = 1
                  this.getList();
               } else {
                  uni.showToast({
                     title: res.data.message,
                     duration: 2000,
                     icon: "none",
                  });
               }
            });
         },
         // 删除所选的数据
         handleClickDeleteSelected(val){
@@ -267,7 +295,12 @@
                  if (data.total == 0) {
                     this.whetherEmpty = true;
                  } else {
                     this.videoHistory.push(...data);
                     this.videoHistory = [
                       ...this.videoHistory,
                       ...res.data.data.filter(
                         (newItem) => !this.videoHistory.some((oldItem) => oldItem.id === newItem.id)
                       ),
                     ];
                  }
               })
            }
@@ -277,7 +310,7 @@
          * 删除足迹
          */
         delTracks(index,ids) {
            deleteHistoryListId(ids || this.trackList[index].goodsId).then((res) => {
            deleteHistoryListId(ids || this.trackList[index].goodsId, 'goods').then((res) => {
               if (res.data.code == 200) {
                  this.trackList = [];
                  this.params.pageNumber = 1
@@ -456,8 +489,8 @@
   
   .video-item {
     display: flex;
     margin-bottom: 30rpx;
     padding-bottom: 30rpx;
     padding-bottom: 10rpx;
     padding-left: 20rpx;
     border-bottom: 1rpx solid #f5f5f5;
   }