|
|
@@ -12,11 +12,11 @@ |
|
|
|
>开始制作写真
|
|
|
|
<view class="free">
|
|
|
|
<image src="../../assets/icon/blackBG.png" mode="aspectFit" />
|
|
|
|
<text>耗金币2枚</text>
|
|
|
|
<text>耗金币{{ needCoin }}枚</text>
|
|
|
|
</view>
|
|
|
|
</view>
|
|
|
|
<view class="balance"
|
|
|
|
>金币余额: 30
|
|
|
|
>金币余额: {{ userInfoModulesPinia.myGlod }}
|
|
|
|
<image src="../../assets/icon/coin.png" mode="aspectFit" />
|
|
|
|
</view>
|
|
|
|
</view>
|
|
|
@@ -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,
|
|
|
|