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

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',
// #endif
// #ifndef H5
host: 'http://91f.xyz:8080',
// host: 'http://b2xbj5.natappfree.cc',
// host: 'http://91f.xyz:8080',
host: 'http://epiryz.natappfree.cc',
// #endif
// 支付方式配置
payType: {

View File

@ -213,7 +213,7 @@ const util = {
responseType: params.responseType || 'text',
// 请求成功返回
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) {
uni.hideLoading()
@ -1535,16 +1535,12 @@ const util = {
let userinfo = uni.$store.state.userinfo
return new Promise((resolve, reject) => {
// 登录
if (!userinfo.id) {
// util.alert('请先登录')
// 失败
reject()
} else {
if (userinfo.id) {
// 成功
resolve()
// 回调
cb ? cb() : ''
}
} else reject()
})
},

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -7,8 +7,16 @@
useStore
} from 'vuex'
import {
computed
ref,
computed,
getCurrentInstance,
} from 'vue';
//
import payPwd from '@/components/mine/payPwd.vue'
//
const {
proxy
} = getCurrentInstance();
// vuex
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>
<template>
@ -42,10 +76,13 @@
</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="fill" style="height: 30rpx;"></view>
<!-- 支付弹窗 -->
<payPwd ref="payPwdRef" @confirm="handleClose" />
</view>
</template>