diff --git a/src/api/lookPhoto.js b/src/api/lookPhoto.js index aa8cd3c..a41a8ac 100644 --- a/src/api/lookPhoto.js +++ b/src/api/lookPhoto.js @@ -12,3 +12,29 @@ export function getPhotoListApi(id) { method: 'get', }) } + + +/** +* @description:超分 +* @param id +* @return: data +*/ +export function photoSupperApi(data) { + return request({ + url: `/api/digitalAvatarPhoto/photoSupper`, + method: 'post', + data + }) +} + +/** +* @description:超分 查询超分状态 +* @param id +* @return: data +*/ +export function getSupperPhotoStateApi(id) { + return request({ + url: `/api/digitalAvatarPhoto/getSupperPhoto?id=${id}`, + method: 'get', + }) +} diff --git a/src/pages/createing/index.vue b/src/pages/createing/index.vue index 4dd9a69..d9933c8 100644 --- a/src/pages/createing/index.vue +++ b/src/pages/createing/index.vue @@ -86,8 +86,8 @@ const styleId = ref(null); //风格id const styleData = ref(""); //风格信息 onLoad((options) => { - // workId.value = options.id; - workId.value = "857147862095679488"; + workId.value = options.id; + // workId.value = "857147862095679488"; getWorkInfo(); // let getWindowInfo = uni.getWindowInfo().screenWidth; diff --git a/src/pages/lookPhoto/index.vue b/src/pages/lookPhoto/index.vue index d97af89..8fe0528 100644 --- a/src/pages/lookPhoto/index.vue +++ b/src/pages/lookPhoto/index.vue @@ -22,6 +22,12 @@ 下载照片 + + + {{ supperTips() }} + @@ -69,16 +75,21 @@ // import myloading from '../../components/myLoading.vue' //#region 导入 import { onLoad } from "@dcloudio/uni-app"; -import { ref, reactive } from "vue"; +import { ref, reactive, watch } from "vue"; import { userInfoModules } from "@/store/modules/userInfo"; -import { getPhotoListApi } from "../../api/lookPhoto.js"; +import { + getPhotoListApi, + photoSupperApi, + getSupperPhotoStateApi, +} from "../../api/lookPhoto.js"; //#endregion const userInfoModulesPinia = userInfoModules(); //#region 轮播图 -const workId = ref(null); -onLoad((options) => { +const workId = ref(null); //作品id +onLoad(async (options) => { workId.value = options.id; - getSwiperList(); + await getSwiperList(); + await getSupperPhotoState(swiperList.value[0].id); }); const swiperList = ref([]); //轮播图 const previewImageList = ref([]); //预览图片列表 @@ -88,7 +99,11 @@ async function getSwiperList() { console.log(res.data.photoList); swiperList.value = res.data.photoList; swiperList.value.forEach((item) => { - previewImageList.value.push(item.image); + if (item.imageSuper) { + previewImageList.value.push(item.imageSuper); + } else { + previewImageList.value.push(item.image); + } }); } //#endregion --------------------- @@ -102,7 +117,9 @@ function downloadImg() { let filePath = wx.env.USER_DATA_PATH + "/" + "zhixiang.png"; uni.downloadFile({ filePath: filePath, - url: swiperList.value[swiperIndex.value].image, //仅为示例,并非真实的资源 + url: swiperList.value[swiperIndex.value].imageSuper + ? swiperList.value[swiperIndex.value].imageSuper + : swiperList.value[swiperIndex.value].image, //仅为示例,并非真实的资源 // url: "http://tmp/iFlp7n9vAaaEa3276321f9c19ed0031617eb27119af4.png", //仅为示例,并非真实的资源 success: (res) => { let data = res; @@ -239,6 +256,79 @@ function buyCoin() { } //#endregion --------------------- +//#region 超分相关 +const supperPhotoState = ref(false); +async function photoSupper() { + if (supperPhotoState.value == 1 || supperPhotoState.value == 2) { + return; + } + // uni.showModal({ + // title: "提示", + // content: "确定高清处理?", + // success: function (res) { + // if (res.confirm) { + // checkboxValue.value = ["同意智像相机用户使用协议"]; + // // handleLogin(); + // getphonenumber(e); + // } else if (res.cancel) { + // } + // }, + // fail: (err) => {}, + // }); + try { + uni.showLoading({ + title: "高清处理中...", + mask: true, + }); + const res = await photoSupperApi({ + id: swiperList.value[swiperIndex.value].id, + }); + console.log(res); + uni.hideLoading(); + uni.showToast({ + title: "高清处理请求成功,请重稍后", + icon: "none", + }); + + getSupperPhotoState(swiperList.value[swiperIndex.value].id); + } catch (error) { + console.log(error, "超分失败"); + uni.hideLoading(); + uni.showToast({ + title: "高清处理失败,请重试", + icon: "none", + }); + } +} + +async function getSupperPhotoState(id) { + try { + const res = await getSupperPhotoStateApi(id); + supperPhotoState.value = res.data.status; + console.log(supperPhotoState.value, "状态"); + } catch (error) { + console.log(error, "超分失败"); + } +} + +function supperTips(params) { + if (supperPhotoState.value == 0 || supperPhotoState.value == 3) { + return "一键高清"; + } else if (supperPhotoState.value == 1) { + return "高清处理中,请稍后"; + } else if (supperPhotoState.value == 2) { + return "已高清处理"; + } +} + +watch( + () => swiperIndex.value, + (index) => { + getSupperPhotoState(swiperList.value[index].id); + } +); +//#endregion --------------------- + //#region //#endregion --------------------- @@ -282,7 +372,7 @@ function buyCoin() { // 俩按钮 .uploadBtn { position: relative; - margin-top: 140rpx; + margin-top: 100rpx; width: 520rpx; height: 100rpx; line-height: 100rpx; @@ -326,18 +416,30 @@ function buyCoin() { } } .grayBtn { - background-color: transparent; - border: 1px solid #6a6c6e; - margin-top: 50rpx; + .free { + position: absolute; + color: #fff; + top: -18rpx; + right: -70rpx; + width: 142rpx; + height: 50rpx; + background-color: #ff4f00; + border-radius: 25rpx 25rpx 25rpx 0; + font-size: 22rpx; + font-weight: 900; + line-height: 50rpx; + text-align: center; + } } + .bottomBox { flex: 1; - position: absolute; + // position: absolute; bottom: 80rpx; width: 100%; display: flex; justify-content: space-between; - padding: 65rpx 50rpx 0; + padding: 65rpx 10rpx 0; .tips { position: absolute; top: 0rpx; @@ -360,29 +462,4 @@ function buyCoin() { background-color: rgba(255, 255, 255, 0.1); } } -// .bottomBox { -// width: 100%; -// display: flex; -// flex-direction: column; -// align-items: center; -// justify-content: center; -// .balance { -// margin-top: 30rpx; -// font-size: 40rpx; -// margin-bottom: 50rpx; -// } -// .buttonBox { -// width: 60%; -// } - -// .shareBox { -// margin-top: 90rpx; -// width: 100%; -// display: flex; -// justify-content: space-between; -// .buttonBox { -// width: 30%; -// } -// } -// } diff --git a/src/pages/uploadPhoto/uploadPhoto.vue b/src/pages/uploadPhoto/uploadPhoto.vue index 9032d3f..5c61d08 100644 --- a/src/pages/uploadPhoto/uploadPhoto.vue +++ b/src/pages/uploadPhoto/uploadPhoto.vue @@ -198,9 +198,9 @@ async function toCloseStyle() { uploadState.value = 3; console.log(showImgUrl.value); console.log(showImgUrl2.value.path); - // 人脸识别接口 + // 百度敏感信息检测 uni.uploadFile({ - url: "https://test.metavatar.cc/C/api/userDigital/checkPhoto", //上传图片api + url: "https://test.metavatar.cc/C/api/baidu/checkPhoto", //上传图片api filePath: showImgUrl2.value.path, name: "file", formData: { @@ -210,66 +210,99 @@ async function toCloseStyle() { // Authorization: userInfoModulesPinia.token, token: userInfoModulesPinia.token, }, - success: (res) => { - if (JSON.parse(res.data).code != 200) { + success: (res0) => { + if (JSON.parse(res0.data).code != 200) { uni.hideLoading(); uploadState.value = 4; return; } - // 上传接口 + // 人脸识别接口 uni.uploadFile({ - url: "https://test.metavatar.cc/C/api/upload/awsImgUpload", //上传图片api + url: "https://test.metavatar.cc/C/api/userDigital/checkPhoto", //上传图片api filePath: showImgUrl2.value.path, name: "file", formData: { user: "test", }, header: { - "Content-Type": "multipart/form-data", + // Authorization: userInfoModulesPinia.token, token: userInfoModulesPinia.token, }, - success: async (res2) => { - let moment = res2; - if (JSON.parse(res2.data).code != 200) { + success: (res) => { + if (JSON.parse(res.data).code != 200) { uni.hideLoading(); - uploadState.value = 5; - uni.showToast({ - title: "网络被数字人偷走了, 请稍后重试", - icon: "none", - }); + uploadState.value = 4; return; } - // 保存接口 + // 上传接口 + uni.uploadFile({ + url: "https://test.metavatar.cc/C/api/upload/awsImgUpload", //上传图片api + filePath: showImgUrl2.value.path, + name: "file", + formData: { + user: "test", + }, + header: { + "Content-Type": "multipart/form-data", + token: userInfoModulesPinia.token, + }, + success: async (res2) => { + let moment = res2; + if (JSON.parse(res2.data).code != 200) { + uni.hideLoading(); + uploadState.value = 5; + uni.showToast({ + title: "网络被数字人偷走了, 请稍后重试", + icon: "none", + }); + return; + } + // 保存接口 - const res3 = await addImageApi({ - image: JSON.parse(res2.data).data.url, - }); + const res3 = await addImageApi({ + image: JSON.parse(res2.data).data.url, + }); - if (res3.code == 200) { - // 改变全局的头像 - userInfoModulesPinia.myAvatar = JSON.parse(moment.data).data.url; - uploadState.value = 1; - uni.hideLoading(); - showImgUrl.value = null; - uni.navigateTo({ - url: "/pages/uploadPhoto/success", - }); - } else { - uni.hideLoading(); - uni.showToast({ - title: "网络被数字人偷走了, 请稍后重试", - icon: "none", - }); - } + if (res3.code == 200) { + // 改变全局的头像 + userInfoModulesPinia.myAvatar = JSON.parse( + moment.data + ).data.url; + uploadState.value = 1; + uni.hideLoading(); + showImgUrl.value = null; + uni.navigateTo({ + url: "/pages/uploadPhoto/success", + }); + } else { + uni.hideLoading(); + uni.showToast({ + title: "网络被数字人偷走了, 请稍后重试", + icon: "none", + }); + } + }, + fail: () => { + uploadState.value = 5; + uni.hideLoading(); + uni.showToast({ + title: "网络被数字人偷走了, 请稍后重试", + icon: "none", + }); + }, + }); }, fail: () => { - uploadState.value = 5; + uploadState.value = 1; uni.hideLoading(); uni.showToast({ title: "网络被数字人偷走了, 请稍后重试", icon: "none", }); }, + // complete: (complete) => { + // uni.hideLoading(); + // }, }); }, fail: () => { @@ -280,9 +313,6 @@ async function toCloseStyle() { icon: "none", }); }, - // complete: (complete) => { - // uni.hideLoading(); - // }, }); } } diff --git a/src/style/my.scss b/src/style/my.scss index 03eb960..4ae183d 100644 --- a/src/style/my.scss +++ b/src/style/my.scss @@ -96,6 +96,7 @@ view { } .grayBtn { + position: relative; margin-top: 30rpx; background-color: transparent; width: 520rpx;