Parcourir la source

Merge branch 'master' of 121.36.198.49:zy_duanju/zhiyu_uni_duanju

zqwang il y a 1 an
Parent
commit
136784ecb1
5 fichiers modifiés avec 420 ajouts et 42 suppressions
  1. 4 0
      common/apis/my.js
  2. 1 1
      common/apis/video.js
  3. 141 4
      pages/client/consume/consume.vue
  4. 112 37
      pages/video/index.nvue
  5. 162 0
      utils/http.js

+ 4 - 0
common/apis/my.js

@@ -4,3 +4,7 @@ import http from "../http.js";
 export const getUserInfo = () => {
 	return http.get('/api/wxapp/userInfo');
 } 
+// 消费记录
+export const getUserConsumeRecord = () => {
+	return http.get('/api/user/consumeRecord');
+} 

+ 1 - 1
common/apis/video.js

@@ -1,4 +1,4 @@
-import http from "../http.js";
+import http from "@/utils/http.js";
 
 // 视频-信息
 export const getVideoInfo = (params) => {

+ 141 - 4
pages/client/consume/consume.vue

@@ -1,22 +1,159 @@
 <template>
 	<view>
-		
+		<view class="integral-log-main">
+			<view class="pd16_15 bd-bottom flex alcenter">
+				<text class="iconfont iconicon_integral_des ft20 cl-main"></text>
+				<text class="ml10 ft16 ftw600 cl-main">消费明细</text>
+			</view>
+			<view class="pd16_15" v-if="listData.length>0">
+				<block v-for="(item,index) in listData" :key="index">
+					<view class="pb16 mb16 bd-bottom flex alcenter space">
+						<view>
+							<view class="ft14 cl-main">{{item.memo}}</view>
+							<view class="mt8 ft12 cl-notice">{{item.createtime}}</view>
+						</view>
+						<view class="ft18 ftw600 cl-main">{{item.jzt}}{{item.score}}</view>
+					</view>
+				</block>
+				<uni-load-more :status="status" :content-text="contentText" />
+			</view>
+
+			<com-empty v-else title="暂无积分记录"></com-empty>
+		</view>
 	</view>
 </template>
 
 <script>
+	import {
+		getUserConsumeRecord
+	} from '@/common/apis/my.js'
 	export default {
 		data() {
 			return {
-				
+				userinfo: [],
+				listData: [],
+				last_id: 0,
+				reload: true,
+				status: 'more',
+				userinfo: [],
+				contentText: {
+					contentdown: '上拉加载更多',
+					contentrefresh: '加载中',
+					contentnomore: '没有数据了'
+				}
 			}
 		},
+		onReachBottom() {
+			this.status = 'more';
+			this.getList();
+		},
+		onLoad() {
+			this.ongrzlTap()
+			this.getList();
+		},
 		methods: {
-			
+			async ongrzlTap() {
+				let data = {};
+				data.token = uni.getStorageSync("userinfo").token;
+				data.uid = uni.getStorageSync("userinfo").id;
+				uni.request({
+					url: this.configs.webUrl + '/api/user/index',
+					data: data,
+					success: res => {
+						if (res.data.code == 1) {
+							let ionfo = res.data.data
+							this.userinfo = ionfo
+						} else {
+							uni.showToast({
+								title: res.data.msg,
+								icon: "none"
+							});
+						}
+					},
+					fail: (data, code) => {
+						//console.log('fail' + JSON.stringify(data));
+					}
+				});
+			},
+			getList() {
+				getUserConsumeRecord().then(res => {
+					console.log(res,'getUserConsumeRecordgetUserConsumeRecordgetUserConsumeRecord')
+				})
+				let data = {
+					//column: 'id,post_id,title,author_name,cover,published_at' //需要的字段名
+				};
+				var limit = 10;
+				if (this.last_id > 0) {
+					//说明已有数据,目前处于上拉加载
+					this.status = 'loading';
+					data.offset = this.last_id * limit;
+					data._ = new Date().getTime() + '';
+				}
+				data.limit = limit
+				// data.token = uni.getStorageSync("userinfo").token;
+				// uni.request({
+				// 	url: this.configs.webUrl + '/api/user/userscoreinfo',
+				// 	data: data,
+				// 	success: data => {
+				// 		console.log(data.data)
+				// 		if (data.data.total > 0) {
+				// 			let list = data.data.rows;
+				// 			this.listData = this.reload ? list : this.listData.concat(list);
+				// 			this.reload = false;
+				// 			this.last_id = this.last_id + 1;
+				// 			if (data.data.total < this.last_id * limit) {
+				// 				this.status = '';
+				// 			}
+				// 		} else {
+				// 			this.contentText.contentdown = '没有数据'
+				// 		}
+				// 	},
+				// 	fail: (data, code) => {
+				// 		//console.log('fail' + JSON.stringify(data));
+				// 	}
+				// });
+			},
 		}
 	}
 </script>
 
 <style>
+	.integral-log-header {
+		position: relative;
+		height: 252rpx;
+	}
+
+	.integral-log-header .bg {
+		width: 100%;
+		height: 252rpx;
+	}
 
-</style>
+	.integral-log-header .main {
+		height: 252rpx;
+		width: 100%;
+		position: absolute;
+		left: 0;
+		top: 0;
+	}
+
+	.btn-integral {
+		width: 192rpx;
+		height: 80rpx;
+		background: #FFFFFF;
+		box-shadow: 0rpx 8rpx 32rpx 0rpx rgba(0, 0, 0, 0.04);
+		border-radius: 40rpx;
+		text-align: center;
+		line-height: 80rpx;
+		color: #6687EF;
+		font-size: 28rpx;
+		font-weight: 500;
+	}
+
+	.integral-log-main {
+		background: #FFFFFF;
+		min-height: 1400rpx;
+		position: relative;
+		margin-top: -32rpx;
+		border-radius: 32rpx 32rpx 0rpx 0rpx;
+	}
+</style>

+ 112 - 37
pages/video/index.nvue

@@ -4,14 +4,15 @@
 			:autoBack="false">
 		</u-navbar>
 		<swiper :style="'width: '+ windowWidth +'px; height:100vh; background-color: #000;'" class="swiper"
-			:circular='false' @change="swiperChange" :current="swiperCurrent" :vertical="true" duration="300">
+			:circular='false' @change="swiperChange" :current="swiperCurrent" :vertical="true" duration="200">
 			<block v-for="content in videoInfo.updated_episode_num">
 				<swiper-item :key="content">
 					<view :style="'width: '+ windowWidth +'px; height:'+heightxw+'vh;'">
-						<video autoplay :key="content" id="myVideo" :controls="controls" :loop="!isplay"
-							:enable-progress-gesture="false" :show-center-play-btn="false" :show-loading="false"
-							:show-fullscreen-btn="false" @ended="ended" @controlstoggle="controlstoggle"
-							@click="tapVides()" :style="'width: '+ windowWidth +'px; height:'+heightxw+'vh;'"
+						<!-- @controlstoggle="controlstoggle" -->
+						<video v-if="isShowVideo(content)" autoplay :key="content" id="myVideo" :controls="controls"
+							:loop="!isplay" preload="auto" :enable-progress-gesture="true" :show-center-play-btn="false"
+							:show-loading="false" :show-fullscreen-btn="false" @ended="ended" @click="tapVides()"
+							:style="'width: '+ windowWidth +'px; height:'+heightxw+'vh;'"
 							:src="currentVideoInfo.video_url" class="tsvideo">
 						</video>
 						<view v-if="isqp" class="userInfo">
@@ -62,24 +63,25 @@
 				</swiper-item>
 			</block>
 		</swiper>
-		<uni-popup type="bottom" ref="select" style="z-index: 100;">
+		<uni-popup type="bottom" ref="select" style="z-index: 100;" :mask-click="true">
 			<view v-if="fenji==1" class="pop-my">
 				<view class="ju-top">
 					<view style="display: flex; flex-direction: column; ">
 						<view style="display: flex; flex-direction: column;">
 							<view style="display: flex; flex-direction: column;">
-								<u-tabs v-if="fenji==1" :activeStyle="activeStyle" lineColor="none"
-									:inactiveStyle="inactiveStyle" style="align-items: center; width: 100%;"
-									:list="list1" :current="current" @click="click"></u-tabs>
+								<view class="utabs-top">
+									<u-tabs v-if="fenji==1" :activeStyle="activeStyle" lineColor="none"
+										:inactiveStyle="inactiveStyle" class="utabs-top" :list="list1"
+										:current="current"></u-tabs>
+								</view>
 								<view class="ju-top-title">
 									{{videoInfo.name}}
 								</view>
 								<view class="ju-top-update"> 已更新至{{videoInfo.updated_episode_num}}集 </view>
 							</view>
 							<u-tabs v-if="fenji==1" :activeStyle="activeStyle" lineColor="none"
-								:inactiveStyle="inactiveStyle" style="align-items: flex-start; width: 100%;"
-								:list="labelList" @click="click"></u-tabs>
-							{{labelList}}
+								:inactiveStyle="inactiveStyle" :current="tabcurrent" :list="labelList"
+								@click="labelListClick"></u-tabs>
 						</view>
 						<view class="down" @click="down">
 							<text class="down-text">收起</text>
@@ -109,6 +111,20 @@
 			</view>
 			<view v-if="fenji==2"
 				:style="'width: '+ windowWidth +'px;height:500px; background-color: #fff; border-top-left-radius: 10px; border-top-right-radius: 10px;'">
+				<view class="charge-wrapper">
+					<view class="top">
+						<text class="charge-title">充值购买后可继续观看{{topTitle}} </text>
+						<text class="charge-info">为保护创作者权益,当前内容需要付费观看。</text>
+						<view class="charge-coin">
+							<text class="ji">本集:</text>
+							<text class="bi">{{videoInfo.charge_coin}}k币</text>
+						</view>
+					</view>
+					<view class="bottom">
+						<text></text>
+						<text></text>
+					</view>
+				</view>
 			</view>
 		</uni-popup>
 	</view>
@@ -126,10 +142,10 @@
 		storeshelf
 	} from '@/common/apis/zju.js'
 	import configs from "@/common/config.js"
