视频详情点赞 弹窗 青少年模式流程问题

This commit is contained in:
sx 2025-02-18 14:08:33 +08:00
parent e13df41690
commit ccb6b7af80
8 changed files with 147 additions and 70 deletions

View File

@ -6,8 +6,8 @@ const config = {
// host: 'h5api', // host: 'h5api',
// #endif // #endif
// #ifndef H5 // #ifndef H5
host: 'http://91f.xyz:8080', // host: 'http://91f.xyz:8080',
// host: 'http://b2xbj5.natappfree.cc', host: 'http://epiryz.natappfree.cc',
// #endif // #endif
// 支付方式配置 // 支付方式配置
payType: { payType: {

View File

@ -213,7 +213,7 @@ const util = {
responseType: params.responseType || 'text', responseType: params.responseType || 'text',
// 请求成功返回 // 请求成功返回
success: res => { success: res => {
console.log('request success', url, res, params.data ? params.data : '') // console.log('request success', url, res, params.data ? params.data : '')
// 关闭加载效果 // 关闭加载效果
if (params.load) { if (params.load) {
uni.hideLoading() uni.hideLoading()
@ -1535,16 +1535,12 @@ const util = {
let userinfo = uni.$store.state.userinfo let userinfo = uni.$store.state.userinfo
return new Promise((resolve, reject) => { return new Promise((resolve, reject) => {
// 登录 // 登录
if (!userinfo.id) { if (userinfo.id) {
// util.alert('请先登录')
// 失败
reject()
} else {
// 成功 // 成功
resolve() resolve()
// 回调 // 回调
cb ? cb() : '' cb ? cb() : ''
} } else reject()
}) })
}, },

View File

@ -63,7 +63,7 @@
type: Number, type: Number,
default: 0, default: 0,
}, },
// 0 1 // 0 1
statistic: { statistic: {
type: [String, Number], type: [String, Number],
default: 0, default: 0,
@ -113,7 +113,6 @@
if (Math.abs(formatNumber(ratio2) - formatNumber(ratio1)) < 1) result = 'cover' if (Math.abs(formatNumber(ratio2) - formatNumber(ratio1)) < 1) result = 'cover'
return result return result
}) })
const userinfo = uni.$store.state.userinfo
watch(() => props.current, (nV) => { watch(() => props.current, (nV) => {
if (nV == props.index) play() if (nV == props.index) play()
@ -137,8 +136,6 @@
// //
if (isTap.value) { if (isTap.value) {
return return
tapList.length = 0
changeVideoPlay()
} else { } else {
isTap.value = true isTap.value = true
// //
@ -389,11 +386,11 @@
*/ */
function handleLike(index, likeType, isLike) { function handleLike(index, likeType, isLike) {
util.isLogin().then(rs => { util.isLogin().then(rs => {
emit('like', { emit('like', {
index, index,
likeType, likeType,
isLike, isLike,
}) })
}).catch(() => { }).catch(() => {
uni.navigateTo({ uni.navigateTo({
url: '/pages/login/loginPhone' url: '/pages/login/loginPhone'
@ -552,7 +549,7 @@
<!-- 操作台 --> <!-- 操作台 -->
<view class="operate f1"> <view class="operate f1">
<!-- 数据中心 --> <!-- 数据中心 -->
<view class="item fmid" @click="handleData" v-if="0"> <view class="item fmid" @click="handleData" v-if="statistic == 1">
<view class="col"> <view class="col">
<image class="wh50" src="/static/statistic.png" mode="aspectFit" /> <image class="wh50" src="/static/statistic.png" mode="aspectFit" />
</view> </view>

View File

@ -32,7 +32,12 @@
isMine: { isMine: {
type: [String, Number], type: [String, Number],
default: 0, default: 0,
} },
// 0 1
statistic: {
type: [String, Number],
default: 0,
},
}) })
// //
const emit = defineEmits(['item']) const emit = defineEmits(['item'])
@ -70,6 +75,7 @@
url: util.setUrl('/pages/index/videoDetail', { url: util.setUrl('/pages/index/videoDetail', {
videoId: item.id, videoId: item.id,
isMine: props.isMine, isMine: props.isMine,
statistic: props.statistic,
}) })
}) })
// videoUrl.value = item.format_videoUrl // videoUrl.value = item.format_videoUrl
@ -78,7 +84,6 @@
} }
// //
else if (props.mode == 'menu') { else if (props.mode == 'menu') {
videoUrl.value = item.format_videoUrl
emit('item', item) emit('item', item)
} }
// //

View File

@ -99,7 +99,7 @@
<template> <template>
<view class=""> <view class="">
<videoMenu :list="list.data" isMine="1" /> <videoMenu :list="list.data" isMine="1" :statistic="1" />
</view> </view>
</template> </template>

View File

@ -604,7 +604,7 @@
function videoLike(param) { function videoLike(param) {
// 当前项 // 当前项
const item = tabCurrent.value.listData()[param.index] const item = tabCurrent.value.listData()[param.index]
console.log('data', { const data = {
// 视频id // 视频id
videoId: item.id, videoId: item.id,
// 点赞用户id // 点赞用户id
@ -615,22 +615,11 @@
likeType: param.likeType, likeType: param.likeType,
// //点赞 0.点赞 1.取消点赞 // //点赞 0.点赞 1.取消点赞
isLike: param.isLike, isLike: param.isLike,
}) }
// //
api.video.videoLike({ api.video.videoLike({
data: { data,
// 视频id
videoId: item.id,
// 点赞用户id
likeUserId: userinfo.value.id,
// 被点赞用户id
targetUserId: item.userId,
// 点赞类型 0.公开赞 1.隐私赞
likeType: param.likeType,
//点赞 0.点赞 1.取消点赞
isLike: param.isLike,
}
}).then(rs => { }).then(rs => {
if (rs.code == 200) { if (rs.code == 200) {
uni.$emit('updateVideo', { uni.$emit('updateVideo', {
@ -689,7 +678,6 @@
* @param {Object} item 视频列表项 * @param {Object} item 视频列表项
*/ */
function handleShowProduct(item) { function handleShowProduct(item) {
console.log('video', item)
// 打开产品详情弹窗 // 打开产品详情弹窗
proxy.$refs.productAltRef.init(item.productId) proxy.$refs.productAltRef.init(item.productId)
} }

View File

@ -7,6 +7,7 @@
ref, ref,
getCurrentInstance, getCurrentInstance,
reactive, reactive,
computed,
} from 'vue' } from 'vue'
import { import {
onLoad, onLoad,
@ -24,6 +25,10 @@
import collectAlt from '@/components/index/collect.vue' import collectAlt from '@/components/index/collect.vue'
// 分享到好友弹窗 // 分享到好友弹窗
import shareFirendAlt from '@/components/index/shareFirend.vue' import shareFirendAlt from '@/components/index/shareFirend.vue'
// 产品详情弹窗
import productAlt from '@/components/index/proDetailAlt.vue'
// 产品规格弹窗
import productSpecAlt from '@/components/shop/detail/makeOrder.vue'
const { const {
proxy proxy
@ -34,11 +39,17 @@
const detail = reactive({}) const detail = reactive({})
// 是否是自己 // 是否是自己
const isMine = ref(false) const isMine = ref(false)
// 显示统计
const statistic = ref('0')
// 用户信息
const userinfo = computed(() => uni.$store.state.userinfo)
onLoad((option) => { onLoad((option) => {
if (option.videoId) videoId.value = option.videoId if (option.videoId) videoId.value = option.videoId
// 是否我的作品 // 是否我的作品
if (option.isMine && option.isMine != 'false') isMine.value = option.isMine if (option.isMine && option.isMine != 'false') isMine.value = option.isMine
// 是否显示统计
if (option.statistic) statistic.value = option.statistic
// 获取视频详情 // 获取视频详情
getVideoDetail() getVideoDetail()
@ -64,12 +75,7 @@
} }
}).then(rs => { }).then(rs => {
if (rs.code == 200) { if (rs.code == 200) {
const result = rs.data Object.assign(detail, rs.data)
result.format_videoUrl = util.format_url(result.videoUrl, 'video')
result.format_header = util.format_url(result.header, 'img')
Object.assign(detail, result)
// 播放视频 // 播放视频
proxy.$refs.indexVideo.play() proxy.$refs.indexVideo.play()
@ -107,41 +113,38 @@
proxy.$refs.shareFirendRef.open() proxy.$refs.shareFirendRef.open()
} }
/** /**
* 视频点赞 * 视频点赞
* @param {Object} param 见下 * @param {Object} param 见下
* @param {Number} param.index 操作的视频下标 * @param {Number} param.index 操作的视频下标
* @param {Number|String} param.isLike 点赞操作 * @param {Number|String} param.isLike 0.点赞 1.取消点赞
* @param {Number|String} param.likeType 点赞类型 0.公开赞 1.隐私赞
*/ */
function videoLike(param) { function videoLike(param) {
const {
index,
isLike
} = param
const item = detail const item = detail
// 操作状态 const data = {
let type = 1 // 视频id
// 0未点赞 1已点赞 3私密赞 videoId: item.id,
if (item.isLike == 0) type = isLike // 点赞用户id
likeUserId: userinfo.value.id,
// 被点赞用户id
targetUserId: item.userId,
// 点赞类型 0.公开赞 1.隐私赞
likeType: param.likeType,
// //点赞 0.点赞 1.取消点赞
isLike: param.isLike,
}
// //
api.video.videoLike({ api.video.videoLike({
query: { data,
// 0赞1取消赞 3私密赞
type,
// 视频id
videoId: item.videoId,
}
}).then(rs => { }).then(rs => {
if (rs.code == 200) { if (rs.code == 200) {
// 同步点赞状态 uni.$emit('updateVideo', {
item.isLike = { ...item,
0: 1, ...rs.data,
1: 0, })
3: 3,
} [type]
// 取消减数量 否则增加
type == 1 ? item.likes-- : item.likes++
return return
} }
util.alert({ util.alert({
@ -206,17 +209,64 @@
* @param {Object} detail * @param {Object} detail
*/ */
function handleDataCenter(detail) { function handleDataCenter(detail) {
uni.navigateTo({
url: util.setUrl('/pages/index/dataCenter/dataCenter', {
videoId: detail.id,
})
})
}
/**
* 打开产品弹窗
* @param {Object} item 视频列表项
*/
function handleShowProduct(item) {
// 打开产品详情弹窗
proxy.$refs.productAltRef.init(item.productId)
}
/**
* 商品弹窗购买
* @param {Object} product
*/
function handleProductBuy(product) {
Object.assign(productDetail, {}, product)
// //
proxy.$refs.productSpecAltRef.open()
}
/**
* 商品购买
* @param {Object} video 视频列表
*/
function handleProBuy(video) {
// 获取商品详情
api.shop.productDetail({
query: {
// 产品id
productionId: video.productId,
},
}).then(rs => {
if (rs.code == 200) {
//
handleProductBuy(rs.data)
return
}
util.alert({
content: rs.msg,
showCancel: false,
})
})
} }
</script> </script>
<template> <template>
<view class="page f1"> <view class="page f1">
<!-- --> <!-- -->
<indexVideo ref="indexVideo" :statistic="1" :item="detail" :tabIndex="0" :isMine="isMine" :index="0" <indexVideo ref="indexVideo" :statistic="statistic" :item="detail" :tabIndex="0" :isMine="isMine" :index="0"
:current="0" mode="detail" @showComment="handleShowCommentAlt" @showCollect="handleShowCollectAlt" :current="0" mode="detail" @showComment="handleShowCommentAlt" @showCollect="handleShowCollectAlt"
@showShareFirend="handleShowShareFirend" @like="videoLike" @detailMenu="detailMenu" @showShareFirend="handleShowShareFirend" @like="videoLike" @detailMenu="detailMenu"
@dataCenter="handleDataCenter" /> @dataCenter="handleDataCenter"@showProduct="handleShowProduct" @proBuy="handleProBuy" />
<!-- 评论弹窗 --> <!-- 评论弹窗 -->
<commentAlt ref="commentRef" /> <commentAlt ref="commentRef" />
@ -224,6 +274,10 @@
<collectAlt ref="collectRef" /> <collectAlt ref="collectRef" />
<!-- 分享到好友弹窗 --> <!-- 分享到好友弹窗 -->
<shareFirendAlt ref="shareFirendRef" /> <shareFirendAlt ref="shareFirendRef" />
<!-- 产品详情弹窗 -->
<productAlt ref="productAltRef" @buy="handleProductBuy" />
<!-- 产品立即下单弹窗 -->
<productSpecAlt ref="productSpecAltRef" :detail="productDetail" @confirm="handlePay" />
</view> </view>
</template> </template>

View File

@ -7,8 +7,16 @@
useStore useStore
} from 'vuex' } from 'vuex'
import { import {
computed ref,
computed,
getCurrentInstance,
} from 'vue'; } from 'vue';
//
import payPwd from '@/components/mine/payPwd.vue'
//
const {
proxy
} = getCurrentInstance();
// vuex // vuex
const store = useStore() const store = useStore()
// //
@ -28,6 +36,32 @@
}) })
}) })
} }
//
function handleClose(userPassword) {
//
api.mine.adolescentClose({
path: [userPassword],
}).then(rs => {
if (rs.code == 200) {
util.alert('青少年模式已关闭')
store.commit('setState', {
key: 'userinfo',
value: {
...userinfo.value,
teenTime: null,
}
})
//
util.getUserinfo()
return
}
util.alert({
content: rs.msg,
showCancel: false,
})
})
}
</script> </script>
<template> <template>
@ -42,10 +76,13 @@
</view> </view>
</view> </view>
<view class="btn pro black mtb30 mlr60" v-if="userinfo.teenTime">已开启青少年模式</view> <view class="btn pro black mtb30 mlr60" v-if="userinfo.teenTime" @click="$refs.payPwdRef.open()">关闭青少年模式</view>
<view class="btn pro black mtb30 mlr60" v-else @click="handleUpdate">开启青少年模式</view> <view class="btn pro black mtb30 mlr60" v-else @click="handleUpdate">开启青少年模式</view>
<view class="fill" style="height: 30rpx;"></view> <view class="fill" style="height: 30rpx;"></view>
<!-- 支付弹窗 -->
<payPwd ref="payPwdRef" @confirm="handleClose" />
</view> </view>
</template> </template>