浏览代码

视频追剧

pansl 2 年之前
父节点
当前提交
80a2e3c330
共有 3 个文件被更改,包括 44 次插入23 次删除
  1. 1 1
      common/apis/zju.js
  2. 6 6
      common/http.js
  3. 37 16
      pages/client/tuan/detail.nvue

+ 1 - 1
common/apis/zju.js

@@ -15,5 +15,5 @@ export const delShelf = id => {
 } 
 // 添加追剧
 export const storeshelf = id => {
-	return http.post('/api/user/watchrecord/storeshel',{video_id:id});
+	return http.post('/api/user/watchrecord/storeshelf',{video_id:id});
 } 

+ 6 - 6
common/http.js

@@ -23,20 +23,20 @@ export default {
 		options.header = options.header || this.config.header;
 		options.method = options.method || this.config.method;
 		options.dataType = options.dataType || this.config.dataType;
-		
+
 		let version = 'web';
-		// #ifdef MP-WEIXIN  
+		// #ifdef MP-WEIXIN  
 		//	微信小程序处理
 		options.header.appid = wxApp.getWXAppId();
-		options.header.source = 'wxapp';
+		options.header.source = 'wxapp';
 		// 过滤不需要token的api
-		if (filterNoToken.indexOf(options.url) === -1) {
+		if (filterNoToken.indexOf(options.url) === -1) {
 			// console.log('getTokenString ',options.url )
 			options.header.Authorization = await (this.getTokenString());
 		}
 		// #endif
-		options.url = this.config.baseUrl + options.url;
-		// console.log('options.url ',options.url )
+		options.url = this.config.baseUrl + options.url;
+		console.log('options.url ', options.url)
 		return uni.request(options).then(res => {
 			res = res[1].data;
 			if (res.code == 500201) {

+ 37 - 16
pages/client/tuan/detail.nvue

@@ -35,20 +35,19 @@
 								@click.stop="share"></button>
 						</view> -->
 							<!-- 4.追剧 -->
-							<view class="comment" @click.stop="toComment(list.iszj,list.pid,list.mid)"
-								style="opacity: 0.9; margin-top: 17px;">
-								<block v-if="videoInfo.is_binge_watch">
+							<view class="comment" style="opacity: 0.9; margin-top: 17px;">
+								<view v-if="videoInfo.is_binge_watch" @click="unBingewatch">
 									<image src="@/static/scRed.png"
 										style="width: 40px; height: 40px; position: absolute; right: 6px;"></image>
 									<text
 										style="color: #ff0000; margin-top: 5px; font-size: 14px; font-weight: bold; text-align: center; margin-top: 40px;">已追</text>
-								</block>
-								<block v-else>
+								</view>
+								<view v-else @click="bingewatch">
 									<image src="@/static/sc.png"
 										style="width: 40px; height: 40px; position: absolute; right: 6px;"></image>
 									<text
 										style="color: #FFFFFF; margin-top: 5px; font-size: 14px; font-weight: bold; text-align: center; margin-top: 40px;">追剧</text>
-								</block>
+								</view>
 							</view>
 
 						</view>
@@ -121,7 +120,11 @@
 		getVideoInfo,
 		videoEpisodePlay,
 		videoEpisodeZan,
-	} from '@/common/apis/video.js'
+	} from '@/common/apis/video.js';
+	import {
+		delShelf,
+		storeshelf
+	} from '@/common/apis/zju.js'
 	import configs from "@/common/config.js"
 	let audo = uni.createInnerAudioContext('myVideo')
 	export default {
@@ -200,6 +203,13 @@
 		},
 		mounted() {
 			this.initTabs();
+			this.initSwiperData(this.swiperCurrent + 1)
+			getVideoInfo({
+				video_id: this.video_id
+			}).then(res => {
+				// console.log(res, 'getVideoInfogetVideoInfogetVideoInfo')
+				this.videoInfo = res
+			})
 		},
 		onLoad(e) {
 			let that = this;
@@ -208,16 +218,9 @@
 					that.top_height = res.statusBarHeight; //data中 声明 top_height:0 
 				}
 			});
-			this.initSwiperData(this.swiperCurrent + 1)
 			if (e.video_id) {
-				this.video_id = e.video_id
+				this.video_id = Number(e.video_id)
 			}
-			getVideoInfo({
-				video_id: 4
-			}).then(res => {
-				console.log(res, 'getVideoInfogetVideoInfogetVideoInfo')
-				this.videoInfo = res
-			})
 			uni.getSystemInfo({
 				success: res => {
 					this.safeArea = res.safeAreaInsets.bottom;
@@ -260,6 +263,23 @@
 		},
 		onBackPress() {},
 		methods: {
+			bingewatch() {
+				storeshelf(this.video_id).then(res => {
+					console.log(res, 'storeshelfstoreshelfstoreshelf')
+					this.videoInfo.is_binge_watch = !Boolean(this.videoInfo.is_binge_watch)
+					uni.showToast({
+						title: '追剧成功',
+						duration: 1000,
+						icon: 'none'
+					});
+				})
+			},
+			unBingewatch() {
+				delShelf(this.video_id).then(res => {
+					console.log(res, 'storeshelfstoreshelfstoreshelf')
+					this.videoInfo.is_binge_watch = !Boolean(this.videoInfo.is_binge_watch)
+				})
+			},
 			leftClick(e) {
 				uni.showModal({
 					title: '加入追剧',
@@ -269,6 +289,7 @@
 					cancelText: '不用了',
 					success: (res) => {
 						if (res.confirm) {
+							this.bingewatch()
 							// 用户点击了确定按钮
 							// 执行加入追剧的逻辑
 						} else if (res.cancel) {
@@ -428,7 +449,7 @@
 			initSwiperData(originIndex) {
 				this.isqp = false
 				videoEpisodePlay({
-					video_id: 4,
+					video_id: this.video_id,
 					sequence: originIndex
 				}).then(res => {
 					this.currentVideoInfo = res