feat: add mini-program privacy auth, update oss urls and refine photo guide
update oss static resource urls to oss.nianxx.cn refactor privacy component to be reusable, add wechat mini-program privacy authorization check before image picking add image urls to photo guide examples, refine photo guide ui styles and remove unused avatarSrc prop
This commit is contained in:
@@ -1,37 +1,20 @@
|
||||
<template>
|
||||
<view class="aigc-use-template-page">
|
||||
<AigcTopBar
|
||||
:points="pointBalance"
|
||||
recharge-label="充值"
|
||||
@back="handleBack"
|
||||
@history="handleHistory"
|
||||
@recharge="handleRecharge"
|
||||
/>
|
||||
<AigcTopBar :points="pointBalance" recharge-label="充值" @back="handleBack" @history="handleHistory"
|
||||
@recharge="handleRecharge" />
|
||||
|
||||
<view class="aigc-use-template-body">
|
||||
<view class="aigc-use-template-content">
|
||||
<TemplateVersionHero :template="currentTemplate" />
|
||||
|
||||
<GenerateConfirmPanel
|
||||
v-if="currentStep === 'generateConfirm'"
|
||||
:cost="currentCost"
|
||||
:balance="pointBalance"
|
||||
@generate="handleGenerate"
|
||||
@recharge="handleRecharge"
|
||||
/>
|
||||
<GeneratingProgressPanel
|
||||
v-else-if="currentStep === 'generating'"
|
||||
:cost="currentCost"
|
||||
:progress="8"
|
||||
@complete="handleGenerateComplete"
|
||||
/>
|
||||
<GenerateConfirmPanel v-if="currentStep === 'generateConfirm'" :cost="currentCost" :balance="pointBalance"
|
||||
@generate="handleGenerate" @recharge="handleRecharge" />
|
||||
<GeneratingProgressPanel v-else-if="currentStep === 'generating'" :cost="currentCost" :progress="8"
|
||||
@complete="handleGenerateComplete" />
|
||||
|
||||
<template v-else>
|
||||
<VersionOptionList
|
||||
:options="templateItems"
|
||||
:selected-value="selectedTemplateItemId"
|
||||
@select="handleSelectTemplateItem"
|
||||
/>
|
||||
<VersionOptionList :options="templateItems" :selected-value="selectedTemplateItemId"
|
||||
@select="handleSelectTemplateItem" />
|
||||
|
||||
<text class="aigc-use-template-note">
|
||||
动效视频版会先生图,再升级为 5 秒内动效视频。
|
||||
@@ -41,42 +24,28 @@
|
||||
</view>
|
||||
|
||||
<view v-if="currentStep === 'uploadGuide'" class="aigc-use-template-popup-host">
|
||||
<PhotoGuidePanel
|
||||
:avatar-src="guideAvatar"
|
||||
:positive-examples="positiveExamples"
|
||||
:negative-examples="negativeExamples"
|
||||
@close="handleCloseGuide"
|
||||
@confirm="handleConfirmGuide"
|
||||
/>
|
||||
<PhotoGuidePanel :positive-examples="positiveExamples" :negative-examples="negativeExamples"
|
||||
@close="handleCloseGuide" @confirm="handleConfirmGuide" />
|
||||
</view>
|
||||
<view v-if="currentStep === 'photoPick'" class="aigc-use-template-popup-host">
|
||||
<PhotoPickDrawer
|
||||
:loading="isUploading"
|
||||
@close="handleCloseGuide"
|
||||
@camera="handlePickCamera"
|
||||
@album="handlePickAlbum"
|
||||
/>
|
||||
<PhotoPickDrawer :loading="isUploading" @close="handleCloseGuide" @camera="handlePickCamera"
|
||||
@album="handlePickAlbum" />
|
||||
</view>
|
||||
<view v-if="currentStep === 'photoConfirm'" class="aigc-use-template-popup-host">
|
||||
<PhotoConfirmDrawer
|
||||
:avatar-src="selectedImageLocalPath || guideAvatar"
|
||||
@close="handleClosePhotoConfirm"
|
||||
@confirm="handleConfirmPhoto"
|
||||
/>
|
||||
<PhotoConfirmDrawer :avatar-src="selectedImageLocalPath || guideAvatar" @close="handleClosePhotoConfirm"
|
||||
@confirm="handleConfirmPhoto" />
|
||||
</view>
|
||||
<PointInsufficientDialog
|
||||
v-if="pointDialogVisible"
|
||||
:cost="currentCost"
|
||||
:balance="pointBalance"
|
||||
@cancel="handleClosePointDialog"
|
||||
@recharge="handlePointRecharge"
|
||||
/>
|
||||
<PointInsufficientDialog v-if="pointDialogVisible" :cost="currentCost" :balance="pointBalance"
|
||||
@cancel="handleClosePointDialog" @recharge="handlePointRecharge" />
|
||||
<Privacy :visible="privacyVisible" :contract-name="privacyContractName" @agree="handlePrivacyAgree"
|
||||
@disagree="handlePrivacyDisagree" />
|
||||
</view>
|
||||
</template>
|
||||
|
||||
<script setup>
|
||||
import { computed, ref } from "vue";
|
||||
import { onLoad, onShow } from "@dcloudio/uni-app";
|
||||
import Privacy from "@/components/Privacy/index.vue";
|
||||
import AigcTopBar from "@/pages-aigc/components/AigcTopBar/index.vue";
|
||||
import { useCurrentCredit } from "@/pages-aigc/hooks/useCurrentCredit.js";
|
||||
import {
|
||||
@@ -108,6 +77,9 @@ const currentStep = ref("version");
|
||||
const pointDialogVisible = ref(false);
|
||||
const isUploading = ref(false);
|
||||
const isCreatingTask = ref(false);
|
||||
const privacyVisible = ref(false);
|
||||
const privacyContractName = ref("隐私保护指引");
|
||||
const pendingImageSourceType = ref("");
|
||||
|
||||
const currentTemplate = computed(() => {
|
||||
return templates.value.find((item) => item.templateId === templateId.value) || templates.value[0] || {};
|
||||
@@ -294,9 +266,47 @@ const chooseImageWithSource = (sourceType) => {
|
||||
};
|
||||
|
||||
const chooseAndUploadImage = (sourceType) => {
|
||||
if (isUploading.value) return;
|
||||
if (isUploading.value || pendingImageSourceType.value) return;
|
||||
|
||||
// #ifdef MP-WEIXIN
|
||||
pendingImageSourceType.value = sourceType;
|
||||
wx.getPrivacySetting({
|
||||
success: (res) => {
|
||||
if (res?.needAuthorization) {
|
||||
privacyContractName.value = res.privacyContractName || "隐私保护指引";
|
||||
privacyVisible.value = true;
|
||||
return;
|
||||
}
|
||||
|
||||
pendingImageSourceType.value = "";
|
||||
chooseImageWithSource(sourceType);
|
||||
},
|
||||
fail: (error) => {
|
||||
pendingImageSourceType.value = "";
|
||||
console.warn("检查微信隐私授权失败", error);
|
||||
showPlaceholderToast("隐私授权检查失败");
|
||||
},
|
||||
});
|
||||
// #endif
|
||||
|
||||
// #ifndef MP-WEIXIN
|
||||
chooseImageWithSource(sourceType);
|
||||
// #endif
|
||||
};
|
||||
|
||||
const handlePrivacyAgree = () => {
|
||||
const sourceType = pendingImageSourceType.value;
|
||||
privacyVisible.value = false;
|
||||
pendingImageSourceType.value = "";
|
||||
|
||||
if (sourceType) {
|
||||
chooseImageWithSource(sourceType);
|
||||
}
|
||||
};
|
||||
|
||||
const handlePrivacyDisagree = () => {
|
||||
privacyVisible.value = false;
|
||||
pendingImageSourceType.value = "";
|
||||
};
|
||||
|
||||
const handlePickCamera = () => {
|
||||
|
||||
Reference in New Issue
Block a user