From c65af658af076c419b0d5018361f42104222487c Mon Sep 17 00:00:00 2001 From: congzc Date: Wed, 13 Sep 2023 15:35:21 +0800 Subject: [PATCH 1/2] 2 --- src/api/lookPhoto.js | 13 +++ src/pages/index/index.vue | 14 ++- src/pages/lookPhoto/index.vue | 150 ++++++++++++++++---------- src/pages/uploadPhoto/uploadPhoto.vue | 3 + src/utils/share.js | 5 + 5 files changed, 125 insertions(+), 60 deletions(-) diff --git a/src/api/lookPhoto.js b/src/api/lookPhoto.js index 7a07bdc..43ac9ca 100644 --- a/src/api/lookPhoto.js +++ b/src/api/lookPhoto.js @@ -38,3 +38,16 @@ export function getSupperPhotoStateApi(id) { method: 'get', }) } + +/** +* @description:生成画报 +* @param {appId,img} +* @return: data +*/ +export function getUserQrcodeApi(data) { + return request({ + url: `/api/miniApp/getUserQrcode`, + method: 'post', + data + }) +} diff --git a/src/pages/index/index.vue b/src/pages/index/index.vue index df65ba9..d5408cb 100644 --- a/src/pages/index/index.vue +++ b/src/pages/index/index.vue @@ -276,9 +276,17 @@ function goLookPhoto(id, status) { } function goCloseStyle() { - uni.navigateTo({ - url: `/pages/closeStyle/closeStyle`, - }); + if (!userInfoModulesPinia.myAvatar) { + uni.showToast({ + title: "请先上传头像", + icon: "none", + mask: true, + }); + } else { + uni.navigateTo({ + url: `/pages/closeStyle/closeStyle`, + }); + } } //#endregion diff --git a/src/pages/lookPhoto/index.vue b/src/pages/lookPhoto/index.vue index d21976b..d39a5f7 100644 --- a/src/pages/lookPhoto/index.vue +++ b/src/pages/lookPhoto/index.vue @@ -34,9 +34,13 @@ 邀请好友可获得2枚金币 - 邀请好友 + 邀请好友 金币充值 + + + + @@ -50,6 +54,7 @@ import { getPhotoListApi, photoSupperApi, getSupperPhotoStateApi, + getUserQrcodeApi, } from "../../api/lookPhoto.js"; //#endregion const userInfoModulesPinia = userInfoModules(); @@ -159,34 +164,34 @@ function previewImage(index) { //#endregion --------------------- //#region 分享 -onShareAppMessage((res) => { - // 分享事件来源:button(页面内分享按钮)、menu(右上角分享按钮) - if (res.from === "button") { - // 来自页面内分享按钮 - return { - //分享标题 - title: "智像", - //页面 path - path: `/pages/login/index`, - // 分享图标 - // imageUr: shopDetailsData.value?.GoodsCoverImg, - success: function () { - // 转发成功 - console.log("res", res); - }, - fail: function () { - // 转发失败 - console.log("res", res); - }, - }; - } else { - return { - title: "智像", - path: "/pages/login/index", - // imageUr: shopDetailsData.value?.GoodsCoverImg, - }; - } -}); +// onShareAppMessage((res) => { +// // 分享事件来源:button(页面内分享按钮)、menu(右上角分享按钮) +// if (res.from === "button") { +// // 来自页面内分享按钮 +// return { +// //分享标题 +// title: "智像", +// //页面 path +// path: `/pages/login/index`, +// // 分享图标 +// // imageUr: shopDetailsData.value?.GoodsCoverImg, +// success: function () { +// // 转发成功 +// console.log("res", res); +// }, +// fail: function () { +// // 转发失败 +// console.log("res", res); +// }, +// }; +// } else { +// return { +// title: "智像", +// path: "/pages/login/index", +// // imageUr: shopDetailsData.value?.GoodsCoverImg, +// }; +// } +// }); // onShareAppMessage((res) => { // return { // title: "页面分享的标题", @@ -222,34 +227,7 @@ function share() { // }, // }); } -function inviteFriend() { - uni.showToast({ - title: "敬请期待!", - icon: "none", - }); - return; - uni.share({ - provider: "weixin", //分享服务提供商(即weixin|qq|sinaweibo) - scene: "WXSceneSession", //WXSceneSession(分享到聊天界面)、WXSenceTimeline(分享到朋友圈)、WXSceneFavorite(分享到微信收藏) - type: 5, - title: "分享给好友", - summary: "分享描述", - href: "www.baidu.com", //分享跳转地址 - imageUrl: "../static/lovehot.png", //分享图片路径(必须是线上可访问图片) - miniProgram: { - id: "gwx75cf14e3a0d45821", - path: "pages/index/index", - type: 0, - webUrl: "", - }, - success: function (res) { - // console.log("success:" + JSON.stringify(res)); - }, - fail: function (err) { - // console.log("fail:" + JSON.stringify(err)); - }, - }); -} + //#endregion --------------------- //#region 页面跳转 @@ -342,6 +320,48 @@ watch( ); //#endregion --------------------- +//#region 生成画报 +const pictorialUrl = ref(""); +const showPictorial = ref(false); +async function getUserQrcode() { + try { + uni.showLoading({ + title: "加载中...", + mask: true, + }); + const data = { + appId: userInfoModulesPinia.getAppId(), + img: swiperList.value[swiperIndex.value].imageSuper + ? swiperList.value[swiperIndex.value].imageSuper + : swiperList.value[swiperIndex.value].image, + }; + const res = await getUserQrcodeApi(data); + if (res.code == 200) { + uni.arrayBufferToBase64(res.data, (base64) => { + pictorialUrl.value = "data:image/jpeg;base64," + base64; // 在前面加上正确的图片格式 + }); + showPictorial.value = true; + } else { + uni.showToast({ + title: "画报生成失败", + icon: "none", + mask: true, + }); + } + uni.hideLoading(); + } catch (error) { + uni.hideLoading(); + uni.showToast({ + title: "画报生成失败", + icon: "none", + mask: true, + }); + console.log(error); + } +} + +//#endregion --------------------- + //#region //#endregion --------------------- @@ -467,12 +487,28 @@ watch( text-align: center; } .shareBtn { + margin: 0; + color: #fff; width: 200rpx; height: 70rpx; line-height: 70rpx; text-align: center; border-radius: 70rpx; + font-size: 26rpx; background-color: rgba(255, 255, 255, 0.1); } } + +.pictorialBox { + position: absolute; + width: 100%; + height: 100vh; + image { + margin-top: 80rpx; + width: 630rpx; + height: 940rpx; + border-radius: 24rpx; + } + z-index: 9; +} diff --git a/src/pages/uploadPhoto/uploadPhoto.vue b/src/pages/uploadPhoto/uploadPhoto.vue index 5d38dc2..70561e1 100644 --- a/src/pages/uploadPhoto/uploadPhoto.vue +++ b/src/pages/uploadPhoto/uploadPhoto.vue @@ -93,6 +93,7 @@ import { onAddToFavorites, onShow, } from "@dcloudio/uni-app"; +import { BASE_URL } from "../../utils/request"; import { loginApi } from "../../api/login"; import { addImageApi } from "../../api/uploadphoto.js"; import { userInfoModules } from "@/store/modules/userInfo"; @@ -351,9 +352,11 @@ onLoad((options) => { console.log(userInfoModulesPinia.openId, "获取openid"); // 获取头像和金币 const res3 = await findImageApi(); + userInfoModulesPinia.myAvatar = res3.data && res3.data.image ? res3.data.image : ""; const res4 = await findGlodApi(); + uni.setStorageSync("userId", res4.data.id); if (!res4.data) { userInfoModulesPinia.myGlod = 0; } else { diff --git a/src/utils/share.js b/src/utils/share.js index 6fc0f46..2612fcd 100644 --- a/src/utils/share.js +++ b/src/utils/share.js @@ -2,6 +2,8 @@ export default { onShareAppMessage() { return { title: "邃芒智像", + path: `/pages/login/index?type=in&userId=${uni.getStorageSync('userId')}`, + }; }, @@ -9,6 +11,8 @@ export default { onShareTimeline() { return { title: "邃芒智像", + path: `/pages/login/index?type=in&userId=${uni.getStorageSync('userId')}`, + }; }, @@ -16,6 +20,7 @@ export default { onAddToFavorites() { return { title: "邃芒智像", + }; } } From f0708588ffa84f38edfdf8945c3a02d2c0faa503 Mon Sep 17 00:00:00 2001 From: XiaoXinPro 14 IAH5R <568170040@qq.com> Date: Wed, 13 Sep 2023 15:38:22 +0800 Subject: [PATCH 2/2] upload --- src/pages/uploadPhoto/uploadPhoto.vue | 11 ----------- 1 file changed, 11 deletions(-) diff --git a/src/pages/uploadPhoto/uploadPhoto.vue b/src/pages/uploadPhoto/uploadPhoto.vue index 08edbe2..57f2b58 100644 --- a/src/pages/uploadPhoto/uploadPhoto.vue +++ b/src/pages/uploadPhoto/uploadPhoto.vue @@ -86,18 +86,7 @@