pc端推进
This commit is contained in:
parent
2e62f3fc61
commit
f4cd69c12a
@ -80,22 +80,27 @@ const install = (Vue, vm) => {
|
||||
const status = vm.$store.state.vuex_token;
|
||||
vm.$u.vuex('vuex_token', '');
|
||||
vm.$u.vuex('user_message', {});
|
||||
vm.$router.go(0);
|
||||
if(status){
|
||||
setTimeout(()=>{
|
||||
uni.showToast({title: '当前登录过期,请重新登录!',icon: 'none'});
|
||||
},500);
|
||||
}
|
||||
// uni.reLaunch({
|
||||
// url:getCurrentPages()[0].route,
|
||||
// complete() {
|
||||
// if(status){
|
||||
// setTimeout(()=>{
|
||||
// uni.showToast({title: '当前登录过期,请重新登录!',icon: 'none'});
|
||||
// },300);
|
||||
// },500);
|
||||
// }
|
||||
// }
|
||||
// })
|
||||
// vm.$router.go(0);
|
||||
uni.setStorageSync('pc_current', 0);
|
||||
uni.reLaunch({
|
||||
url:'/pages/pc_web/index/index',
|
||||
complete() {
|
||||
if(status){
|
||||
setTimeout(()=>{
|
||||
uni.showToast({title: '当前登录过期,请重新登录!',icon: 'none'});
|
||||
},300);
|
||||
}else{
|
||||
setTimeout(()=>{
|
||||
uni.showToast({title: '请登录!',icon: 'none'});
|
||||
},300);
|
||||
}
|
||||
}
|
||||
})
|
||||
}
|
||||
return result;
|
||||
break;
|
||||
|
@ -32,7 +32,7 @@
|
||||
<scroll-view class="hss-scroll-view" @scroll="scroller" ref="scrollView"
|
||||
scroll-with-animation :scroll-left="scrollLeft" scroll-x>
|
||||
<view class="hss-services">
|
||||
<view class="hss-service" v-for="(item,index) in serviceList.slice(1)" :key="index">
|
||||
<view class="hss-service" v-for="(item,index) in serviceList.slice(1)" :key="index" @click="$emit('handleChangeService', item.id)">
|
||||
<image :src="encodeURI(staticIp+item.icon)"></image>
|
||||
{{ item.name }}
|
||||
</view>
|
||||
@ -52,7 +52,7 @@
|
||||
<view class="sign-text">{{ item.serviceName || '暂无' }}</view>
|
||||
<image :lazy-load="true" class="sign" :src="fileUrl+sign"></image>
|
||||
<view class="work-todo">
|
||||
<view class="wt-same">
|
||||
<view class="wt-same" @click.stop="$emit('handleChangeService', item.serviceId)">
|
||||
<image :src="fileUrl+magicWand"></image>
|
||||
<text>做同款</text>
|
||||
</view>
|
||||
@ -407,9 +407,9 @@ export default {
|
||||
}
|
||||
.hs-services{
|
||||
padding: 40rpx;
|
||||
column-count:6;
|
||||
-moz-column-count:6; /* Firefox */
|
||||
-webkit-column-count:6; /* Safari 和 Chrome */
|
||||
column-count:5;
|
||||
-moz-column-count:5; /* Firefox */
|
||||
-webkit-column-count:5; /* Safari 和 Chrome */
|
||||
column-gap: 2em;
|
||||
-moz-column-gap: 2em;
|
||||
-webkit-column-gap: 2em;
|
||||
|
@ -25,7 +25,7 @@
|
||||
:title="item.serviceName||'暂无'">
|
||||
<el-image class="work-module" :src="getImagePath(item.path)"
|
||||
:preview-src-list="[getImagePath(item.path)]"></el-image>
|
||||
<view class="work-todo">
|
||||
<view class="work-todo" @click.stop="$emit('changeService',item.serviceId)">
|
||||
<image :src="fileUrl+magicWand"></image>
|
||||
<text>做同款</text>
|
||||
</view>
|
||||
@ -35,7 +35,7 @@
|
||||
</view>
|
||||
</view>
|
||||
<view class="second-content">
|
||||
<Second @showToast="showToast" />
|
||||
<Second @showToast="showToast" @handleChangeService="handleChangeService"/>
|
||||
</view>
|
||||
<u-toast ref="uToast"></u-toast>
|
||||
</view>
|
||||
@ -95,6 +95,10 @@ export default {
|
||||
return '';
|
||||
}
|
||||
},
|
||||
// 服务跳转
|
||||
handleChangeService(id){
|
||||
this.$emit('changeService',id)
|
||||
},
|
||||
// 首页上传文件
|
||||
uploadFile(file, fileList){
|
||||
this.$refs.uploadCover.clearFiles();
|
||||
|
@ -2,11 +2,11 @@
|
||||
<view>
|
||||
<!-- <el-container class="pc-container">
|
||||
<view class="pc-header">
|
||||
<Header :currentPage="refs[current]" :isLogin="isLogin" @changePlat="changePlat" />
|
||||
<Header ref="header" :currentPage="refs[current]" :isLogin="isLogin" @changePlat="changePlat" />
|
||||
</view>
|
||||
<view style="width: 100%;height: 100rpx;"></view>
|
||||
<view class="pc-main">
|
||||
<component ref="pageRef" :is="refs[current]" />
|
||||
<component ref="pageRef" @changeService="changeService" :sid="serviceId" :is="refs[current]" />
|
||||
</view>
|
||||
</el-container>
|
||||
<Loading :show="loading" />
|
||||
@ -51,6 +51,8 @@ export default {
|
||||
pcBackground: 'pc-background.png',
|
||||
// 禁用pc端的缺省图
|
||||
sleep: 'sleep.png',
|
||||
// 服务id
|
||||
serviceId: '',
|
||||
}
|
||||
},
|
||||
computed: {
|
||||
@ -78,10 +80,21 @@ export default {
|
||||
}
|
||||
});
|
||||
},
|
||||
// 服务更换
|
||||
changeService(id){
|
||||
this.serviceId = id;
|
||||
this.changePlat(1);
|
||||
},
|
||||
// 切换主体
|
||||
changePlat(current){
|
||||
this.current = current;
|
||||
if(this.current === current) return;
|
||||
if(current === 1 && !this.isLogin){
|
||||
this.$refs.header.showLogin = true;
|
||||
this.$refs.uToast.show({type: 'warning', title: '请先登录!'});
|
||||
return;
|
||||
}
|
||||
uni.setStorageSync('pc_current', current);
|
||||
this.current = current;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
158
pages/pc_web/workshops/components/editor.vue
Normal file
158
pages/pc_web/workshops/components/editor.vue
Normal file
@ -0,0 +1,158 @@
|
||||
<template>
|
||||
<view class="workshops-editor">
|
||||
<view class="we-title">
|
||||
<view class="wet-left">
|
||||
<u-icon :name="icon" size="35"></u-icon>
|
||||
<slot name="title">
|
||||
<text class="slot">{{ title }}</text>
|
||||
</slot>
|
||||
</view>
|
||||
<view class="wet-right">
|
||||
<u-icon :name="fileUrl+strengthen" label="强化提示词" margin-left="10rpx"
|
||||
label-color="#d5ff00" size="34" @click="strengthenTip" />
|
||||
</view>
|
||||
</view>
|
||||
<view class="we-content">
|
||||
<u-input :placeholder="placeholder" v-model="defaultValue" :clearable="false" maxlength="300"
|
||||
type="textarea" :custom-style="{ height: height+'rpx', fontSize: '25rpx', overflowY: 'scroll',
|
||||
color: '#fff'}" placeholderStyle="color:#7f7c86" @input="input"/>
|
||||
<view class="strengthen-tips">
|
||||
<u-icon :name="rightIcon" size="30" :label="rightTip" @click="rightIconClick"
|
||||
margin-left="10rpx" label-color="#a19daa" color="#a19daa" />
|
||||
</view>
|
||||
<view class="we-loading" v-show="showLoading">
|
||||
<u-loading :show="showLoading" mode="flower" size="40"></u-loading>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import configService from '@/common/config.service.js';
|
||||
export default {
|
||||
props: {
|
||||
value: {
|
||||
type: [String, Number],
|
||||
default: ''
|
||||
},
|
||||
title: {
|
||||
type: String,
|
||||
default: '',
|
||||
},
|
||||
placeholder: {
|
||||
type: String,
|
||||
default: ''
|
||||
},
|
||||
icon: {
|
||||
type: String,
|
||||
default: ''
|
||||
},
|
||||
rightTip: {
|
||||
type: String,
|
||||
default: ''
|
||||
},
|
||||
rightIcon: {
|
||||
type: String,
|
||||
default: ''
|
||||
},
|
||||
rightIconClick: {
|
||||
type: Function,
|
||||
default: ()=>{}
|
||||
},
|
||||
height: {
|
||||
type: [String, Number],
|
||||
default: '200'
|
||||
}
|
||||
},
|
||||
data(){
|
||||
return{
|
||||
// 基础路径
|
||||
fileUrl: configService.fileUrl + 'pixel/workshops/',
|
||||
// 默认值
|
||||
defaultValue: this.value,
|
||||
// 魔法棒
|
||||
strengthen: 'new-strengthen.png',
|
||||
// 加载动画
|
||||
showLoading: false,
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
// 输入监听
|
||||
input(){
|
||||
this.$emit('input', this.defaultValue);
|
||||
},
|
||||
// 强化提示词
|
||||
strengthenTip(){
|
||||
let that = this;
|
||||
this.showLoading = true;
|
||||
this.$emit('strengthenTip', { input: this.defaultValue,
|
||||
deal: (result)=>{
|
||||
if(result){
|
||||
that.$emit('input', result);
|
||||
that.defaultValue = result;
|
||||
}
|
||||
that.showLoading = false;
|
||||
}});
|
||||
}
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
<style scoped lang="scss">
|
||||
.workshops-editor{
|
||||
.we-title{
|
||||
display: flex;
|
||||
align-items: flex-end;
|
||||
justify-content: space-between;
|
||||
.wet-left{
|
||||
display: flex;
|
||||
align-items: center;
|
||||
.u-icon{
|
||||
margin-right: 24rpx;
|
||||
}
|
||||
.slot{
|
||||
color: #fff;
|
||||
font-size: 32rpx;
|
||||
font-weight: bold;
|
||||
}
|
||||
}
|
||||
.wet-right{
|
||||
color: #d5ff00;
|
||||
margin-right: 5rpx;
|
||||
.u-icon{
|
||||
font-size: 25rpx;
|
||||
}
|
||||
}
|
||||
}
|
||||
.we-content{
|
||||
margin: 20rpx 0;
|
||||
// max-height: 150rpx;
|
||||
background: #2a233d;
|
||||
border-radius: 30rpx;
|
||||
padding: 30rpx 30rpx 20rpx;
|
||||
box-shadow: 0 0 8rpx #eee;
|
||||
position: relative;
|
||||
.u-input{
|
||||
height: 170rpx;
|
||||
}
|
||||
.strengthen-tips{
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: flex-end;
|
||||
text-shadow: 0 0 4rpx #7f7c86;
|
||||
}
|
||||
.we-loading{
|
||||
position: absolute;
|
||||
border-radius: 30rpx;
|
||||
top: 0;
|
||||
left: 0;
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
background-color: rgba(254,254,254,0.3);
|
||||
}
|
||||
}
|
||||
}
|
||||
</style>
|
801
pages/pc_web/workshops/workshops.vue
Normal file
801
pages/pc_web/workshops/workshops.vue
Normal file
@ -0,0 +1,801 @@
|
||||
<template>
|
||||
<view class="pc-workshops" :style="windowHeight>1000?{}:{ minHeight: windowHeight+'px'}">
|
||||
<!-- 左侧控制台 -->
|
||||
<view class="workshops-controls" v-loading="loading">
|
||||
<!-- 控制台——服务列表 -->
|
||||
<view class="controls-left">
|
||||
<view class="cl-title">
|
||||
AI创作
|
||||
</view>
|
||||
<view class="cl-item" :title="item.name" v-for="(item,index) in serviceList"
|
||||
:key="index" :class="item.id === serviceId ? 'cl-item-selected' : ''" @click="changeWork(item,index)">
|
||||
{{ item.name }}
|
||||
</view>
|
||||
</view>
|
||||
<!-- 控制台——服务详情 -->
|
||||
<view class="controls-right">
|
||||
<!-- 服务顶栏 -->
|
||||
<view class="control-top">
|
||||
<view class="ct-title">{{ serviceItem.name }}</view>
|
||||
<u-icon name="question-circle" size="35" label="宝典" color="#d2686b"
|
||||
label-size="34" label-color="#d2686b" margin-left="10" @click="showTutorial" />
|
||||
</view>
|
||||
<!-- 服务中心 -->
|
||||
<view class="control-center">
|
||||
<!-- 文生图 -->
|
||||
<view v-if="!formData.resultFile && serviceItem.type===1">
|
||||
<EditorBox :height="200" :icon="ip+editorIcon" title="提示词"
|
||||
v-model="formData.text" placeholder="请输入描述的提示词(限制300词)~~" rightIcon="question-circle"
|
||||
rightTip="使用教程" :rightIconClick="showTutorial" @strengthenTip="strengthenTip"/>
|
||||
</view>
|
||||
<view class="use-tips">使用提示:{{ serviceItem.tips || '智能创作~' }}</view>
|
||||
</view>
|
||||
<!-- 服务底栏 -->
|
||||
<view class="control-bottom">
|
||||
<view class="cb-left">
|
||||
实付:<view>{{ serviceItem.price }}<u-icon :name="fileUrl+diamondIcon" size="40" /></view>
|
||||
</view>
|
||||
<view class="cb-right">
|
||||
<el-popover :append-to-body='false' placement="top" title="收费明细" trigger="click"
|
||||
:content="`${serviceItem.name}\t1张——${serviceItem.price}💎`" v-model="detailShow">
|
||||
<view slot="reference" class="popover-detail">
|
||||
明细<u-icon :name="detailShow?'arrow-down':'arrow-up'" />
|
||||
</view>
|
||||
</el-popover>
|
||||
<u-button class="cb-btn" @click="startDeal" v-if="formData.resultFile===''" :disabled="functionDisable"
|
||||
:style="{opacity: functionDisable?'0.6':'1'}"
|
||||
ripple :hairLine="false" shape="circle" rippleBgColor="#f0fdbf" :loading='dotLoading'>
|
||||
<u-icon name="edit-pen" size="32"></u-icon>开启魔法
|
||||
</u-button>
|
||||
<u-button class="cb-btn cbu-btn" ripple :hairLine="false" shape="circle" v-else
|
||||
rippleBgColor="#f0fdbf" @click="redraw" :class="transition?'transition':''">
|
||||
<u-icon name="edit-pen" size="32"></u-icon>
|
||||
<text>重新绘制</text>
|
||||
</u-button>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
<!-- 图片上传框 -->
|
||||
<view class="workshops-upload">
|
||||
<el-upload class="upload-view" drag action="#" :auto-upload="false" ref="uploadCover"
|
||||
:multiple="false" accept="image/*" list-type="picture-card" :class="{disabled:uploadDisabled}"
|
||||
:on-change="selectImage" :file-list="formData.fileList" :disabled="formData.resultFile===''&&(serviceItem.type===3||serviceItem.type===1)">
|
||||
<view class="ulview-block" v-if="formData.fileList&&formData.fileList.length === 0"
|
||||
:style="formData.resultFile===''&&(serviceItem.type===3||serviceItem.type===1)?{opacity:0.6,cursor: 'default'}:{}">
|
||||
<image class="upload-gif" src="/static/upload-center.gif"></image>
|
||||
<view class="upload-title">点击 / 拖拽上传图片</view>
|
||||
<view class="upload-tips">请上传大小为<text>5KB~5MB</text>的图片</view>
|
||||
</view>
|
||||
<template slot="file" slot-scope="{file}">
|
||||
<view class="upload-preview">
|
||||
<image class="up-image el-upload-list__item-thumbnail" :src="file.url" mode="aspectFit"
|
||||
@click="changeLoadingImage"></image>
|
||||
<view class="el-upload-list__item-actions" v-show="asyncPollTime === -1">
|
||||
<span class="upload-icon el-upload-list__item-preview" @click="handlePreview()">
|
||||
<u-icon size="90" :name="fileUrl+previewIcon"></u-icon>
|
||||
</span>
|
||||
<span class="upload-icon el-upload-list__item-delete" v-if="formData.resultFile" @click="download">
|
||||
<u-icon size="90" :name="fileUrl+downloadIcon"></u-icon>
|
||||
</span>
|
||||
<span class="upload-icon el-upload-list__item-delete" v-else>
|
||||
<u-icon size="90" :name="fileUrl+deleteIcon" @click="handleDelete(file)"></u-icon>
|
||||
</span>
|
||||
</view>
|
||||
</view>
|
||||
</template>
|
||||
</el-upload>
|
||||
</view>
|
||||
<!-- <Loading :show="loading"></Loading> -->
|
||||
<u-toast ref="uToast"></u-toast>
|
||||
</view>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import configService from '@/common/config.service.js';
|
||||
import { ossUpload } from '@/common/ossutil/ossWebUpload.js';
|
||||
import EditorBox from './components/editor.vue';
|
||||
import { tools } from '@/utils/utils.js';
|
||||
export default {
|
||||
components: { EditorBox },
|
||||
props:{
|
||||
sid: {
|
||||
type: [Number,String],
|
||||
default: ''
|
||||
}
|
||||
},
|
||||
data(){
|
||||
return{
|
||||
// 基础路径
|
||||
ip: configService.ip,
|
||||
fileUrl: configService.fileUrl + 'pixel/pc/workshops/',
|
||||
// 下载图标
|
||||
downloadIcon: 'download.png',
|
||||
// 删除图标
|
||||
deleteIcon: 'delete.png',
|
||||
// 预览图标
|
||||
previewIcon: 'preview.png',
|
||||
// 钻石图标
|
||||
diamondIcon: 'diamond.png',
|
||||
// 编辑图标
|
||||
editorIcon: 'static/pixel/workshops/editor.png',
|
||||
// 屏幕高度
|
||||
windowHeight: 0,
|
||||
// 服务列表
|
||||
serviceList: [],
|
||||
// 服务id
|
||||
serviceId: '',
|
||||
// 当前服务
|
||||
serviceItem: {},
|
||||
// 全加载
|
||||
loading: false,
|
||||
// 明细显示
|
||||
detailShow: false,
|
||||
// 图片处理加载动画
|
||||
dotLoading: false,
|
||||
// 过渡动画
|
||||
transition: false,
|
||||
// 按钮禁用
|
||||
functionDisable: false,
|
||||
// 上传禁用
|
||||
uploadDisabled: false,
|
||||
// 加载中随机图片
|
||||
rangeImageList: [],
|
||||
// 图片上传表单存储
|
||||
formData: {
|
||||
fileList: [],
|
||||
uploadFile: '',// 上传图片
|
||||
resultFile: '',// 结果图
|
||||
text: '',// 提示词
|
||||
},
|
||||
// 进度条
|
||||
dealPercent: 0,
|
||||
// 进度条计时器
|
||||
dealPercentTimer: 1,
|
||||
// 轮询次数——不轮询-1
|
||||
asyncPollTime: -1,
|
||||
// 异步结果——成功true,失败false
|
||||
asyncResult: false,
|
||||
// 生成失败提示词
|
||||
errorTips: '',
|
||||
}
|
||||
},
|
||||
beforeMount() {
|
||||
// 计算当前窗口高度
|
||||
this.windowHeight = window.screen.height;
|
||||
if(this.sid){
|
||||
this.serviceId = Number(this.sid);
|
||||
this.singleService();
|
||||
}
|
||||
this.getRangeImages();
|
||||
this.getServices();
|
||||
},
|
||||
methods: {
|
||||
// 获取服务筛选列表
|
||||
async getServices(){
|
||||
try{
|
||||
this.loading = true;
|
||||
let res = await this.$api.allServices();
|
||||
if(res.success){
|
||||
this.serviceList = res.data;
|
||||
if(!this.serviceId){
|
||||
this.serviceId = this.serviceList[0]?.id;
|
||||
this.serviceItem = this.serviceList[0];
|
||||
}
|
||||
}else{
|
||||
this.$refs.uToast.show({type: 'error', title: '服务列表获取失败'});
|
||||
}
|
||||
}catch(e){
|
||||
this.$refs.uToast.show({type: 'error', title: '服务列表获取失败'});
|
||||
}finally{
|
||||
this.loading = false;
|
||||
}
|
||||
},
|
||||
// 获取加载中图片
|
||||
async getRangeImages(){
|
||||
let res = await this.$api.getCpPhotoById({labelId: 6});
|
||||
if(res?.success){
|
||||
this.rangeImageList = res.data;
|
||||
}else{
|
||||
this.$refs.uToast.show({type:'error',title: "随机加载图片获取失败!"});
|
||||
}
|
||||
},
|
||||
// 获取单个服务内容
|
||||
async singleService(){
|
||||
let res = await this.$api.singleServices(this.serviceId);
|
||||
if(res.success){
|
||||
res.data.type = Number(res.data.type);
|
||||
this.serviceItem = res.data;
|
||||
}else{
|
||||
this.$refs.uToast.show({type:'error',title: "ai功能暂未开放!"});
|
||||
}
|
||||
},
|
||||
// 更换服务
|
||||
changeWork(item,index){
|
||||
if(this.serviceId === item.id) return;
|
||||
this.serviceId = item.id;
|
||||
this.$emit('changeService',item.id);
|
||||
this.serviceItem = this.serviceList[index];
|
||||
this.serviceItem.type = Number(this.serviceItem.type);
|
||||
if(this.serviceItem.type===3||this.serviceItem.type===1) this.handleDelete();
|
||||
},
|
||||
// 宝典
|
||||
showTutorial(){
|
||||
if(this.serviceItem.exampleUrl){
|
||||
window.open(encodeURI(this.serviceItem.exampleUrl));
|
||||
}else{
|
||||
this.$refs.uToast.show({type:'warning',title: "暂无使用教程,请自求多福!"});
|
||||
}
|
||||
},
|
||||
// 增强提示词
|
||||
async strengthenTip({input, deal}){
|
||||
if(input === ''){
|
||||
this.$refs.uToast.show({type:'warning',title: "请提供部分词句!"});
|
||||
deal();
|
||||
return;
|
||||
}else{
|
||||
let res = await this.$api.createTip(input);
|
||||
if(res.success){
|
||||
deal(res.data);
|
||||
}else{
|
||||
this.$refs.uToast.show({type:'error',title: "提示词强化失败!"});
|
||||
deal();
|
||||
return;
|
||||
}
|
||||
}
|
||||
},
|
||||
// 上传图片
|
||||
selectImage(file,uploadFiles){
|
||||
let that = this;
|
||||
if (file.raw.type.indexOf('image/') === -1) {
|
||||
this.$refs.uploadCover.clearFiles();
|
||||
that.$refs.uToast.show({type: 'warning',title: "图片上传格式错误!"});
|
||||
return;
|
||||
}
|
||||
|
||||
const size = file.raw.size / 1024; // 计算文件大小
|
||||
if(size<5 || (size/1024)>5){
|
||||
this.$refs.uploadCover.clearFiles();
|
||||
that.$refs.uToast.show({type: 'warning',title: "图片大小不符合规范!"});
|
||||
return;
|
||||
}
|
||||
that.uploadDisabled = true;
|
||||
that.formData.fileList = uploadFiles;
|
||||
that.formData.uploadFile = uploadFiles[0]?.url;
|
||||
},
|
||||
// 表单合法判断
|
||||
legalJudge(){
|
||||
const currentType = this.serviceItem.type;
|
||||
if(currentType !== 3 && currentType !== 1 && this.formData.uploadFile === ''){
|
||||
this.$refs.uToast.show({type:'error',title: currentType === 4 ? "请选择模特!" : "请上传图片!"});
|
||||
// this.dotLoading = false;
|
||||
return false;
|
||||
}
|
||||
// if(currentType === 1){
|
||||
// if(this.selectElementIndex === '' || !this.form.text){
|
||||
// this.$refs.uToast.show({type:'error',title: "请完善信息!"});
|
||||
// // this.dotLoading = false;
|
||||
// return false;
|
||||
// }
|
||||
// }
|
||||
// if(currentType === 2 && this.selectElementIndex === ''){
|
||||
// this.$refs.uToast.show({type:'error',title: "请选择图片元素!"});
|
||||
// // this.dotLoading = false;
|
||||
// return false;
|
||||
// }
|
||||
// if(currentType === 3){
|
||||
// if(this.selectElementIndex === '' || !this.form.text || !this.form.promt){
|
||||
// this.$refs.uToast.show({type:'error',title: "请完善信息!"});
|
||||
// // this.dotLoading = false;
|
||||
// return false;
|
||||
// }
|
||||
// }
|
||||
// if(currentType === 4){
|
||||
// const { bottomImageUrl, topImageUrl } = this.$refs.dressRef.form;
|
||||
// if(topImageUrl===''){
|
||||
// this.$refs.uToast.show({type:'error',title: "请选择更换上衣!"});
|
||||
// // this.dotLoading = false;
|
||||
// return false;
|
||||
// }
|
||||
// }
|
||||
|
||||
return true;
|
||||
},
|
||||
// 开始处理图片
|
||||
async startDeal(){
|
||||
try{
|
||||
let that = this;
|
||||
// 判断图片是否符合规范
|
||||
if(!this.legalJudge()) return;
|
||||
that.dotLoading = true;
|
||||
// let mannequinIndex = that.form.type === 4 ? that.$refs.dressRef.form.mannequinIndex : '';
|
||||
// if(that.uploadFile && (mannequinIndex === '' || mannequinIndex === -1)){
|
||||
if(that.formData.fileList.length > 0){
|
||||
// 上传图片
|
||||
ossUpload(that,that.formData.uploadFile,(path)=>{
|
||||
if(!path) return;
|
||||
that.formData.uploadFile = path;
|
||||
that.formData.fileList[0].url = path;
|
||||
// 再实际处理
|
||||
that.realUpload();
|
||||
});
|
||||
}else{
|
||||
// 再实际处理
|
||||
that.realUpload();
|
||||
}
|
||||
}catch(e){
|
||||
this.dotLoading = false;
|
||||
}finally{
|
||||
}
|
||||
},
|
||||
// 真正处理方法
|
||||
async realUpload(){
|
||||
let that = this;
|
||||
let resp = await that.$api.generateImages(that.getParams(that.serviceItem));
|
||||
if(resp?.success){
|
||||
that.setResultFile(resp.data.path);
|
||||
that.$refs.uToast.show({type:'success',title:
|
||||
'等待ai生成中......点击先看临时工表演',duration: 3000});
|
||||
that.dotLoading = false;
|
||||
// 开启轮询
|
||||
that.delayLoadImage(resp.data.id);
|
||||
}else{
|
||||
that.$refs.uToast.show({type:'error',title: `${that.serviceItem.name}失败!`});
|
||||
that.dotLoading = false;
|
||||
}
|
||||
},
|
||||
// 开启轮询查询结果图片
|
||||
delayLoadImage(id){
|
||||
if(id){
|
||||
this.dealPercent = 0;
|
||||
this.asyncPollTime = 0;
|
||||
this.startDealPercent();
|
||||
this.asyncPoll(id);
|
||||
}
|
||||
},
|
||||
// 设置结果图
|
||||
setResultFile(path = ''){
|
||||
const length = this.rangeImageList.length;
|
||||
// 获取随机下标
|
||||
let num = Math.floor(Math.random() * length);
|
||||
let image = this.rangeImageList[num]?.path;
|
||||
this.formData.resultFile = length>0 ?
|
||||
(image.startsWith("http") ? image : encodeURI(this.ip+image)) : path;
|
||||
this.formData.fileList[0].url = this.formData.resultFile;
|
||||
},
|
||||
// 获取参数值
|
||||
getParams({id, type, options, text, promt}){
|
||||
let result,that = this;
|
||||
switch(Number(type)){
|
||||
case 0 :
|
||||
result = {
|
||||
serviceId: id,
|
||||
imageUrl: that.formData.uploadFile,
|
||||
}
|
||||
break;
|
||||
// case 1 :
|
||||
// result = {
|
||||
// serviceId: id,
|
||||
// option: options[that.selectElementIndex].optionKey,
|
||||
// text: text,
|
||||
// }
|
||||
// if(this.selectSizeIndex !== '') result.size = that.form.id === 4 ? that.aliDimensions[that.selectSizeIndex].name : that.volcengineDimensions[that.selectSizeIndex].name;
|
||||
// break;
|
||||
// case 2 :
|
||||
// result = {
|
||||
// serviceId: id,
|
||||
// imageUrl: that.uploadFile,
|
||||
// option: options[that.selectElementIndex].optionKey
|
||||
// }
|
||||
// break;
|
||||
// case 3 :
|
||||
// result = {
|
||||
// serviceId: id,
|
||||
// option: options[that.selectElementIndex].optionKey,
|
||||
// text: text,
|
||||
// promt: promt
|
||||
// }
|
||||
// break;
|
||||
// case 4 :
|
||||
// const { bottomImageUrl, topImageUrl } = this.$refs.dressRef.form;
|
||||
// result = {
|
||||
// serviceId: id,
|
||||
// bottomImageUrl: bottomImageUrl,
|
||||
// topImageUrl: topImageUrl,
|
||||
// imageUrl: that.getImagePath(that.uploadFile),
|
||||
// };
|
||||
// if(bottomImageUrl === '') delete result.bottomImageUrl;
|
||||
// else result.bottomImageUrl = that.getImagePath(bottomImageUrl);
|
||||
// if(topImageUrl === '') delete result.topImageUrl;
|
||||
// else result.topImageUrl = that.getImagePath(topImageUrl);
|
||||
// break;
|
||||
}
|
||||
return result;
|
||||
},
|
||||
// 设置进度条——最多15秒
|
||||
startDealPercent(){
|
||||
let that = this;
|
||||
let timerx = 1;
|
||||
let timer = function(){
|
||||
let random = Math.floor(Math.random()*3.5);
|
||||
let num = timerx === 75 ? 99 : that.dealPercent + random;
|
||||
if(num<99){
|
||||
that.dealPercent = num;
|
||||
timerx++;
|
||||
}else{
|
||||
that.dealPercent = 99;
|
||||
clearInterval(that.dealPercentTimer);
|
||||
}
|
||||
}
|
||||
this.dealPercentTimer = setInterval(timer,200);
|
||||
},
|
||||
// 轮询
|
||||
async asyncPoll(id) {
|
||||
if(this.asyncPollTime === -1) return;
|
||||
// 超13次轮询结束
|
||||
if(this.asyncPollTime > 13) {
|
||||
this.asyncPollTime = -1;
|
||||
this.$refs.uToast.show({type:'warning',title:'生成时间过长,请移步作品栏目查看图片'});
|
||||
return;
|
||||
}
|
||||
if(this.asyncPollTime === 3){
|
||||
this.$refs.uToast.show({type:'warning',title:'火速插队中......客官可稍后移步作品栏目查看图片',
|
||||
duration: 3000});
|
||||
}
|
||||
try {
|
||||
let res = await this.$api.singlePhotoById(id);
|
||||
if(res?.success && res.data !== null && res.data?.creationState !== "create"){
|
||||
this.dealPercent = 100;
|
||||
this.formData.resultFile = res.data?.path;
|
||||
this.formData.fileList[0].url = res.data?.path;
|
||||
setTimeout(()=>{this.asyncPollTime = -1;},100);
|
||||
// 结果判断
|
||||
this.asyncResult = res.data?.creationState === 't';
|
||||
this.errorTips = this.asyncResult ? '' : res.data?.reason;
|
||||
this.$refs.uToast.show({type:this.asyncResult?'success':'error',title: `${this.serviceItem.name}${this.asyncResult?'成功':'失败'}`});
|
||||
return;
|
||||
}
|
||||
this.asyncPollTime++;
|
||||
console.log('轮询次数:',this.asyncPollTime);
|
||||
} catch (error) {
|
||||
return;
|
||||
}
|
||||
setTimeout(() => this.asyncPoll(id), 5000);
|
||||
},
|
||||
// 图片预览
|
||||
handlePreview(){
|
||||
let files = [this.formData.uploadFile];
|
||||
if(this.formData.resultFile !== '') files.push(this.formData.resultFile);
|
||||
if(!files || files?.length === 0) return;
|
||||
tools.methods.lookImage(files.length-1,files);
|
||||
},
|
||||
// 图片删除
|
||||
handleDelete(){
|
||||
this.$refs.uploadCover.clearFiles();
|
||||
this.formData.fileList = [];
|
||||
setTimeout(()=>{
|
||||
this.uploadDisabled = false;
|
||||
},400);
|
||||
},
|
||||
// 下载图片
|
||||
download(){
|
||||
window.open(this.formData.resultFile);
|
||||
},
|
||||
// 重新绘制
|
||||
redraw(){
|
||||
let that = this;
|
||||
// 判断是否为异步生图
|
||||
if(this.asyncPollTime !== -1){
|
||||
uni.showModal({
|
||||
title: '提示',
|
||||
content: `图片生成中,是否确认重新绘制?`,
|
||||
confirmColor: '#94d500',
|
||||
success: (res) => {if (res.confirm) that.realRedraw();}
|
||||
});
|
||||
} else this.realRedraw();
|
||||
},
|
||||
// 真正重绘方法
|
||||
realRedraw(){
|
||||
this.handleDelete();
|
||||
this.formData.resultFile = '';
|
||||
this.formData.uploadFile = '';
|
||||
// if(this.form.type === 4) this.$refs.dressRef.resetForm();
|
||||
this.errorTips = '';
|
||||
this.asyncPollTime = -1;
|
||||
setTimeout(()=>{this.dealPercent = 100;});
|
||||
},
|
||||
// 切换加载图片
|
||||
changeLoadingImage(){
|
||||
if(this.asyncPollTime !== -1){
|
||||
this.setResultFile();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
<style scoped lang="scss">
|
||||
.pc-workshops{
|
||||
background-image: linear-gradient(to left top, #ffffff, #fcfbfc, #f8f8f9, #f5f4f7, #f1f1f4, #eef0f6, #eaeff7, #e5eff8, #ddf3f9, #d9f6f2, #def7e6, #eef6d9);
|
||||
margin-top: 20rpx;
|
||||
min-height: 2050rpx;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
padding: 40rpx 50rpx;
|
||||
.workshops-controls{
|
||||
width: 1070rpx;
|
||||
height: 1620rpx;
|
||||
background-color: #fff;
|
||||
border-radius: 40rpx;
|
||||
transition: 0.3s;
|
||||
display: flex;
|
||||
overflow: hidden;
|
||||
border: 2rpx solid #d5d5d5;
|
||||
.controls-left{
|
||||
width: 276rpx;
|
||||
height: 100%;
|
||||
background-color: #fefefe;
|
||||
border-right: 2rpx solid #d5d5d5;
|
||||
overflow-y: scroll;
|
||||
color: #c0c0c0;
|
||||
font-size: 30rpx;
|
||||
.cl-title{
|
||||
padding: 24rpx 40rpx;
|
||||
color: #6b6b6b;
|
||||
}
|
||||
.cl-item{
|
||||
overflow: hidden;
|
||||
white-space: nowrap;
|
||||
text-overflow: ellipsis;
|
||||
padding: 14rpx 50rpx;
|
||||
cursor: pointer;
|
||||
margin-left: 10rpx;
|
||||
margin-bottom: 28rpx;
|
||||
&:nth-last-child(1){
|
||||
margin-bottom: 0;
|
||||
}
|
||||
&:hover{
|
||||
color: #a3d4fe;
|
||||
margin-left: 0;
|
||||
border-left: 8rpx solid #a3d4fe;
|
||||
}
|
||||
}
|
||||
.cl-item-selected{
|
||||
color: #99d7ff;
|
||||
margin-left: 0;
|
||||
border-left: 8rpx solid #99d7ff;
|
||||
background-image: linear-gradient(to right, rgba(139, 243, 254, 0.3) 0%, rgba(248,248,248,0.7) 100%);
|
||||
}
|
||||
}
|
||||
.controls-right{
|
||||
flex: 1;
|
||||
height: 100%;
|
||||
background-color: rgba(248,248,248,0.7);
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
.control-top{
|
||||
padding: 20rpx 40rpx;
|
||||
display: flex;
|
||||
align-items: flex-end;
|
||||
justify-content: space-between;
|
||||
border-bottom: 2rpx solid rgba(224, 224, 224, 0.5);
|
||||
.ct-title{
|
||||
font-weight: bold;
|
||||
color: #6b6b6b;
|
||||
font-size: 38rpx;
|
||||
}
|
||||
.u-icon{
|
||||
cursor: pointer;
|
||||
&:hover{
|
||||
opacity: 0.8;
|
||||
}
|
||||
&:active{
|
||||
opacity: 0.6;
|
||||
}
|
||||
}
|
||||
}
|
||||
.control-center{
|
||||
flex: 1;
|
||||
overflow-y: scroll;
|
||||
// background-color: #99d7ff;
|
||||
padding: 40rpx;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
.use-tips{
|
||||
font-size: 30rpx;
|
||||
color: #6b6b6b;
|
||||
}
|
||||
}
|
||||
.control-bottom{
|
||||
height: 140rpx;
|
||||
border-top: 2rpx solid #d5d5d5;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
padding: 0 34rpx;
|
||||
color: #6b6b6b;
|
||||
.cb-left{
|
||||
flex: 1;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
font-size: 32rpx;
|
||||
height: 100%;
|
||||
view{
|
||||
height: 33%;
|
||||
color: #b2d210;
|
||||
display: flex;
|
||||
align-items: flex-end;
|
||||
.u-icon{
|
||||
margin-left: 10rpx;
|
||||
}
|
||||
}
|
||||
}
|
||||
.cb-right{
|
||||
display: flex;
|
||||
align-items: center;
|
||||
height: 100%;
|
||||
position: relative;
|
||||
.popover-detail{
|
||||
cursor: pointer;
|
||||
.u-icon{
|
||||
margin-left: 10rpx;
|
||||
}
|
||||
&:hover{
|
||||
opacity: 0.8;
|
||||
}
|
||||
&:active{
|
||||
opacity: 0.6;
|
||||
}
|
||||
}
|
||||
.cb-btn{
|
||||
// color: rgba(42, 35, 61, 0.9);
|
||||
margin-left: 30rpx;
|
||||
height: 60%;
|
||||
min-width: 240rpx;
|
||||
border: none;
|
||||
font-size: 30rpx;
|
||||
font-weight: bold;
|
||||
background-size: 200% auto;
|
||||
transition: 0.5s;
|
||||
animation-duration: 1s;
|
||||
animation-fill-mode: both;
|
||||
box-shadow: 0 0 10rpx #99d7ff;
|
||||
background-image: linear-gradient(to right, #c2fc3b 0%, #c2ffd8 51%, #c2fc3b 100%);
|
||||
&:hover {
|
||||
background-position: right center;
|
||||
color: #fff;
|
||||
text-decoration: none;
|
||||
}
|
||||
&:active{
|
||||
filter: opacity(0.6);
|
||||
}
|
||||
.u-icon{
|
||||
margin-right: 10rpx;
|
||||
}
|
||||
.transition{
|
||||
animation-name: fadeIn;
|
||||
}
|
||||
}
|
||||
.cbu-btn{
|
||||
background-image: linear-gradient(to right, #4AC29A 0%, #BDFFF3 51%, #4AC29A 100%);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
&:hover{
|
||||
box-shadow: 0 0 14rpx #c6c6c6;
|
||||
}
|
||||
}
|
||||
.workshops-upload{
|
||||
flex: 1;
|
||||
height: 100%;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
.upload-view{
|
||||
border: 4rpx dashed #99d7ff;
|
||||
border-radius: 40rpx;
|
||||
width: 1350rpx;
|
||||
height: 1350rpx;
|
||||
display: flex;
|
||||
justify-content: center;
|
||||
align-items: center;
|
||||
overflow: hidden;
|
||||
&:hover{
|
||||
border: 4rpx dashed #6ec0ff;
|
||||
}
|
||||
&::v-deep .el-upload,&::v-deep .el-upload-dragger{
|
||||
width: 100%;
|
||||
border: none;
|
||||
min-height: 1350rpx;
|
||||
border-radius: 40rpx;
|
||||
}
|
||||
&::v-deep .el-upload--picture-card{
|
||||
line-height: 46rpx;
|
||||
}
|
||||
&::v-deep .el-upload-list--picture-card{
|
||||
display: none;
|
||||
}
|
||||
.ulview-block{
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
flex-direction: column;
|
||||
.upload-gif{
|
||||
margin-top: -100rpx;
|
||||
}
|
||||
.upload-title{
|
||||
background-image: linear-gradient(to right, #a3d4ff 0%, #bee7df 100%);
|
||||
background-clip: text;
|
||||
-webkit-background-clip: text;
|
||||
-webkit-text-fill-color: transparent;
|
||||
font-size: 40rpx;
|
||||
font-weight: bold;
|
||||
}
|
||||
.upload-tips{
|
||||
margin-top: 34rpx;
|
||||
font-size: 30rpx;
|
||||
color: #aaafb8;
|
||||
text{
|
||||
margin: 0 10rpx;
|
||||
color: rgba(229, 64, 70, 1);
|
||||
}
|
||||
}
|
||||
}
|
||||
.upload-preview{
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
.up-image{
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
border-radius: 40rpx;
|
||||
cursor: pointer;
|
||||
img{
|
||||
border-radius: 40rpx !important;
|
||||
}
|
||||
}
|
||||
.upload-icon{
|
||||
margin: 0 50rpx;
|
||||
&:hover{
|
||||
opacity: 0.8;
|
||||
}
|
||||
&:active{
|
||||
opacity: 0.6;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
::v-deep .el-popper[x-placement^=top]{
|
||||
top: 0;
|
||||
}
|
||||
@keyframes fadeIn {
|
||||
from {
|
||||
opacity: 0;
|
||||
}
|
||||
|
||||
to {
|
||||
opacity: 1;
|
||||
}
|
||||
}
|
||||
::v-deep .disabled{
|
||||
border: none !important;
|
||||
.el-upload-list--picture-card{
|
||||
display: block !important;
|
||||
width: 100% !important;
|
||||
height: 100% !important;
|
||||
.el-upload-list__item{
|
||||
border-radius: 40rpx;
|
||||
width: 100% !important;
|
||||
height: 100% !important;
|
||||
background-color: #ffffff00 !important;
|
||||
border: none;
|
||||
}
|
||||
}
|
||||
.el-upload,.el-upload-dragger{
|
||||
display: none;
|
||||
}
|
||||
}
|
||||
</style>
|
BIN
static/upload-center.gif
Normal file
BIN
static/upload-center.gif
Normal file
Binary file not shown.
After Width: | Height: | Size: 497 KiB |
Loading…
Reference in New Issue
Block a user