-	let audo = uni.createInnerAudioContext('myVideo')
 	export default {
 		data() {
 			return {
+				limitPage: 15,
 				top_height: 0,
 				episode: 1,
 				swiperCurrent: 0,
@@ -144,16 +160,9 @@
 					color: '#606266',
 					transform: 'scale(1)'
 				},
-				activeIndex: 0,
+				activeIndex: 1,
 				tabcurrent: 0,
-				videoInfo: {
-					"name": "test1-112",
-					"charge_sequence": 24,
-					"charge_coin": 125,
-					"total_episode_num": 98,
-					"updated_episode_num": 24,
-					"update_type": 1
-				},
+				videoInfo: {},
 				labelList: [],
 				list1: [{
 					name: '当前剧集',
@@ -167,6 +176,7 @@
 					strShareSummary: "分享总结",
 					strShareImageUrl: ""
 				},
+				isShow: true,
 				fenji: 0,
 				controls: true,
 				windowWidth: 0,
@@ -184,6 +194,11 @@
 			};
 		},
 		computed: {
+			isShowVideo(item) {
+				return (item) => {
+					return this.swiperCurrent == item && this.isShow
+				}
+			},
 			isShowVip(item) {
 				return (item) => {
 					return item >= this.videoInfo.charge_sequence && item <= this.videoInfo.updated_episode_num
@@ -195,20 +210,20 @@
 				}
 			},
 			topTitle() {
-				return `${this.videoInfo.name} 第${this.episode}集`
+				return `${this.videoInfo.name} 第${this.episode}集`
 			}
 		},
 		onReady: function(res) {
 			this.videoContext = uni.createVideoContext('myVideo')
 		},
 		mounted() {
-			this.initTabs();
 			this.initSwiperData(this.swiperCurrent + 1)
 			getVideoInfo({
 				video_id: this.video_id
 			}).then(res => {
 				// console.log(res, 'getVideoInfogetVideoInfogetVideoInfo')
-				this.videoInfo = res
+				this.videoInfo = res.data
+				this.initTabs();
 			})
 		},
 		onLoad(e) {
@@ -261,6 +276,12 @@
 			return obj
 			// #endif
 		},
+		watch: {
+			activeIndex(newVal, oldVal) {
+				let index = this.labelList.findIndex(el => el.content.includes(newVal))
+				this.tabcurrent = index
+			}
+		},
 		onBackPress() {},
 		methods: {
 			bingewatch() {
@@ -330,7 +351,7 @@
 					}
 					return arr
 				}
-				const pageSize = 15;
+				const pageSize = this.limitPage;
 				const total = this.videoInfo.total_episode_num;
 				const pageCount = Math.ceil(total / pageSize);
 				for (let i = 0; i < pageCount; i++) {
@@ -380,9 +401,9 @@
 					this.down();
 				}
 			},
