Compare commits

18 Commits

Author SHA1 Message Date
9f19842054 修复:上传丢失页面 2025-11-27 17:47:55 +08:00
38c4519e79 修复:合并丢失的代码 2025-11-27 17:32:58 +08:00
3b596e0a70 修复:合并丢失的代码 2025-11-27 16:10:55 +08:00
b513979995 revert f9cad8d740
revert 更新:谷歌支付
2025-11-27 15:44:12 +08:00
ee5431e57a revert 2a067e0954
revert 更新:积分列表
2025-11-27 15:43:56 +08:00
64abd3d4ab revert 33c22eaad9
revert 解决冲突
2025-11-27 15:38:24 +08:00
3da220526b revert f70fc65c24
revert 解决冲突
2025-11-27 15:38:07 +08:00
d209c05a18 revert 26cef66e82
revert 解决冲突报错
2025-11-27 15:37:53 +08:00
21a3335939 revert 277b6cf0b6
revert 修改:解决谷歌支付调方法时机问题
2025-11-27 15:37:31 +08:00
cbc48b8193 revert 277b6cf0b6
revert 修改:解决谷歌支付调方法时机问题
2025-11-27 15:36:57 +08:00
574644349c revert 277b6cf0b6
revert 修改:解决谷歌支付调方法时机问题
2025-11-27 15:36:43 +08:00
2ccd53ab94 revert 277b6cf0b6
revert 修改:解决谷歌支付调方法时机问题
2025-11-27 15:36:20 +08:00
277b6cf0b6 修改:解决谷歌支付调方法时机问题 2025-11-27 15:04:26 +08:00
26cef66e82 解决冲突报错 2025-11-27 15:01:31 +08:00
f70fc65c24 解决冲突 2025-11-27 14:37:48 +08:00
33c22eaad9 解决冲突 2025-11-27 14:35:11 +08:00
2a067e0954 更新:积分列表 2025-11-27 14:18:35 +08:00
f9cad8d740 更新:谷歌支付 2025-11-27 14:17:50 +08:00
19 changed files with 606 additions and 377 deletions

View File

