Browse Source

情侣头像

feature-1.1
langz 3 years ago
parent
commit
acb3415327
  1. 3
      main.js
  2. 262
      pages/ai/paint/loverPainResult.vue
  3. 69
      pages/ai/paint/loverPaint.vue
  4. 26
      pages/index/indexProto.vue

3
main.js

@ -5,8 +5,9 @@ import common from './utils/common.js'
// const baseURL = 'http://localhost:7010'
// const baseURL = 'http://81.69.47.31:7010'
const baseURL = 'https://service.bnyer.cn'
// const baseURL = 'https://service.bnyer.cn'
//const baseURL = 'http://vaqc3e.natappfree.cc'
const baseURL = 'http://47.108.66.163:7010'
Vue.prototype.baseURL = baseURL;
Vue.prototype.$noMultipleClicks = common.noMultipleClicks;

262
pages/ai/paint/loverPainResult.vue

@ -1,31 +1,65 @@
<template>
<view class="wrap">
11111
<view class="top-box">
<view class="love-title">
</view>
<view class="top-img-box">
<view v-if="!finishDraw" class="loading">
<view class="loading-icon">
<uni-icons type="spinner-cycle" size="40"></uni-icons>
</view>
<view class="loading-tips">
Ai正在拼命绘制中.....
</view>
</view>
<view v-if="finishDraw" class="img-item-box">
<img class="img-item" :src="`data:image/png;base64,${resultImg[0]}`" >
<img class="img-item" :src="`data:image/png;base64,${resultImg[1]}`" >
<view class="heart-icon"></view>
</view>
</view>
<view v-if="finishDraw" class="button-box">
<view class="save-button" @click="clickSave(resultImg[0])"></view>
<view class="save-button" @click="clickSave(resultImg[1])"></view>
</view>
</view>
</view>
</template>
<script>
import { textToImg} from '@/api/paint.js';
import base64ToImg from '@/utils/base64Utils';
import { textToImgLove} from '@/api/paint.js';
export default {
data() {
return {
resultImg: [],
finishDraw: false
}
},
onLoad(options) {
//
const paintData = JSON.parse(options.data);
console.log('paintData',paintData);
// this.imgHeight = paintData.height;
// this.imgWidth = paintData.width;
// this.prompt = paintData.prompt;
// this.styleName = paintData.styleName;
textToImg(paintData).then(res =>{
// console.log('paintData',paintData);
// let paintData = {
// appType: 0,
// painterId: 1657690826066698200,
// painterName: "LangZ",
// platform: 1,
// prompt: "",
// scenePrompt: ""
// }
const that = this
textToImgLove(paintData).then(res =>{
if(res.data.code === 200){
uni.hideLoading();
console.log('res',res);
// this.base64ToPath(res.data.data.images);
// this.successFlag = true;
// this.paintTime = res.data.data.paintTime;
// this.paintId = res.data.data.paintId;
that.resultImg = res.data.data
that.finishDraw = true
console.log(that.resultImg);
}else{
uni.switchTab({
url: '/pages/ai/paint/paint',
uni.navigateBack({
success() {
uni.showToast({
title: res.data.msg,
@ -34,17 +68,209 @@
});
}
})
}
});
//广
//initReward();
},
methods: {
//base64
clickSave(url){
let str = "data:image/png;base64,"+url;
base64ToImg(str,res =>{
console.log('解析出的图片路径为:',res)
// this.saveUrl = res;
this.download(res)
//complatecss
});
},
//
download(url) {
// url = this.base64ToPath(url)
let that = this;
//console.log('',that.transImg)
uni.showLoading({
title: '正在保存图片...',
success() {
//
uni.getSetting({
success: (res) => {
//
if (!res.authSetting["scope.album"]) {
//
uni.authorize({
scope: "scope.album",
success: () => {
uni.saveImageToPhotosAlbum({
//
filePath: url,
success: (res) => {
},
fail: (res) => {
return uni.showToast({
title: res.errMsg,
icon: 'none'
});
},
complete: (res) => {
uni.hideLoading();
if (res.errMsg !== "saveImageToPhotosAlbum:ok") {
return uni.showToast({
title: "下载失败!",
icon: 'none'
});
} else {
return uni.showToast({
title: "保存成功!",
icon: 'none',
success() {
}
});
}
},
});
},
//
fail: () => {
uni.hideLoading();
uni.showModal({
title: "您已拒绝获取相册权限",
content: "是否进入权限管理,调整授权?",
success: (res) => {
if (res.confirm) {
//
uni.openSetting({
success: (res) => {
},
});
} else if (res.cancel) {
return uni.showToast({
title: "已取消!",
icon: 'none'
});
}
},
});
},
});
} else {
//
uni.saveImageToPhotosAlbum({
filePath: url,
success: (res) => {
console.log('有权限下载图片结果为',res)
console.log('333333')
},
fail: (res) => {
return uni.showToast({
title: res.errMsg,
icon: 'none'
});
},
//
complete: (res) => {
uni.hideLoading();
if (res.errMsg !== "saveImageToPhotosAlbum:ok") {
return uni.showToast({
title: "下载失败!",
icon: 'none'
});
}else{
return uni.showToast({
title: "保存成功!",
duration: 2000,
icon: 'none'
});
}
},
});
}
},
fail: (res) => {},
});
}
});
}
}
}
</script>
<style>
<style lang="scss" scoped>
.wrap {
padding: 20px 0px;
width: 100%;
min-height: 100vh;
background-color: #faf0f3;
.top-box {
.love-title {
margin-top: 30rpx;
margin-left: 40rpx;
width: 677rpx;
height: 245rpx;
// border: 1px solid black;
background-image: url('https://vediocnd.corpring.com/520love/520_title.png');
background-size: 100% 100%;
// z-index: 10;
margin-bottom: -10px;
}
.top-img-box {
// margin-top: -10px;
width: 100%;
height: 750rpx;
background-image: url('https://vediocnd.corpring.com/520love/love_bg_1.gif');
background-size: 110% 110%;
background-position: center;
padding: 200rpx 30rpx;
box-sizing: border-box;
.loading {
margin-top: 40rpx;
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
color: #fc1f8d;
}
.img-item-box {
// margin-top: 100rpx;
display: flex;
justify-content: space-around;
position: relative;
.heart-icon {
position: absolute;
width: 70px;
height: 60px;
top: 50%;
left: 50%;
transform: translate(-50%, -50%);
background-image: url('https://vediocnd.corpring.com/520love/heart_icon_1.png');
background-size: 100% 100%;
}
.img-item {
box-sizing: border-box;
border: 3px solid #faf0f3;
width: 300rpx;
height: 300rpx;
// background-color: #fff;
border-radius: 10px;
}
}
}
.button-box {
padding: 0rpx 30rpx;
box-sizing: border-box;
display: flex;
justify-content: space-around;
.save-button {
width: 250rpx;
height: 75rpx;
background-image: url('https://vediocnd.corpring.com/520love/save_button.png');
background-size: 100% 100%;
}
}
}
}
</style>

69
pages/ai/paint/loverPaint.vue

@ -3,7 +3,7 @@
<view class="desc-box">
<text class="title">内容描述</text>
<textarea class="desc-input" v-model="contentDesc"
placeholder="请输入内容描述" />
placeholder="请输入内容描述~" />
<!-- <view class="bottom-box">
<view class="keyTips" @click="clickRandomKey()"></view>
<view class="limit">{{drawDesc.length}}/50</view>
@ -12,7 +12,7 @@
<view class="desc-box">
<text class="title">场景描述</text>
<textarea class="desc-input" v-model="sceneDesc"
placeholder="请输入场景描述" />
placeholder="描述一下你们的场景吧~" />
<!-- <view class="bottom-box">
<view class="keyTips" @click="clickRandomKey()"></view>
<view class="limit">{{drawDesc.length}}/50</view>
@ -25,7 +25,9 @@
<view class="type-item" v-for="(item, index) in paintStyle" @click="selectType(index)"
:style="{ backgroundImage: `url(${item.imgUrl})` }"
:class="curType == index? 'active' : ''">
<view class="title">
{{item.name}}
</view>
</view>
</view>
</view>
@ -58,15 +60,6 @@
// this.getPrompt();
},
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();
},
@ -178,16 +171,6 @@
});
// const data = {
// msg: this.drawDesc,
// type: this.curType,
// size: this.curSize,
// mobile: getApp().globalData.userInfo.phoneNumber
// }
// uni.navigateTo({
// url: '/pages/resultPgae/resultPage?data='+ encodeURIComponent(JSON.stringify(data)),
// });
}
}
@ -199,13 +182,13 @@
padding: 20px;
width: 100%;
min-height: 100vh;
background-color: #1d1d1d;
background-color: #faf0f3;
.draw-button {
position: fixed;
left: 50%;
bottom: 50rpx;
transform: translateX(-50%);
background: linear-gradient(#4090f6, #2150d2);
background: linear-gradient(#fc1f8d, #d2158a);
width: 400rpx;
height: 100rpx;
border-radius: 50rpx;
@ -214,28 +197,41 @@
justify-content: center;
align-items: center;
color: #fff;
font-size: 14px;
font-size: 20px;
}
.desc-box {
margin-bottom: 10px;
.title {
color: #fff;
font-size: 16px;
font-size: 18px;
// margin-bottom: 20px;
color: #fc1f8d;
font-weight: bold;
}
.desc-input {
margin-top: 10px;
border: 2px solid #fc1f8d;
margin-top: 5px;
width: 100%;
height: 200rpx;
background-color: #373737;
background-color: #fff;
border-radius: 8px;
padding: 20rpx;
box-sizing: border-box;
color: #fff;
// color: #fff;
}
}
.type-box {
.title {
color: #fff;
font-size: 18px;
// margin-bottom: 5px;
color: #fc1f8d;
font-weight: bold;
}
.type-item-box {
margin-top: 5px;
display: flex;
justify-content: space-between;
flex-wrap: wrap;
@ -243,9 +239,22 @@
width: 160rpx;
height: 160rpx;
background-size: 100% 100%;
border-radius: 5px;
box-sizing: border-box;
position: relative;
.title {
position: absolute;
bottom: 0px;
width: 100%;
background-color: rgba(255, 255, 255, 0.7);
color: #fc1f8d;
text-align: center;
font-size: 14px;
}
}
.active {
border: 5px solid #4090f6;
border: 4px solid #fc1f8d;
}
}
}

26
pages/index/indexProto.vue

@ -39,6 +39,9 @@
<uni-load-more :status="loadStatus"></uni-load-more>
</view>
</view>
<view class="love-icon" @click="goLoveDraw()">
</view>
</view>
</template>
@ -119,6 +122,11 @@
}
},
methods: {
goLoveDraw() {
uni.navigateTo({
url:'/pages/ai/paint/loverPaint'
})
},
changeSwiper(e){
this.current = e.detail.current;
},
@ -249,6 +257,24 @@
</script>
<style lang="scss" scoped>
.love-icon {
width: 140rpx;
height: 140rpx;
background-image: url('https://vediocnd.corpring.com/520love/520_icon.png');
background-size: 100% 100%;
position: fixed;
bottom: 40rpx;
right: 10rpx;
animation-name: breath ;
animation-duration: 2.5s;
animation-iteration-count: infinite;
animation-fill-mode: both;
}
@keyframes breath {
0% { transform: scale(1); }
50% { transform: scale(1.1); }
100% { transform: scale(1); }
}
.swiper-box {
height: 30vh;

Loading…
Cancel
Save