Browse Source

feature:流量主及AI绘画细节优化

feature-1.0
Penny 3 years ago
parent
commit
01e3fec032
  1. 5
      api/paint.js
  2. 111
      pages/ai/paint/paint.vue
  3. 19
      pages/ai/paint/paintDetail.vue
  4. 46
      pages/creator/imgDetail.vue
  5. 94
      utils/tiktokAd.js

5
api/paint.js

@ -39,12 +39,11 @@ export function getAiPaintPage(data) {
} }
// 检查某平台用户当日ai绘画次数是否超标 // 检查某平台用户当日ai绘画次数是否超标
export function checkUserCanAiPaint(data, headers) { export function checkUserCanAiPaint(data) {
return request({ return request({
url: `${serviceTitle}${prefix}/checkUserCanAiPaint`, url: `${serviceTitle}${prefix}/checkUserCanAiPaint`,
method: 'post', method: 'post',
data, data
headers: headers
}) })
} }

111
pages/ai/paint/paint.vue

@ -86,8 +86,7 @@
<script> <script>
import base64ToImg from '@/utils/base64Utils'; import base64ToImg from '@/utils/base64Utils';
import {getPaintStyle, getPrompt, textToImg} from '@/api/paint.js'; import {getPaintStyle, getPrompt, textToImg, checkUserCanAiPaint} from '@/api/paint.js';
import tiktokAd from '@/utils/tiktokAd.js'
export default { export default {
data() { data() {
return { return {
@ -102,8 +101,8 @@
checkPrompt: undefined, //true;false checkPrompt: undefined, //true;false
checkStyleBox: undefined, //true;false checkStyleBox: undefined, //true;false
checkSize: undefined, //true;false checkSize: undefined, //true;false
checkCanPaint: false, //true;false
}, },
advertise: '0qfnoa4053uwkefbas',
userInfo: {}, userInfo: {},
noClick:true, // noClick:true, //
promptList: [], promptList: [],
@ -138,31 +137,26 @@
}, },
onLoad() { onLoad() {
this.checkLogin();
this.getPaintStyleList(); this.getPaintStyleList();
this.getPrompt(); this.getPrompt();
//this.initReward();//广
//tiktokAd.rewarded.load('0qfnoa4053uwkefbas');
}, },
onShow() {
//
this.formData.height = undefined;
this.formData.width = undefined;
this.formData.modelName = undefined;
this.formData.styleName = undefined;
this.formData.promptText = undefined;
this.size_active = 0;
this.style_active = 0;
this.prompt_active = 0;
this.checkLogin();
this.checkUserCanAiPaint();
},
methods: { methods: {
//广
initReward(){
let that = this;
//console.log('that.advertise',that.advertise)
tiktokAd.rewarded.load('0qfnoa4053uwkefbas', () => {
console.log('进入了广告');
// uni.setClipboardData({
// data: that.draw.draw_text
// })
})
},
// //
// //
checkLogin(){ checkLogin(){
let that = this; let that = this;
@ -170,37 +164,44 @@
console.log('userInfo:',that.userInfo) console.log('userInfo:',that.userInfo)
let token = uni.getStorageSync('token'); let token = uni.getStorageSync('token');
if((Object.keys(that.userInfo).length==0) && (Object.keys(token).length==0)){ if((Object.keys(that.userInfo).length==0) && (Object.keys(token).length==0)){
uni.showModal({ console.error('尚未登录!');
title:'提示', // uni.showModal({
content:'您还没有登录!点击确定跳转登录界面以体验服务', // title:'',
success(res) { // content:'!',
if (res.confirm) { // success(res) {
// // if (res.confirm) {
uni.switchTab({ // //
url: '/pages/userInfo/userInfo' // uni.switchTab({
}); // url: '/pages/userInfo/userInfo'
}else if(res.cancel){ // });
uni.showToast({ // }else if(res.cancel){
title:'登录获取更好的服务体验哟!', // uni.showToast({
duration: 2000 // title:'!',
}); // duration: 2000
} // });
} // }
}); // }
// });
} }
}, },
// //
startPaint(){ startPaint(){
//tiktokAd.rewarded.show();
//
const that = this; const that = this;
//console.log('that.checkData.checkCanPaint',that.checkData.checkCanPaint)
//ai
if(that.checkData.checkCanPaint === true){
return uni.showToast({
title: '当日绘画次数已用完,请明日再来!',
icon: 'none'
})
}
//
//console.log('prompt',that.formData.promptText) //console.log('prompt',that.formData.promptText)
// console.log('',that.formData.height) // console.log('',that.formData.height)
// console.log('',that.formData.width) // console.log('',that.formData.width)
//console.log('',that.formData.styleName) //console.log('',that.formData.styleName)
if(that.formData.promptText == undefined){ if(that.formData.promptText == undefined){
console.log('test1111')
uni.showToast({ uni.showToast({
title: '请输入提示词!', title: '请输入提示词!',
duration: 1000, duration: 1000,
@ -232,7 +233,9 @@
modelName: that.formData.modelName, modelName: that.formData.modelName,
styleName: that.formData.styleName, styleName: that.formData.styleName,
painterId: that.userInfo.id, painterId: that.userInfo.id,
painterName: that.userInfo.username painterName: that.userInfo.username,
appType: 0,
platform: 0
} }
uni.navigateTo({ uni.navigateTo({
url: './paintDetail?data='+JSON.stringify(data) url: './paintDetail?data='+JSON.stringify(data)
@ -321,6 +324,30 @@
this.promptText = this.promptList[this.prompt_active].text this.promptText = this.promptList[this.prompt_active].text
}, },
//AI
async checkUserCanAiPaint(){
let that = this;
const data = {
userId: that.userInfo.id,
platform: 0,
appType: 0
}
const res = await checkUserCanAiPaint(data);
//console.log('res',res)
if(res.data.code === 200){
if(res.data.data === true){
that.checkData.checkCanPaint = true;
}else{
that.checkData.checkCanPaint = false;
}
}else{
return uni.showModal({
content: '检查绘画上限失败!',
showCancel: false
});
}
},
// //
async getPaintStyleList() { async getPaintStyleList() {
const res = await getPaintStyle(); const res = await getPaintStyle();

19
pages/ai/paint/paintDetail.vue

@ -1,5 +1,5 @@
<template> <template>
<view class="container"> <view class="container" :style="{backgroundColor: 'black',width: 100 + '%',height: 100 + '%'}">
<!-- 图片绘制区域 --> <!-- 图片绘制区域 -->
<view class="paint"> <view class="paint">
<view class="cover" v-if="successFlag === false"> <view class="cover" v-if="successFlag === false">
@ -18,6 +18,7 @@
</view> </view>
</view> </view>
<!-- <view class="complete" :style="{backgroundImage: 'url(' + transImg + ')'}"> -->
<view class="complete"> <view class="complete">
<!-- prompt关键词 --> <!-- prompt关键词 -->
<view class="keywords"> <view class="keywords">
@ -78,18 +79,12 @@
</view> </view>
</view> </view>
<!-- 底部流量主 -->
<!-- <view class="ad" v-if="spool.video.status == 10"> -->
<view class="ad">
<ad :unit-id="spool.video.id" ad-type="video" ad-theme="white"></ad>
</view>
</view> </view>
</template> </template>
<script> <script>
import base64ToImg from '@/utils/base64Utils'; import base64ToImg from '@/utils/base64Utils';
import rewarded from '@/utils/tiktokAd.js'
import { textToImg} from '@/api/paint.js'; import { textToImg} from '@/api/paint.js';
import {loginTiktok} from '@/api/auth.js' import {loginTiktok} from '@/api/auth.js'
export default { export default {
@ -398,6 +393,7 @@
base64ToImg(str,res =>{ base64ToImg(str,res =>{
console.log('解析出的图片路径为:',res) console.log('解析出的图片路径为:',res)
this.transImg = res; this.transImg = res;
//complatecss
}); });
}, },
}, },
@ -497,11 +493,14 @@
align-items: flex-start; align-items: flex-start;
margin-top: 15rpx; margin-top: 15rpx;
.style { .style {
display: flex; display: flex;
flex-direction: row; flex-direction: row;
align-items: flex-start; align-items: flex-start;
margin-top: 30rpx; margin-top: 30rpx;
color:#fff;
font-weight: bolder;
.i { .i {
//background-color: #fff; //background-color: #fff;
@ -514,7 +513,7 @@
.text { .text {
font-size: 40rpx; font-size: 40rpx;
font-weight: bolder; font-weight: bolder;
color: #000000; color: #fff;
background-color: #1A94BC1A; background-color: #1A94BC1A;
} }
} }
@ -530,10 +529,11 @@
.keywords { .keywords {
width: 90%; width: 90%;
margin: 0 auto; margin: 0 auto;
background-color: #1A94BC1A; //background-color: #1A94BC1A;
padding: 15rpx; padding: 15rpx;
border-radius: 10rpx; border-radius: 10rpx;
margin-top: 15rpx; margin-top: 15rpx;
font-weight: bolder;
.content { .content {
display: -webkit-box; display: -webkit-box;
@ -541,6 +541,7 @@
-webkit-line-clamp: 2; -webkit-line-clamp: 2;
/*这里设置几行*/ /*这里设置几行*/
overflow: hidden; overflow: hidden;
color: #fff;
} }
} }
} }

46
pages/creator/imgDetail.vue

@ -48,7 +48,6 @@
checkUserCanDownload// checkUserCanDownload//
} from '@/api/creator.js' } from '@/api/creator.js'
import {loginTiktok} from '@/api/auth.js' import {loginTiktok} from '@/api/auth.js'
// import tiktokAd from '@/utils/tiktokAd.js'
export default { export default {
data() { data() {
return { return {
@ -79,12 +78,9 @@
//广 //广
let num = Math.floor(Math.random() * this.adList.length + 1)-1; let num = Math.floor(Math.random() * this.adList.length + 1)-1;
//console.log('id',this.adList[num]) //console.log('id',this.adList[num])
//tiktokAd.rewarded.load(this.adList[num])
this.loadAdvertise(this.adList[num]); this.loadAdvertise(this.adList[num]);
}, },
onShow() { onShow() {
console.log('进入onshow')
//tiktokAd.rewarded.load(this.adList[num])
//this.achieveSaveImg(); //this.achieveSaveImg();
}, },
onHide() { onHide() {
@ -131,7 +127,7 @@
}) })
that.videoAd = videoAd that.videoAd = videoAd
videoAd.onLoad(() => { videoAd.onLoad(() => {
console.log('激励视频广告'+adId+'加载成功') //console.log('广'+adId+'')
}) })
videoAd.onError((err) => { videoAd.onError((err) => {
that.err() that.err()
@ -140,11 +136,11 @@
if (res && res.isEnded || res === undefined) { if (res && res.isEnded || res === undefined) {
// //
that.isplayOver = true; that.isplayOver = true;
console.log('激励视频广告观看完毕',that.isplayOver) //console.log('广',that.isplayOver)
that.achieveSaveImg(); that.achieveSaveImg();
} else { } else {
that.isplayOver = false; that.isplayOver = false;
console.log('激励视频广告尚未看完',that.isplayOver) //console.log('广',that.isplayOver)
uni.showToast({ uni.showToast({
title: '您还没有看完视频,无法下载图片', title: '您还没有看完视频,无法下载图片',
icon: 'none' icon: 'none'
@ -158,8 +154,8 @@
showAdvertise(url){ showAdvertise(url){
let videoAd = this.videoAd let videoAd = this.videoAd
this.downloadUrl = url; this.downloadUrl = url;
console.log('看广告时传入进来的url',url); //console.log('广url',url);
console.log('this.downloadUrl看广告时',this.downloadUrl); //console.log('this.downloadUrl广',this.downloadUrl);
videoAd.show().catch(() => { videoAd.show().catch(() => {
// //
videoAd.load() videoAd.load()
@ -318,13 +314,14 @@
likeCollect(val) { likeCollect(val) {
if (!this.userInfo) { if (!this.userInfo) {
this.getUserInfoLogin(res => { this.getUserInfoLogin(res => {
succ
this.lickOrCollect(val) this.lickOrCollect(val)
}) })
} else { } else {
this.lickOrCollect(val) this.lickOrCollect(val)
} }
}, },
async loginFunc(res, userInfo, callBack) { async loginFunc(res, userInfo, callBack) {
const params = { const params = {
code: res.code, code: res.code,
@ -487,15 +484,15 @@
if(that.isplayOver){ if(that.isplayOver){
//广 //广
let url = that.downloadUrl; let url = that.downloadUrl;
console.log('that.downloadUrl观看完广告',that.downloadUrl); //console.log('that.downloadUrl广',that.downloadUrl);
console.log('url观看完广告',url); //console.log('url广',url);
uni.showLoading({ uni.showLoading({
title: '正在保存图片...', title: '正在保存图片...',
success() { success() {
// //
uni.getSetting({ uni.getSetting({
success(res){ success(res){
console.log('授权res',res) //console.log('res',res)
// //
if (!res.authSetting["scope.album"]) { if (!res.authSetting["scope.album"]) {
// //
@ -575,18 +572,18 @@
}); });
} else { } else {
// //
console.log('已有相册权限,开始保存图片',url); //console.log(',',url);
// //
uni.downloadFile({ uni.downloadFile({
url, url,
success: (res) => { success: (res) => {
console.log('进入图片下载',res); //console.log('',res);
if (res.statusCode === 200) { if (res.statusCode === 200) {
uni.saveImageToPhotosAlbum({ uni.saveImageToPhotosAlbum({
// //
filePath: res.tempFilePath, filePath: res.tempFilePath,
success: (res) => { success: (res) => {
console.log('保存图片状态',res); //console.log('',res);
}, },
fail: (res) => { fail: (res) => {
return uni.showToast({ return uni.showToast({
@ -640,11 +637,22 @@
if (that.canDownload !== true) { if (that.canDownload !== true) {
// //
that.isDownload = true that.isDownload = true
//广 //console.log('res123',123)
that.showAdvertise(url); uni.showModal({
title: '提示',
content: '看一段广告解锁图片下载',
success: function (res) {
//console.log('res',res)
if(res.confirm){
//广
that.showAdvertise(url);
}
}
});
} else { } else {
// canDownloadtrue // canDownloadtrue
uni.showToast({ return uni.showToast({
title: '当日下载次数已用完,请明日再来!', title: '当日下载次数已用完,请明日再来!',
icon: 'none' icon: 'none'
}) })

94
utils/tiktokAd.js

@ -1,94 +0,0 @@
//激励视频广告组件
var videoAd = null;
let rewarded = {
//加载激励视频广告
load(id) {
if (tt.createRewardedVideoAd) {
const achieveStatus = false;
videoAd = tt.createRewardedVideoAd({
adUnitId: id
})
videoAd.onLoad(() => {
console.log('激励视频广告加载成功')
})
//防止奖励重复发放
// try {
// if (videoAd.onClose) {
// videoAd.offClose(videoAd.onClose);
// console.log("videoAd.offClose卸载成功");
// }
// } catch (e) {
// console.log("videoAd.offClose 卸载失败");
// console.error(e);
// }
videoAd.onError(err => {
console.log('激励视频广告加载失败,错误原因为:',err)
})
videoAd.onClose((res) => {
// 用户点击了【关闭广告】按钮
if (res && res.isEnded || res === undefined) {
// 正常播放结束,可以下发奖励
videoAd.offClose()
this.achieveStatus = true;
console.log("激励视频广告播放完毕,可下发奖励",this.achieveStatus);
return this.achieveStatus;
} else {
// 播放中途退出,不下发奖励
}
})
}
},
//展示激励视频广告
show() {
if (videoAd) {
videoAd.onClose((status) => {
console.log(status + '视频激励广告关闭')
})
videoAd.show().catch(() => {
// 失败重试
videoAd.load()
.then(() => videoAd.show())
.catch(err => {
console.log('激励视频 广告显示失败')
})
})
}
}
}
//插屏广告组件
var interstitialAd = null;
let insert = {
//加载插屏广告
load(id) {
if (tt.createInterstitialAd) {
interstitialAd = tt.createInterstitialAd({
adUnitId: id
})
interstitialAd.onLoad(() => {
console.log('插屏广告加载中')
})
interstitialAd.onError((err) => {
console.log('加载错误', err)
})
interstitialAd.onClose((res) => {
console.log('插屏广告关闭', res)
})
}
},
//展示插屏广告
show() {
if (interstitialAd) {
interstitialAd.show().catch((err) => {
console.error(err)
})
}
}
}
module.exports = {
insert,
rewarded
};
Loading…
Cancel
Save