-			click(item) {
+			labelListClick(item) {
 				this.tabcurrent = item.index
-				console.log('item', item);
+				console.log('itemitemitemitemitem', item);
 			},
 			share() {
 				var href = '/pages/video/index?video_id=' + this.video_id
@@ -446,17 +467,31 @@
 					console.log('显示swiper Index:', this.displayIndex)
 				}
 			},
-			/**
-			 * 初始一个显示的swiper数据
-			 * @originIndex  从源数据的哪个开始显示默认0,如从其他页面跳转进来,要显示第n个,这个参数就是他的下标
-			 */
 			initSwiperData(originIndex) {
-				this.isqp = false
+				this.episode = originIndex;
+				this.isqp = true
 				videoEpisodePlay({
 					video_id: this.video_id,
 					sequence: originIndex
 				}).then(res => {
-					this.currentVideoInfo = res
+					if (res.code == 0) {
+						this.currentVideoInfo = res.data
+						this.activeIndex = this.episode;
+						this.isShow = true
+					} else if (res.code == 500101) {
+						console.log(this.currentVideoInfo, 'res.code == 500101res.code == 500101')
+						this.currentVideoInfo.video_url = ""
+						this.isShow = false
+						this.isqp = true
+						this.videoContext.stop()
+						this.fenji = 2
+						this.$refs.select.open('bottom');
+						// this.currentVideoInfo = {}
+					} else {
+						this.currentVideoInfo.video_url = ""
+						this.isShow = false
+					}
+
 					console.log(res, 'getVideoEpisodePlaygetVideoEpisodePlay')
 				})
 			},
