Browse Source

修改

feature-1.1
helming 3 years ago
parent
commit
579c3e4d3f
  1. 8
      api/paint.js
  2. 8
      pages.json
  3. 34
      pages/ai/paint/paint.vue
  4. 34
      pages/userInfo/aiPaint/aiPaint.vue
  5. 414
      pages/userInfo/aiPaint/aiPaintDetail.vue
  6. 1
      pages/userInfo/userInfo.vue

8
api/paint.js

@ -62,5 +62,13 @@ export function useCdk(data) {
data data
}) })
} }
//判断是否VIP vip是否过期
export function checkVip(data) {
return request({
url: `${serviceTitle}/img/mini/vipRecord/queryUserVipRecord `,
method: 'get',
config: {params: data}
})
}

8
pages.json

@ -84,6 +84,14 @@
"enablePullDownRefresh": true "enablePullDownRefresh": true
} }
},
{
"path": "pages/userInfo/aiPaint/aiPaintDetail",
"style": {
"navigationBarTitleText": "创作工坊",
"enablePullDownRefresh": true
}
}, },
{ {
"path": "pages/userInfo/question/question", "path": "pages/userInfo/question/question",

34
pages/ai/paint/paint.vue

@ -141,6 +141,7 @@
<script> <script>
import base64ToImg from '@/utils/base64Utils'; import base64ToImg from '@/utils/base64Utils';
import {getPaintStyle, getPrompt, textToImg, checkUserCanAiPaint} from '@/api/paint.js'; import {getPaintStyle, getPrompt, textToImg, checkUserCanAiPaint} from '@/api/paint.js';
import {checkVip} from "@/api/paint";
export default { export default {
data() { data() {
return { return {
@ -248,16 +249,31 @@
}, },
methods: { methods: {
openAdvancedSetting(e) { openAdvancedSetting(e) {
//TODO VIP if (e.detail.value) {
checkVip({userId: this.userInfo.id, userClientType: "10"}).then(res => {
if (res.data.code === 200) {
if (res.data.data.isVip === "1") {
this.advancedSetting = e.detail.value; this.advancedSetting = e.detail.value;
this.formData.sfgScale = undefined; } else {
this.formData.negativePrompt = undefined; this.advancedSetting = !e.detail.value;
this.formData.seed = -1; uni.showToast({
this.formData.batchSize = 1; title: '还不是会员,开通会员后再尝试',
this.formData.sfgScale = 7; icon: 'none'
this.formData.steps = 20; })
this.formData.eta = 0; }
this.formData.samplerIndex = `Euler a`; }
})
} else {
this.advancedSetting = e.detail.value;
// this.formData.sfgScale = undefined;
// this.formData.negativePrompt = undefined;
// this.formData.seed = -1;
// this.formData.batchSize = 1;
// this.formData.sfgScale = 7;
// this.formData.steps = 20;
// this.formData.eta = 0;
// this.formData.samplerIndex = `Euler a`;
}
}, },
// //

34
pages/userInfo/aiPaint/aiPaint.vue

@ -33,7 +33,7 @@
toTopFlag: false toTopFlag: false
} }
}, },
onShow() { created() {
let that = this; let that = this;
that.userInfo = uni.getStorageSync('userInfo') that.userInfo = uni.getStorageSync('userInfo')
if (that.userInfo) { if (that.userInfo) {
@ -43,12 +43,12 @@
} }
}, },
// //
onPullDownRefresh() { // onPullDownRefresh() {
this.pageNum = 1 // this.pageNum = 1
this.imgList = [] // this.imgList = []
this.getImgList() // this.getImgList()
uni.stopPullDownRefresh() // uni.stopPullDownRefresh()
}, // },
// //
onReachBottom() {// onReachBottom() {//
if(!this.isLoadMore) { // if(!this.isLoadMore) { //
@ -114,28 +114,10 @@
// //
targetDetail(item) { targetDetail(item) {
if (item.id) { if (item.id) {
console.log('图片为',item)
uni.setStorage({
key: 'detailId',
data: item.id,
success() {
uni.navigateTo({
url: '../../creator/imgDetail'
})
}
})
}
/*if (item.id) {
uni.setStorage({
key: 'detailId',
data: item.id,
success() {
uni.navigateTo({ uni.navigateTo({
url: '../creator/imgDetail' url: './aiPaintDetail?data='+JSON.stringify(item)
}) })
} }
})
}*/
}, },
}, },
// onload(e) { // onload(e) {

414
pages/userInfo/aiPaint/aiPaintDetail.vue

@ -0,0 +1,414 @@
<template>
<!-- -->
<view class="aiPaintDetail_M">
<view class="paint">
<!-- 绘制好的图替换默认图展示 -->
<view class="successCover" v-if="transImg">
<image :src="transImg" mode="widthFix" class="img"/>
</view>
</view>
<view class="complete">
<!-- prompt关键词 -->
<view class="keywords">
<view>
<view class="promptTitle">关键词</view>
</view>
<view class="content">
<text>{{prompt}}</text>
</view>
</view>
<!-- 图画详细参数 -->
<view class="label">
<!-- <view class="style">
<view class="i">关键词</view>
<view class="text">{{ prompt }}</view>
</view> -->
<view class="style">
<view class="i">画布:</view>
<view class="text">{{ imgWidth }}x{{ imgHeight }}</view>
</view>
<view class="style">
<view class="i">创作风格:</view>
<view class="text">{{styleName}}</view>
</view>
<view class="style">
<view class="i">作品编号:</view>
<view class="text">{{paintId}}</view>
</view>
<view class="style">
<view class="i">创作时间:</view>
<view class="text">{{paintTime}}</view>
</view>
</view>
</view>
<!-- 底部操作栏(绘制成功替换告知图片保存在用户画册里) -->
<view class="action" >
<view class="action-group">
<view class="actionBtn">
<view class="grid" @click="onCopyPrompt">
<view><uni-icons type="link" size="24"></uni-icons></view>
<text class="grid-text">复制关键词</text>
</view>
</view>
<view class="actionBtn">
<view class="grid" @click="onSaveImage(transImg)">
<view><uni-icons type="cloud-download" size="24"></uni-icons></view>
<text class="grid-text">保存作品</text>
</view>
</view>
<button open-type="share" size="mini" class="actionBtn" plain="true" type="default">
<view class="grid" >
<view><uni-icons type="paperplane" size="24"></uni-icons></view>
<text class="grid-text">分享好友</text>
</view>
</button>
</view>
</view>
</view>
</template>
<script>
export default {
name: "aiPaintDetail",
//import使
components: {},
//
mixins: [],
//
props: {},
data() {
//
return {
transImg: undefined,
imgHeight: undefined,
imgWidth: undefined,
prompt: undefined,
successFlag: false,
paintId: undefined,
paintTime: undefined,
styleName: undefined,
batchSize: undefined,
};
},
onLoad(options) {
//
const paintData = JSON.parse(options.data);
this.imgHeight = paintData.height;
this.imgWidth = paintData.width;
this.prompt = paintData['prompt'];
this.styleName = paintData.styleName;
this.batchSize = paintData.batchSize;
this.paintTime = paintData.createTime;
this.transImg = paintData.imgUrl;
this.paintId = paintData.id;
},
// data
computed: {},
//data
watch: {},
//
methods: {
//
onSaveImage(url){
let that = this;
that.download(url)
},
//
download(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) => {},
});
}
});
},
//
onCopyPrompt(){
let that = this;
//console.log('')
uni.setClipboardData({
data: that.prompt,
success() {
uni.showToast({
title: '复制关键词成功!'
});
}
})
},
},
created() {
}, // - 访this
mounted() {
}, // - 访DOM
beforeCreate() {
}, // -
beforeMount() {
}, // -
beforeUpdate() {
}, // -
updated() {
}, // -
beforeDestroy() {
}, // -
destroyed() {
}, // -
activated() {
} //keep-alive
}
</script>
<style scoped lang="scss">
.aiPaintDetail_M {
.complete {
padding-bottom: 200rpx;
.Multi-sheet-tips {
width: 92%;
margin: 0 auto;
font-size: 24rpx;
line-height: 38rpx;
color: $uni-base-color;
border-bottom: 1rpx solid $uni-border-2;
}
.label {
width: 92%;
margin: 0 auto;
display: flex;
flex-direction: column;
justify-content: left;
align-items: flex-start;
margin-top: 15rpx;
.style {
display: flex;
flex-direction: row;
align-items: flex-start;
margin-top: 30rpx;
font-weight: bolder;
.i {
font-size: 28rpx;
color: $uni-primary;
border-radius: 5rpx;
margin-right: 15rpx;
line-height: 38rpx;
}
.text {
font-size: 26rpx;
line-height: 38rpx;
font-weight: bolder;
color: $uni-base-color;
}
}
}
.promptTitle{
text-align: center;
font-weight: bolder;
font-size: 28rpx;
color: $uni-primary;
}
.keywords {
width: 90%;
margin: 0 auto;
//background-color: #1A94BC1A;
//padding: 15rpx;
border-radius: 10rpx;
margin-top: 15rpx;
font-weight: bolder;
.content {
margin-top: 20rpx;
display: -webkit-box;
-webkit-box-orient: vertical;
-webkit-line-clamp: 2;
/*这里设置几行*/
overflow: hidden;
color: $uni-base-color;
font-size: 26rpx;
}
}
}
.paint {
.successCover {
width: 100%;
height: auto;
border-radius: 10 rpx;
.img {
width: 100%;
height: auto;
border-radius: 10 rpx;
}
}
}
.action {
width: 100%;
position: fixed;
bottom: 0rpx;
left: 0rpx;
background-color: #fff;
padding: 20rpx 10rpx;
.action-group {
width: 90%;
margin: 0 auto;
display: flex;
flex-direction: row;
justify-content: space-between;
button {
background-color: transparent;
border: 0;
outline: 0;
font-size: 28rpx;
padding: 0;
line-height: inherit;
}
button::after{
border: none;
outline: 0;
}
.actionBtn{
width: 50%;
display: flex;
flex-direction: row;
justify-content: center;
//margin:0rpx 25rpx 0rpx 25rpx;
.grid {
display: flex;
flex-direction: column;
align-items: center;
.grid-text {
font-size: 28rpx;
margin-top: 10rpx;
}
}
}
}
}
}
</style>

1
pages/userInfo/userInfo.vue

@ -452,6 +452,7 @@ import UniIcons from "../../uni_modules/uni-icons/components/uni-icons/uni-icons
font-size: 26rpx; font-size: 26rpx;
text-align: left; text-align: left;
line-height: 14px; line-height: 14px;
padding: 0 10px;
} }
} }

Loading…
Cancel
Save