From 36028936c7464e7469dd411ee7ad729399acafe1 Mon Sep 17 00:00:00 2001 From: YeMingfei666 <1619116647@qq.com> Date: Mon, 13 Jan 2025 10:52:47 +0800 Subject: [PATCH 1/6] =?UTF-8?q?=E8=A7=86=E9=A2=91=E5=88=97=E8=A1=A8?= =?UTF-8?q?=E7=BB=84=E4=BB=B6=E4=BB=A3=E7=A0=81=E6=9B=B4=E6=96=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- components/my-video-list/list-item.vue | 20 +++++-- components/my-video-list/my-video-list.vue | 61 +++++++++++----------- 2 files changed, 47 insertions(+), 34 deletions(-) diff --git a/components/my-video-list/list-item.vue b/components/my-video-list/list-item.vue index c5c557d..3878bab 100644 --- a/components/my-video-list/list-item.vue +++ b/components/my-video-list/list-item.vue @@ -4,12 +4,13 @@ - + @@ -150,8 +151,11 @@ function waiting() { } - + + + let isPlying=false function videoPlay() { + isPlying=true // #ifdef H5 emits('controlstoggles', { detail:{show:true} @@ -161,6 +165,7 @@ } function onpause(){ + isPlying=false // #ifdef H5 emits('controlstoggles', { detail:{show:false} @@ -187,7 +192,16 @@ function popupShow(key) { emits('popupShow', key) } - + function videoClick(){ + if(video){ + if(isPlying){ + video.pause() + }else{ + video.play() + } + } + } + let first = true function appear() { diff --git a/components/my-video-list/my-video-list.vue b/components/my-video-list/my-video-list.vue index f3bb27b..cbfba9e 100644 --- a/components/my-video-list/my-video-list.vue +++ b/components/my-video-list/my-video-list.vue @@ -10,7 +10,7 @@ :showControls="control.showControls" :current="current" :isCollect="isCollect" @toDetail="toDetail(item,index)" @controlstoggles="controlstoggles" :playSpeeds="playSpeeds" :index="index" :nowIndex="nowIndex" @dianzanClick="dianzanClick(item,index)" @share="share(item)" - @zhuijuClick="zhuijuClick(item)" @popupShow="popupShow"> + @zhuijuClick="zhuijuClick(item)" @popupShow="popupShow($event,item,index)"> @@ -27,7 +27,7 @@ @itemMounted="itemMounted" @controlstoggles="controlstoggles" :index="index" :instance="instance" :nowIndex="nowIndex" @appear="appear($event,item,index)" :playSpeeds="playSpeeds" @disappear="disappear(item,index)" @dianzanClick="dianzanClick(item,index)" @share="share(item)" - @zhuijuClick="zhuijuClick(item)" @popupShow="popupShow"> + @zhuijuClick="zhuijuClick(item)" @popupShow="popupShow($event,item,index)"> @@ -80,15 +80,19 @@ 每日前10次付款均可获取抽奖机会,抽奖保底抽中付款金额等额红包,红包可直接提现。当前为第1次付款 - + {{info.price}}元解锁全剧 - + + + {{info.price}}元解锁全剧 + + {{nowDanjiPrice*jinbiBili}}金币解锁单集视频 - + {{nowDanjiPrice}}元解锁单集视频 @@ -121,7 +125,7 @@ - + 我已经阅读并同意 @@ -129,7 +133,7 @@ - + 确认支付 @@ -287,7 +291,9 @@ show: false, pay: false, payTips: false, - speed: false + speed: false, + data:null, + payType:null }) @@ -321,12 +327,22 @@ //确认支付 function payConfirm() { + console.log(isAgree.value); if (!isAgree.value) { return infoBox.showToast('请阅读并同意 《付费须知说明》') } + let data = { + courseId: this.courseId + } + if(popup.payType=='all'){ + + } + + } - function payBtnClick() { + function payBtnClick(type,num) { + popup.payType=`${type}-${num}` popupClose() popupShow('payTips') } @@ -384,8 +400,11 @@ } } - function popupShow(key = 'show') { + function popupShow(key = 'show',item,index) { + console.log(item); popup[key] = true + popup['data'] = item + popup['index'] = index } @@ -419,22 +438,6 @@ } - const posterData = reactive({ - show: false, - // 用户姓名 - name: '小明', - // 用户头像 - logo: '/static/images/share.png', - // 商品名称 - title: '精美时尚苹果手机一部', - // 商品价格 - money: '5200.90', - // 商品图片(小程序需要换成自己服务器白名单设置的地址) - img: '', - // 商品链接 - url: 'https://www.apple.com.cn/iphone/' - - }) let nowIndex = ref(0) let current = ref(0) let videoList = ref([]) @@ -537,10 +540,6 @@ } - function posterHide() { - posterData.show = false - } - const insertHistory = debounce(() => { @@ -603,7 +602,7 @@ } console.log(videoList.value); if (!item.videoUrl) { - popupShow('pay') + popupShow('pay',item,index) } } From 8728844446c0328ef51069199c40671dc4db8c2f Mon Sep 17 00:00:00 2001 From: YeMingfei666 <1619116647@qq.com> Date: Mon, 13 Jan 2025 13:57:50 +0800 Subject: [PATCH 2/6] =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E6=94=AF=E4=BB=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- api/video/index.js | 44 +++ components/my-video-list/my-video-list.vue | 116 +++++-- http/http.js | 363 +++++++++++---------- pages.json | 7 + pages/pays/pays.vue | 86 +++++ pages/video/detail.nvue | 28 +- 6 files changed, 421 insertions(+), 223 deletions(-) create mode 100644 pages/pays/pays.vue diff --git a/api/video/index.js b/api/video/index.js index 77b8b56..661a324 100644 --- a/api/video/index.js +++ b/api/video/index.js @@ -66,3 +66,47 @@ export function tuijianVideo(data){ } }) } +//解锁10集视频 +export function buyTenVideo(data){ + return http.request({ + url: 'order/insertCourseOrders/limit10', + method:'GET', + data:data + }) +} +//解锁单集或者全部视频 +export function buyVideo(data){ + return http.request({ + url: 'order/insertCourseOrders', + method:'GET', + data:data + }) +} +//订单支付 +export function payOrder(data){ + let payType='h5' + // #ifdef APP + payType='app' + // #endif + return http.request({ + url: 'wuyou/payOrder/'+data.orderId+'?payType='+payType, + method:'GET' + }) +} +//获取订单支付状态 +export function getOrderInfo(data){ + return http.request({ + url: 'wuyou/queryOrder/'+data.orderId, + method:'GET' + }) +} +//金币解锁 +export function goldPay(data){ + return http.request({ + url: 'order/payOrders', + method:'POST', + data:{...data,header:{ + 'content-type':'application/x-www-form-urlencoded' + }} + }) +} \ No newline at end of file diff --git a/components/my-video-list/my-video-list.vue b/components/my-video-list/my-video-list.vue index cbfba9e..addc099 100644 --- a/components/my-video-list/my-video-list.vue +++ b/components/my-video-list/my-video-list.vue @@ -5,12 +5,12 @@ @change="swiperChange" :current="current" :circular="true" vertical class="u-flex-1" @transition="transition" :indicator-dots="false" :autoplay="false" :interval="0" :duration="200"> - + @@ -22,12 +22,12 @@ + :rightStyle="rightStyle" :infoStyle="infoStyle" :isCommand="isCommand" + :showControls="control.showControls" @toDetail="toDetail(item,index)" @itemMounted="itemMounted" + @controlstoggles="controlstoggles" :index="index" :instance="instance" :nowIndex="nowIndex" + @appear="appear($event,item,index)" :playSpeeds="playSpeeds" @disappear="disappear(item,index)" + @dianzanClick="dianzanClick(item,index)" @share="share(item)" @zhuijuClick="zhuijuClick(item)" + @popupShow="popupShow($event,item,index)"> @@ -125,7 +125,8 @@ - + 我已经阅读并同意 @@ -213,7 +214,7 @@ showControls: true }) // #ifdef APP - control.showControls=false + control.showControls = false // #endif const customStyle = computed(() => { @@ -229,7 +230,7 @@ function controlstoggles(e) { control.showControls = e.detail.show - console.log(control.showControls ); + console.log(control.showControls); control.showBack = control.showControls console.log(control); } @@ -292,8 +293,8 @@ pay: false, payTips: false, speed: false, - data:null, - payType:null + data: null, + payType: null }) @@ -325,25 +326,68 @@ } + + //非金币支付 + async function payOrder(data) { + const res = await Api.payOrder(data) + console.log(res); + if (res) { + uni.navigateTo({ + url: '/pages/pays/pays?orderId=' + data.orderId + '&url=' + res.h5Url + }); + return + // #ifdef APP + uni.navigateTo({ + url: '/pages/pays/pays?orderId=' + res.orderId + '&url=' + res.h5Url + }); + // #endif + // #ifdef H5 + window.location.href = res.h5Url + // #endif + } + } + //金币支付 + async function goldPay(data) { + const res = await Api.goldPay(data) + console.log(res); + } //确认支付 - function payConfirm() { - console.log(isAgree.value); + async function payConfirm() { if (!isAgree.value) { return infoBox.showToast('请阅读并同意 《付费须知说明》') } + const [type, num] = popup.payType.split('-'); + console.log(type, num); let data = { - courseId: this.courseId + courseId: popup.data.courseId } - if(popup.payType=='all'){ + if (num == 1) { + data.courseDetailsId = popup.data.courseDetailsId + } + + const res = num == '10' ? await Api.buyTenVideo(data) : await Api.buyVideo(data) + if (res) { + if(type=='gold'){ + goldPay({ + orderId: res.orders.ordersId + }) + }else{ + payOrder({ + orderId: res.orders.ordersId + }) + } + + } else { } - - + + } - function payBtnClick(type,num) { - popup.payType=`${type}-${num}` - popupClose() + function payBtnClick(type, num) { + console.log(type, num); + popup.payType = `${type}-${num}` + popupClose('show') popupShow('payTips') } @@ -370,7 +414,10 @@ }; } //滚动到指定位置 + let positonmer = null + function goListPosition(index) { + clearTimeout(positonmer) console.log('goListPosition:' + index) const el = refList.value[index] if ($mountedComponents[props.list.length - 1]) { @@ -382,7 +429,7 @@ setVideoList(item) insertHistory() } else { - setTimeout(() => { + positonmer = setTimeout(() => { goListPosition(index) }, 30) } @@ -400,11 +447,13 @@ } } - function popupShow(key = 'show',item,index) { + function popupShow(key = 'show', item, index) { console.log(item); popup[key] = true - popup['data'] = item - popup['index'] = index + if (item) { + popup['data'] = item + popup['index'] = index + } } @@ -602,7 +651,7 @@ } console.log(videoList.value); if (!item.videoUrl) { - popupShow('pay',item,index) + popupShow('pay', item, index) } } @@ -632,7 +681,7 @@ const nowDanjiPrice = computed(() => { return videoList.value[current.value].price }) - const rightStyle=computed(()=>{ + const rightStyle = computed(() => { // #ifdef H5 return { transform: `translateX(${!control.showControls?'0':60}px)` @@ -644,7 +693,7 @@ } // #endif }) - const infoStyle=computed(()=>{ + const infoStyle = computed(() => { // #ifdef H5 return { transform: `translateX(${!control.showControls?0:'-110%'})` @@ -656,6 +705,7 @@ } // #endif }) + function loadmore() { console.log('loadmore'); } diff --git a/http/http.js b/http/http.js index 2cdba93..72572f4 100644 --- a/http/http.js +++ b/http/http.js @@ -1,152 +1,161 @@ // 导入全局属性 -import { sm4DecryptByResData } from "@/utils/encryptUtil.js"; +import { + sm4DecryptByResData +} from "@/utils/encryptUtil.js"; import infoBox from "@/utils/infoBox.js"; -import { reject } from "lodash"; +import { + reject +} from "lodash"; import config from "@/commons/config.js"; // 测试服 let baseUrl = config.baseApiUrl + "app"; const loadingShowTime = 200; -function getHeader() { - const headerObject = {}; - headerObject["token"] = uni.getStorageSync("token"); - return headerObject; +function getHeader(data) { + const header = data ? data.header : {} + const headerObject = { + ...header + }; + headerObject["token"] = uni.getStorageSync("token"); + return headerObject; } // 通用处理逻辑 -function commonsProcess(showLoading, httpReqCallback,isreturm) { - // 判断是否请求完成(用作 是否loading ) - // 包括: 'ing', 'ingLoading', 'finish' - let reqState = "ing"; - // 是否已经提示的错误信息 - let isShowErrorToast = false; - // 请求完成, 需要处理的动作 - let reqFinishFunc = () => { - if (reqState == "ingLoading") { - // 关闭loading弹层 - infoBox.hideLoading(); - } - reqState = "finish"; // 请求完毕 - }; - // 明确显示loading - if (showLoading) { - // xx ms内响应完成,不提示loading - setTimeout(() => { - if (reqState == "ing") { - reqState = "ingLoading"; - infoBox.showLoading(); - } - }, loadingShowTime); - } +function commonsProcess(showLoading, httpReqCallback, isreturm) { + // 判断是否请求完成(用作 是否loading ) + // 包括: 'ing', 'ingLoading', 'finish' + let reqState = "ing"; + // 是否已经提示的错误信息 + let isShowErrorToast = false; + // 请求完成, 需要处理的动作 + let reqFinishFunc = () => { + if (reqState == "ingLoading") { + // 关闭loading弹层 + infoBox.hideLoading(); + } + reqState = "finish"; // 请求完毕 + }; + // 明确显示loading + if (showLoading) { + // xx ms内响应完成,不提示loading + setTimeout(() => { + if (reqState == "ing") { + reqState = "ingLoading"; + infoBox.showLoading(); + } + }, loadingShowTime); + } - return httpReqCallback() - .then((httpData) => { + return httpReqCallback() + .then((httpData) => { - reqFinishFunc(); // 请求完毕的动作 - // 从http响应数据中解构响应数据 [ 响应码、 bodyData ] - let { statusCode, data } = httpData; - // 避免混淆重新命名 - let bodyData = data; - if(isreturm){ - return Promise.resolve(bodyData.data || bodyData.page|| bodyData); - } - if (statusCode == 500) { - isShowErrorToast = true; - return Promise.reject(bodyData); // 跳转到catch函数 - } + reqFinishFunc(); // 请求完毕的动作 + // 从http响应数据中解构响应数据 [ 响应码、 bodyData ] + let { + statusCode, + data + } = httpData; + // 避免混淆重新命名 + let bodyData = data; + if (isreturm) { + return Promise.resolve(bodyData.data || bodyData.page || bodyData); + } + if (statusCode == 500) { + isShowErrorToast = true; + return Promise.reject(bodyData); // 跳转到catch函数 + } - if (statusCode == 401) { - // 提示信息 - isShowErrorToast = true; - return Promise.reject(bodyData); // 跳转到catch函数 - } - // http响应码不正确 - if (statusCode != 200 && statusCode != 204 && statusCode != 201) { - isShowErrorToast = true; - data.message = - data.message == "Bad credentials" ? "用户名或密码错误" : data.message; - infoBox.showToast(data.message || "服务器异常"); - return Promise.reject(bodyData); // 跳转到catch函数 - } - if (bodyData.code == 401) { - // 提示信息 - isShowErrorToast = true; - return Promise.reject(bodyData); // 跳转到catch函数 - } - if (bodyData.code == 500) { - // 提示信息 - isShowErrorToast = true; - return Promise.reject(bodyData); // 跳转到catch函数 - } - if (bodyData.code != 0) { - infoBox.showToast(data.message); - return; - } + if (statusCode == 401) { + // 提示信息 + isShowErrorToast = true; + return Promise.reject(bodyData); // 跳转到catch函数 + } + // http响应码不正确 + if (statusCode != 200 && statusCode != 204 && statusCode != 201) { + isShowErrorToast = true; + data.message = + data.message == "Bad credentials" ? "用户名或密码错误" : data.message; + infoBox.showToast(data.message || "服务器异常"); + return Promise.reject(bodyData); // 跳转到catch函数 + } + if (bodyData.code == 401) { + // 提示信息 + isShowErrorToast = true; + return Promise.reject(bodyData); // 跳转到catch函数 + } + if (bodyData.code == 500) { + // 提示信息 + isShowErrorToast = true; + return Promise.reject(bodyData); // 跳转到catch函数 + } + if (bodyData.code != 0) { + infoBox.showToast(data.message); + return; + } - // 加密数据 - if (!bodyData.data && bodyData.encryptData) { - return Promise.resolve({ - bizData: sm4DecryptByResData(bodyData.encryptData), - code: bodyData.code, - }); - } - - // 构造请求成功的响应数据 - return Promise.resolve(bodyData.data || bodyData.page|| bodyData); - }) - .catch((res) => { - - if (res.status == 404) { - infoBox.showErrorToast("接口404").then(() => {}); - reject(); - return; - } + // 加密数据 + if (!bodyData.data && bodyData.encryptData) { + return Promise.resolve({ + bizData: sm4DecryptByResData(bodyData.encryptData), + code: bodyData.code, + }); + } - if (res.code == 401) { - infoBox.showErrorToast(res.message || "请登录").then(() => { - uni.redirectTo({ - url: "/pages/login/login", - }); - reject(); - }); - } - if (res.code != 0) { - infoBox.showErrorToast(res.msg).then(() => {}); - reject(); - } - if (res.code == 500) { - infoBox.showErrorToast(res.msg || "服务器异常").then(() => {}); - reject(); - } - reqFinishFunc(); // 请求完毕的动作 + // 构造请求成功的响应数据 + return Promise.resolve(bodyData.data || bodyData.page || bodyData); + }) + .catch((res) => { - // 如果没有提示错误, 那么此处提示 异常。 - if (!isShowErrorToast) { - infoBox.showErrorToast(`请求网络异常`); - } + if (res.status == 404) { + infoBox.showErrorToast("接口404").then(() => {}); + reject(); + return; + } - return Promise.reject(res); - }) - .finally(() => { - // finally 是 then结束后再执行, 此处不适用。 需要在请求完成后立马调用: reqFinishFunc() - }); + if (res.code == 401) { + infoBox.showErrorToast(res.message || "请登录").then(() => { + uni.redirectTo({ + url: "/pages/login/login", + }); + reject(); + }); + } + if (res.code != 0) { + infoBox.showErrorToast(res.msg).then(() => {}); + reject(); + } + if (res.code == 500) { + infoBox.showErrorToast(res.msg || "服务器异常").then(() => {}); + reject(); + } + reqFinishFunc(); // 请求完毕的动作 + + // 如果没有提示错误, 那么此处提示 异常。 + if (!isShowErrorToast) { + infoBox.showErrorToast(`请求网络异常`); + } + + return Promise.reject(res); + }) + .finally(() => { + // finally 是 then结束后再执行, 此处不适用。 需要在请求完成后立马调用: reqFinishFunc() + }); } // 默认 显示loading(控制 xxs 内 不提示loading ) function req(uri, data, method = "GET", showLoading = true, extParams = {}) { - return commonsProcess(showLoading, () => { - return uni.request( - Object.assign( - { - url: baseUrl + uri, - data: data, - method: method, - header: getHeader(), - }, - extParams - ) - ); - }); + return commonsProcess(showLoading, () => { + return uni.request( + Object.assign({ + url: baseUrl + uri, + data: data, + method: method, + header: getHeader(data), + }, + extParams + ) + ); + }); } // 默认 显示loading(控制 xxs 内 不提示loading ) @@ -158,16 +167,17 @@ function request(args) { method = "GET", showLoading = true, extParams = {}, - isreturm=false + isreturm = false } = args if (params) { let result = '' Object.keys(params).forEach((key) => { - if (!Object.is(params[key], undefined) && !Object.is(params[key], null) && !Object.is(JSON.stringify(params[key]), '{}')) { - result += encodeURIComponent(key) + '=' + encodeURIComponent(params[key]) + "&" - } + if (!Object.is(params[key], undefined) && !Object.is(params[key], null) && !Object.is(JSON + .stringify(params[key]), '{}')) { + result += encodeURIComponent(key) + '=' + encodeURIComponent(params[key]) + "&" + } }) - url = url+'?'+(result.slice(0,result.length-1)) + url = url + '?' + (result.slice(0, result.length - 1)) params = null } let headerObject = {} @@ -177,60 +187,59 @@ function request(args) { url: slash(baseUrl, url), data: params || data, method: method, - header: getHeader() + header: getHeader(data) }, extParams) ) - },isreturm) + }, isreturm) } // 处理/ function slash(baseUrl, url) { - let u = ""; - if (baseUrl[baseUrl.length - 1] == "/") { - u += baseUrl; - } else { - u = u + baseUrl + "/"; - } - if (url[0] == "/") { - u = u + url.slice(1); - } else { - u = u + url; - } - return u; + let u = ""; + if (baseUrl[baseUrl.length - 1] == "/") { + u += baseUrl; + } else { + u = u + baseUrl + "/"; + } + if (url[0] == "/") { + u = u + url.slice(1); + } else { + u = u + url; + } + return u; } // 上传 function upload(uri, data, file, showLoading = true, extParams = {}) { - // 放置token - let headerObject = {}; - return commonsProcess(showLoading, () => { - return uni - .uploadFile( - Object.assign( - { - url: baseUrl + uri, - formData: data, - name: "file", - filePath: file.path || file.url, - header: getHeader(), - }, - extParams - ) - ) - .then((httpData) => { - // uni.upload 返回bodyData 的是 string类型。 需要解析。 - httpData.data = JSON.parse(httpData.data); - return Promise.resolve(httpData); - }) - .catch((err) => { - uni.hideLoading(); - infoBox.showErrorToast(`上传失败`); - }); - }); + // 放置token + let headerObject = {}; + return commonsProcess(showLoading, () => { + return uni + .uploadFile( + Object.assign({ + url: baseUrl + uri, + formData: data, + name: "file", + filePath: file.path || file.url, + header: getHeader(data), + }, + extParams + ) + ) + .then((httpData) => { + // uni.upload 返回bodyData 的是 string类型。 需要解析。 + httpData.data = JSON.parse(httpData.data); + return Promise.resolve(httpData); + }) + .catch((err) => { + uni.hideLoading(); + infoBox.showErrorToast(`上传失败`); + }); + }); } export default { - req: req, - request, - upload: upload, -}; + req: req, + request, + upload: upload, +}; \ No newline at end of file diff --git a/pages.json b/pages.json index 794f373..c82795c 100644 --- a/pages.json +++ b/pages.json @@ -192,6 +192,13 @@ { "navigationBarTitleText" : "抽奖" } + }, + { + "path" : "pages/pays/pays", + "style" : + { + "navigationBarTitleText" : "" + } } ], "globalStyle": { diff --git a/pages/pays/pays.vue b/pages/pays/pays.vue new file mode 100644 index 0000000..5ef6368 --- /dev/null +++ b/pages/pays/pays.vue @@ -0,0 +1,86 @@ + + + + \ No newline at end of file diff --git a/pages/video/detail.nvue b/pages/video/detail.nvue index 2bff792..da418ea 100644 --- a/pages/video/detail.nvue +++ b/pages/video/detail.nvue @@ -1,8 +1,7 @@ @@ -18,8 +17,8 @@ import { slice } from 'lodash' - const boxStyle={ - height:'835px' + const boxStyle = { + height: '835px' } let options = {} const state = reactive({ @@ -44,23 +43,26 @@ // } } } - function update({index,item}){ - state.list[index]=item + + function update({ + index, + item + }) { + state.list[index] = item } onLoad((opt) => { Object.assign(options, opt) init() }) - + function swiperChange({ current, direction, data - }) { - } + }) {} onShow(() => { - + init() }) @@ -71,8 +73,8 @@ background-color: #000; overflow: hidden; } - .u-popup{ + + .u-popup { position: fixed; } - \ No newline at end of file From adf4fcfcfcf076eca84be6c10c45a13f89b46888 Mon Sep 17 00:00:00 2001 From: YeMingfei666 <1619116647@qq.com> Date: Mon, 13 Jan 2025 14:33:04 +0800 Subject: [PATCH 3/6] =?UTF-8?q?=E4=BF=AE=E5=A4=8Dh5=E4=B8=80=E8=BF=9B?= =?UTF-8?q?=E6=9D=A5=E6=98=AF=E6=9C=AA=E8=A7=A3=E9=94=81=E5=89=A7=E9=9B=86?= =?UTF-8?q?=E6=97=B6=E9=80=89=E9=9B=86=E7=AD=89=E4=BF=A1=E6=81=AF=E4=B8=8D?= =?UTF-8?q?=E5=87=BA=E7=8E=B0=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- components/my-video-list/list-item.vue | 1 + components/my-video-list/my-video-list.vue | 42 ++++++++++++++++------ pages/video/detail.nvue | 6 +++- 3 files changed, 37 insertions(+), 12 deletions(-) diff --git a/components/my-video-list/list-item.vue b/components/my-video-list/list-item.vue index 3878bab..f1f1cbc 100644 --- a/components/my-video-list/list-item.vue +++ b/components/my-video-list/list-item.vue @@ -233,6 +233,7 @@ }) onMounted(() => { init() + console.log('itemMounted', props.index); emits('itemMounted', props.index) }) diff --git a/components/my-video-list/my-video-list.vue b/components/my-video-list/my-video-list.vue index addc099..acd7606 100644 --- a/components/my-video-list/my-video-list.vue +++ b/components/my-video-list/my-video-list.vue @@ -332,10 +332,6 @@ const res = await Api.payOrder(data) console.log(res); if (res) { - uni.navigateTo({ - url: '/pages/pays/pays?orderId=' + data.orderId + '&url=' + res.h5Url - }); - return // #ifdef APP uni.navigateTo({ url: '/pages/pays/pays?orderId=' + res.orderId + '&url=' + res.h5Url @@ -348,8 +344,20 @@ } //金币支付 async function goldPay(data) { + emits('update', { + index: popup.index + }) const res = await Api.goldPay(data) - console.log(res); + if (res) { + uni.showToast({ + title: '解锁成功', + icon: 'none' + }) + emits('update', { + index: popup.index + }) + } + } //确认支付 async function payConfirm() { @@ -364,21 +372,21 @@ if (num == 1) { data.courseDetailsId = popup.data.courseDetailsId } - + const res = num == '10' ? await Api.buyTenVideo(data) : await Api.buyVideo(data) if (res) { - if(type=='gold'){ + if (type == 'gold') { goldPay({ orderId: res.orders.ordersId }) - }else{ + } else { payOrder({ orderId: res.orders.ordersId }) } - + } else { - + } @@ -420,7 +428,7 @@ clearTimeout(positonmer) console.log('goListPosition:' + index) const el = refList.value[index] - if ($mountedComponents[props.list.length - 1]) { + if ($mountedComponents[props.list.length - 1] && $mountedComponents[index]) { domModule.scrollToElement(el, { animated: false }) @@ -682,6 +690,12 @@ return videoList.value[current.value].price }) const rightStyle = computed(() => { + const item = props.list[nowIndex.value] + if (!item.videoUrl) { + return { + transform: `translateX(0)` + } + } // #ifdef H5 return { transform: `translateX(${!control.showControls?'0':60}px)` @@ -694,6 +708,12 @@ // #endif }) const infoStyle = computed(() => { + const item = props.list[nowIndex.value] + if (!item.videoUrl) { + return { + transform: `translateX(0)` + } + } // #ifdef H5 return { transform: `translateX(${!control.showControls?0:'-110%'})` diff --git a/pages/video/detail.nvue b/pages/video/detail.nvue index da418ea..e27861d 100644 --- a/pages/video/detail.nvue +++ b/pages/video/detail.nvue @@ -48,7 +48,11 @@ index, item }) { - state.list[index] = item + if(item){ + state.list[index] = item + }else{ + init() + } } onLoad((opt) => { Object.assign(options, opt) From 3433ebb6aaed61c235cd1283c6601871c66e2189 Mon Sep 17 00:00:00 2001 From: YeMingfei666 <1619116647@qq.com> Date: Mon, 13 Jan 2025 15:50:56 +0800 Subject: [PATCH 4/6] =?UTF-8?q?=E8=A7=86=E9=A2=91=E5=88=97=E8=A1=A8?= =?UTF-8?q?=E6=94=AF=E4=BB=98=E6=9B=B4=E6=96=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- components/my-video-list/list-item.vue | 95 ++++++++++++++-------- components/my-video-list/my-video-list.vue | 73 ++++++----------- pages/pays/pays.vue | 3 +- pages/video/detail.nvue | 10 ++- 4 files changed, 92 insertions(+), 89 deletions(-) diff --git a/components/my-video-list/list-item.vue b/components/my-video-list/list-item.vue index f1f1cbc..d1cc9bb 100644 --- a/components/my-video-list/list-item.vue +++ b/components/my-video-list/list-item.vue @@ -2,15 +2,14 @@ - + @@ -44,8 +43,8 @@ 分享 - - + + {{isCollect?'已追':'追剧'}} @@ -71,19 +70,19 @@ } } }, - rightStyle:{ - type:Object, - default:()=>{ + rightStyle: { + type: Object, + default: () => { return { - + } } }, - infoStyle:{ - type:Object, - default:()=>{ + infoStyle: { + type: Object, + default: () => { return { - + } } }, @@ -125,7 +124,7 @@ type: Number, default: 1 }, - showControls:{ + showControls: { type: Boolean, default: true } @@ -133,11 +132,10 @@ let autoplay = ref(props.item.videoUrl ? true : false) const emits = defineEmits(['controlstoggles', 'disappear', 'appear', 'waiting', 'videoPlay', 'ended', 'dianzanClick', - 'share', 'zhuijuClick', 'popupShow', 'itemMounted', 'toDetail' + 'share', 'zhuijuClick', 'popupShow', 'itemMounted', 'toDetail', 'showInfo' ]) function controlstoggles(e) { - console.log(e); emits('controlstoggles', e) } @@ -151,28 +149,39 @@ function waiting() { } + + + let isPlying = ref(false) + watch(() => isPlying.value, (newval) => { + console.log(newval); + emits('showInfo', newval) + }) - - let isPlying=false function videoPlay() { - isPlying=true + isPlying.value = true // #ifdef H5 emits('controlstoggles', { - detail:{show:true} + detail: { + show: true + } }) // #endif - + } - - function onpause(){ - isPlying=false + + function onpause() { + isPlying.value = false // #ifdef H5 emits('controlstoggles', { - detail:{show:false} + detail: { + show: false + } }) // #endif } + + function ended() { } @@ -192,16 +201,18 @@ function popupShow(key) { emits('popupShow', key) } - function videoClick(){ - if(video){ - if(isPlying){ + + function videoClick() { + console.log('videoClick'); + if (video) { + if (isPlying.value) { video.pause() - }else{ + } else { video.play() } } } - + let first = true function appear() { @@ -233,7 +244,6 @@ }) onMounted(() => { init() - console.log('itemMounted', props.index); emits('itemMounted', props.index) }) @@ -242,6 +252,8 @@ if (props.item.videoUrl && showVideo.value) { video = uni.createVideoContext('myVideo' + props.item.courseDetailsId) video.playbackRate(props.playSpeeds) + video.play() + console.log('init play'); } } catch (error) { console.error('------') @@ -255,13 +267,28 @@ } }) watch(() => showVideo.value, (newval) => { + console.log('showVideo change:'+newval); if (newval) { - init() + nextTick(()=>{ + init() + }) } else { video = null } }) + + const infoStyle = computed(() => { + return { + transform: `translateX(${(!isPlying.value||!props.item.videoUrl)?0:'-110%'})` + } + }) + + const rightStyle = computed(() => { + return { + transform: `translateX(${(!isPlying.value||!props.item.videoUrl)?'0':60}px)` + } + })