调整接口

This commit is contained in:
Double-_-Z 2024-12-06 23:58:58 +08:00
parent 220bac6166
commit 5321fdbbe6
10 changed files with 128 additions and 72 deletions

View File

@ -1,5 +1,5 @@
// 接口环境 // 接口环境
let BASE_URL = 'http://8.138.171.103:8082'; let BASE_URL = '/pixelApi';
let IP = 'http://8.138.171.103/'; let IP = 'http://8.138.171.103/';
let FILE_URL = IP+'static/'; let FILE_URL = IP+'static/';
// 火山引擎ai接口地址 // 火山引擎ai接口地址

View File

@ -6,6 +6,10 @@ const install = (Vue, vm) => {
vm.$api.login = async (params = {}) => await vm.$u.get('/acUser/phoneLogin', params);// 手机号登录 vm.$api.login = async (params = {}) => await vm.$u.get('/acUser/phoneLogin', params);// 手机号登录
vm.$api.register = async (params = {}) => await vm.$u.get('/acUser/phoneRegister', params);// 手机号注册 vm.$api.register = async (params = {}) => await vm.$u.get('/acUser/phoneRegister', params);// 手机号注册
// 应用服务
vm.$api.allServices = async (params = {}) => await vm.$u.get('/paServices/all', params);// 获取全部应用
vm.$api.singleServices = async (id) => await vm.$u.get(`/paServices/${id}`);// 获取单个应用
// 留言板 // 留言板
vm.$api.addMessage = async (params = {}) => await vm.$u.post('/cpMessage', params);// 添加留言 vm.$api.addMessage = async (params = {}) => await vm.$u.post('/cpMessage', params);// 添加留言

View File

@ -9,9 +9,10 @@ import configService from '@/common/config.service.js';
const install = (Vue, vm) => { const install = (Vue, vm) => {
let url = '' let url = ''
// 此处仅作调试新接口的开发环境,会在开发环境时影响旧接口的请求,不影响上线使用 // 此处仅作调试新接口的开发环境,会在开发环境时影响旧接口的请求,不影响上线使用
if (process.env.NODE_ENV === 'development') { // if (process.env.NODE_ENV === 'development') {
url = configService.apiUrl; // url = configService.apiUrl;
} // }
url = configService.apiUrl;
// #ifdef H5 // #ifdef H5
typeof window.fastUrl !== 'undefined' ? url = window.fastUrl : '', typeof window.fastUrl !== 'undefined' ? url = window.fastUrl : '',
// #endif // #endif

View File

@ -102,6 +102,15 @@
"devServer" : { "devServer" : {
"disableHostCheck" : true, "disableHostCheck" : true,
"proxy" : { "proxy" : {
"/pixelApi" : {
"target" : "http://8.138.171.103:8082",
"changeOrigin" : true,
"secure" : true,
"ws" : false,
"pathRewrite" : {
"^/pixelApi" : ""
}
},
"/upload" : { "/upload" : {
"target" : "http://8.138.171.103", "target" : "http://8.138.171.103",
"changeOrigin" : true, "changeOrigin" : true,

View File

@ -21,18 +21,19 @@
<image :src="fileUrl+functionImg[1].picture" class="go"></image> <image :src="fileUrl+functionImg[1].picture" class="go"></image>
</view> </view>
<view class="ff-right"> <view class="ff-right">
<image @click="toDeal({name: '涂抹重绘',model: 'repaint'})" class="redraw" :src="fileUrl+functionImg[2].picture"></image> <image @click="toDeal()" class="redraw" :src="fileUrl+functionImg[2].picture"></image>
<image class="tip" :src="fileUrl+functionImg[3].picture"></image> <image class="tip" :src="fileUrl+functionImg[3].picture"></image>
</view> </view>
</view> </view>
<!-- 轮播功能栏 --> <!-- 轮播功能栏 -->
<view class="second-functions"> <view class="second-functions">
<swiper class="swiper" duration="300" @change="categoryChange"> <swiper class="swiper" duration="300" @change="categoryChange">
<swiper-item v-for="(item, index) in swiperFunctionList" :key="item.picture"> <swiper-item v-for="(item, index) in swiperFunctionList" :key="index">
<view class="category flex" :style="item.length===5?{justifyContent: 'space-between'}:{}"> <view class="category flex" :style="item.length===5?{justifyContent: 'space-between'}:{}">
<template v-for="(category, itemIndex) in item"> <template v-for="(category, itemIndex) in item">
<view class="category-item" @click="toDeal(category)"> <view class="category-item" @click="toDeal(category.id)">
<image :style="category.name==='人物动漫化'?{width:'115rpx'}:category.name==='证件照'?{width:'85rpx'}:{}" :src="fileUrl+category.picture"></image> <image :style="category.name==='人物动漫化'?{width:'115rpx'}:category.name==='证件照'?{width:'85rpx'}:{}"
:src="fileUrl+(category.icon||'autoreplace.png')"></image>
{{ category.name }} {{ category.name }}
</view> </view>
</template> </template>
@ -51,7 +52,7 @@
<view class="tfc-right"> <view class="tfc-right">
筛选 筛选
<view class="tfcr-btn" @click="showSift = true"> <view class="tfcr-btn" @click="showSift = true">
<u-icon :label="siftList[siftIndex].label" :name="fileUrl+select" color="#d4ff00" <u-icon :label="siftList[siftIndex]?siftList[siftIndex].label:'暂无'" :name="fileUrl+select" color="#d4ff00"
size="17" label-pos="left" label-color="#d4ff00"></u-icon> size="17" label-pos="left" label-color="#d4ff00"></u-icon>
</view> </view>
</view> </view>
@ -60,7 +61,7 @@
<view @click="maskTouchend(item,index)" class="work-item" v-for="(item,index) in workList" :key="item.id"> <view @click="maskTouchend(item,index)" class="work-item" v-for="(item,index) in workList" :key="item.id">
<view :class="item.display?'ribbon-fadeOutUp':''" class="collect-ribbon" v-show="item.collect">收藏</view> <view :class="item.display?'ribbon-fadeOutUp':''" class="collect-ribbon" v-show="item.collect">收藏</view>
<image class="work-picture" :src="item.picture" mode="widthFix"></image> <image class="work-picture" :src="item.picture" mode="widthFix"></image>
<view class="sign-text">{{ siftList[item.type].label }}</view> <view class="sign-text">{{ siftList[item.type]?siftList[item.type].label:'暂无' }}</view>
<image class="sign" :src="fileUrl+sign"></image> <image class="sign" :src="fileUrl+sign"></image>
<image class="compare-sign" mode="widthFix" :src="item.compare"></image> <image class="compare-sign" mode="widthFix" :src="item.compare"></image>
</view> </view>
@ -73,6 +74,7 @@
</view> </view>
</view> </view>
<u-toast ref="uToast"></u-toast>
<!-- 筛选项下拉栏 --> <!-- 筛选项下拉栏 -->
<u-select v-model="showSift" :list="siftList" @confirm="selectSift" <u-select v-model="showSift" :list="siftList" @confirm="selectSift"
confirm-color="#94d500"></u-select> confirm-color="#94d500"></u-select>
@ -123,33 +125,35 @@ export default {
// { // {
// // // //
// name: '', // name: '',
// picture:'autoreplace.png', // icon:'autoreplace.png',
// model: '', // type: '',
// // 'stylereplace' // // 'stylereplace'
// }, // },
{ {
// //
id: 1,
name: '人物动漫化', name: '人物动漫化',
picture:'save.png', icon:'save.png',
model: 'animeization' type: 0
}, },
// { // {
// // // //
// name: '', // name: '',
// picture:'passport.png', // icon:'passport.png',
// model: '' // type: ''
// }, // },
{ {
// //
id: 2,
name: '旧照修复', name: '旧照修复',
picture:'oldrepair.png', icon:'oldrepair.png',
model: 'oldrepair' type: 0
}, },
// { // {
// // // //
// name: '', // name: '',
// picture:'headrepair.png', // icon:'headrepair.png',
// model: '' // type: ''
// } // }
], ],
// [] // []
@ -228,6 +232,20 @@ export default {
} }
}, },
methods:{ methods:{
//
async init(){
let res = await this.$api.allServices();
if(res.success){
// 5
this.swiperFunctionList = [];
const arr = res.data;
for (let i = 0; i < arr.length; i += 5) {
this.swiperFunctionList.push(arr.slice(i, i + 5));
}
}else{
this.$refs.uToast.show({type:'error',title: "应用列表获取失败!"});
}
},
// //
categoryChange(event){ categoryChange(event){
this.currentPageindex = event.detail.current+1; this.currentPageindex = event.detail.current+1;
@ -264,9 +282,10 @@ export default {
},250) },250)
}, },
// //
toDeal({name, model}){ toDeal(id = null){
if(name && model) if(id!==null)
uni.navigateTo({url: `/pages/mobile_web/workshops/index?name=${name}&model=${model}`}); uni.navigateTo({url: `/pages/mobile_web/workshops/index?id=${id}`});
else this.$refs.uToast.show({type:'error',title: "暂未开放对应功能!"});
}, },
// //
linkTo(e){ linkTo(e){

View File

@ -1,9 +1,10 @@
<template> <template>
<view class="mobile-index"> <view class="mobile-index">
<view class="u-page upage"> <view class="u-page upage">
<Home ref="home" :topLevel="topLevel" :siftList="siftList" v-if="current===0" /> <!-- <Home ref="home" :topLevel="topLevel" :siftList="siftList" v-show="current===0" />
<Work ref="work" :topLevel="topLevel" :siftList="siftList" v-else-if="current===1" /> <Work ref="work" :topLevel="topLevel" :siftList="siftList" v-show="current===1" />
<My ref="my" :topLevel="topLevel" v-else-if="current===2" /> <My ref="my" :topLevel="topLevel" v-show="current===2" /> -->
<component ref="pageRef" :topLevel="topLevel" :siftList="siftList" :is="refs[current]"></component>
</view> </view>
<view class="navigation"> <view class="navigation">
<view @click="changeCurrent(index)" class="nav-item" v-for="(item,index) in navicationList" :key="index"> <view @click="changeCurrent(index)" class="nav-item" v-for="(item,index) in navicationList" :key="index">
@ -55,6 +56,8 @@ export default {
{label: "涂抹重绘", value: 6},{label: "AI换装", value: 7}], {label: "涂抹重绘", value: 6},{label: "AI换装", value: 7}],
// //
scrollTop: 0, scrollTop: 0,
// refs
refs: ['home','work','my']
} }
}, },
onPageScroll(e) { onPageScroll(e) {
@ -66,8 +69,17 @@ export default {
this.scrollTop = e.scrollTop; this.scrollTop = e.scrollTop;
}, },
// #ifdef H5
onShow(){ onShow(){
let index = uni.getStorageSync('current');
this.current = index?index:0;
this.changeCurrent(this.current)
// #ifndef H5
}
// #endif
// #ifdef H5
let that = this; let that = this;
window.onscroll = function () { window.onscroll = function () {
// //
@ -84,14 +96,17 @@ export default {
}, },
// #endif // #endif
onLoad() {
},
methods:{ methods:{
// //
changeCurrent(index){ changeCurrent(index){
this.current = index; this.current = index;
uni.setStorageSync('current',index); uni.setStorageSync('current',index);
} const currentRef = this.refs[index];
console.log(index,this.refs[index]);
this.$nextTick(()=>{
this.$refs.pageRef.init();
})
},
} }
} }
</script> </script>

View File

@ -164,6 +164,10 @@ export default {
} }
}, },
methods:{ methods:{
//
init(){
},
// //
toControl(item){ toControl(item){
if(item.path) uni.navigateTo({ url: item.path }); if(item.path) uni.navigateTo({ url: item.path });

View File

@ -153,6 +153,10 @@ export default {
} }
}, },
methods:{ methods:{
//
init(){
},
// //
changeSelect(index){ changeSelect(index){
this.current = index; this.current = index;

View File

@ -3,37 +3,31 @@ import configService from "@/common/config.service";
// 处理选择器 // 处理选择器
const selectDealFunction = (vm,model,params,success) => { const selectDealFunction = (vm,model,params,success) => {
switch(model){ switch(model){
case 'oldrepair' : case 0 :
oldrepair(vm,params,success); diagramOfTheSketch(vm,params,success);
break;
case 'animeization' :
selfieAnime(vm,params,success);
break; break;
}; };
return; return;
} }
// 旧照修复 // 图生图
const oldrepair = async (vm,params,success) => { const diagramOfTheSketch = async (vm,params,success) => {
commonUpload(vm,'/AiPicture/Colourize',params,success); commonUpload(vm,params,success);
}
// 人像动漫化
const selfieAnime = async(vm,params,success) => {
// let res = await vm.$api.selfieAnime(params);
commonUpload(vm,'/AiPicture/selfie_anime',params,success);
} }
// 通用上传方法 // 通用上传方法
const commonUpload = (vm,path,params,success) =>{ const commonUpload = (vm,params,success) =>{
const image = params.filePath;
delete params.filePath;
uni.uploadFile({ uni.uploadFile({
url: configService.apiUrl+path, url: configService.apiUrl+'/AiPicture/GenerateImages',
filePath: params.filePath, filePath: image,
name: 'image', name: 'image',
formData: params,
header:{'token':vm.$store.state.vuex_token}, header:{'token':vm.$store.state.vuex_token},
success: (res) => { success: (res) => {
if(res.data){ if(res.data){
success(encodeURI(JSON.parse(res.data).data)); success(encodeURI(JSON.parse(res.data).data.path));
} else { } else {
vm.$refs.uToast.show({type: 'error',title: "余额不足,请充值!"}); vm.$refs.uToast.show({type: 'error',title: "余额不足,请充值!"});
vm.dotLoading = false; vm.dotLoading = false;
@ -42,6 +36,7 @@ const commonUpload = (vm,path,params,success) =>{
}, },
fail: function (res) { fail: function (res) {
vm.$refs.uToast.show({type: 'error',title: "处理失败!"}); vm.$refs.uToast.show({type: 'error',title: "处理失败!"});
vm.dotLoading = false;
} }
}); });
} }

View File

@ -16,7 +16,7 @@
</view> </view>
<view class="mw-title"> <view class="mw-title">
<u-icon name="arrow-left" size="40" color="#fff" class="back" @click="back"></u-icon> <u-icon name="arrow-left" size="40" color="#fff" class="back" @click="back"></u-icon>
{{ form.title }} {{ form.name }}
</view> </view>
<view class="mw-upload"> <view class="mw-upload">
<view class="mwu-cover" v-if="uploadFile==''" @click="selectImage"> <view class="mwu-cover" v-if="uploadFile==''" @click="selectImage">
@ -29,7 +29,7 @@
<view class="center-image" v-else> <view class="center-image" v-else>
<image mode="widthFix" :src="ip+resultFile" @click="previewImage"></image> <image mode="widthFix" :src="ip+resultFile" @click="previewImage"></image>
</view> </view>
<view class="selections" v-if="form.model=='repaint'"> <view class="selections" v-if="form.type===1">
<view class="selections-item" :style="currentSelect===index?{ backgroundImage: `url(${fileUrl+selectBackground})` }: <view class="selections-item" :style="currentSelect===index?{ backgroundImage: `url(${fileUrl+selectBackground})` }:
{ color: '#000', backgroundImage: `url(${fileUrl+noSelectBackground})` }" { color: '#000', backgroundImage: `url(${fileUrl+noSelectBackground})` }"
v-for="(item,index) in selections" :key="index" @click="currentSelect=index"> v-for="(item,index) in selections" :key="index" @click="currentSelect=index">
@ -37,7 +37,7 @@
</view> </view>
</view> </view>
</view> </view>
<view class="mw-editor" v-if="form.model=='repaint'"> <view class="mw-editor" v-if="form.type===1">
<EditorBox :icon="fileUrl+editorIcon" <EditorBox :icon="fileUrl+editorIcon"
placeholder="如: 衣服/鞋子/头发或者英文:clothes and shose"> placeholder="如: 衣服/鞋子/头发或者英文:clothes and shose">
<template #title> <template #title>
@ -52,7 +52,7 @@
</EditorBox> </EditorBox>
</view> </view>
<view class="workshops-tip" v-else> <view class="workshops-tip" v-else>
Tips{{ resultFile ? '点击预览图片效果~' : placeholderList[form.model] }} Tips{{ resultFile ? '点击预览图片效果~' : '尝试魔法吧~~' }}
</view> </view>
</view> </view>
<view class="workshops-btn"> <view class="workshops-btn">
@ -104,8 +104,7 @@ export default {
background: 'background.png', background: 'background.png',
// //
form: { form: {
title: '',// id: ''//id
model: ''//
}, },
// //
selections:["保留模式","替换模式"], selections:["保留模式","替换模式"],
@ -118,11 +117,11 @@ export default {
// //
editorIcon: 'editor.png', editorIcon: 'editor.png',
// //
placeholderList: { // placeholderList: {
stylereplace: '上传图片后,选择更换不同风格~', // stylereplace: '~',
animeization: '上传人像图快进入anime的世界吧~', // animeization: 'anime~',
oldrepair: '上传黑白旧照片,焕发色彩~' // oldrepair: '~'
}, // },
// //
resultFunction: { resultFunction: {
download: { download: {
@ -182,10 +181,20 @@ export default {
}, },
// #endif // #endif
onLoad(options) { onLoad(options) {
this.form.title = options.name; this.form.id = options.id;
this.form.model = options.model; this.getForm();
}, },
methods:{ methods:{
// ai
async getForm(){
let res = await this.$api.singleServices(this.form.id);
if(res.success){
res.data.type = Number(res.data.type);
this.form = res.data;
}else{
this.$refs.uToast.show({type:'error',title: "ai功能暂未开放!"});
}
},
// //
back(){ back(){
uni.navigateBack(); uni.navigateBack();
@ -227,10 +236,10 @@ export default {
return; return;
} }
// //
selectDealFunction(that,that.form.model,that.getParams(that.form.model), selectDealFunction(that,that.form.type,that.getParams(that.form.type),
(path)=>{ (path)=>{
that.resultFile = path; that.resultFile = path;
that.$refs.uToast.show({type:'success',title: `${that.form.title}成功!`}); that.$refs.uToast.show({type:'success',title: `${that.form.name}成功!`});
this.dotLoading = false; this.dotLoading = false;
}); });
}catch(e){ }catch(e){
@ -239,17 +248,13 @@ export default {
} }
}, },
// //
getParams(model){ getParams(type){
let result,that = this; let result,that = this;
switch(model){ switch(type){
case 'oldrepair' : case 0 :
result = { result = {
filePath: this.uploadFile, serviceId: that.form.id,
} filePath: that.uploadFile,
break;
case 'animeization' :
result = {
filePath: this.uploadFile,
} }
break; break;
} }