jiuyiUniapp/jiuyi2/pages/index/dataCenter/push.vue

558 lines
13 KiB
Vue
Raw Normal View History

2024-12-18 15:46:27 +08:00
<script setup>
/**
* 投流推广
*/
import {
onMounted,
ref,
computed,
reactive,
getCurrentInstance,
watch,
defineExpose,
} from 'vue';
import {
useStore,
} from 'vuex'
2024-12-27 15:03:48 +08:00
//
2024-12-18 15:46:27 +08:00
import util from '@/common/js/util';
// api
import api from '@/api/index.js'
import {
onLoad,
onReady,
onHide,
onUnload,
} from '@dcloudio/uni-app'
2025-02-21 17:56:36 +08:00
2024-12-18 15:46:27 +08:00
// 顶部
import apex from '@/components/header/apex.vue';
// 视频菜单
import videoMenu from '@/components/index/videoMenu.vue';
2025-03-08 09:40:51 +08:00
//
import payPwd from '@/components/mine/payPwd.vue';
2025-02-21 17:56:36 +08:00
2024-12-18 15:46:27 +08:00
const {
proxy
} = getCurrentInstance()
const store = useStore()
// 榴莲果兑换展播量比例
const durainChangeShowPlay = ref(0)
// 榴莲果兑换完播量比例
const durainChangeFullPlay = ref(0)
// 榴莲果
const durainChangeFullPlayLimit = ref(0)
2025-03-08 09:40:51 +08:00
// 用户信息
const userinfo = computed(() => store.state.userinfo)
// 我的视频列表
2024-12-18 15:46:27 +08:00
const list = reactive({
data: [],
pageSize: 10,
pageNum: 1,
total: 0,
})
// 选择的我的作品
const myVideo = ref({})
// 选择的收藏的视频
const collecVideo = ref({})
// 申请数量
const playNum = ref('')
// 榴莲果交易类型 5展播量兑换 7完播量兑换
const transactionType = ref('')
// 已选择的视频
const selectVideo = computed(() => myVideo.value || collecVideo.value || {})
// 榴莲果支付价格
const price = computed(() => {
let result = parseFloat(playNum.value)
if (transactionType.value == 5) result = result
if (transactionType.value == 7) result = result + durainChangeFullPlayLimit.value
2024-12-18 15:46:27 +08:00
return result
})
// 展播量预计结果
const showPlayCount = computed(() => {
return (playNum.value || 0) * durainChangeShowPlay.value
2025-03-21 08:33:35 +08:00
})
2025-03-08 09:40:51 +08:00
// 钱包
const purse = computed(() => store.state.purse)
2024-12-18 15:46:27 +08:00
onLoad(() => {
// 获取视频列表
2024-12-18 15:46:27 +08:00
getList()
2025-02-16 22:35:46 +08:00
// 开启监听
2024-12-18 15:46:27 +08:00
addListener()
// 获取榴莲果兑换展播量
getShowPlayConfig()
// 获取榴莲果兑换完播量
getFullPlayConfig()
2025-03-08 09:40:51 +08:00
// 获取钱包
util.getPurse()
2024-12-18 15:46:27 +08:00
})
onUnload(() => {
removeListener()
})
// 开启监听
function addListener() {
// 选择投流的收藏视频
uni.$on('selectPushCollectVideo', (item) => {
myVideo.value = {}
collecVideo.value = item
2024-12-18 15:46:27 +08:00
})
}
// 关闭监听
function removeListener() {
uni.$off('selectPushCollectVideo')
}
// 获取榴莲果兑换展播量比例
function getShowPlayConfig() {
api.durian.getShowPlayConfig({}).then(rs => {
if (rs.code == 200) {
// 展播量兑换比例
durainChangeShowPlay.value = rs.data.proportion
return
}
util.alert({
content: rs.msg,
showCancel: false,
})
})
}
// 获取榴莲果兑换完播量比例
function getFullPlayConfig() {
api.durian.getFullPlayConfig({}).then(rs => {
2025-02-16 22:35:46 +08:00
if (rs.code == 200) {
// 完播量兑换比例
durainChangeFullPlay.value = rs.data.proportion
// 完播量兑换门槛
durainChangeFullPlayLimit.value = rs.data.minConsumption
2025-02-16 22:35:46 +08:00
return
}
util.alert({
content: rs.msg,
showCancel: false,
})
})
}
2024-12-18 15:46:27 +08:00
// 刷新列表
function refreshList() {
list.pageNum = 1
getList()
}
// 获取更多列表
function getMoreList() {
if (list.data.length >= list.total) return
list.pageNum++
getList()
}
// 获取列表
function getList() {
//
2025-02-15 16:10:05 +08:00
api.video.myWorks({
2024-12-18 15:46:27 +08:00
query: {
2025-02-15 16:10:05 +08:00
userId: userinfo.value.id,
2024-12-18 15:46:27 +08:00
pageSize: list.pageSize,
pageNum: list.pageNum,
}
}).then(rs => {
if (rs.code == 200) {
if (list.pageNum == 1) list.data.length = []
list.data.push(...rs.rows)
2024-12-18 15:46:27 +08:00
list.total = rs.total
return
}
util.alert({
content: rs.msg,
showCancel: false,
})
})
}
/**
* 选择我的视频
* @param {Object} item 选择的视频对象
*/
function handleMyWork(item) {
myVideo.value = item
collecVideo.value = {}
proxy.$refs.select.close()
}
// 展播量申请弹窗
function handleShowViewRef() {
if (!selectVideo.value.id) {
util.alert("请选择需要投流的视频")
2024-12-18 15:46:27 +08:00
return
}
proxy.$refs.viewsRef.open()
}
// 完播量申请弹窗
function handleShowApplyRef() {
if (!myVideo.value.id) {
util.alert("请选择自己的作品")
return
}
proxy.$refs.applyRef.open()
2025-03-08 09:40:51 +08:00
}
// 推送视频
function handlePushShow() {
if (purse.value.fruit <= playNum.value * durainChangeShowPlay.value) {
2024-12-18 15:46:27 +08:00
util.alert({
content: "榴莲果不足",
showCancel: false,
})
return
}
// 展播量
transactionType.value = 5
proxy.$refs.viewsRef.close()
2025-03-08 09:40:51 +08:00
proxy.$refs.payPwdRef.open()
2024-12-18 15:46:27 +08:00
}
// 完播申请
function handlePushFull() {
if (purse.value.fruit <= playNum.value * durainChangeFullPlay.value + durainChangeFullPlayLimit.value) {
2024-12-18 15:46:27 +08:00
util.alert({
content: "榴莲果不足",
showCancel: false,
})
return
}
// 展播量
transactionType.value = 7
proxy.$refs.applyRef.close()
proxy.$refs.payPwdRef.open()
2024-12-18 15:46:27 +08:00
}
/**
* 取消选择的收藏的别人的视频
2024-12-18 15:46:27 +08:00
*/
function handleCancel() {
2024-12-18 15:46:27 +08:00
util.alert({
content: `确认取消投流${selectVideo.title}`,
2024-12-18 15:46:27 +08:00
}).then(rs => {
if (!rs.confirm) return
selectVideo.value = {}
2024-12-18 15:46:27 +08:00
})
}
2025-02-21 17:56:36 +08:00
// 推流收藏视频
2024-12-18 15:46:27 +08:00
function pushCollect() {
2025-02-21 17:56:36 +08:00
link(util.setUrl('/pages/index/dataCenter/pushVideoCollects', {
ids: selectVideo.value.id,
2025-02-21 17:56:36 +08:00
}))
2024-12-18 15:46:27 +08:00
}
// 跳转
2025-02-21 17:56:36 +08:00
function link(path) {
2024-12-18 15:46:27 +08:00
uni.navigateTo({
url: path
2025-03-08 09:40:51 +08:00
})
}
/**
* 二级密码确认
* @param {Object} event 二级密码
*/
function handlePwdConfirm(event) {
2025-03-08 09:40:51 +08:00
// 榴莲果交易
api.durian.consume({
data: {
// 更新用户信息
userId: userinfo.value.id,
// 交易类型
transactionType: transactionType.value,
2025-03-08 09:40:51 +08:00
// 榴莲果交易数量
fruitAmount: price.value,
2025-03-08 09:40:51 +08:00
// 交易值
totalAmount: price.value,
2025-03-08 09:40:51 +08:00
// 二级密码
secondPassword: event,
2025-03-08 09:40:51 +08:00
// 视频id
videoIds: [selectVideo.value.id],
2025-03-08 09:40:51 +08:00
}
}).then(rs => {
if (rs.code === 200) {
util.getPurse()
2025-03-22 08:52:53 +08:00
uni.navigateBack()
2025-03-08 09:40:51 +08:00
return
}
util.alert({
content: rs.msg,
showCancel: false,
})
})
2024-12-18 15:46:27 +08:00
}
</script>
<template>
<view class="app">
<apex title="投流推广">
<template #right>
2025-02-21 17:56:36 +08:00
<view class="c333 f28" @click="link('/pages/index/dataCenter/pushHistory')">历史推流</view>
2024-12-18 15:46:27 +08:00
</template>
</apex>
<view class="first oh mtb30 mlr20 plr20 bfff br10" @click="$refs.select.open()">
2024-12-18 15:46:27 +08:00
<view class="rows mtb30 c333 f36">
<view class="col">
<view class="df aic">
<view class="">我想投流的视频</view>
<uni-icons type="bottom" />
</view>
</view>
<view class="line uploadBox f28">
<view class="key">选择自己的作品</view>
2024-12-18 15:46:27 +08:00
</view>
</view>
<view class="listBox mtb30" v-if="myVideo.id">
2024-12-18 15:46:27 +08:00
<scroll-view scroll-x="true" class="scroll">
<view class="list df">
<view class="item oh pr fs0 mr20 br20">
<image class="poster br20" :src="myVideo.coverUrl" mode="aspectFill" />
2024-12-18 15:46:27 +08:00
<!-- <view class="window pfull"></view> -->
</view>
</view>
</scroll-view>
</view>
<!-- 须知 -->
<!-- <view class="notice f28 c666">种了很多榴莲果树 大家都来买</view> -->
</view>
2025-03-28 08:51:18 +08:00
<view class="second oh mtb30 mlr20 ptb25 plr30 c333 f36 br10 bfff" @click="pushCollect">
2024-12-18 15:46:27 +08:00
<view class="fmid">
<view>我想投流Ta的视频</view>
<uni-icons type="right" color="#666" size="28rpx" />
<view class="c666 f28">我的收藏</view>
</view>
<!-- 限制只能分享别人的视频限制一个 -->
<view class="collectList" v-if="collecVideo.id">
2025-03-21 08:33:35 +08:00
<view class="item df mtb30">
<view class="poster oh pr fs0 mr20 br10">
<image class="image br10" :src="collecVideo.coverUrl" mode="aspectFill" />
2025-03-21 08:33:35 +08:00
<!-- <view class="window pfull br10"></view> -->
2024-12-18 15:46:27 +08:00
</view>
<view class="f1 df jcsb fdc">
<view class="f1">
<view class="f38 b">{{collecVideo.title}}</view>
<view class="mtb20 c666 f28">{{collecVideo.userNickname}}</view>
2024-12-18 15:46:27 +08:00
<!-- 如果是商家发布的带链接的视频 增加显示 商家出让佣金 -->
<view class="cFF9B27 f24" v-if="collecVideo.productId">商家出让佣金 {{collecVideo.commission}}
2025-03-21 08:33:35 +08:00
</view>
2024-12-18 15:46:27 +08:00
</view>
2024-12-18 15:46:27 +08:00
<view class="">
<view class="btn bar black w200" @click.stop="handleCancel()">取消</view>
2024-12-18 15:46:27 +08:00
</view>
</view>
</view>
</view>
</view>
2025-03-28 08:51:18 +08:00
<!-- 我想要 -->
<view class="second oh mtb20 mlr20 plr20 c333 f36 br10 bfff">
2025-03-28 08:51:18 +08:00
<view class="title mtb20">我想要</view>
<view class="list mtb20">
<view class="item fmid fdc br10" @click="handleShowViewRef">
2025-03-28 08:51:18 +08:00
<view class="">展示播放量</view>
<!-- <view class="mtb10 c666 f20">无需平台审核</view> -->
<view class="button btn black mt10">投流</view>
2025-03-28 08:51:18 +08:00
</view>
<view class="item fmid fdc br10" @click="handleShowApplyRef">
2025-03-28 08:51:18 +08:00
<view>完播播放量</view>
<!-- <view class="mtb10 c666 f20">需申请平台审核</view> -->
<view class="button btn black mt10">申请</view>
2025-03-28 08:51:18 +08:00
</view>
</view>
<!-- 规则 -->
<view class="rule mtb20 c666 f24">
<view class="c333">投流说明</view>
<view>1. 只能选择一个视频用来投流推广</view>
<view>2. 展示播放量可以选择自己发布的视频和收藏的视频</view>
<view>3. 完播播放量只能选择自己的视频需要先向平台发起申请</view>
</view>
2025-03-28 08:51:18 +08:00
</view>
2024-12-18 15:46:27 +08:00
<view class="fill" style="height: 210rpx;"></view>
<!-- 填充 -->
<view class="footerBar footer bfff shadow">
<view class="hint ptb10 plr30 c333">
<view>消耗 1 榴莲果可提升 {{durainChangeShowPlay}}+ 展示播放量</view>
<view>消耗 1 榴莲果可提升 {{durainChangeFullPlay}}+ 完播播放量</view>
2025-02-16 22:35:46 +08:00
</view>
2024-12-18 15:46:27 +08:00
<view class="content rows pt30 plr30">
<view class="f1 c333 f48">当前拥有{{userinfo.fruit}}榴莲果</view>
</view>
</view>
</view>
2025-03-08 09:40:51 +08:00
<!-- 二级支付 -->
<payPwd ref="payPwdRef" :price="price" unitKey="durian" @confirm="handlePwdConfirm" />
2025-03-08 09:40:51 +08:00
<!-- 展播量申请 -->
<uni-popup ref="viewsRef" type="center">
2025-03-08 09:40:51 +08:00
<view class="viewAlt popMid plr30 bfff">
<view class="title mt50 mb30 tac">
<view>展示播放量</view>
</view>
<view class="form f28">
<view class="row mtb20">
<view class="key">耗榴莲果投流视频</view>
2025-03-08 09:40:51 +08:00
<view class="value inputBox f1 mt10 plr20">
<input v-model="playNum" type="number" placeholder="请输入榴莲果数量" />
2025-03-08 09:40:51 +08:00
</view>
</view>
</view>
<view class="notice mt30 f20">预计获得 {{showPlayCount}}+ 展示播放量</view>
2025-03-08 09:40:51 +08:00
<view class="btn lg black mt10 mb40" @click="handlePushShow">推流</view>
2025-03-08 09:40:51 +08:00
</view>
</uni-popup>
<!-- 完播量申请 -->
2024-12-18 15:46:27 +08:00
<uni-popup ref="applyRef" type="center">
<view class="applyAlt popMid plr60 c333 f36 bfff">
<view class="title mt50 mb30 tac">
<view>完播播放量</view>
<view class="">消耗{{durainChangeFullPlayLimit}}榴莲果</view>
2024-12-18 15:46:27 +08:00
</view>
<view class="form f28">
<view class="row mtb20">
<view class="key">消耗榴莲果</view>
<view class="value inputBox f1 mt20 plr20">
<input v-model="playNum" type="number" placeholder="请输入榴莲果数量" />
2024-12-18 15:46:27 +08:00
</view>
</view>
</view>
<view class="notice mt30 f20">申请成功则消耗全部榴莲果申请不成功则返回申请榴莲果</view>
<view class="btn lg black mt10 mb40" @click="handlePushFull">提交申请</view>
2024-12-18 15:46:27 +08:00
</view>
</uni-popup>
<!-- 选择自己的视频 -->
<uni-popup ref="select" type="bottom">
<view class="selectAlt popBot df fdc bfff">
<view class="header rows ptb20 plr20">
<view class="title plr30 c333 f34">
<text>作品</text>
<text class="ml10">{{list.total}}</text>
</view>
<view class="fmid c999 f28" @click="refreshList">
<uni-icons type="refreshempty" color="" />
<text>刷新</text>
</view>
</view>
<!-- 视频菜单 -->
<scroll-view scroll-y="true" class="scroll" @scrolltolower="getMoreList">
<videoMenu :list="list.data" mode="menu" @item="handleMyWork" />
2024-12-18 15:46:27 +08:00
</scroll-view>
</view>
</uni-popup>
</template>
<style lang="scss" scoped>
// 第一
.first {
.hint {
color: #868686;
}
.item {
width: 220rpx;
height: 280rpx;
background-color: #F4F4F4;
}
.poster {
width: 100%;
height: 100%;
}
}
// 第二
.second {
.list {
display: grid;
grid-template-columns: repeat(2, 1fr);
grid-gap: 20rpx;
.item {
height: 200rpx;
background-color: #F4F4F4;
}
.button {
padding: 10rpx;
width: 80rpx;
font-size: 20rpx;
}
}
}
// 收藏的视频列表
.collectList {
.item {
.poster {
height: 288rpx;
// height: 192rpx;
width: 162rpx;
// width: 108rpx;
.image {
width: 100%;
height: 100%;
}
}
}
}
// 底部
.footerBar {
padding-top: 0;
.hint {
background-color: #e2e2e2;
}
}
.applyAlt {
.notice {
color: #b4b4b4;
}
}
//
.selectAlt {
.scroll {
height: 70vh;
}
}
</style>