diff --git a/src/pages/closeStyle/goCreatePhoto.vue b/src/pages/closeStyle/goCreatePhoto.vue index 526f0b3..96572fb 100644 --- a/src/pages/closeStyle/goCreatePhoto.vue +++ b/src/pages/closeStyle/goCreatePhoto.vue @@ -12,11 +12,11 @@ >开始制作写真 - 耗金币2枚 + 耗金币{{ needCoin }}枚 金币余额:  30 + >金币余额:  {{ userInfoModulesPinia.myGlod }} @@ -31,6 +31,9 @@ import { findImageApi, createPhotoApi, } from "../../api/closeStyle"; +import { findGlodApi } from "../../api/home"; +import { userInfoModules } from "@/store/modules/userInfo"; +const userInfoModulesPinia = userInfoModules(); //#endregion //#region 初始化 @@ -39,10 +42,24 @@ const styleData = ref({}); onLoad((options) => { styleId.value = options.id; getInfo(); + getMyCoin(); }); +// 查询我的金币 +async function getMyCoin() { + const res4 = await findGlodApi(); + if (!res4.data) { + userInfoModulesPinia.myGlod = 0; + } else { + userInfoModulesPinia.myGlod = res4.data.digitalAvatarGlod + ? res4.data.digitalAvatarGlod + : 0; + } +} +const needCoin = ref(""); //模版消耗金币 async function getInfo() { try { const res = await findByIdApi(styleId.value); + needCoin.value = res.data.salePrice; console.log(res); styleData.value = res.data; } catch (error) { @@ -54,15 +71,23 @@ async function getInfo() { } //#endregion --------------------- + //#region 生成写真照片 + async function createing(id) { + if (needCoin.value > userInfoModulesPinia.myGlod) { + uni.showToast({ + title: "金币不足,请充值", + icon: "none", + }); + return; + } try { uni.showLoading({ title: "加载中...", mask: true, }); const res = await findImageApi(); - console.log(res); let myImg = res.data.image; const data = { digitalAvatarId: id, diff --git a/src/pages/uploadPhoto/uploadPhoto.vue b/src/pages/uploadPhoto/uploadPhoto.vue index 1602da3..1033f3b 100644 --- a/src/pages/uploadPhoto/uploadPhoto.vue +++ b/src/pages/uploadPhoto/uploadPhoto.vue @@ -287,7 +287,7 @@ onLoad((options) => { const res2 = await loginApi(data); userInfoModulesPinia.openId = res2.data.openId; if (res2.data.token) { - // userInfoModulesPinia.token = res2.data.token; + userInfoModulesPinia.token = res2.data.token; console.log(userInfoModulesPinia.openId, "获取openid"); // 获取头像和金币 const res3 = await findImageApi();