修复:解决测试发现的问题
This commit is contained in:
@@ -128,7 +128,7 @@
|
||||
</text>
|
||||
</view>
|
||||
</view>
|
||||
<wd-button type="primary" custom-class="buy-btn" @click="handlePurchase">
|
||||
<wd-button type="primary" block @click="handlePurchase">
|
||||
{{ $t('bookDetails.buy') }}
|
||||
</wd-button>
|
||||
</view>
|
||||
@@ -222,15 +222,12 @@ function initScrollHeight() {
|
||||
// 加载书籍详情
|
||||
async function loadBookInfo() {
|
||||
try {
|
||||
uni.showLoading({ title: t('global.loading') })
|
||||
const res = await bookApi.getBookInfo(bookId.value)
|
||||
uni.hideLoading()
|
||||
|
||||
if (res.bookInfo) {
|
||||
bookInfo.value = res.bookInfo
|
||||
}
|
||||
} catch (error) {
|
||||
uni.hideLoading()
|
||||
console.error('Failed to load book info:', error)
|
||||
}
|
||||
}
|
||||
@@ -531,6 +528,7 @@ function goToDetail(id: number) {
|
||||
&.buy-full {
|
||||
flex: 1;
|
||||
padding: 0 30rpx;
|
||||
text-align: center;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -330,7 +330,6 @@ const getBooksByLabel = async (
|
||||
labelId: number,
|
||||
type: 'activity' | 'category'
|
||||
) => {
|
||||
uni.showLoading({ title: t('common.loading') })
|
||||
try {
|
||||
const res = await homeApi.getBooksByLabel(labelId)
|
||||
if (type === 'activity') {
|
||||
@@ -348,8 +347,6 @@ const getBooksByLabel = async (
|
||||
}
|
||||
} catch (error) {
|
||||
console.error('获取图书列表失败:', error)
|
||||
} finally {
|
||||
uni.hideLoading()
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -130,11 +130,9 @@ async function loadBookInfo() {
|
||||
// 加载章节列表
|
||||
async function loadChapterList() {
|
||||
try {
|
||||
uni.showLoading({ title: t('global.loading') })
|
||||
const res = await bookApi.getBookChapter({
|
||||
bookId: bookId.value
|
||||
})
|
||||
uni.hideLoading()
|
||||
|
||||
if (res.chapterList && res.chapterList.length > 0) {
|
||||
chapterList.value = res.chapterList
|
||||
@@ -142,7 +140,6 @@ async function loadChapterList() {
|
||||
nullText.value = t('common.data_null')
|
||||
}
|
||||
} catch (error) {
|
||||
uni.hideLoading()
|
||||
nullText.value = t('common.data_null')
|
||||
console.error('Failed to load chapter list:', error)
|
||||
}
|
||||
|
||||
@@ -258,8 +258,6 @@ async function loadBookInfo() {
|
||||
// 加载章节列表
|
||||
async function loadChapterList() {
|
||||
try {
|
||||
uni.showLoading({ title: t('common.loading') })
|
||||
|
||||
const res = await bookApi.getBookChapter({
|
||||
bookId: bookId.value
|
||||
})
|
||||
@@ -269,8 +267,6 @@ async function loadChapterList() {
|
||||
if (res.chapterList && res.chapterList.length > 0) {
|
||||
chapterList.value = res.chapterList
|
||||
|
||||
uni.hideLoading()
|
||||
|
||||
// 加载当前章节内容
|
||||
if (currentChapterIndex.value < chapterList.value.length) {
|
||||
const currentChapter = chapterList.value[currentChapterIndex.value]
|
||||
@@ -280,14 +276,12 @@ async function loadChapterList() {
|
||||
playChapter(currentChapter)
|
||||
}
|
||||
} else {
|
||||
uni.hideLoading()
|
||||
uni.showToast({
|
||||
title: '章节列表为空',
|
||||
icon: 'none'
|
||||
})
|
||||
}
|
||||
} catch (error) {
|
||||
uni.hideLoading()
|
||||
console.error('Failed to load chapter list:', error)
|
||||
uni.showToast({
|
||||
title: '加载章节失败',
|
||||
@@ -298,9 +292,7 @@ async function loadChapterList() {
|
||||
|
||||
// 加载章节内容(带音频时间点)
|
||||
async function loadChapterContent(chapterId: number) {
|
||||
try {
|
||||
uni.showLoading({ title: t('common.loading') })
|
||||
|
||||
try {
|
||||
console.log('加载章节内容, chapterId:', chapterId)
|
||||
const res = await bookApi.getChapterContentListen(chapterId)
|
||||
console.log('章节内容响应:', res)
|
||||
@@ -327,11 +319,8 @@ async function loadChapterContent(chapterId: number) {
|
||||
console.log('章节内容为空')
|
||||
currentContent.value = '暂无内容'
|
||||
}
|
||||
|
||||
uni.hideLoading()
|
||||
} catch (error) {
|
||||
console.error('Failed to load chapter content:', error)
|
||||
uni.hideLoading()
|
||||
uni.showToast({
|
||||
title: '加载内容失败',
|
||||
icon: 'none'
|
||||
@@ -364,7 +353,6 @@ function playChapter(chapter: IChapter) {
|
||||
|
||||
if (audioContext.value) {
|
||||
console.log('设置音频源:', chapter.voices)
|
||||
uni.showLoading({ title: t('common.readAudio') })
|
||||
|
||||
audioContext.value.src = chapter.voices
|
||||
audioContext.value.playbackRate = playbackRate.value
|
||||
@@ -372,7 +360,6 @@ function playChapter(chapter: IChapter) {
|
||||
// 监听音频准备就绪
|
||||
audioContext.value.onCanplay(() => {
|
||||
console.log('音频准备就绪')
|
||||
uni.hideLoading()
|
||||
})
|
||||
|
||||
audioContext.value.play()
|
||||
|
||||
0
pages/book/order.vue
Normal file
0
pages/book/order.vue
Normal file
@@ -2,12 +2,27 @@
|
||||
<view class="reader-page" :class="themeClass">
|
||||
<!-- 顶部标题栏 (可隐藏) -->
|
||||
<view class="reader-header" :style="{ top: notchHeight + 'px' }">
|
||||
<wd-icon name="arrow-left" size="20px" @click="goBack" />
|
||||
<wd-icon name="arrow-left" size="20px" @click="onPageBack" />
|
||||
<text class="chapter-title">{{ currentChapterTitle }}</text>
|
||||
</view>
|
||||
|
||||
<!-- 阅读内容区域 -->
|
||||
<view class="reader-content" @click="toggleControls">
|
||||
<!-- 仿真翻页 -->
|
||||
<!-- <view class="content-wrapper">
|
||||
<nx-turn
|
||||
:initPage="0"
|
||||
:pageCount="4"
|
||||
>
|
||||
<template v-slot:page-content="{ page }">
|
||||
<text>{{ page }}</text>
|
||||
</template>
|
||||
<template v-slot:next-page-content="{ page }">
|
||||
<text>{{ page }}</text>
|
||||
</template>
|
||||
</nx-turn>
|
||||
</view> -->
|
||||
|
||||
<!-- 左右翻页模式 -->
|
||||
<view
|
||||
v-if="readMode === 'page'"
|
||||
@@ -37,9 +52,9 @@
|
||||
</view>
|
||||
|
||||
<!-- 页码指示器 -->
|
||||
<view v-show="showControls" class="page-indicator">
|
||||
<!-- <view v-show="showControls" class="page-indicator">
|
||||
{{ currentPage }} / {{ totalPages }}
|
||||
</view>
|
||||
</view> -->
|
||||
</view>
|
||||
|
||||
<!-- 上下滚动模式 -->
|
||||
@@ -99,8 +114,6 @@
|
||||
<wd-icon v-if="isLocked(index)" name="lock" size="20px" />
|
||||
</view>
|
||||
</scroll-view>
|
||||
<!-- 底部占位 -->
|
||||
<view class="setting-ooter-placeholder"></view>
|
||||
</view>
|
||||
</wd-popup>
|
||||
|
||||
@@ -165,13 +178,11 @@
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
<!-- 底部占位 -->
|
||||
<view class="setting-ooter-placeholder"></view>
|
||||
</wd-popup>
|
||||
|
||||
<!-- 空状态 -->
|
||||
<view v-if="chapterList.length === 0 && !loading" class="empty-state">
|
||||
<text>{{ nullStatus }}</text>
|
||||
<text>{{ $t('common.data_null') }}</text>
|
||||
</view>
|
||||
</view>
|
||||
</template>
|
||||
@@ -183,6 +194,7 @@ import { useI18n } from 'vue-i18n'
|
||||
import { useBookStore } from '@/stores/book'
|
||||
import { bookApi } from '@/api/modules/book'
|
||||
import type { IChapter, IChapterContent, IReadProgress } from '@/types/book'
|
||||
import { onPageBack } from '@/utils/index'
|
||||
|
||||
const { t } = useI18n()
|
||||
const bookStore = useBookStore()
|
||||
@@ -199,7 +211,6 @@ const currentChapterIndex = ref(0)
|
||||
const currentChapterId = ref(0)
|
||||
const currentContentId = ref(0)
|
||||
const loading = ref(false)
|
||||
const nullStatus = ref('')
|
||||
|
||||
// 阅读设置
|
||||
const fontSizeLevel = ref(1)
|
||||
@@ -260,7 +271,6 @@ const currentChapterTitle = computed(() => {
|
||||
return chapter.chapter + (chapter.content ? ' - ' + chapter.content : '')
|
||||
})
|
||||
|
||||
// 生命周期
|
||||
onLoad((options: any) => {
|
||||
if (options.bookId) bookId.value = Number(options.bookId)
|
||||
if (options.isBuy) isBuy.value = options.isBuy
|
||||
@@ -290,20 +300,23 @@ onShow(() => {
|
||||
}, 300)
|
||||
} else {
|
||||
currentPage.value = 1
|
||||
calculatePages()
|
||||
|
||||
}
|
||||
})
|
||||
|
||||
onMounted(() => {
|
||||
initHeights()
|
||||
calculatePages()
|
||||
})
|
||||
|
||||
onHide(() => {
|
||||
saveProgress()
|
||||
console.log('onHide')
|
||||
})
|
||||
|
||||
onBackPress(() => {
|
||||
saveProgress()
|
||||
console.log('onBackPress')
|
||||
return false
|
||||
})
|
||||
|
||||
@@ -313,7 +326,7 @@ function initHeights() {
|
||||
const windowHeight = systemInfo.windowHeight
|
||||
|
||||
// 翻页模式高度
|
||||
const math = Math.floor((windowHeight - (notchHeight.value + 130)) / lineHeight.value)
|
||||
const math = Math.floor((windowHeight - (notchHeight.value + 80)) / lineHeight.value)
|
||||
wrapHeight.value = math * lineHeight.value
|
||||
|
||||
// 滚动模式高度
|
||||
@@ -359,11 +372,8 @@ async function loadChapterList() {
|
||||
|
||||
// 默认加载第一章
|
||||
await loadChapterContent(chapterList.value[0].id, 0)
|
||||
} else {
|
||||
nullStatus.value = t('common.data_null')
|
||||
}
|
||||
} catch (error) {
|
||||
nullStatus.value = t('common.data_null')
|
||||
console.error('Failed to load chapter list:', error)
|
||||
} finally {
|
||||
loading.value = false
|
||||
@@ -373,9 +383,7 @@ async function loadChapterList() {
|
||||
// 加载章节内容
|
||||
async function loadChapterContent(chapterId: number, index: number) {
|
||||
try {
|
||||
uni.showLoading({ title: t('global.loading') })
|
||||
const res = await bookApi.getChapterContent(chapterId)
|
||||
uni.hideLoading()
|
||||
|
||||
if (res.contentPage && res.contentPage.length > 0) {
|
||||
contentList.value = res.contentPage
|
||||
@@ -402,7 +410,6 @@ async function loadChapterContent(chapterId: number, index: number) {
|
||||
catalogVisible.value = false
|
||||
}
|
||||
} catch (error) {
|
||||
uni.hideLoading()
|
||||
console.error('Failed to load chapter content:', error)
|
||||
}
|
||||
}
|
||||
@@ -524,6 +531,7 @@ function toggleControls() {
|
||||
function showCatalog() {
|
||||
catalogVisible.value = true
|
||||
settingsVisible.value = false
|
||||
showControls.value = false
|
||||
}
|
||||
|
||||
// 关闭目录
|
||||
@@ -534,9 +542,9 @@ function closeCatalog() {
|
||||
|
||||
// 显示设置
|
||||
function showSettings() {
|
||||
console.log('currentLanguage', currentLanguage.value)
|
||||
settingsVisible.value = true
|
||||
catalogVisible.value = false
|
||||
showControls.value = false
|
||||
}
|
||||
// 关闭设置
|
||||
function closeSettings() {
|
||||
@@ -615,21 +623,12 @@ const changeBookLanguage = (language: any) => {
|
||||
|
||||
// 保存进度
|
||||
async function saveProgress() {
|
||||
if (isBuy.value === '0') {
|
||||
try {
|
||||
await bookApi.saveReadProgress(bookId.value, currentChapterId.value, currentContentId.value)
|
||||
} catch (error) {
|
||||
console.error('Failed to save progress:', error)
|
||||
}
|
||||
try {
|
||||
await bookApi.saveReadProgress(bookId.value, currentChapterId.value, currentContentId.value)
|
||||
} catch (error) {
|
||||
console.error('Failed to save progress:', error)
|
||||
}
|
||||
}
|
||||
|
||||
// 返回
|
||||
function goBack() {
|
||||
uni.navigateTo({
|
||||
url: '/pages/book/detail?id=' + bookId.value
|
||||
})
|
||||
}
|
||||
</script>
|
||||
|
||||
<style lang="scss" scoped>
|
||||
@@ -885,10 +884,5 @@ function goBack() {
|
||||
color: #999;
|
||||
}
|
||||
}
|
||||
|
||||
/* 底部占位 */
|
||||
.setting-ooter-placeholder {
|
||||
height: 55px;
|
||||
}
|
||||
}
|
||||
</style>
|
||||
|
||||
@@ -181,9 +181,7 @@ async function loadComments() {
|
||||
}
|
||||
|
||||
try {
|
||||
uni.showLoading({ title: t('global.loading') })
|
||||
const res = await bookApi.getBookComments(bookId.value, page.value.current, page.value.limit)
|
||||
uni.hideLoading()
|
||||
|
||||
commentsCount.value = res.commentsCount || 0
|
||||
|
||||
@@ -194,7 +192,6 @@ async function loadComments() {
|
||||
nullText.value = t('common.data_null')
|
||||
}
|
||||
} catch (error) {
|
||||
uni.hideLoading()
|
||||
nullText.value = t('common.data_null')
|
||||
console.error('Failed to load comments:', error)
|
||||
}
|
||||
@@ -472,7 +469,7 @@ function toggleEmoji() {
|
||||
}
|
||||
|
||||
.editor {
|
||||
border: 1rpx solid #ddd;
|
||||
border: 1px solid #ddd;
|
||||
width: 100%;
|
||||
min-height: 200rpx;
|
||||
height: 200rpx;
|
||||
|
||||
@@ -1,22 +0,0 @@
|
||||
<template>
|
||||
<view class="container">
|
||||
<no-data></no-data>
|
||||
</view>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
export default {
|
||||
data() {
|
||||
return {
|
||||
title: this.$t('')
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
<style>
|
||||
|
||||
</style>
|
||||
@@ -192,16 +192,13 @@ const getCode = async () => {
|
||||
if (!isEmailVerified(email.value)) return
|
||||
|
||||
try {
|
||||
uni.showLoading()
|
||||
await commonApi.sendMailCaptcha(email.value)
|
||||
uni.hideLoading()
|
||||
uni.showToast({
|
||||
title: t('login.sendCodeSuccess'),
|
||||
icon: 'none'
|
||||
})
|
||||
getCodeState()
|
||||
} catch (error) {
|
||||
uni.hideLoading()
|
||||
console.error('Send code error:', error)
|
||||
}
|
||||
}
|
||||
@@ -268,9 +265,7 @@ const onSubmit = async () => {
|
||||
if (!isPasswordMatch()) return
|
||||
|
||||
try {
|
||||
uni.showLoading()
|
||||
await resetPassword(email.value, code.value, password.value)
|
||||
uni.hideLoading()
|
||||
|
||||
uni.showModal({
|
||||
title: t('global.tips'),
|
||||
@@ -281,7 +276,6 @@ const onSubmit = async () => {
|
||||
}
|
||||
})
|
||||
} catch (error) {
|
||||
uni.hideLoading()
|
||||
console.error('Reset password error:', error)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -115,11 +115,11 @@
|
||||
</view>
|
||||
|
||||
<!-- 游客体验 -->
|
||||
<view class="youke-l">
|
||||
<!-- <view class="youke-l">
|
||||
<view @click="onPageJump('/pages/visitor/visitor')">
|
||||
{{ $t('login.noLogin') }}
|
||||
</view>
|
||||
</view>
|
||||
</view> -->
|
||||
</view>
|
||||
|
||||
<!-- 用户协议弹窗 -->
|
||||
@@ -357,16 +357,13 @@ const onSetCode = async () => {
|
||||
if (!isEmailVerified(email.value)) return false
|
||||
|
||||
try {
|
||||
uni.showLoading()
|
||||
await commonApi.sendMailCaptcha(email.value)
|
||||
uni.hideLoading()
|
||||
uni.showToast({
|
||||
title: t('login.sendCodeSuccess'),
|
||||
icon: 'none'
|
||||
})
|
||||
getCodeState()
|
||||
} catch (error) {
|
||||
uni.hideLoading()
|
||||
submitClickNum.value++ // 发送验证码失败时增加提交点击次数
|
||||
console.error('Send code error:', error)
|
||||
}
|
||||
|
||||
@@ -36,10 +36,7 @@
|
||||
</view>
|
||||
</view> -->
|
||||
<wd-cell-group border class="contact-info">
|
||||
<wd-cell :title="$t('user.hotline')" clickable @click="handlePhoneCall">
|
||||
022-24142321
|
||||
<img src="/static/icon/tel.png" width="23" height="23" />
|
||||
</wd-cell>
|
||||
<wd-cell :title="$t('user.hotline')" clickable icon="call" value="022-24142321" @click="handlePhoneCall"></wd-cell>
|
||||
<!-- <wd-cell :title="$t('user.wechat')" value="yilujiankangkefu" clickable @click="handlePhoneCall" /> -->
|
||||
</wd-cell-group>
|
||||
|
||||
@@ -86,7 +83,7 @@ const getAppVersion = () => {
|
||||
* 拨打电话
|
||||
*/
|
||||
const handlePhoneCall = () => {
|
||||
makePhoneCall('022-24142321', t('user.hotline'), t)
|
||||
makePhoneCall('022-24142321', t('user.hotline'))
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -11,6 +11,7 @@
|
||||
<wd-select-picker
|
||||
v-model="form.type"
|
||||
type="radio"
|
||||
style="border-bottom: 1px solid #ddd;"
|
||||
:columns="issueTypeOptions"
|
||||
:placeholder="$t('common.pleaseSelect')"
|
||||
:show-confirm="false"
|
||||
@@ -227,8 +228,6 @@ const handleSubmit = async () => {
|
||||
}
|
||||
|
||||
try {
|
||||
uni.showLoading()
|
||||
|
||||
// 处理图片
|
||||
if (imageUrl.value.length > 0) {
|
||||
form.value.image = imageUrl.value.join(',')
|
||||
@@ -236,8 +235,6 @@ const handleSubmit = async () => {
|
||||
|
||||
// 提交反馈
|
||||
await submitFeedback(form.value)
|
||||
|
||||
uni.hideLoading()
|
||||
|
||||
uni.showModal({
|
||||
title: t('global.tips'),
|
||||
@@ -265,7 +262,6 @@ const handleSubmit = async () => {
|
||||
})
|
||||
} catch (error) {
|
||||
console.error('提交反馈失败:', error)
|
||||
uni.hideLoading()
|
||||
uni.showToast({
|
||||
title: t('user.feedbackFailed'),
|
||||
icon: 'none'
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
<template>
|
||||
<view class="user-page">
|
||||
<view class="user-page" :style="{ paddingTop: getNotchHeight() + 30 + 'px' }">
|
||||
<!-- 设置图标 -->
|
||||
<view class="settings-icon" @click="goSettings">
|
||||
<view class="settings-icon" :style="{ top: getNotchHeight() + 30 + 'px' }" @click="goSettings">
|
||||
<wd-icon name="setting1" size="24px" color="#666" />
|
||||
<text>{{ $t('user.settings') }}</text>
|
||||
</view>
|
||||
@@ -27,7 +27,8 @@
|
||||
<!-- VIP订阅卡片 -->
|
||||
<view class="vip-card-section">
|
||||
<view class="vip-card">
|
||||
<view v-if="vipInfo.id" class="vip-info">
|
||||
用户VIP功能重写中。。。
|
||||
<!-- <view v-if="vipInfo.id" class="vip-info">
|
||||
<text class="label">{{ $t('user.vip') }}</text>
|
||||
<text class="value">{{ vipInfo.endTime ? vipInfo.endTime.split(' ')[0] : '' }}</text>
|
||||
</view>
|
||||
@@ -38,7 +39,16 @@
|
||||
@click="goSubscribe"
|
||||
>
|
||||
{{ $t('user.subscribe') }}
|
||||
</wd-button>
|
||||
</wd-button> -->
|
||||
</view>
|
||||
</view>
|
||||
|
||||
<!-- 我的资产 -->
|
||||
<view class="vip-card-section wallet-section">
|
||||
<view class="vip-card wallet_l">
|
||||
我的资产功能重写中。。。
|
||||
<!-- <text class="wallet_title">{{$t('my.coin')}}<uni-icons type="help" size="19" color="#666"></uni-icons></text>
|
||||
<text class="wallet_count">{{userMes.peanutCoin}}</text> -->
|
||||
</view>
|
||||
</view>
|
||||
|
||||
@@ -65,6 +75,7 @@ import { useUserStore } from '@/stores/user'
|
||||
import { getUserInfo, getVipInfo } from '@/api/modules/user'
|
||||
import type { IVipInfo } from '@/types/user'
|
||||
import { useI18n } from 'vue-i18n'
|
||||
import { getNotchHeight } from '@/utils/system'
|
||||
|
||||
const { t } = useI18n()
|
||||
const userStore = useUserStore()
|
||||
@@ -205,13 +216,11 @@ $theme-color: #54a966;
|
||||
.user-page {
|
||||
min-height: 100vh;
|
||||
background-color: #f7faf9;
|
||||
padding-top: 130rpx;
|
||||
}
|
||||
|
||||
.settings-icon {
|
||||
position: absolute;
|
||||
right: 40rpx;
|
||||
top: 60rpx;
|
||||
right: 20px;
|
||||
z-index: 2;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
|
||||
@@ -98,11 +98,9 @@ async function loadBookList() {
|
||||
}
|
||||
|
||||
loading.value = true
|
||||
uni.showLoading({ title: t('global.loading') })
|
||||
|
||||
try {
|
||||
const res = await bookApi.getMyBooks(page.value.current, page.value.limit)
|
||||
uni.hideLoading()
|
||||
|
||||
if (res.page && res.page.records) {
|
||||
total.value = res.page.total
|
||||
@@ -115,7 +113,6 @@ async function loadBookList() {
|
||||
}
|
||||
}
|
||||
} catch (error) {
|
||||
uni.hideLoading()
|
||||
console.error('Failed to load book list:', error)
|
||||
} finally {
|
||||
loading.value = false
|
||||
|
||||
@@ -112,13 +112,8 @@ const getData = async () => {
|
||||
|
||||
try {
|
||||
loading.value = true
|
||||
uni.showLoading({
|
||||
title: t('common.loading')
|
||||
})
|
||||
|
||||
const res = await getOrderList(page.value.current, page.value.limit)
|
||||
|
||||
uni.hideLoading()
|
||||
|
||||
if (res.orders && res.orders.records) {
|
||||
total.value = res.orders.total
|
||||
@@ -139,7 +134,6 @@ const getData = async () => {
|
||||
}
|
||||
} catch (error) {
|
||||
console.error('获取订单列表失败:', error)
|
||||
uni.hideLoading()
|
||||
} finally {
|
||||
loading.value = false
|
||||
}
|
||||
|
||||
@@ -27,7 +27,7 @@
|
||||
@click="editField(field)"
|
||||
>
|
||||
<view class="value-wrapper">
|
||||
<text v-if="userInfo[field.key]" class="value">
|
||||
<text v-if="userInfo[field.key] || userInfo[field.key] === 0" class="value">
|
||||
{{ formatValue(field, userInfo[field.key]) }}
|
||||
</text>
|
||||
<text v-else class="placeholder">{{ $t('user.notSet') }}</text>
|
||||
@@ -163,7 +163,8 @@ const fields = computed(() => [
|
||||
// 性别选项
|
||||
const sexOptions = [
|
||||
{ label: t('user.male'), value: 1 },
|
||||
{ label: t('user.female'), value: 2 }
|
||||
{ label: t('user.female'), value: 0 },
|
||||
{ label: t('user.secrecy'), value: 2 },
|
||||
]
|
||||
|
||||
// 编辑相关
|
||||
@@ -198,10 +199,8 @@ const avatarUrl = ref('')
|
||||
*/
|
||||
const userInfo = ref<any>({}) // 用户信息
|
||||
const getData = async () => {
|
||||
uni.showLoading()
|
||||
try {
|
||||
const res = await getUserInfo()
|
||||
uni.hideLoading()
|
||||
if (res.result) {
|
||||
userStore.setUserInfo(res.result)
|
||||
userInfo.value = res.result
|
||||
@@ -216,7 +215,22 @@ const getData = async () => {
|
||||
*/
|
||||
const formatValue = (field: any, value: any) => {
|
||||
if (field.key === 'sex') {
|
||||
return value === 1 ? t('user.male') : t('user.female')
|
||||
let result = null
|
||||
switch(value) {
|
||||
case 1:
|
||||
result = t('user.male')
|
||||
break
|
||||
case 0:
|
||||
result = t('user.female')
|
||||
break
|
||||
case 2:
|
||||
result = t('user.secrecy')
|
||||
break
|
||||
default:
|
||||
result = null
|
||||
break
|
||||
}
|
||||
return result
|
||||
}
|
||||
if (field.key === 'password') {
|
||||
return '******'
|
||||
@@ -385,8 +399,6 @@ const handleSubmit = async () => {
|
||||
const key = currentField.value?.key
|
||||
|
||||
try {
|
||||
uni.showLoading()
|
||||
|
||||
// 构建更新数据对象
|
||||
let updateData: any = Object.assign({}, userInfo.value)
|
||||
|
||||
@@ -394,7 +406,6 @@ const handleSubmit = async () => {
|
||||
case 'email':
|
||||
// 更新邮箱
|
||||
if (!editForm.value.email || !editForm.value.code) {
|
||||
uni.hideLoading()
|
||||
uni.showToast({
|
||||
title: t('user.pleaseInputCode'),
|
||||
icon: 'none'
|
||||
@@ -407,7 +418,6 @@ const handleSubmit = async () => {
|
||||
case 'password':
|
||||
// 更新密码
|
||||
if (!passwordOk.value) {
|
||||
uni.hideLoading()
|
||||
uni.showToast({
|
||||
title: passwordNote.value,
|
||||
icon: 'none'
|
||||
@@ -415,7 +425,6 @@ const handleSubmit = async () => {
|
||||
return
|
||||
}
|
||||
if (editForm.value.password !== editForm.value.confirmPassword) {
|
||||
uni.hideLoading()
|
||||
uni.showToast({
|
||||
title: t('user.passwordNotMatch'),
|
||||
icon: 'none'
|
||||
@@ -429,7 +438,6 @@ const handleSubmit = async () => {
|
||||
// 更新头像
|
||||
console.log('avatarUrl.value:', avatarUrl.value)
|
||||
if (!avatarUrl.value) {
|
||||
uni.hideLoading()
|
||||
uni.showToast({
|
||||
title: t('common.pleaseSelect') + t('user.avatar'),
|
||||
icon: 'none'
|
||||
@@ -444,8 +452,7 @@ const handleSubmit = async () => {
|
||||
|
||||
case 'sex':
|
||||
// 更新性别
|
||||
const sexValue = editValue.value === 2 ? 0 : editValue.value
|
||||
updateData.sex = sexValue
|
||||
updateData.sex = editValue.value
|
||||
await updateUserInfo(updateData)
|
||||
break
|
||||
|
||||
@@ -463,7 +470,6 @@ const handleSubmit = async () => {
|
||||
break
|
||||
}
|
||||
|
||||
uni.hideLoading()
|
||||
uni.showToast({
|
||||
title: t('user.updateSuccess'),
|
||||
icon: 'success'
|
||||
@@ -477,7 +483,6 @@ const handleSubmit = async () => {
|
||||
}, 500)
|
||||
} catch (error) {
|
||||
console.error('更新失败:', error)
|
||||
uni.hideLoading()
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -142,13 +142,7 @@ const getPlatform = () => {
|
||||
*/
|
||||
const getPackages = async () => {
|
||||
try {
|
||||
uni.showLoading({
|
||||
title: t('common.loading')
|
||||
})
|
||||
|
||||
const res = await getVipPackages()
|
||||
|
||||
uni.hideLoading()
|
||||
|
||||
if (res.sysDictDatas && res.sysDictDatas.length > 0) {
|
||||
packages.value = res.sysDictDatas
|
||||
@@ -163,7 +157,6 @@ const getPackages = async () => {
|
||||
}
|
||||
} catch (error) {
|
||||
console.error('获取套餐列表失败:', error)
|
||||
uni.hideLoading()
|
||||
}
|
||||
}
|
||||
|
||||
@@ -246,10 +239,6 @@ const handleSubscribe = async () => {
|
||||
}
|
||||
|
||||
try {
|
||||
uni.showLoading({
|
||||
title: t('common.loading')
|
||||
})
|
||||
|
||||
// 创建订单
|
||||
const orderData = {
|
||||
paymentMethod: paymentMethod.value,
|
||||
@@ -273,7 +262,6 @@ const handleSubscribe = async () => {
|
||||
}
|
||||
} catch (error) {
|
||||
console.error('创建订单失败:', error)
|
||||
uni.hideLoading()
|
||||
}
|
||||
}
|
||||
|
||||
@@ -283,7 +271,6 @@ const handleSubscribe = async () => {
|
||||
const initiateGooglePay = async () => {
|
||||
// TODO: 集成 Google Pay SDK
|
||||
// 这里需要使用 sn-googlepay5 插件
|
||||
uni.hideLoading()
|
||||
uni.showToast({
|
||||
title: 'Google Pay 功能开发中',
|
||||
icon: 'none'
|
||||
@@ -295,7 +282,6 @@ const initiateGooglePay = async () => {
|
||||
*/
|
||||
const initiateIAP = async () => {
|
||||
// TODO: 集成 IAP SDK
|
||||
uni.hideLoading()
|
||||
uni.showToast({
|
||||
title: 'IAP 功能开发中',
|
||||
icon: 'none'
|
||||
|
||||
@@ -91,20 +91,14 @@ const getData = async () => {
|
||||
|
||||
try {
|
||||
loading.value = true
|
||||
uni.showLoading({
|
||||
title: t('common.loading')
|
||||
})
|
||||
|
||||
const res = await getTransactionList(userStore.userInfo.id)
|
||||
|
||||
uni.hideLoading()
|
||||
|
||||
if (res.transactionDetailsList && res.transactionDetailsList.length > 0) {
|
||||
transactionList.value = res.transactionDetailsList
|
||||
}
|
||||
} catch (error) {
|
||||
console.error('获取交易记录失败:', error)
|
||||
uni.hideLoading()
|
||||
} finally {
|
||||
loading.value = false
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user