@@ -467,8 +502,8 @@
 				const {
 					current
 				} = event.detail;
-				this.episode = current + 1;
-				this.activeIndex = this.episode;
+				this.swiperCurrent = current
+				console.log(this.swiperCurrent, 'this.swiperCurrentthis.swiperCurrent')
 				this.initSwiperData(current + 1)
 			},
 			controlstoggle(e) {
@@ -479,7 +514,7 @@
 </script>
 
 <style lang="scss" scoped>
-	page {
+	.content {
 		background: #000000;
 	}
 
@@ -535,6 +570,42 @@
 </style>
 
 <style lang="scss" scoped>
+	.charge-wrapper {
+		margin-top: 15px;
+		width: 100%;
+
+		.top {
+			width: 100%;
+			display: flex;
+			align-items: center;
+
+			.charge-title {
+				font-size: 18px;
+				font-weight: bold;
+			}
+
+			.charge-info {
+				font-size: 15px;
+				color: #868686;
+				margin: 8px 0;
+			}
+
+			.charge-coin {
+				display: flex;
+				flex-direction: row;
+
+				.ji {
+					font-size: 18px;
+				}
+
+				.bi {
+					font-size: 18px;
+					color: $accent-color;
+				}
+			}
+		}
+	}
+
 	.down {
 		display: flex;
 		flex-direction: row;
@@ -654,4 +725,8 @@
 			}
 		}
 	}
+
+	.utabs-top /deep/ .u-tabs {
+		align-items: flex-start;
+	}
 </style>

+ 162 - 0
utils/http.js

