diff --git a/src/assets/icon/sound-2.png b/src/assets/icon/sound-2.png new file mode 100644 index 0000000..f7ef17e Binary files /dev/null and b/src/assets/icon/sound-2.png differ diff --git a/src/assets/icon/sound.png b/src/assets/icon/sound.png new file mode 100644 index 0000000..669dca7 Binary files /dev/null and b/src/assets/icon/sound.png differ diff --git a/src/assets/icon/soundBG.png b/src/assets/icon/soundBG.png new file mode 100644 index 0000000..f7f5b24 Binary files /dev/null and b/src/assets/icon/soundBG.png differ diff --git a/src/assets/img/homeImg.jpg b/src/assets/img/homeImg.jpg new file mode 100644 index 0000000..1a94881 Binary files /dev/null and b/src/assets/img/homeImg.jpg differ diff --git a/src/assets/img/homeImg.png b/src/assets/img/homeImg.png deleted file mode 100644 index c49e675..0000000 Binary files a/src/assets/img/homeImg.png and /dev/null differ diff --git a/src/pages/closeStyle/closeStyle copy.vue b/src/pages/closeStyle/closeStyle copy.vue new file mode 100644 index 0000000..1745c1b --- /dev/null +++ b/src/pages/closeStyle/closeStyle copy.vue @@ -0,0 +1,161 @@ + + + + + diff --git a/src/pages/closeStyle/closeStyle.vue b/src/pages/closeStyle/closeStyle.vue index cde7a3e..5c58a75 100644 --- a/src/pages/closeStyle/closeStyle.vue +++ b/src/pages/closeStyle/closeStyle.vue @@ -20,14 +20,30 @@ diff --git a/src/pages/closeStyle/multiplayer copy.vue b/src/pages/closeStyle/multiplayer copy.vue new file mode 100644 index 0000000..bcd0e10 --- /dev/null +++ b/src/pages/closeStyle/multiplayer copy.vue @@ -0,0 +1,235 @@ + + + + + diff --git a/src/pages/closeStyle/multiplayer.vue b/src/pages/closeStyle/multiplayer.vue index cd67564..207cbd3 100644 --- a/src/pages/closeStyle/multiplayer.vue +++ b/src/pages/closeStyle/multiplayer.vue @@ -5,37 +5,98 @@ /> {{ styleData.title }} + - + + + + + {{ + avatarList[0].isMyAvatar ? "授权用户头像" : "已上传第1个头像" + }} + 更换头像 + 上传头像 + - - 更换头像 + + + + + {{ + avatarList[1].isMyAvatar ? "授权用户头像" : "已上传第2个头像" + }} + 更换头像 + 上传头像 - - - 上传头像 + + + + + + + {{ + avatarList[2].isMyAvatar ? "授权用户头像" : "已上传第3个头像" + }} + 更换头像 + 上传头像 - 人物头像对应模板任务位置,点击按钮可以调整顺序 + 人物头像对应模板人物位置,点击按钮可以调整顺序 开始制作写真 - 耗金币2枚 + 耗金币{{ styleData.salePrice }}枚 金币余额:  30 + >金币余额:  {{ userInfoModulesPinia.myGlod }} @@ -50,16 +111,23 @@ import { findImageApi, createPhotoApi, } from "../../api/closeStyle"; +import { findGlodApi } from "../../api/home"; +import { userInfoModules } from "@/store/modules/userInfo"; //#endregion +const userInfoModulesPinia = userInfoModules(); //#region 初始化 const styleId = ref(null); const styleData = ref({}); onLoad((options) => { // styleId.value = options.id; - styleId.value = 4; + // styleId.value = "857147862095679488"; + styleId.value = "2003"; + // styleId.value = "246"; getInfo(); + // getMyCoin(); }); + async function getInfo() { try { const res = await findByIdApi(styleId.value); @@ -72,25 +140,201 @@ async function getInfo() { }); } } +// 查询我的金币 +async function getMyCoin() { + const res4 = await findGlodApi(); + if (!res4.data) { + userInfoModulesPinia.myGlod = 0; + } else { + userInfoModulesPinia.myGlod = res4.data.digitalAvatarResidueGlod + ? res4.data.digitalAvatarResidueGlod + : 0; + } +} +//#endregion --------------------- +//#region 上传图片 +const avatarList = ref([ + { + url: userInfoModulesPinia.myAvatar, + // url: "https://suimang.oss-accelerate.aliyuncs.com/builtin/digital_avatar/girl/%E9%A3%8E%E9%87%87%E5%87%BA%E4%BC%97.jpg", + isMyAvatar: true, + }, + { + url: "", + // url: "https://suimang.oss-accelerate.aliyuncs.com/builtin/digital_avatar/girl/%E9%AA%8F%E9%A9%AC%E4%BD%B3%E4%BA%BA.jpg", + isMyAvatar: false, + }, + { + url: "", + // url: "https://suimang.oss-accelerate.aliyuncs.com/builtin/digital_avatar/girl/%E7%B4%AB%E8%96%87%E7%90%B4%E9%9F%B5.png", + isMyAvatar: false, + }, +]); +// 切换位置 +function swapItems() { + const temp = avatarList.value[0]; + avatarList.value[0] = avatarList.value[1]; + avatarList.value[1] = temp; +} +function swapItems2() { + const temp = avatarList.value[1]; + avatarList.value[1] = avatarList.value[2]; + avatarList.value[2] = temp; +} +// 打开图片选择,包含了百度检测人脸检测和上传图片 +function chooseImg(index) { + uni.chooseImage({ + count: 1, + success: async (res) => { + console.log(res, "887"); + uni.showLoading({ + title: "上传中...", + mask: true, + }); + // 百度敏感信息检测 + uni.uploadFile({ + url: "https://test.metavatar.cc/C/api/baidu/checkPhoto", //上传图片api + filePath: res.tempFilePaths[0], + name: "file", + formData: { + user: "test", + }, + header: { + // Authorization: userInfoModulesPinia.token, + token: userInfoModulesPinia.token, + }, + success: async (res2) => { + if (JSON.parse(res2.data).code != 200) { + uni.hideLoading(); + uni.showToast({ + title: "图片不符合规范, 请重试", + icon: "none", + }); + return; + } else { + // 人脸识别接口 + uni.uploadFile({ + url: "https://test.metavatar.cc/C/api/userDigital/checkPhoto", //上传图片api + filePath: res.tempFilePaths[0], + name: "file", + formData: { + user: "test", + }, + header: { + // Authorization: userInfoModulesPinia.token, + token: userInfoModulesPinia.token, + }, + success: (res3) => { + if (JSON.parse(res3.data).code != 200) { + uni.hideLoading(); + uni.showToast({ + title: "图片不符合规范, 请重试", + icon: "none", + }); + return; + } else { + // 上传接口 + uni.uploadFile({ + url: "https://test.metavatar.cc/C/api/upload/awsImgUpload", //上传图片api + filePath: res.tempFilePaths[0], + name: "file", + formData: { + user: "test", + }, + header: { + "Content-Type": "multipart/form-data", + token: userInfoModulesPinia.token, + }, + success: async (res4) => { + if (JSON.parse(res4.data).code != 200) { + uni.hideLoading(); + uni.showToast({ + title: "网络被数字人偷走了, 请稍后重试", + icon: "none", + }); + return; + } + // 赋值 + avatarList.value[index].url = JSON.parse( + res4.data + ).data.url; + uni.hideLoading(); + }, + fail: () => { + uni.hideLoading(); + uni.showToast({ + title: "网络被数字人偷走了, 请稍后重试", + icon: "none", + }); + }, + }); + } + }, + fail: () => { + uni.hideLoading(); + uni.showToast({ + title: "网络被数字人偷走了, 请稍后重试", + icon: "none", + }); + }, + }); + } + }, + fail: (err) => { + console.error("选择图片失败", err); + uni.hideLoading(); + uni.showToast({ + title: "选择图片失败, 请稍后重试", + icon: "none", + }); + }, + }); + }, + fail: (err) => { + console.error("选择图片失败", err); + uni.showToast({ + title: "选择图片失败, 请稍后重试", + icon: "none", + }); + }, + }); +} + +// 上传图片 +function uploadImg(index) {} //#endregion --------------------- + //#region 生成写真照片 async function createing(id) { try { - const res = await findImageApi(); - console.log(res); - let myImg = res.data.image; + uni.showLoading({ + title: "加载中...", + mask: true, + }); + // const res = await findImageApi(); + // console.log(res); + // let myImg = res.data.image; + let myImgList = []; + avatarList.value.forEach((item) => { + myImgList.push(item.url); + }); const data = { digitalAvatarId: id, - userImages: JSON.stringify([myImg]), + userImages: + styleData.value.mouldType == 2 + ? JSON.stringify(myImgList.slice(0, 2)) + : JSON.stringify(myImgList), }; const res2 = await createPhotoApi(data); console.log(res2); + uni.hideLoading(); uni.navigateTo({ url: `/pages/createing/index?id=${res2.data.id}`, }); } catch (error) { console.log(error); + uni.hideLoading(); uni.showToast({ title: "生成失败,请重试", icon: "none", @@ -140,17 +384,45 @@ async function createing(id) { margin-top: 67rpx; } .imgBoxItem { + position: relative; width: 180rpx; + height: 250rpx; display: flex; flex-direction: column; align-items: center; - image { + .avatar { + position: absolute; + width: 180rpx; + height: 180rpx; + border-radius: 24rpx; + } + .noUrlBox { + position: absolute; width: 180rpx; height: 180rpx; + line-height: 180rpx; + color: #ff4f00; + font-size: 50rpx; + font-weight: 900; + text-align: center; + border-radius: 24rpx; + background-color: #393a3d; + } + .maskTips { + position: absolute; + width: 180rpx; + height: 180rpx; + line-height: 180rpx; + color: #fff; + font-size: 20rpx; + font-weight: 900; + text-align: center; + border-radius: 24rpx; + background-color: rgba(0, 0, 0, 0.3); } .reUploadBtn, .uploadBtn { - margin-top: 20rpx; + margin-top: 200rpx; width: 150rpx; height: 50rpx; text-align: center; diff --git a/src/pages/createing/index.vue b/src/pages/createing/index.vue index d9933c8..ab6e3cf 100644 --- a/src/pages/createing/index.vue +++ b/src/pages/createing/index.vue @@ -88,6 +88,7 @@ const styleData = ref(""); //风格信息 onLoad((options) => { workId.value = options.id; // workId.value = "857147862095679488"; + getWorkInfo(); // let getWindowInfo = uni.getWindowInfo().screenWidth; diff --git a/src/pages/index/index.vue b/src/pages/index/index.vue index 4f2fb42..1ac9f02 100644 --- a/src/pages/index/index.vue +++ b/src/pages/index/index.vue @@ -5,7 +5,7 @@ - + @@ -212,7 +212,13 @@ + + diff --git a/src/pages/recorded/index.vue b/src/pages/recorded/index.vue index 2a23c32..d3473ef 100644 --- a/src/pages/recorded/index.vue +++ b/src/pages/recorded/index.vue @@ -1,75 +1,50 @@