@@ -34,7 +34,7 @@ export function responseInterceptor(res: UniApp.RequestSuccessCallbackResult) {
} }
// 可能为字符串,尝试解析(原项目也做了类似处理) // 可能为字符串,尝试解析(原项目也做了类似处理)
let httpData: IApiResponse | string = res.data; let httpData: IApiResponse | string = res.data as any;
if (typeof httpData === 'string') { if (typeof httpData === 'string') {
try { try {
httpData = JSON.parse(httpData); httpData = JSON.parse(httpData);
@@ -44,20 +44,19 @@ export function responseInterceptor(res: UniApp.RequestSuccessCallbackResult) {
} }
// 规范化 message 字段 // 规范化 message 字段
const message = (httpData as IApiResponse).msg || (httpData as IApiResponse).message || (httpData as IApiResponse).errMsg || ''; const message = (httpData as any).msg || (httpData as any).message || (httpData as any).errMsg || '';
const code = (httpData as IApiResponse).code; // 成功判断:与原项目一致的条件
const successFlag = (httpData as any).success === true || (httpData as any).code === 0;
// 成功判断
const successFlag = (httpData as IApiResponse).success === true || code === 0;
if (successFlag) { if (successFlag) {
// 返回原始 httpData // 返回原始 httpData(与原项目 dataFactory 返回 Promise.resolve(httpData) 保持一致)
// 实际数据每个接口不同,调用者需根据实际情况取 .data 字段 // 但大多数调用者更关心 data 字段,这里返回整个 httpData调用者可取 .data
return Promise.resolve(httpData); return Promise.resolve(httpData);
} }
// 登录失效或需要强制登录的一些 code // 登录失效或需要强制登录的一些 code(与原项目一致)
const code = (httpData as any).code;
if (code === '401' || code === 401) { if (code === '401' || code === 401) {
// 触发登出流程 // 触发登出流程
handleAuthExpired(); handleAuthExpired();
@@ -65,7 +64,7 @@ export function responseInterceptor(res: UniApp.RequestSuccessCallbackResult) {
} }
// 原项目还将 1000,1001,1100,402 等视作需要强制登录 // 原项目还将 1000,1001,1100,402 等视作需要强制登录
if (code == 1000 || code == 1001 || code === 1100 || code === 402) { if (code === '1000' || code === '1001' || code === 1000 || code === 1001 || code === 1100 || code === '402' || code === 402) {
handleAuthExpired(); handleAuthExpired();
return Promise.reject({ statusCode: 0, errMsg: message || t('global.loginExpired'), data: httpData }); return Promise.reject({ statusCode: 0, errMsg: message || t('global.loginExpired'), data: httpData });
} }

View File

@@ -8,7 +8,6 @@ import { t } from '@/utils/i18n'
export function createRequestClient(cfg: ICreateClientConfig) { export function createRequestClient(cfg: ICreateClientConfig) {
const baseURL = cfg.baseURL; const baseURL = cfg.baseURL;
const timeout = cfg.timeout ?? REQUEST_TIMEOUT; const timeout = cfg.timeout ?? REQUEST_TIMEOUT;
let reqCount= 0
async function request<T = any>(options: IRequestOptions): Promise<T> { async function request<T = any>(options: IRequestOptions): Promise<T> {
// 组装 final options // 组装 final options
@@ -24,18 +23,14 @@ export function createRequestClient(cfg: ICreateClientConfig) {
// 全局处理请求 loading // 全局处理请求 loading
const loading = !cfg.loading ? true : cfg.loading // 接口请求参数不传loading默认显示loading const loading = !cfg.loading ? true : cfg.loading // 接口请求参数不传loading默认显示loading
if (loading) { loading && uni.showLoading()
uni.showLoading({ mask: true })
reqCount++
}
return new Promise((resolve, reject) => { return new Promise((resolve, reject) => {
uni.request({ uni.request({
...intercepted, ...intercepted,
complete() { complete() {
// 请求完成关闭 loading // 请求完成关闭 loading
loading && reqCount-- loading && uni.hideLoading()
reqCount <= 0 && uni.hideLoading()
}, },
success(res: any) { success(res: any) {
// 委托给响应拦截器处理 // 委托给响应拦截器处理

View File

@@ -259,8 +259,11 @@ const handleChapterClick = (chapter: IChapter) => {
border-bottom-left-radius: 40rpx; border-bottom-left-radius: 40rpx;
.vip-badge { .vip-badge {
display: inline-block; position: absolute;
left: 0;
top: 0;
font-size: 24rpx; font-size: 24rpx;
display: inline-block;
background: linear-gradient(90deg, #6429db 0%, #0075ed 100%); background: linear-gradient(90deg, #6429db 0%, #0075ed 100%);
color: #fff; color: #fff;
padding: 10rpx 20rpx; padding: 10rpx 20rpx;

View File

@@ -4,7 +4,7 @@
<view class="payment-item"> <view class="payment-item">
<view class="payment-left"> <view class="payment-left">
<image src="/static/icon/pay_3.png" class="payment-icon" /> <image src="/static/icon/pay_3.png" class="payment-icon" />
<text class="">{{ $t('global.coin') }}</text> <text class="">{{ $t('order.virtualCoin') }}</text>
<text class="text-[#7dc1f0]"> <text class="text-[#7dc1f0]">
({{ $t('order.balance') }}{{ peanutCoin || 0 }}) ({{ $t('order.balance') }}{{ peanutCoin || 0 }})
</text> </text>
@@ -25,12 +25,19 @@
<view class="tip-title">{{ $t('order.paymentTipTitle') }}</view> <view class="tip-title">{{ $t('order.paymentTipTitle') }}</view>
<view class="tip-item">{{ $t('order.paymentTip1') }}</view> <view class="tip-item">{{ $t('order.paymentTip1') }}</view>
<view class="tip-item"> <view class="tip-item">
{{ $t('order.paymentTip2-1') }} {{ $t('order.paymentTip2') }}
<text class="link-text" @click="copyToClipboard('yilujiankangkefu')">yilujiankangkefu</text> <text class="link-text" @click="makePhoneCall('022-24142321')">022-24142321</text>
{{ $t('order.paymentTip2-2') }} </view>
<text class="link-text" @click="copyToClipboard('AmazingLimited@163.com')"> <view class="tip-item">
AmazingLimited@163.com {{ $t('order.paymentTip3') }}
<text class="link-text" @click="copyToClipboard('publisher@tmrjournals.com')">
publisher@tmrjournals.com
</text> </text>
{{ $t('order.paymentTip3_1') }}
<text class="link-text" @click="copyToClipboard('yilujiankangkefu')">
yilujiankangkefu
</text>
{{ $t('order.paymentTip3_2') }}
</view> </view>
</view> </view>
</view> </view>
@@ -46,15 +53,6 @@ const props = defineProps({
default: 0 default: 0
} }
}) })
/**
* 跳转到充值页面
*/
const goToRecharge = () => {
uni.navigateTo({
url: '/pages/user/wallet/recharge/index?source=order'
})
}
</script> </script>
<style lang="scss" scoped> <style lang="scss" scoped>

View File

@@ -230,43 +230,70 @@ function initScrollHeight() {
// 加载书籍详情 // 加载书籍详情
async function loadBookInfo() { async function loadBookInfo() {
const res = await bookApi.getBookInfo(bookId.value) try {
bookInfo.value = res.bookInfo const res = await bookApi.getBookInfo(bookId.value)
if (res.bookInfo) {
bookInfo.value = res.bookInfo
}
} catch (error) {
console.error('Failed to load book info:', error)
}
} }
// 加载购买商品信息 // 加载购买商品信息
async function loadGoodsInfo() { async function loadGoodsInfo() {
const res = await bookApi.getBookGoods(bookId.value) try {
goodsList.value = res.productList || [] const res = await bookApi.getBookGoods(bookId.value)
if (res.code === 0) {
goodsList.value = res.productList || []
}
} catch (error) {
console.error('Failed to load goods info:', error)
}
} }
// 加载统计数据 // 加载统计数据
async function loadBookCount() { async function loadBookCount() {
const res = await bookApi.getBookReadCount(bookId.value) try {
if (res.code === 0) { const res = await bookApi.getBookReadCount(bookId.value)
readCount.value = res.readCount || 0 if (res.code === 0) {
listenCount.value = res.listenCount || 0 readCount.value = res.readCount || 0
buyCount.value = res.buyCount || 0 listenCount.value = res.listenCount || 0
buyCount.value = res.buyCount || 0
}
} catch (error) {
console.error('Failed to load book count:', error)
} }
} }
// 加载评论 // 加载评论
async function loadComments() { async function loadComments() {
const res = await bookApi.getBookComments(bookId.value, 1, 10) try {
if (res.commentsTree && res.commentsTree.length > 0) { const res = await bookApi.getBookComments(bookId.value, 1, 10)
commentList.value = res.commentsTree if (res.commentsTree && res.commentsTree.length > 0) {
} else { commentList.value = res.commentsTree
} else {
nullText.value = t('common.data_null')
}
} catch (error) {
nullText.value = t('common.data_null') nullText.value = t('common.data_null')
console.error('Failed to load comments:', error)
} }
} }
// 加载推荐书籍 // 加载推荐书籍
async function loadRecommendBooks() { async function loadRecommendBooks() {
const res = await bookApi.getRecommendBook(bookId.value) try {
if (res.bookList && res.bookList.length > 0) { const res = await bookApi.getRecommendBook(bookId.value)
relatedBooks.value = res.bookList if (res.bookList && res.bookList.length > 0) {
} else { relatedBooks.value = res.bookList
} else {
nullBookText.value = t('common.data_null')
}
} catch (error) {
nullBookText.value = t('common.data_null') nullBookText.value = t('common.data_null')
console.error('Failed to load recommend books:', error)
} }
} }

View File

@@ -162,7 +162,7 @@
> >
<image :src="item.images" /> <image :src="item.images" />
<text class="book-text">{{ item.name }}</text> <text class="book-text">{{ item.name }}</text>
<text class="book-price">{{ item.minPrice }} {{ t('global.coin') }}</text> <text class="book-price">{{ item.minPrice }} 天医币</text>
<text v-if="formatStats(item)" class="book-flag">{{ <text v-if="formatStats(item)" class="book-flag">{{
formatStats(item) formatStats(item)
}}</text> }}</text>
@@ -219,9 +219,13 @@ const vipInfo = ref<IVipInfo | null>(null)
* 获取VIP信息 * 获取VIP信息
*/ */
const getVipInfo = async () => { const getVipInfo = async () => {
const res = await homeApi.getVipInfo() try {
if (res.vipInfo) { const res = await homeApi.getVipInfo()
vipInfo.value = res.vipInfo if (res.vipInfo) {
vipInfo.value = res.vipInfo
}
} catch (error) {
console.error('获取VIP信息失败:', error)
} }
} }
@@ -229,17 +233,21 @@ const getVipInfo = async () => {
* 获取我的书单 * 获取我的书单
*/ */
const getMyBooks = async () => { const getMyBooks = async () => {
const res = await homeApi.getMyBooks(1, 10) try {
if (res && res.code === 0) { const res = await homeApi.getMyBooks(1, 10)
showMyBooks.value = true if (res && res.code === 0) {
if (res.page.records && res.page.records.length > 0) { showMyBooks.value = true
myBooksList.value = res.page.records if (res.page.records && res.page.records.length > 0) {
myBooksList.value = res.page.records
}
} else {
// 未登录,跳转到登录页
uni.navigateTo({
url: '/pages/login/login'
})
} }
} else { } catch (error) {
// 未登录,跳转到登录页 console.error('获取我的书单失败:', error)
uni.navigateTo({
url: '/pages/login/login'
})
} }
} }
@@ -247,9 +255,13 @@ const getMyBooks = async () => {
* 获取推荐图书 * 获取推荐图书
*/ */
const getRecommendBooks = async () => { const getRecommendBooks = async () => {
const res = await homeApi.getRecommendBooks() try {
if (res.books && res.books.length > 0) { const res = await homeApi.getRecommendBooks()
recommendBooksList.value = res.books if (res.books && res.books.length > 0) {
recommendBooksList.value = res.books
}
} catch (error) {
console.error('获取推荐图书失败:', error)
} }
} }
@@ -257,12 +269,16 @@ const getRecommendBooks = async () => {
* 获取活动标签列表 * 获取活动标签列表
*/ */
const getActivityLabels = async () => { const getActivityLabels = async () => {
const res = await homeApi.getBookLabelList(1) try {
showActivity.value = true const res = await homeApi.getBookLabelList(1)
if (res.lableList && res.lableList.length > 0) { showActivity.value = true
activityLabelList.value = res.lableList if (res.lableList && res.lableList.length > 0) {
// 默认加载第一个标签的图书列表 activityLabelList.value = res.lableList
await getBooksByLabel(res.lableList[0].id, 'activity') // 默认加载第一个标签的图书列表
await getBooksByLabel(res.lableList[0].id, 'activity')
}
} catch (error) {
console.error('获取活动标签失败:', error)
} }
} }
@@ -270,12 +286,16 @@ const getActivityLabels = async () => {
* 获取分类标签列表 * 获取分类标签列表
*/ */
const getCategoryLabels = async () => { const getCategoryLabels = async () => {
const res = await homeApi.getBookLabelList(0) try {
showCategory.value = true const res = await homeApi.getBookLabelList(0)
if (res.lableList && res.lableList.length > 0) { showCategory.value = true
categoryLevel1List.value = res.lableList if (res.lableList && res.lableList.length > 0) {
// 默认加载第一个标签的二级标签 categoryLevel1List.value = res.lableList
await getSubLabels(res.lableList[0].id, 0) // 默认加载第一个标签的二级标签
await getSubLabels(res.lableList[0].id, 0)
}
} catch (error) {
console.error('获取分类标签失败:', error)
} }
} }
@@ -283,17 +303,21 @@ const getCategoryLabels = async () => {
* 获取二级标签列表 * 获取二级标签列表
*/ */
const getSubLabels = async (pid: number, index: number) => { const getSubLabels = async (pid: number, index: number) => {
const res = await homeApi.getSubLabelList(pid) try {
currentLevel1Index.value = index const res = await homeApi.getSubLabelList(pid)
if (res.lableList && res.lableList.length > 0) { currentLevel1Index.value = index
categoryLevel2List.value = res.lableList if (res.lableList && res.lableList.length > 0) {
currentLevel2Index.value = 0 categoryLevel2List.value = res.lableList
// 加载第一个二级标签的图书列表 currentLevel2Index.value = 0
await getBooksByLabel(res.lableList[0].id, 'category') // 加载第一个二级标签的图书列表
} else { await getBooksByLabel(res.lableList[0].id, 'category')
// 没有二级标签,直接加载一级标签的图书列表 } else {
categoryLevel2List.value = [] // 没有二级标签,直接加载一级标签的图书列表
await getBooksByLabel(pid, 'category') categoryLevel2List.value = []
await getBooksByLabel(pid, 'category')
}
} catch (error) {
console.error('获取二级标签失败:', error)
} }
} }
@@ -304,19 +328,23 @@ const getBooksByLabel = async (
labelId: number, labelId: number,
type: 'activity' | 'category' type: 'activity' | 'category'
) => { ) => {
const res = await homeApi.getBooksByLabel(labelId) try {
if (type === 'activity') { const res = await homeApi.getBooksByLabel(labelId)
if (res.bookList && res.bookList.length > 0) { if (type === 'activity') {
activityList.value = res.bookList if (res.bookList && res.bookList.length > 0) {
activityList.value = res.bookList
} else {
activityList.value = []
}
} else { } else {
activityList.value = [] if (res.bookList && res.bookList.length > 0) {
} categoryBookList.value = res.bookList
} else { } else {
if (res.bookList && res.bookList.length > 0) { categoryBookList.value = []
categoryBookList.value = res.bookList }
} else {
categoryBookList.value = []
} }
} catch (error) {
console.error('获取图书列表失败:', error)
} }
} }

View File

@@ -117,20 +117,31 @@ function initScrollHeight() {
// 加载书籍信息 // 加载书籍信息
async function loadBookInfo() { async function loadBookInfo() {
const res = await bookApi.getBookInfo(bookId.value) try {
bookInfo.value = res.bookInfo const res = await bookApi.getBookInfo(bookId.value)
if (res.bookInfo) {
bookInfo.value = res.bookInfo
}
} catch (error) {
console.error('Failed to load book info:', error)
}
} }
// 加载章节列表 // 加载章节列表
async function loadChapterList() { async function loadChapterList() {
const res = await bookApi.getBookChapter({ try {
bookId: bookId.value const res = await bookApi.getBookChapter({
}) bookId: bookId.value
})
if (res.chapterList && res.chapterList.length > 0) {
chapterList.value = res.chapterList if (res.chapterList && res.chapterList.length > 0) {
} else { chapterList.value = res.chapterList
} else {
nullText.value = t('common.data_null')
}
} catch (error) {
nullText.value = t('common.data_null') nullText.value = t('common.data_null')
console.error('Failed to load chapter list:', error)
} }
} }

View File

@@ -245,8 +245,14 @@ function initAudioContext() {
// 加载书籍信息 // 加载书籍信息
async function loadBookInfo() { async function loadBookInfo() {
const res = await bookApi.getBookInfo(bookId.value) try {
bookInfo.value = res.bookInfo const res = await bookApi.getBookInfo(bookId.value)
if (res.bookInfo) {
bookInfo.value = res.bookInfo
}
} catch (error) {
console.error('Failed to load book info:', error)
}
} }
// 加载章节列表 // 加载章节列表

View File

@@ -164,9 +164,13 @@ function initScrollHeight() {
// 加载书籍信息 // 加载书籍信息
async function loadBookInfo() { async function loadBookInfo() {
const res = await bookApi.getBookInfo(bookId.value) try {
if (res.bookInfo) { const res = await bookApi.getBookInfo(bookId.value)
bookInfo.value = res.bookInfo if (res.bookInfo) {
bookInfo.value = res.bookInfo
}
} catch (error) {
console.error('Failed to load book info:', error)
} }
} }
@@ -176,15 +180,20 @@ async function loadComments() {
return return
} }
const res = await bookApi.getBookComments(bookId.value, page.value.current, page.value.limit) try {
const res = await bookApi.getBookComments(bookId.value, page.value.current, page.value.limit)
commentsCount.value = res.commentsCount || 0 commentsCount.value = res.commentsCount || 0
if (res.commentsTree && res.commentsTree.length > 0) { if (res.commentsTree && res.commentsTree.length > 0) {
commentList.value = [...commentList.value, ...res.commentsTree] commentList.value = [...commentList.value, ...res.commentsTree]
page.value.current += 1 page.value.current += 1
} else if (commentList.value.length === 0) { } else if (commentList.value.length === 0) {
nullText.value = t('common.data_null')
}
} catch (error) {
nullText.value = t('common.data_null') nullText.value = t('common.data_null')
console.error('Failed to load comments:', error)
} }
} }
@@ -266,29 +275,33 @@ function handleEmj(i: any) {
// 提交评论 // 提交评论
async function submitComment() { async function submitComment() {
const content = await getEditorContent() try {
const content = await getEditorContent()
if (!content || content === '<p><br></p>') {
uni.showToast({
title: t('bookDetails.enterText'),
icon: 'none'
})
return
}
const pid = replyTarget.value?.id || 0
await bookApi.insertComment(bookId.value, content, pid)
if (!content || content === '<p><br></p>') {
uni.showToast({ uni.showToast({
title: t('bookDetails.enterText'), title: t('workOrder.submit_success'),
icon: 'none' icon: 'success',
duration: 500
}) })
return
setTimeout(() => {
editorCtx.value?.clear()
resetComments()
}, 500)
} catch (error) {
console.error('Failed to submit comment:', error)
} }
const pid = replyTarget.value?.id || 0
await bookApi.insertComment(bookId.value, content, pid)
uni.showToast({
title: t('workOrder.submit_success'),
icon: 'success',
duration: 500
})
setTimeout(() => {
editorCtx.value?.clear()
resetComments()
}, 500)
} }
// 点赞/取消点赞 // 点赞/取消点赞
@@ -301,25 +314,29 @@ async function handleLike(comment: IComment) {
return return
} }
if (comment.isLike === 0) { try {
await bookApi.likeComment(comment.id) if (comment.isLike === 0) {
uni.showToast({ await bookApi.likeComment(comment.id)
title: t('bookDetails.supportSuccess'), uni.showToast({
icon: 'success', title: t('bookDetails.supportSuccess'),
duration: 1000 icon: 'success',
}) duration: 1000
} else { })
await bookApi.unlikeComment(comment.id) } else {
uni.showToast({ await bookApi.unlikeComment(comment.id)
title: t('bookDetails.supportCancel'), uni.showToast({
icon: 'success', title: t('bookDetails.supportCancel'),
duration: 1000 icon: 'success',
}) duration: 1000
})
}
setTimeout(() => {
resetComments()
}, 200)
} catch (error) {
console.error('Failed to like comment:', error)
} }
setTimeout(() => {
resetComments()
}, 200)
} }
// 删除评论 // 删除评论
@@ -331,16 +348,20 @@ function handleDelete(comment: IComment) {
confirmText: t('common.confirm_text'), confirmText: t('common.confirm_text'),
success: async (res) => { success: async (res) => {
if (res.confirm) { if (res.confirm) {
await bookApi.deleteComment(comment.id) try {
uni.showToast({ await bookApi.deleteComment(comment.id)
title: t('bookDetails.deleteSuccess'), uni.showToast({
icon: 'success', title: t('bookDetails.deleteSuccess'),
duration: 500 icon: 'success',
}) duration: 500
})
setTimeout(() => {
resetComments() setTimeout(() => {
}, 500) resetComments()
}, 500)
} catch (error) {
console.error('Failed to delete comment:', error)
}
} }
} }
}) })

View File

@@ -70,8 +70,14 @@ onLoad((options: any) => {
* 获取VIP信息 * 获取VIP信息
*/ */
const getVipInfo = async () => { const getVipInfo = async () => {
const res = await homeApi.getVipInfo() try {
vipInfo.value = res.vipInfo const res = await homeApi.getVipInfo()
if (res.vipInfo) {
vipInfo.value = res.vipInfo
}
} catch (error) {
console.error('获取VIP信息失败:', error)
}
} }
/** /**
@@ -85,19 +91,26 @@ const handleSearch = async () => {
loading.value = true loading.value = true
isEmpty.value = false isEmpty.value = false
const res = await homeApi.searchBooks({ try {
title: keyword.value.trim(), const res = await homeApi.searchBooks({
page: 1, title: keyword.value.trim(),
limit: 10, page: 1,
}) limit: 10,
if (res.bookList && res.bookList.length > 0) { })
searchResults.value = res.bookList if (res.bookList && res.bookList.length > 0) {
isEmpty.value = false searchResults.value = res.bookList
} else { isEmpty.value = false
} else {
searchResults.value = []
isEmpty.value = true
}
} catch (error) {
console.error('搜索失败:', error)
searchResults.value = [] searchResults.value = []
isEmpty.value = true isEmpty.value = true
} finally {
loading.value = false
} }
loading.value = false
} }
/** /**

View File

@@ -164,19 +164,23 @@ onLoad((options: any) => {
* 加载章节详情 * 加载章节详情
*/ */
const loadChapterDetail = async () => { const loadChapterDetail = async () => {
const res = await courseApi.getChapterDetail(chapterId.value) try {
if (res.code === 0 && res.data) { const res = await courseApi.getChapterDetail(chapterId.value)
chapterDetail.value = res.data.detail if (res.code === 0 && res.data) {
videoList.value = res.data.videos || [] chapterDetail.value = res.data.detail
videoList.value = res.data.videos || []
// 如果有历史播放记录,定位到对应视频 // 如果有历史播放记录,定位到对应视频
if (res.data.current) { if (res.data.current) {
const index = videoList.value.findIndex(v => v.id === res.data.current) const index = videoList.value.findIndex(v => v.id === res.data.current)
if (index !== -1) { if (index !== -1) {
currentVideoIndex.value = index currentVideoIndex.value = index
activeVideoIndex.value = index activeVideoIndex.value = index
}
} }
} }
} catch (error) {
console.error('加载章节详情失败:', error)
} }
} }

View File

@@ -257,25 +257,29 @@ const handleFirstLevelClick = (item: string) => {
* 获取课程分类数据 * 获取课程分类数据
*/ */
const getMedicalTags = async () => { const getMedicalTags = async () => {
const res = await courseSubjectClassificationApi.getCourseMedicalTree() try {
if (res && res.code === 0) { const res = await courseSubjectClassificationApi.getCourseMedicalTree()
if (res.labels && res.labels.length > 0) { if (res && res.code === 0) {
curseTagList.value = res.labels if (res.labels && res.labels.length > 0) {
// 根据 currentIndex 设置初始选中的分类 curseTagList.value = res.labels
if (res.labels[currentIndex.value]) { // 根据 currentIndex 设置初始选中的分类
const selectedTag = res.labels[currentIndex.value] if (res.labels[currentIndex.value]) {
if (selectedTag.isLast === 0) { const selectedTag = res.labels[currentIndex.value]
// 非终极分类,显示子分类 if (selectedTag.isLast === 0) {
if (selectedTag.children && selectedTag.children.length > 0) { // 非终极分类,显示子分类
sbuMedicalTagsList.value = selectedTag.children if (selectedTag.children && selectedTag.children.length > 0) {
} else { sbuMedicalTagsList.value = selectedTag.children
sbuMedicalTagsList.value = [] } else {
sbuMedicalTagsList.value = []
}
} }
} }
} else {
curseTagList.value = []
} }
} else {
curseTagList.value = []
} }
} catch (error) {
console.error('获取医学课程分类失败:', error)
} }
} }
/** /**
@@ -305,9 +309,13 @@ const curseClick = (item: IMedicalTag, index: number) => {
*/ */
const soulCateList = ref<IMedicalTag[]>([]) const soulCateList = ref<IMedicalTag[]>([])
const getSoulCateList = async () => { const getSoulCateList = async () => {
const res = await courseSubjectClassificationApi.getCourseSoulTree() try {
if (res.labels&&res.labels.length>0) { const res = await courseSubjectClassificationApi.getCourseSoulTree()
soulCateList.value = res.labels; if (res.labels&&res.labels.length>0) {
soulCateList.value = res.labels;
}
} catch (error) {
console.error('获取心理学课程分类失败:', error)
} }
} }
@@ -317,9 +325,13 @@ const getSoulCateList = async () => {
*/ */
const sociologyCateList = ref<IMedicalTag[]>([]) const sociologyCateList = ref<IMedicalTag[]>([])
const getSociologyCateList = async () => { const getSociologyCateList = async () => {
const res = await courseSubjectClassificationApi.getCourseSociologyTree() try {
if (res.labels&&res.labels.length>0) { const res = await courseSubjectClassificationApi.getCourseSociologyTree()
sociologyCateList.value = res.labels; if (res.labels&&res.labels.length>0) {
sociologyCateList.value = res.labels;
}
} catch (error) {
console.error('获取国学课程分类失败:', error)
} }
} }
@@ -357,13 +369,17 @@ const learnList = ref<ICourse[]>([]) // 观看记录列表
* 获取观看记录 * 获取观看记录
*/ */
const getLearnCourse = async () => { const getLearnCourse = async () => {
const res = await courseApi.getUserLateCourseList() try {
if (res && res.code === 0) { const res = await courseApi.getUserLateCourseList()
if (res.page && res.page.length > 0) { if (res && res.code === 0) {
learnList.value = res.page if (res.page && res.page.length > 0) {
} else { learnList.value = res.page
learnList.value = [] } else {
learnList.value = []
}
} }
} catch (error) {
console.error('获取观看记录失败:', error)
} }
} }
@@ -373,13 +389,17 @@ const newsList = ref<INews[]>([]) // 新闻列表
* 获取新闻列表 * 获取新闻列表
*/ */
const getNewsList = async () => { const getNewsList = async () => {
const res = await commonApi.getMessageList(0, 1, 0) try {
if (res && res.code === 0) { const res = await commonApi.getMessageList(0, 1, 0)
if (res.messages && res.messages.length > 0) { if (res && res.code === 0) {
newsList.value = res.messages if (res.messages && res.messages.length > 0) {
} else { newsList.value = res.messages
newsList.value = [] } else {
newsList.value = []
}
} }
} catch (error) {
console.error('获取新闻列表失败:', error)
} }
} }
/** /**
@@ -403,17 +423,21 @@ const tryListenList = ref<ICourse[]>([]) // 试听课程列表
* 获取试听课程列表 * 获取试听课程列表
*/ */
const getTryListenList = async () => { const getTryListenList = async () => {
const res = await courseApi.getMarketCourseList({ try {
page: 1, const res = await courseApi.getMarketCourseList({
limit: 6, page: 1,
id: 1 limit: 6,
}) id: 1
if (res && res.code === 0) { })
if (res.courseList && res.courseList.records && res.courseList.records.length > 0) { if (res && res.code === 0) {
tryListenList.value = res.courseList.records if (res.courseList && res.courseList.records && res.courseList.records.length > 0) {
} else { tryListenList.value = res.courseList.records
tryListenList.value = [] } else {
tryListenList.value = []
}
} }
} catch (error) {
console.error('获取试听课程失败:', error)
} }
} }

View File

@@ -52,26 +52,30 @@ const subCategoryList = ref<ICategory[]>([]) // 子级分类列表
* 获取分类下的子级分类 * 获取分类下的子级分类
*/ */
const getSubCategoryList = async () => { const getSubCategoryList = async () => {
let res: any = null try {
switch (subject.value) { let res: any = null
case '医学': switch (subject.value) {
res = await courseSubjectClassificationApi.getCourseMedicalChildLabels(categoryId.value) case '医学':
break res = await courseSubjectClassificationApi.getCourseMedicalChildLabels(categoryId.value)
case '心理学': break
res = await courseSubjectClassificationApi.getCourseSoulChildLabels(categoryId.value) case '心理学':
break res = await courseSubjectClassificationApi.getCourseSoulChildLabels(categoryId.value)
} break
if (res && res.code === 0) {
if (res.labels && res.labels.length > 0) {
subCategoryList.value = res.labels
// 默认选中第一个tab
tab_category_id.value = res.labels[0].id
radio_category_id.value = res.labels[0].children[0] && res.labels[0].children[0].id || 0
} else {
subCategoryList.value = []
tab_category_id.value = 0
radio_category_id.value = 0
} }
if (res && res.code === 0) {
if (res.labels && res.labels.length > 0) {
subCategoryList.value = res.labels
// 默认选中第一个tab
tab_category_id.value = res.labels[0].id
radio_category_id.value = res.labels[0].children[0] && res.labels[0].children[0].id || 0
} else {
subCategoryList.value = []
tab_category_id.value = 0
radio_category_id.value = 0
}
}
} catch (error) {
console.error('获取分类下的子级分类失败:', error)
} }
} }

View File

@@ -191,12 +191,16 @@ const getCode = async () => {
if (!isEmailEmpty()) return if (!isEmailEmpty()) return
if (!isEmailVerified(email.value)) return if (!isEmailVerified(email.value)) return
await commonApi.sendMailCaptcha(email.value) try {
uni.showToast({ await commonApi.sendMailCaptcha(email.value)
title: t('login.sendCodeSuccess'), uni.showToast({
icon: 'none' title: t('login.sendCodeSuccess'),
}) icon: 'none'
getCodeState() })
getCodeState()
} catch (error) {
console.error('Send code error:', error)
}
} }
/** /**
@@ -260,16 +264,20 @@ const onSubmit = async () => {
if (!isConfirmPasswordEmpty()) return if (!isConfirmPasswordEmpty()) return
if (!isPasswordMatch()) return if (!isPasswordMatch()) return
await resetPassword(email.value, code.value, password.value) try {
await resetPassword(email.value, code.value, password.value)
uni.showModal({ uni.showModal({
title: t('global.tips'), title: t('global.tips'),
content: t('forget.passwordChanged'), content: t('forget.passwordChanged'),
showCancel: false, showCancel: false,
success: () => { success: () => {
uni.navigateBack() uni.navigateBack()
} }
}) })
} catch (error) {
console.error('Reset password error:', error)
}
} }
</script> </script>

View File

@@ -285,8 +285,13 @@ const verifyCodeLogin = async () => {
if (!isCodeEmpty()) return false if (!isCodeEmpty()) return false
const res = await loginWithCode(email.value, code.value) try {
return res || null const res = await loginWithCode(email.value, code.value)
return res
} catch (error) {
console.error('验证码登录失败:', error)
return null
}
} }
// 密码登录 // 密码登录
const passwordLogin = async () => { const passwordLogin = async () => {
@@ -296,8 +301,13 @@ const passwordLogin = async () => {
if (!isPasswordEmpty()) return false if (!isPasswordEmpty()) return false
const res = await loginWithPassword(phoneEmail.value, password.value) try {
return res || null const res = await loginWithPassword(phoneEmail.value, password.value)
return res
} catch (error) {
console.error('密码登录失败:', error)
return null
}
} }
// 提交登录 // 提交登录
const onSubmit = async () => { const onSubmit = async () => {

View File

@@ -26,8 +26,28 @@
<!-- 商品信息 --> <!-- 商品信息 -->
<view class="goods-info"> <view class="goods-info">
<text class="goods-name">{{ item.productName }}</text> <text class="goods-name">{{ item.productName }}</text>
<!-- 商品价格组件 -->
<GoodsPrice :goods="item" /> <!-- 价格信息 -->
<view class="price-info">
<!-- VIP优惠价 -->
<!-- <view v-if="item.isVipPrice === 1 && item.vipPrice" class="price-row">
<text class="vip-price">{{ item.vipPrice.toFixed(2) }}</text>
<text class="vip-label">{{ $t('order.vipPriceLabel') }}</text>
<text class="original-price">{{ item.price.toFixed(2) }}</text>
</view> -->
<!-- 活动价 -->
<!-- <view v-else-if="item.activityPrice && item.activityPrice > 0" class="price-row">
<text class="activity-price">{{ item.activityPrice.toFixed(2) }}</text>
<text class="activity-label">{{ $t('order.activityLabel') }}</text>
<text class="original-price">{{ item.price.toFixed(2) }}</text>
</view> -->
<!-- 普通价格 -->
<view class="price-row">
<text class="normal-price">{{ item.price.toFixed(2) }} 天医币</text>
</view>
</view>
<!-- 数量 --> <!-- 数量 -->
<!-- <view class="quantity-row"> <!-- <view class="quantity-row">
@@ -49,20 +69,25 @@
</template> </template>
<script lang="ts" setup> <script lang="ts" setup>
import { ref } from 'vue' import { ref, computed } from 'vue'
import { onLoad } from '@dcloudio/uni-app' import { onLoad } from '@dcloudio/uni-app'
import { orderApi } from '@/api/modules/order' import { orderApi } from '@/api/modules/order'
import type { IOrderGoods } from '@/types/order'
import Confirm from '@/components/order/Confirm.vue'; import Confirm from '@/components/order/Confirm.vue';
import GoodsPrice from '@/components/order/GoodsPrice.vue'; import type { IOrderGoods } from '@/types/order'
/** /**
* 获取用户信息 * 获取用户信息
*/ */
const userInfo = ref({}) const userInfo = ref(null)
const getUserInfo = async () => { const getUserInfo = async () => {
const res = await orderApi.getUserInfo() try {
userInfo.value = res.result || {} const res = await orderApi.getUserInfo()
if (res.code === 0) {
userInfo.value = res.result || {}
}
} catch (error) {
console.error('获取用户信息失败:', error)
}
} }
/** /**
@@ -71,11 +96,15 @@ const getUserInfo = async () => {
const goodsIds = ref<string>('') const goodsIds = ref<string>('')
const goodsList = ref<IOrderGoods[]>([]) const goodsList = ref<IOrderGoods[]>([])
const getGoodsList = async () => { const getGoodsList = async () => {
// 获取商品详情 try {
const res = await orderApi.getShopProductListByIds(goodsIds.value) // 获取商品详情
const res = await orderApi.getShopProductListByIds(goodsIds.value)
if (res.shopProductList?.length > 0) {
goodsList.value = res.shopProductList if (res.code === 0 && res.shopProductList?.length > 0) {
goodsList.value = res.shopProductList
}
} catch (error) {
console.error('获取商品列表失败:', error)
} }
} }
@@ -152,6 +181,43 @@ onLoad(async (options: any) => {
overflow: hidden; overflow: hidden;
} }
.price-info {
.price-row {
display: flex;
align-items: baseline;
gap: 10rpx;
.vip-price,
.activity-price {
font-size: 32rpx;
font-weight: bold;
color: #e97512;
}
.normal-price {
font-size: 32rpx;
font-weight: bold;
color: #333;
}
.vip-label {
font-size: 22rpx;
color: #fa2d12;
}
.activity-label {
font-size: 22rpx;
color: #613804;
}
.original-price {
font-size: 24rpx;
color: #999;
text-decoration: line-through;
}
}
}
.quantity-row { .quantity-row {
display: flex; display: flex;
align-items: center; align-items: center;

View File

@@ -27,7 +27,7 @@
<ProductInfo v-if="order.orderType === 'abroadBook'" :data="order.bookEntity" :type="order.orderType" /> <ProductInfo v-if="order.orderType === 'abroadBook'" :data="order.bookEntity" :type="order.orderType" />
<ProductInfo v-if="order.orderType === 'vip'" :data="order.vipBuyConfigEntity" :type="order.orderType" /> <ProductInfo v-if="order.orderType === 'vip'" :data="order.vipBuyConfigEntity" :type="order.orderType" />
<!-- 三种订单类型商品信息 end --> <!-- 三种订单类型商品信息 end -->
<view class="order-item-total-price">实付款{{ order.orderMoney }} {{ t('global.coin') }}</view> <view class="order-item-total-price">实付款{{ order.orderMoney }} 天医币</view>
<template #footer> <template #footer>
<view> <view>

View File

@@ -199,10 +199,14 @@ const avatarUrl = ref('')
*/ */
const userInfo = ref<any>({}) // 用户信息 const userInfo = ref<any>({}) // 用户信息
const getData = async () => { const getData = async () => {
const res = await getUserInfo() try {
if (res.result) { const res = await getUserInfo()
userStore.setUserInfo(res.result) if (res.result) {
userInfo.value = res.result userStore.setUserInfo(res.result)
userInfo.value = res.result
}
} catch (error) {
console.error('获取用户信息失败:', error)
} }
} }
@@ -320,12 +324,16 @@ const sendCode = async () => {
return return
} }
await sendEmailCode(editForm.value.email) try {
uni.showToast({ await sendEmailCode(editForm.value.email)
title: t('user.sendCodeSuccess'), uni.showToast({
icon: 'none' title: t('user.sendCodeSuccess'),
}) icon: 'none'
startCountdown() })
startCountdown()
} catch (error) {
console.error('发送验证码失败:', error)
}
} }
/** /**
@@ -390,88 +398,92 @@ const checkPasswordStrength = () => {
const handleSubmit = async () => { const handleSubmit = async () => {
const key = currentField.value?.key const key = currentField.value?.key
// 构建更新数据对象 try {
let updateData: any = Object.assign({}, userInfo.value) // 构建更新数据对象
let updateData: any = Object.assign({}, userInfo.value)
switch (key) { switch (key) {
case 'email': case 'email':
// 更新邮箱 // 更新邮箱
if (!editForm.value.email || !editForm.value.code) { if (!editForm.value.email || !editForm.value.code) {
uni.showToast({ uni.showToast({
title: t('user.pleaseInputCode'), title: t('user.pleaseInputCode'),
icon: 'none' icon: 'none'
}) })
return return
} }
await updateEmail(userInfo.value.id, editForm.value.email, editForm.value.code) await updateEmail(userInfo.value.id, editForm.value.email, editForm.value.code)
break break
case 'password': case 'password':
// 更新密码 // 更新密码
if (!passwordOk.value) { if (!passwordOk.value) {
uni.showToast({ uni.showToast({
title: passwordNote.value, title: passwordNote.value,
icon: 'none' icon: 'none'
}) })
return return
} }
if (editForm.value.password !== editForm.value.confirmPassword) { if (editForm.value.password !== editForm.value.confirmPassword) {
uni.showToast({ uni.showToast({
title: t('user.passwordNotMatch'), title: t('user.passwordNotMatch'),
icon: 'none' icon: 'none'
}) })
return return
} }
await updatePassword(userInfo.value.id, editForm.value.password) await updatePassword(userInfo.value.id, editForm.value.password)
break break
case 'avatar': case 'avatar':
// 更新头像 // 更新头像
console.log('avatarUrl.value:', avatarUrl.value) console.log('avatarUrl.value:', avatarUrl.value)
if (!avatarUrl.value) { if (!avatarUrl.value) {
uni.showToast({ uni.showToast({
title: t('common.pleaseSelect') + t('user.avatar'), title: t('common.pleaseSelect') + t('user.avatar'),
icon: 'none' icon: 'none'
}) })
return return
} }
// 如果是新上传的图片,需要先上传 // 如果是新上传的图片,需要先上传
updateData.avatar = avatarUrl.value updateData.avatar = avatarUrl.value
await updateUserInfo(updateData) await updateUserInfo(updateData)
break break
case 'sex': case 'sex':
// 更新性别 // 更新性别
updateData.sex = editValue.value updateData.sex = editValue.value
await updateUserInfo(updateData) await updateUserInfo(updateData)
break break
default: default:
// 更新其他字段 // 更新其他字段
if (!editValue.value) { if (!editValue.value) {
uni.showToast({ uni.showToast({
title: getPlaceholder(key), title: getPlaceholder(key),
icon: 'none' icon: 'none'
}) })
return return
} }
updateData[key] = editValue.value updateData[key] = editValue.value
await updateUserInfo(updateData) await updateUserInfo(updateData)
break break
}
uni.showToast({
title: t('user.updateSuccess'),
icon: 'success'
})
closeModal()
// 刷新数据
setTimeout(() => {
getData()
}, 500)
} catch (error) {
console.error('更新失败:', error)
} }
uni.showToast({
title: t('user.updateSuccess'),
icon: 'success'
})
closeModal()
// 刷新数据
setTimeout(() => {
getData()
}, 500)
} }
/** /**

View File

@@ -9,7 +9,7 @@
:class="aloneItem.priceTypeId === item.priceTypeId ? 'selected' : ''" :class="aloneItem.priceTypeId === item.priceTypeId ? 'selected' : ''"
v-for="item in rechargeList.bookBuyConfigList" :key="item.priceTypeId"> v-for="item in rechargeList.bookBuyConfigList" :key="item.priceTypeId">
<view class="recharge_money">{{item.money}}</view> <view class="recharge_money">{{item.money}}</view>
<view>{{item.realMoney}}{{ t('global.coin') }}</view> <view>{{item.realMoney}}{{$t('order.virtualCoin')}}</view>
<!-- 红框位置的618活动标签 --> <!-- 红框位置的618活动标签 -->
<!-- <view class="activity-tag">618活动</view> --> <!-- <view class="activity-tag">618活动</view> -->
<span class="activity-label" v-if="item.givejf >0">618充值活动</span> <span class="activity-label" v-if="item.givejf >0">618充值活动</span>