@@ -0,0 +1,162 @@
+// 引入配置文件
+import config from "@/common/config.js";
+// #ifdef MP-WEIXIN
+import wxApp from "@/common/wecaht.min.app.js"
+import {
+	getToken,
+	clearToken
+} from '@/common/token.js'
+// #endif
+const filterNoToken = ["/api/auth/refreshToken", "/api/auth/login"];
+
+export default {
+	config: {
+		baseUrl: config.apiUrl,
+		header: {
+			'Content-Type': 'application/json;charset=UTF-8',
+		},
+		data: {},
+		method: "GET",
+		dataType: "json",
+	},
+	async request(options = {}) {
+		// 请求拦截器
+		uni.addInterceptor('request', {
+			invoke: (request) => {
+				// 在发送请求之前的处理逻辑,例如添加请求头、请求日志等
+				// request.header = {
+				// 	'Content-Type': 'application/json', // 设置请求头
+				// 	// 在这里可以添加其他自定义请求头
+				// };
+				// console.log('Request:', request);
+				return request;
+			},
+		});
+		// 响应拦截器
+		uni.addInterceptor('response', {
+			invoke: (response) => {
+				// 在接收到响应数据之后的处理逻辑,例如统一处理错误码、响应日志等
+				// console.log('Response:', response);
+				return response;
+			},
+		});
+		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  
+		//	微信小程序处理
+		options.header.appid = wxApp.getWXAppId();
+		options.header.source = 'wxapp';
+		// 过滤不需要token的api
+		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)
+		return new Promise((resolve, reject) => {
+			options.success = (e) => {
+				console.log(e, 'successsuccesssuccesssuccesssuccess')
+				let res = e.data;
+				if (e.statusCode === 200) {
+					if (res.code == 500201) {
+						// 未登录
+						clearToken();
+						getToken();
+						if (filterNoToken.indexOf(options.url) === -1) {
+							return this.request(options);
+						}
+					} else {
+						if (res.code != 0) {
+							uni.showToast({
+								title: res.msg,
+								duration: 1000,
+								icon: 'none'
+							});
+						}
+					}
+					resolve(res);
+				} else {
+					uni.showToast({
+						title: "网络异常,请稍后再试",
+						duration: 1000,
+						icon: 'none'
+					});
+					reject(new Error('Request failed'));
+				}
+			}
+			options.fail = (err) => {
+				console.log(err)
+				reject(err);
+			}
+			uni.request(options)
+		})
+
+	},
+	get(url, data, options = {}) {
+		options.url = url;
+		options.data = data;
+		options.method = 'GET';
+		return this.request(options);
+	},
+	post(url, data, options = {}) {
+		options.url = url;
+		options.data = data;
+		options.method = 'POST';
+		return this.request(options);
+	},
+
+	// 上传图片
+	upload(url, options = {}) {
+		options.url = this.config.baseUrl + url;
+		options.header = options.header || this.config.header;
+		options.fileType = options.fileType || "image";
+		options.formData = options.formData || {};
+		options.filePath = options.filePath;
+		options.name = options.name;
+		// TODO:token增加等操作
+		if (options.token) {
+			// 验证是否登录
+			if (!this.checkToken(options.checkToken)) return;
+			// 验证权限
+			if (!this.checkAuth(options.checkAuth)) return;
+			options.header.token = User.token;
+		}
+
+		return uni.uploadFile(options);
+	},
+	// 错误处理
+	errorCheck(err, res, errfun = false, resfun = false) {
+		if (err) {
+			typeof errfun === 'function' && errfun();
+			uni.showToast({
+				title: '加载失败',
+				icon: "none"
+			});
+			return false;
+		}
+		if (res.data.errorCode) {
+			typeof errfun === 'function' && resfun();
+			uni.showToast({
+				title: res.data.msg,
+				icon: "none"
+			});
+			return false;
+		}
+		return true;
+	},
+	async getTokenString() {
+		// console.log('getTokenString-----start');
+		await getToken();
+		let token = uni.getStorageSync('token');
+		// token格式化
+		if (token && typeof token === "string") {
+			token = JSON.parse(token);
+		}
+		// console.log('getTokenString--end', token);
+		return token.token;
+	}
+}