From 5321fdbbe6c827cd082f779887cf6f081a199d06 Mon Sep 17 00:00:00 2001
From: Double-_-Z <2492419643@qq.com>
Date: Fri, 6 Dec 2024 23:58:58 +0800
Subject: [PATCH] =?UTF-8?q?=E8=B0=83=E6=95=B4=E6=8E=A5=E5=8F=A3?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
common/config.service.js | 2 +-
common/http.api.js | 4 ++
common/http.interceptor.js | 7 +--
manifest.json | 9 ++++
pages/mobile_web/home/home.vue | 57 +++++++++++++-------
pages/mobile_web/index/index.vue | 29 +++++++---
pages/mobile_web/my/my.vue | 4 ++
pages/mobile_web/work/work.vue | 4 ++
pages/mobile_web/workshops/common/imgDeal.js | 31 +++++------
pages/mobile_web/workshops/index.vue | 53 +++++++++---------
10 files changed, 128 insertions(+), 72 deletions(-)
diff --git a/common/config.service.js b/common/config.service.js
index a0a3155..c101ac9 100644
--- a/common/config.service.js
+++ b/common/config.service.js
@@ -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 FILE_URL = IP+'static/';
// 火山引擎ai接口地址
diff --git a/common/http.api.js b/common/http.api.js
index 2eb97b2..88950c5 100644
--- a/common/http.api.js
+++ b/common/http.api.js
@@ -6,6 +6,10 @@ const install = (Vue, vm) => {
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.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);// 添加留言
diff --git a/common/http.interceptor.js b/common/http.interceptor.js
index 5f05298..ccf49f1 100644
--- a/common/http.interceptor.js
+++ b/common/http.interceptor.js
@@ -9,9 +9,10 @@ import configService from '@/common/config.service.js';
const install = (Vue, vm) => {
let url = ''
// 此处仅作调试新接口的开发环境,会在开发环境时影响旧接口的请求,不影响上线使用
- if (process.env.NODE_ENV === 'development') {
- url = configService.apiUrl;
- }
+ // if (process.env.NODE_ENV === 'development') {
+ // url = configService.apiUrl;
+ // }
+ url = configService.apiUrl;
// #ifdef H5
typeof window.fastUrl !== 'undefined' ? url = window.fastUrl : '',
// #endif
diff --git a/manifest.json b/manifest.json
index d948ccf..a2a2f0f 100644
--- a/manifest.json
+++ b/manifest.json
@@ -102,6 +102,15 @@
"devServer" : {
"disableHostCheck" : true,
"proxy" : {
+ "/pixelApi" : {
+ "target" : "http://8.138.171.103:8082",
+ "changeOrigin" : true,
+ "secure" : true,
+ "ws" : false,
+ "pathRewrite" : {
+ "^/pixelApi" : ""
+ }
+ },
"/upload" : {
"target" : "http://8.138.171.103",
"changeOrigin" : true,
diff --git a/pages/mobile_web/home/home.vue b/pages/mobile_web/home/home.vue
index 8995777..033833f 100644
--- a/pages/mobile_web/home/home.vue
+++ b/pages/mobile_web/home/home.vue
@@ -21,18 +21,19 @@
-
+
-
+
-
-
+
+
{{ category.name }}
@@ -51,7 +52,7 @@
筛选
-
@@ -60,7 +61,7 @@
收藏
- {{ siftList[item.type].label }}
+ {{ siftList[item.type]?siftList[item.type].label:'暂无' }}
@@ -73,6 +74,7 @@
+
@@ -123,33 +125,35 @@ export default {
// {
// // 风格替换
// name: '风格替换',
- // picture:'autoreplace.png',
- // model: '',
+ // icon:'autoreplace.png',
+ // type: '',
// // 'stylereplace'
// },
{
// 人物动漫化
+ id: 1,
name: '人物动漫化',
- picture:'save.png',
- model: 'animeization'
+ icon:'save.png',
+ type: 0
},
// {
// // 证件照
// name: '证件照',
- // picture:'passport.png',
- // model: ''
+ // icon:'passport.png',
+ // type: ''
// },
{
// 旧照修复
+ id: 2,
name: '旧照修复',
- picture:'oldrepair.png',
- model: 'oldrepair'
+ icon:'oldrepair.png',
+ type: 0
},
// {
// // 人脸修复
// name: '人脸修复',
- // picture:'headrepair.png',
- // model: ''
+ // icon:'headrepair.png',
+ // type: ''
// }
],
// []
@@ -228,6 +232,20 @@ export default {
}
},
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){
this.currentPageindex = event.detail.current+1;
@@ -264,9 +282,10 @@ export default {
},250)
},
// 前往工作室
- toDeal({name, model}){
- if(name && model)
- uni.navigateTo({url: `/pages/mobile_web/workshops/index?name=${name}&model=${model}`});
+ toDeal(id = null){
+ if(id!==null)
+ uni.navigateTo({url: `/pages/mobile_web/workshops/index?id=${id}`});
+ else this.$refs.uToast.show({type:'error',title: "暂未开放对应功能!"});
},
// 轮播图跳转
linkTo(e){
diff --git a/pages/mobile_web/index/index.vue b/pages/mobile_web/index/index.vue
index c99a1c1..02159e1 100644
--- a/pages/mobile_web/index/index.vue
+++ b/pages/mobile_web/index/index.vue
@@ -1,9 +1,10 @@
-
-
-
+
+
@@ -55,6 +56,8 @@ export default {
{label: "涂抹重绘", value: 6},{label: "AI换装", value: 7}],
// 滚动顶部
scrollTop: 0,
+ // refs组件列表
+ refs: ['home','work','my']
}
},
onPageScroll(e) {
@@ -66,8 +69,17 @@ export default {
this.scrollTop = e.scrollTop;
},
- // #ifdef H5
+
onShow(){
+
+ let index = uni.getStorageSync('current');
+ this.current = index?index:0;
+ this.changeCurrent(this.current)
+ // #ifndef H5
+ }
+ // #endif
+
+ // #ifdef H5
let that = this;
window.onscroll = function () {
//为了保证兼容性,这里取三个值,哪个有值取哪一个
@@ -84,14 +96,17 @@ export default {
},
// #endif
- onLoad() {
- },
methods:{
// 切换页面
changeCurrent(index){
this.current = index;
uni.setStorageSync('current',index);
- }
+ const currentRef = this.refs[index];
+ console.log(index,this.refs[index]);
+ this.$nextTick(()=>{
+ this.$refs.pageRef.init();
+ })
+ },
}
}
diff --git a/pages/mobile_web/my/my.vue b/pages/mobile_web/my/my.vue
index 61b1eba..16c6516 100644
--- a/pages/mobile_web/my/my.vue
+++ b/pages/mobile_web/my/my.vue
@@ -164,6 +164,10 @@ export default {
}
},
methods:{
+ // 初始化
+ init(){
+
+ },
// 操作栏
toControl(item){
if(item.path) uni.navigateTo({ url: item.path });
diff --git a/pages/mobile_web/work/work.vue b/pages/mobile_web/work/work.vue
index 202c9f4..77117a5 100644
--- a/pages/mobile_web/work/work.vue
+++ b/pages/mobile_web/work/work.vue
@@ -153,6 +153,10 @@ export default {
}
},
methods:{
+ // 初始化
+ init(){
+
+ },
// 切换选项
changeSelect(index){
this.current = index;
diff --git a/pages/mobile_web/workshops/common/imgDeal.js b/pages/mobile_web/workshops/common/imgDeal.js
index 3453c8e..47f1606 100644
--- a/pages/mobile_web/workshops/common/imgDeal.js
+++ b/pages/mobile_web/workshops/common/imgDeal.js
@@ -3,37 +3,31 @@ import configService from "@/common/config.service";
// 处理选择器
const selectDealFunction = (vm,model,params,success) => {
switch(model){
- case 'oldrepair' :
- oldrepair(vm,params,success);
- break;
- case 'animeization' :
- selfieAnime(vm,params,success);
+ case 0 :
+ diagramOfTheSketch(vm,params,success);
break;
};
return;
}
-// 旧照修复
-const oldrepair = async (vm,params,success) => {
- commonUpload(vm,'/AiPicture/Colourize',params,success);
-}
-
-// 人像动漫化
-const selfieAnime = async(vm,params,success) => {
- // let res = await vm.$api.selfieAnime(params);
- commonUpload(vm,'/AiPicture/selfie_anime',params,success);
+// 图生图
+const diagramOfTheSketch = async (vm,params,success) => {
+ commonUpload(vm,params,success);
}
// 通用上传方法
-const commonUpload = (vm,path,params,success) =>{
+const commonUpload = (vm,params,success) =>{
+ const image = params.filePath;
+ delete params.filePath;
uni.uploadFile({
- url: configService.apiUrl+path,
- filePath: params.filePath,
+ url: configService.apiUrl+'/AiPicture/GenerateImages',
+ filePath: image,
name: 'image',
+ formData: params,
header:{'token':vm.$store.state.vuex_token},
success: (res) => {
if(res.data){
- success(encodeURI(JSON.parse(res.data).data));
+ success(encodeURI(JSON.parse(res.data).data.path));
} else {
vm.$refs.uToast.show({type: 'error',title: "余额不足,请充值!"});
vm.dotLoading = false;
@@ -42,6 +36,7 @@ const commonUpload = (vm,path,params,success) =>{
},
fail: function (res) {
vm.$refs.uToast.show({type: 'error',title: "处理失败!"});
+ vm.dotLoading = false;
}
});
}
diff --git a/pages/mobile_web/workshops/index.vue b/pages/mobile_web/workshops/index.vue
index 589acd3..ddbf8ff 100644
--- a/pages/mobile_web/workshops/index.vue
+++ b/pages/mobile_web/workshops/index.vue
@@ -16,7 +16,7 @@
- {{ form.title }}
+ {{ form.name }}
@@ -29,7 +29,7 @@
-
+
@@ -37,7 +37,7 @@
-
+
@@ -52,7 +52,7 @@
- Tips:{{ resultFile ? '点击预览图片效果~' : placeholderList[form.model] }}
+ Tips:{{ resultFile ? '点击预览图片效果~' : '尝试魔法吧~~' }}
@@ -104,8 +104,7 @@ export default {
background: 'background.png',
// 数据
form: {
- title: '',// 标题
- model: ''// 模式
+ id: ''//id
},
// 模式选择
selections:["保留模式","替换模式"],
@@ -118,11 +117,11 @@ export default {
// 编辑图标
editorIcon: 'editor.png',
// 提示语列表
- placeholderList: {
- stylereplace: '上传图片后,选择更换不同风格~',
- animeization: '上传人像图,快进入anime的世界吧~',
- oldrepair: '上传黑白旧照片,焕发色彩~'
- },
+ // placeholderList: {
+ // stylereplace: '上传图片后,选择更换不同风格~',
+ // animeization: '上传人像图,快进入anime的世界吧~',
+ // oldrepair: '上传黑白旧照片,焕发色彩~'
+ // },
// 创作之后的操作按钮
resultFunction: {
download: {
@@ -182,10 +181,20 @@ export default {
},
// #endif
onLoad(options) {
- this.form.title = options.name;
- this.form.model = options.model;
+ this.form.id = options.id;
+ this.getForm();
},
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(){
uni.navigateBack();
@@ -227,10 +236,10 @@ export default {
return;
}
// 再实际处理
- selectDealFunction(that,that.form.model,that.getParams(that.form.model),
+ selectDealFunction(that,that.form.type,that.getParams(that.form.type),
(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;
});
}catch(e){
@@ -239,17 +248,13 @@ export default {
}
},
// 获取参数值
- getParams(model){
+ getParams(type){
let result,that = this;
- switch(model){
- case 'oldrepair' :
+ switch(type){
+ case 0 :
result = {
- filePath: this.uploadFile,
- }
- break;
- case 'animeization' :
- result = {
- filePath: this.uploadFile,
+ serviceId: that.form.id,
+ filePath: that.uploadFile,
}
break;
}