Compare commits
14 Commits
f70fc65c24
...
master
| Author | SHA1 | Date | |
|---|---|---|---|
| 9f19842054 | |||
| 38c4519e79 | |||
| 3b596e0a70 | |||
| b513979995 | |||
| ee5431e57a | |||
| 64abd3d4ab | |||
| 3da220526b | |||
| d209c05a18 | |||
| 21a3335939 | |||
| cbc48b8193 | |||
| 574644349c | |||
| 2ccd53ab94 | |||
| 277b6cf0b6 | |||
| 26cef66e82 |
@@ -7,8 +7,8 @@ export const ENV = process.env.NODE_ENV || 'development';
|
||||
*/
|
||||
const BASE_URL_MAP = {
|
||||
development: {
|
||||
//MAIN: 'http://192.168.110.100:9300/pb/', // 张川川
|
||||
MAIN: 'https://global.nuttyreading.com/', // 线上
|
||||
MAIN: 'http://192.168.110.100:9300/pb/', // 张川川
|
||||
// MAIN: 'https://global.nuttyreading.com/', // 线上
|
||||
// PAYMENT: 'https://dev-pay.example.com', // 暂时用不到
|
||||
// CDN: 'https://cdn-dev.example.com', // 暂时用不到
|
||||
},
|
||||
|
||||
@@ -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') {
|
||||
try {
|
||||
httpData = JSON.parse(httpData);
|
||||
@@ -44,20 +44,19 @@ export function responseInterceptor(res: UniApp.RequestSuccessCallbackResult) {
|
||||
}
|
||||
|
||||
// 规范化 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 IApiResponse).success === true || code === 0;
|
||||
// 成功判断:与原项目一致的条件
|
||||
const successFlag = (httpData as any).success === true || (httpData as any).code === 0;
|
||||
|
||||
if (successFlag) {
|
||||
// 返回原始 httpData
|
||||
// 实际数据每个接口不同,调用者需根据实际情况取 .data 字段
|
||||
// 返回原始 httpData(与原项目 dataFactory 返回 Promise.resolve(httpData) 保持一致)
|
||||
// 但大多数调用者更关心 data 字段,这里返回整个 httpData,调用者可取 .data
|
||||
return Promise.resolve(httpData);
|
||||
}
|
||||
|
||||
// 登录失效或需要强制登录的一些 code
|
||||
// 登录失效或需要强制登录的一些 code(与原项目一致)
|
||||
const code = (httpData as any).code;
|
||||
if (code === '401' || code === 401) {
|
||||
// 触发登出流程
|
||||
handleAuthExpired();
|
||||
@@ -65,7 +64,7 @@ export function responseInterceptor(res: UniApp.RequestSuccessCallbackResult) {
|
||||
}
|
||||
|
||||
// 原项目还将 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();
|
||||
return Promise.reject({ statusCode: 0, errMsg: message || t('global.loginExpired'), data: httpData });
|
||||
}
|
||||
|
||||
@@ -1,14 +1,14 @@
|
||||
// api/modules/user.ts
|
||||
import { mainClient } from '@/api/clients/main'
|
||||
import type { IApiResponse } from '@/api/types'
|
||||
import type {
|
||||
IUserInfo,
|
||||
IVipInfo,
|
||||
IOrder,
|
||||
IVipPackage,
|
||||
ITransaction,
|
||||
IFeedbackForm,
|
||||
IPageData
|
||||
import type {
|
||||
IUserInfo,
|
||||
IVipInfo,
|
||||
IOrder,
|
||||
IVipPackage,
|
||||
ITransaction,
|
||||
IFeedbackForm,
|
||||
IPageData
|
||||
} from '@/types/user'
|
||||
import { SERVICE_MAP } from '@/api/config'
|
||||
|
||||
@@ -16,22 +16,22 @@ import { SERVICE_MAP } from '@/api/config'
|
||||
* 获取用户信息
|
||||
*/
|
||||
export async function getUserInfo() {
|
||||
const res = await mainClient.request<IApiResponse<{ user : IUserInfo }>>({
|
||||
url: 'common/user/getUserInfo',
|
||||
method: 'POST'
|
||||
})
|
||||
return res
|
||||
const res = await mainClient.request<IApiResponse<{ user: IUserInfo }>>({
|
||||
url: 'common/user/getUserInfo',
|
||||
method: 'POST'
|
||||
})
|
||||
return res
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取VIP信息
|
||||
*/
|
||||
export async function getVipInfo() {
|
||||
const res = await mainClient.request<IApiResponse<{ vipInfo : IVipInfo }>>({
|
||||
url: 'bookAbroad/home/getVipInfo',
|
||||
method: 'POST'
|
||||
})
|
||||
return res
|
||||
const res = await mainClient.request<IApiResponse<{ vipInfo: IVipInfo }>>({
|
||||
url: 'bookAbroad/home/getVipInfo',
|
||||
method: 'POST'
|
||||
})
|
||||
return res
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -39,64 +39,64 @@ export async function getVipInfo() {
|
||||
* @param current 当前页码
|
||||
* @param limit 每页数量
|
||||
*/
|
||||
export async function getOrderList(page : number, limit : number, orderStatus : string) {
|
||||
const res = await mainClient.request<IApiResponse<{ orders : IPageData<IOrder> }>>({
|
||||
url: 'common/buyOrder/commonBuyOrderList',
|
||||
method: 'POST',
|
||||
data: { page, limit, orderStatus, come: '10', userId: uni.getStorageSync('userInfo').id }
|
||||
})
|
||||
return res
|
||||
export async function getOrderList(page: number, limit: number, orderStatus: string) {
|
||||
const res = await mainClient.request<IApiResponse<{ orders: IPageData<IOrder> }>>({
|
||||
url: 'common/buyOrder/commonBuyOrderList',
|
||||
method: 'POST',
|
||||
data: { page, limit, orderStatus, come: '10', userId: uni.getStorageSync('userInfo').id }
|
||||
})
|
||||
return res
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取VIP套餐列表
|
||||
*/
|
||||
export async function getVipPackages() {
|
||||
const res = await mainClient.request<IApiResponse<{ sysDictDatas : IVipPackage[] }>>({
|
||||
url: 'book/sysdictdata/getData',
|
||||
method: 'POST',
|
||||
data: { dictLabel: 'googleVip' }
|
||||
})
|
||||
return res
|
||||
const res = await mainClient.request<IApiResponse<{ sysDictDatas: IVipPackage[] }>>({
|
||||
url: 'book/sysdictdata/getData',
|
||||
method: 'POST',
|
||||
data: { dictLabel: 'googleVip' }
|
||||
})
|
||||
return res
|
||||
}
|
||||
|
||||
/**
|
||||
* 创建订单
|
||||
* @param data 订单数据
|
||||
*/
|
||||
export async function createOrder(data : any) {
|
||||
const res = await mainClient.request<IApiResponse<{ orderSn : string }>>({
|
||||
url: 'bookAbroad/order/placeOrder',
|
||||
method: 'POST',
|
||||
data
|
||||
})
|
||||
return res
|
||||
export async function createOrder(data: any) {
|
||||
const res = await mainClient.request<IApiResponse<{ orderSn: string }>>({
|
||||
url: 'bookAbroad/order/placeOrder',
|
||||
method: 'POST',
|
||||
data
|
||||
})
|
||||
return res
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取交易记录列表
|
||||
* @param userId 用户ID
|
||||
*/
|
||||
export async function getTransactionList(userId : number) {
|
||||
const res = await mainClient.request<IApiResponse<{ transactionDetailsList : ITransaction[] }>>({
|
||||
url: 'common/transactionDetails/getTransactionDetailsList',
|
||||
method: 'POST',
|
||||
data: { userId }
|
||||
})
|
||||
return res
|
||||
export async function getTransactionList(userId: number) {
|
||||
const res = await mainClient.request<IApiResponse<{ transactionDetailsList: ITransaction[] }>>({
|
||||
url: 'common/transactionDetails/getTransactionDetailsList',
|
||||
method: 'POST',
|
||||
data: { userId }
|
||||
})
|
||||
return res
|
||||
}
|
||||
|
||||
/**
|
||||
* 更新用户基本信息
|
||||
* @param data 用户信息
|
||||
*/
|
||||
export async function updateUserInfo(data : Partial<IUserInfo>) {
|
||||
const res = await mainClient.request<IApiResponse>({
|
||||
url: 'book/user/update',
|
||||
method: 'POST',
|
||||
data
|
||||
})
|
||||
return res
|
||||
export async function updateUserInfo(data: Partial<IUserInfo>) {
|
||||
const res = await mainClient.request<IApiResponse>({
|
||||
url: 'book/user/update',
|
||||
method: 'POST',
|
||||
data
|
||||
})
|
||||
return res
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -105,13 +105,13 @@ export async function updateUserInfo(data : Partial<IUserInfo>) {
|
||||
* @param email 邮箱地址
|
||||
* @param code 验证码
|
||||
*/
|
||||
export async function updateEmail(id : number, email : string, code : string) {
|
||||
const res = await mainClient.request<IApiResponse>({
|
||||
url: 'common/user/updateUserEmail',
|
||||
method: 'POST',
|
||||
data: { id, email, code }
|
||||
})
|
||||
return res
|
||||
export async function updateEmail(id: number, email: string, code: string) {
|
||||
const res = await mainClient.request<IApiResponse>({
|
||||
url: 'common/user/updateUserEmail',
|
||||
method: 'POST',
|
||||
data: { id, email, code }
|
||||
})
|
||||
return res
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -119,32 +119,32 @@ export async function updateEmail(id : number, email : string, code : string) {
|
||||
* @param id 用户ID
|
||||
* @param password 新密码
|
||||
*/
|
||||
export async function updatePassword(id : number, password : string) {
|
||||
const res = await mainClient.request<IApiResponse>({
|
||||
url: 'common/user/setPasswordById',
|
||||
method: 'POST',
|
||||
headers: {
|
||||
'Content-Type': 'application/x-www-form-urlencoded',
|
||||
},
|
||||
data: { id, password }
|
||||
})
|
||||
return res
|
||||
export async function updatePassword(id: number, password: string) {
|
||||
const res = await mainClient.request<IApiResponse>({
|
||||
url: 'common/user/setPasswordById',
|
||||
method: 'POST',
|
||||
headers: {
|
||||
'Content-Type': 'application/x-www-form-urlencoded',
|
||||
},
|
||||
data: { id, password }
|
||||
})
|
||||
return res
|
||||
}
|
||||
|
||||
/**
|
||||
* 发送邮箱验证码
|
||||
* @param email 邮箱地址
|
||||
*/
|
||||
export async function sendEmailCode(email : string) {
|
||||
const res = await mainClient.request<IApiResponse>({
|
||||
url: 'common/user/getMailCaptcha',
|
||||
method: 'POST',
|
||||
headers: {
|
||||
'Content-Type': 'application/x-www-form-urlencoded',
|
||||
},
|
||||
data: { email }
|
||||
})
|
||||
return res
|
||||
export async function sendEmailCode(email: string) {
|
||||
const res = await mainClient.request<IApiResponse>({
|
||||
url: 'common/user/getMailCaptcha',
|
||||
method: 'POST',
|
||||
headers: {
|
||||
'Content-Type': 'application/x-www-form-urlencoded',
|
||||
},
|
||||
data: { email }
|
||||
})
|
||||
return res
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -152,40 +152,40 @@ export async function sendEmailCode(email : string) {
|
||||
* @param filePath 本地文件路径
|
||||
* @returns 图片URL
|
||||
*/
|
||||
export function uploadImage(filePath : string) : Promise<string> {
|
||||
return new Promise((resolve, reject) => {
|
||||
uni.uploadFile({
|
||||
url: `${SERVICE_MAP.MAIN}oss/fileoss`,
|
||||
filePath,
|
||||
name: 'file',
|
||||
success: (res) => {
|
||||
try {
|
||||
const data = JSON.parse(res.data)
|
||||
if (data.url) {
|
||||
resolve(data.url)
|
||||
} else {
|
||||
reject(new Error('上传失败'))
|
||||
}
|
||||
} catch (error) {
|
||||
reject(error)
|
||||
}
|
||||
},
|
||||
fail: reject
|
||||
})
|
||||
})
|
||||
export function uploadImage(filePath: string): Promise<string> {
|
||||
return new Promise((resolve, reject) => {
|
||||
uni.uploadFile({
|
||||
url: `${SERVICE_MAP.MAIN}oss/fileoss`,
|
||||
filePath,
|
||||
name: 'file',
|
||||
success: (res) => {
|
||||
try {
|
||||
const data = JSON.parse(res.data)
|
||||
if (data.url) {
|
||||
resolve(data.url)
|
||||
} else {
|
||||
reject(new Error('上传失败'))
|
||||
}
|
||||
} catch (error) {
|
||||
reject(error)
|
||||
}
|
||||
},
|
||||
fail: reject
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
/**
|
||||
* 提交问题反馈
|
||||
* @param data 反馈表单数据
|
||||
*/
|
||||
export async function submitFeedback(data : IFeedbackForm) {
|
||||
const res = await mainClient.request<IApiResponse>({
|
||||
url: 'common/sysFeedback/addSysFeedback',
|
||||
method: 'POST',
|
||||
data
|
||||
})
|
||||
return res
|
||||
export async function submitFeedback(data: IFeedbackForm) {
|
||||
const res = await mainClient.request<IApiResponse>({
|
||||
url: 'common/sysFeedback/addSysFeedback',
|
||||
method: 'POST',
|
||||
data
|
||||
})
|
||||
return res
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -194,27 +194,26 @@ export async function submitFeedback(data : IFeedbackForm) {
|
||||
* @param orderSn 订单号
|
||||
* @param productId 产品ID
|
||||
*/
|
||||
export async function verifyGooglePay(productId : number, purchaseToken : string, orderSn : string) {
|
||||
console.log(productId, purchaseToken, orderSn);
|
||||
const res = await mainClient.request<IApiResponse>({
|
||||
url: 'pay/googlepay/googleVerify',
|
||||
method: 'POST',
|
||||
data: { productId, purchaseToken, orderSn }
|
||||
})
|
||||
return res
|
||||
export async function verifyGooglePay(purchaseToken: string, orderSn: string, productId: string) {
|
||||
const res = await mainClient.request<IApiResponse>({
|
||||
url: 'pay/googlepay/googleVerify',
|
||||
method: 'POST',
|
||||
data: { purchaseToken, orderSn, productId }
|
||||
})
|
||||
return res
|
||||
}
|
||||
|
||||
/**
|
||||
* 验证IAP支付
|
||||
* @param data 支付数据
|
||||
*/
|
||||
export async function verifyIAP(data : any) {
|
||||
const res = await mainClient.request<IApiResponse>({
|
||||
url: 'Ipa/veri',
|
||||
method: 'POST',
|
||||
data
|
||||
})
|
||||
return res
|
||||
export async function verifyIAP(data: any) {
|
||||
const res = await mainClient.request<IApiResponse>({
|
||||
url: 'Ipa/veri',
|
||||
method: 'POST',
|
||||
data
|
||||
})
|
||||
return res
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -222,80 +221,48 @@ export async function verifyIAP(data : any) {
|
||||
* @param type 固定值 point
|
||||
* @param qudao 支付类型
|
||||
*/
|
||||
export async function getBookBuyConfigList(type : string, qudao : string) {
|
||||
const res = await mainClient.request<IApiResponse>({
|
||||
url: 'common/bookBuyConfig/getBookBuyConfigList',
|
||||
method: 'POST',
|
||||
data: { type, qudao }
|
||||
})
|
||||
return res
|
||||
export async function getBookBuyConfigList(type: string, qudao: string) {
|
||||
const res = await mainClient.request<IApiResponse>({
|
||||
url: 'common/bookBuyConfig/getBookBuyConfigList',
|
||||
method: 'POST',
|
||||
data: {type, qudao}
|
||||
})
|
||||
return res
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取隐私协议
|
||||
* @param id 101众妙之门隐私政策
|
||||
*/
|
||||
export async function getAgreement(id : string) {
|
||||
export async function getAgreement(id: string) {
|
||||
console.log(id, 'id');
|
||||
const res = await mainClient.request<IApiResponse>({
|
||||
url: '/sys/agreement/getAgreement',
|
||||
method: 'POST',
|
||||
data: { id }
|
||||
})
|
||||
return res
|
||||
const res = await mainClient.request<IApiResponse>({
|
||||
url: '/sys/agreement/getAgreement',
|
||||
method: 'POST',
|
||||
data: {id}
|
||||
})
|
||||
return res
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取活动说明
|
||||
*/
|
||||
export async function getActivityDescription() {
|
||||
const res = await mainClient.request<IApiResponse>({
|
||||
url: 'common/bookBuyConfig/getRechargeActivity',
|
||||
method: 'POST'
|
||||
})
|
||||
return res
|
||||
const res = await mainClient.request<IApiResponse>({
|
||||
url: 'common/bookBuyConfig/getRechargeActivity',
|
||||
method: 'POST'
|
||||
})
|
||||
return res
|
||||
}
|
||||
|
||||
/**
|
||||
* 充值记录列表
|
||||
* @param current 当前页码
|
||||
* @param limit 每页数量
|
||||
* @param userId 用户id
|
||||
* @return
|
||||
*/
|
||||
export async function getTransactionDetailsList(current : number, limit : number, userId : string) {
|
||||
const res = await mainClient.request<IApiResponse>({
|
||||
url: 'common/transactionDetails/getTransactionDetailsList',
|
||||
method: 'POST',
|
||||
data: { current, limit, userId, }
|
||||
})
|
||||
return res
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取订单编号
|
||||
* @return
|
||||
*/
|
||||
export async function getPlaceOrder(data: object) {
|
||||
|
||||
const res = await mainClient.request<IApiResponse>({
|
||||
url: '/book/buyOrder/placeOrder',
|
||||
method: 'POST',
|
||||
data: data
|
||||
})
|
||||
return res
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取积分数据
|
||||
* @return
|
||||
*/
|
||||
export async function getPointsData(current : number, limit : number, userId : string,) {
|
||||
|
||||
const res = await mainClient.request<IApiResponse>({
|
||||
url: 'common/jfTransactionDetails/getJfTransactionDetailsList',
|
||||
method: 'POST',
|
||||
data: { current, limit, userId, }
|
||||
})
|
||||
return res
|
||||
* 获取充值列表
|
||||
*/
|
||||
export async function getTransactionDetailsList(current: number, limit: number, userId: string,) {
|
||||
const res = await mainClient.request<IApiResponse>({
|
||||
url: 'common/transactionDetails/getTransactionDetailsList',
|
||||
method: 'POST',
|
||||
data: { current, limit, userId, }
|
||||
})
|
||||
return res
|
||||
}
|
||||
@@ -8,7 +8,6 @@ import { t } from '@/utils/i18n'
|
||||
export function createRequestClient(cfg: ICreateClientConfig) {
|
||||
const baseURL = cfg.baseURL;
|
||||
const timeout = cfg.timeout ?? REQUEST_TIMEOUT;
|
||||
let reqCount= 0
|
||||
|
||||
async function request<T = any>(options: IRequestOptions): Promise<T> {
|
||||
// 组装 final options
|
||||
@@ -24,18 +23,14 @@ export function createRequestClient(cfg: ICreateClientConfig) {
|
||||
|
||||
// 全局处理请求 loading
|
||||
const loading = !cfg.loading ? true : cfg.loading // 接口请求参数不传loading,默认显示loading
|
||||
if (loading) {
|
||||
uni.showLoading({ mask: true })
|
||||
reqCount++
|
||||
}
|
||||
loading && uni.showLoading()
|
||||
|
||||
return new Promise((resolve, reject) => {
|
||||
uni.request({
|
||||
...intercepted,
|
||||
complete() {
|
||||
// 请求完成关闭 loading
|
||||
loading && reqCount--
|
||||
reqCount <= 0 && uni.hideLoading()
|
||||
loading && uni.hideLoading()
|
||||
},
|
||||
success(res: any) {
|
||||
// 委托给响应拦截器处理
|
||||
|
||||
@@ -259,8 +259,11 @@ const handleChapterClick = (chapter: IChapter) => {
|
||||
border-bottom-left-radius: 40rpx;
|
||||
|
||||
.vip-badge {
|
||||
display: inline-block;
|
||||
position: absolute;
|
||||
left: 0;
|
||||
top: 0;
|
||||
font-size: 24rpx;
|
||||
display: inline-block;
|
||||
background: linear-gradient(90deg, #6429db 0%, #0075ed 100%);
|
||||
color: #fff;
|
||||
padding: 10rpx 20rpx;
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
<view class="payment-item">
|
||||
<view class="payment-left">
|
||||
<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]">
|
||||
({{ $t('order.balance') }}:{{ peanutCoin || 0 }})
|
||||
</text>
|
||||
@@ -25,12 +25,19 @@
|
||||
<view class="tip-title">{{ $t('order.paymentTipTitle') }}</view>
|
||||
<view class="tip-item">{{ $t('order.paymentTip1') }}</view>
|
||||
<view class="tip-item">
|
||||
{{ $t('order.paymentTip2-1') }}
|
||||
<text class="link-text" @click="copyToClipboard('yilujiankangkefu')">yilujiankangkefu</text>
|
||||
{{ $t('order.paymentTip2-2') }}
|
||||
<text class="link-text" @click="copyToClipboard('AmazingLimited@163.com')">
|
||||
AmazingLimited@163.com
|
||||
{{ $t('order.paymentTip2') }}
|
||||
<text class="link-text" @click="makePhoneCall('022-24142321')">022-24142321</text>
|
||||
</view>
|
||||
<view class="tip-item">
|
||||
{{ $t('order.paymentTip3') }}
|
||||
<text class="link-text" @click="copyToClipboard('publisher@tmrjournals.com')">
|
||||
publisher@tmrjournals.com
|
||||
</text>
|
||||
{{ $t('order.paymentTip3_1') }}
|
||||
<text class="link-text" @click="copyToClipboard('yilujiankangkefu')">
|
||||
yilujiankangkefu
|
||||
</text>
|
||||
{{ $t('order.paymentTip3_2') }}
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
@@ -46,15 +53,6 @@ const props = defineProps({
|
||||
default: 0
|
||||
}
|
||||
})
|
||||
|
||||
/**
|
||||
* 跳转到充值页面
|
||||
*/
|
||||
const goToRecharge = () => {
|
||||
uni.navigateTo({
|
||||
url: '/pages/user/wallet/recharge/index?source=order'
|
||||
})
|
||||
}
|
||||
</script>
|
||||
|
||||
<style lang="scss" scoped>
|
||||
|
||||
@@ -79,13 +79,7 @@
|
||||
"navigationBarTitleText": "%user.virtual%",
|
||||
"navigationStyle": "custom"
|
||||
}
|
||||
},{
|
||||
"path": "pages/user/points/index",
|
||||
"style": {
|
||||
"navigationBarTitleText": "%user.points%",
|
||||
"navigationStyle": "custom"
|
||||
}
|
||||
},{
|
||||
}, {
|
||||
"path": "pages/user/myBook/index",
|
||||
"style": {
|
||||
"navigationStyle": "custom",
|
||||
|
||||
@@ -230,43 +230,70 @@ function initScrollHeight() {
|
||||
|
||||
// 加载书籍详情
|
||||
async function loadBookInfo() {
|
||||
const res = await bookApi.getBookInfo(bookId.value)
|
||||
bookInfo.value = res.bookInfo
|
||||
try {
|
||||
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() {
|
||||
const res = await bookApi.getBookGoods(bookId.value)
|
||||
goodsList.value = res.productList || []
|
||||
try {
|
||||
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() {
|
||||
const res = await bookApi.getBookReadCount(bookId.value)
|
||||
if (res.code === 0) {
|
||||
readCount.value = res.readCount || 0
|
||||
listenCount.value = res.listenCount || 0
|
||||
buyCount.value = res.buyCount || 0
|
||||
try {
|
||||
const res = await bookApi.getBookReadCount(bookId.value)
|
||||
if (res.code === 0) {
|
||||
readCount.value = res.readCount || 0
|
||||
listenCount.value = res.listenCount || 0
|
||||
buyCount.value = res.buyCount || 0
|
||||
}
|
||||
} catch (error) {
|
||||
console.error('Failed to load book count:', error)
|
||||
}
|
||||
}
|
||||
|
||||
// 加载评论
|
||||
async function loadComments() {
|
||||
const res = await bookApi.getBookComments(bookId.value, 1, 10)
|
||||
if (res.commentsTree && res.commentsTree.length > 0) {
|
||||
commentList.value = res.commentsTree
|
||||
} else {
|
||||
try {
|
||||
const res = await bookApi.getBookComments(bookId.value, 1, 10)
|
||||
if (res.commentsTree && res.commentsTree.length > 0) {
|
||||
commentList.value = res.commentsTree
|
||||
} else {
|
||||
nullText.value = t('common.data_null')
|
||||
}
|
||||
} catch (error) {
|
||||
nullText.value = t('common.data_null')
|
||||
console.error('Failed to load comments:', error)
|
||||
}
|
||||
}
|
||||
|
||||
// 加载推荐书籍
|
||||
async function loadRecommendBooks() {
|
||||
const res = await bookApi.getRecommendBook(bookId.value)
|
||||
if (res.bookList && res.bookList.length > 0) {
|
||||
relatedBooks.value = res.bookList
|
||||
} else {
|
||||
try {
|
||||
const res = await bookApi.getRecommendBook(bookId.value)
|
||||
if (res.bookList && res.bookList.length > 0) {
|
||||
relatedBooks.value = res.bookList
|
||||
} else {
|
||||
nullBookText.value = t('common.data_null')
|
||||
}
|
||||
} catch (error) {
|
||||
nullBookText.value = t('common.data_null')
|
||||
console.error('Failed to load recommend books:', error)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -162,7 +162,7 @@
|
||||
>
|
||||
<image :src="item.images" />
|
||||
<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">{{
|
||||
formatStats(item)
|
||||
}}</text>
|
||||
@@ -219,9 +219,13 @@ const vipInfo = ref<IVipInfo | null>(null)
|
||||
* 获取VIP信息
|
||||
*/
|
||||
const getVipInfo = async () => {
|
||||
const res = await homeApi.getVipInfo()
|
||||
if (res.vipInfo) {
|
||||
vipInfo.value = res.vipInfo
|
||||
try {
|
||||
const res = await homeApi.getVipInfo()
|
||||
if (res.vipInfo) {
|
||||
vipInfo.value = res.vipInfo
|
||||
}
|
||||
} catch (error) {
|
||||
console.error('获取VIP信息失败:', error)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -229,17 +233,21 @@ const getVipInfo = async () => {
|
||||
* 获取我的书单
|
||||
*/
|
||||
const getMyBooks = async () => {
|
||||
const res = await homeApi.getMyBooks(1, 10)
|
||||
if (res && res.code === 0) {
|
||||
showMyBooks.value = true
|
||||
if (res.page.records && res.page.records.length > 0) {
|
||||
myBooksList.value = res.page.records
|
||||
try {
|
||||
const res = await homeApi.getMyBooks(1, 10)
|
||||
if (res && res.code === 0) {
|
||||
showMyBooks.value = true
|
||||
if (res.page.records && res.page.records.length > 0) {
|
||||
myBooksList.value = res.page.records
|
||||
}
|
||||
} else {
|
||||
// 未登录,跳转到登录页
|
||||
uni.navigateTo({
|
||||
url: '/pages/login/login'
|
||||
})
|
||||
}
|
||||
} else {
|
||||
// 未登录,跳转到登录页
|
||||
uni.navigateTo({
|
||||
url: '/pages/login/login'
|
||||
})
|
||||
} catch (error) {
|
||||
console.error('获取我的书单失败:', error)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -247,9 +255,13 @@ const getMyBooks = async () => {
|
||||
* 获取推荐图书
|
||||
*/
|
||||
const getRecommendBooks = async () => {
|
||||
const res = await homeApi.getRecommendBooks()
|
||||
if (res.books && res.books.length > 0) {
|
||||
recommendBooksList.value = res.books
|
||||
try {
|
||||
const res = await homeApi.getRecommendBooks()
|
||||
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 res = await homeApi.getBookLabelList(1)
|
||||
showActivity.value = true
|
||||
if (res.lableList && res.lableList.length > 0) {
|
||||
activityLabelList.value = res.lableList
|
||||
// 默认加载第一个标签的图书列表
|
||||
await getBooksByLabel(res.lableList[0].id, 'activity')
|
||||
try {
|
||||
const res = await homeApi.getBookLabelList(1)
|
||||
showActivity.value = true
|
||||
if (res.lableList && res.lableList.length > 0) {
|
||||
activityLabelList.value = res.lableList
|
||||
// 默认加载第一个标签的图书列表
|
||||
await getBooksByLabel(res.lableList[0].id, 'activity')
|
||||
}
|
||||
} catch (error) {
|
||||
console.error('获取活动标签失败:', error)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -270,12 +286,16 @@ const getActivityLabels = async () => {
|
||||
* 获取分类标签列表
|
||||
*/
|
||||
const getCategoryLabels = async () => {
|
||||
const res = await homeApi.getBookLabelList(0)
|
||||
showCategory.value = true
|
||||
if (res.lableList && res.lableList.length > 0) {
|
||||
categoryLevel1List.value = res.lableList
|
||||
// 默认加载第一个标签的二级标签
|
||||
await getSubLabels(res.lableList[0].id, 0)
|
||||
try {
|
||||
const res = await homeApi.getBookLabelList(0)
|
||||
showCategory.value = true
|
||||
if (res.lableList && res.lableList.length > 0) {
|
||||
categoryLevel1List.value = res.lableList
|
||||
// 默认加载第一个标签的二级标签
|
||||
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 res = await homeApi.getSubLabelList(pid)
|
||||
currentLevel1Index.value = index
|
||||
if (res.lableList && res.lableList.length > 0) {
|
||||
categoryLevel2List.value = res.lableList
|
||||
currentLevel2Index.value = 0
|
||||
// 加载第一个二级标签的图书列表
|
||||
await getBooksByLabel(res.lableList[0].id, 'category')
|
||||
} else {
|
||||
// 没有二级标签,直接加载一级标签的图书列表
|
||||
categoryLevel2List.value = []
|
||||
await getBooksByLabel(pid, 'category')
|
||||
try {
|
||||
const res = await homeApi.getSubLabelList(pid)
|
||||
currentLevel1Index.value = index
|
||||
if (res.lableList && res.lableList.length > 0) {
|
||||
categoryLevel2List.value = res.lableList
|
||||
currentLevel2Index.value = 0
|
||||
// 加载第一个二级标签的图书列表
|
||||
await getBooksByLabel(res.lableList[0].id, 'category')
|
||||
} else {
|
||||
// 没有二级标签,直接加载一级标签的图书列表
|
||||
categoryLevel2List.value = []
|
||||
await getBooksByLabel(pid, 'category')
|
||||
}
|
||||
} catch (error) {
|
||||
console.error('获取二级标签失败:', error)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -304,19 +328,23 @@ const getBooksByLabel = async (
|
||||
labelId: number,
|
||||
type: 'activity' | 'category'
|
||||
) => {
|
||||
const res = await homeApi.getBooksByLabel(labelId)
|
||||
if (type === 'activity') {
|
||||
if (res.bookList && res.bookList.length > 0) {
|
||||
activityList.value = res.bookList
|
||||
try {
|
||||
const res = await homeApi.getBooksByLabel(labelId)
|
||||
if (type === 'activity') {
|
||||
if (res.bookList && res.bookList.length > 0) {
|
||||
activityList.value = res.bookList
|
||||
} else {
|
||||
activityList.value = []
|
||||
}
|
||||
} else {
|
||||
activityList.value = []
|
||||
}
|
||||
} else {
|
||||
if (res.bookList && res.bookList.length > 0) {
|
||||
categoryBookList.value = res.bookList
|
||||
} else {
|
||||
categoryBookList.value = []
|
||||
if (res.bookList && res.bookList.length > 0) {
|
||||
categoryBookList.value = res.bookList
|
||||
} else {
|
||||
categoryBookList.value = []
|
||||
}
|
||||
}
|
||||
} catch (error) {
|
||||
console.error('获取图书列表失败:', error)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -117,20 +117,31 @@ function initScrollHeight() {
|
||||
|
||||
// 加载书籍信息
|
||||
async function loadBookInfo() {
|
||||
const res = await bookApi.getBookInfo(bookId.value)
|
||||
bookInfo.value = res.bookInfo
|
||||
try {
|
||||
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() {
|
||||
const res = await bookApi.getBookChapter({
|
||||
bookId: bookId.value
|
||||
})
|
||||
|
||||
if (res.chapterList && res.chapterList.length > 0) {
|
||||
chapterList.value = res.chapterList
|
||||
} else {
|
||||
try {
|
||||
const res = await bookApi.getBookChapter({
|
||||
bookId: bookId.value
|
||||
})
|
||||
|
||||
if (res.chapterList && res.chapterList.length > 0) {
|
||||
chapterList.value = res.chapterList
|
||||
} else {
|
||||
nullText.value = t('common.data_null')
|
||||
}
|
||||
} catch (error) {
|
||||
nullText.value = t('common.data_null')
|
||||
console.error('Failed to load chapter list:', error)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -245,8 +245,14 @@ function initAudioContext() {
|
||||
|
||||
// 加载书籍信息
|
||||
async function loadBookInfo() {
|
||||
const res = await bookApi.getBookInfo(bookId.value)
|
||||
bookInfo.value = res.bookInfo
|
||||
try {
|
||||
const res = await bookApi.getBookInfo(bookId.value)
|
||||
if (res.bookInfo) {
|
||||
bookInfo.value = res.bookInfo
|
||||
}
|
||||
} catch (error) {
|
||||
console.error('Failed to load book info:', error)
|
||||
}
|
||||
}
|
||||
|
||||
// 加载章节列表
|
||||
|
||||
@@ -164,9 +164,13 @@ function initScrollHeight() {
|
||||
|
||||
// 加载书籍信息
|
||||
async function loadBookInfo() {
|
||||
const res = await bookApi.getBookInfo(bookId.value)
|
||||
if (res.bookInfo) {
|
||||
bookInfo.value = res.bookInfo
|
||||
try {
|
||||
const res = await bookApi.getBookInfo(bookId.value)
|
||||
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
|
||||
}
|
||||
|
||||
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
|
||||
|
||||
if (res.commentsTree && res.commentsTree.length > 0) {
|
||||
commentList.value = [...commentList.value, ...res.commentsTree]
|
||||
page.value.current += 1
|
||||
} else if (commentList.value.length === 0) {
|
||||
commentsCount.value = res.commentsCount || 0
|
||||
|
||||
if (res.commentsTree && res.commentsTree.length > 0) {
|
||||
commentList.value = [...commentList.value, ...res.commentsTree]
|
||||
page.value.current += 1
|
||||
} else if (commentList.value.length === 0) {
|
||||
nullText.value = t('common.data_null')
|
||||
}
|
||||
} catch (error) {
|
||||
nullText.value = t('common.data_null')
|
||||
console.error('Failed to load comments:', error)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -266,29 +275,33 @@ function handleEmj(i: any) {
|
||||
|
||||
// 提交评论
|
||||
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({
|
||||
title: t('bookDetails.enterText'),
|
||||
icon: 'none'
|
||||
title: t('workOrder.submit_success'),
|
||||
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
|
||||
}
|
||||
|
||||
if (comment.isLike === 0) {
|
||||
await bookApi.likeComment(comment.id)
|
||||
uni.showToast({
|
||||
title: t('bookDetails.supportSuccess'),
|
||||
icon: 'success',
|
||||
duration: 1000
|
||||
})
|
||||
} else {
|
||||
await bookApi.unlikeComment(comment.id)
|
||||
uni.showToast({
|
||||
title: t('bookDetails.supportCancel'),
|
||||
icon: 'success',
|
||||
duration: 1000
|
||||
})
|
||||
try {
|
||||
if (comment.isLike === 0) {
|
||||
await bookApi.likeComment(comment.id)
|
||||
uni.showToast({
|
||||
title: t('bookDetails.supportSuccess'),
|
||||
icon: 'success',
|
||||
duration: 1000
|
||||
})
|
||||
} else {
|
||||
await bookApi.unlikeComment(comment.id)
|
||||
uni.showToast({
|
||||
title: t('bookDetails.supportCancel'),
|
||||
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'),
|
||||
success: async (res) => {
|
||||
if (res.confirm) {
|
||||
await bookApi.deleteComment(comment.id)
|
||||
uni.showToast({
|
||||
title: t('bookDetails.deleteSuccess'),
|
||||
icon: 'success',
|
||||
duration: 500
|
||||
})
|
||||
|
||||
setTimeout(() => {
|
||||
resetComments()
|
||||
}, 500)
|
||||
try {
|
||||
await bookApi.deleteComment(comment.id)
|
||||
uni.showToast({
|
||||
title: t('bookDetails.deleteSuccess'),
|
||||
icon: 'success',
|
||||
duration: 500
|
||||
})
|
||||
|
||||
setTimeout(() => {
|
||||
resetComments()
|
||||
}, 500)
|
||||
} catch (error) {
|
||||
console.error('Failed to delete comment:', error)
|
||||
}
|
||||
}
|
||||
}
|
||||
})
|
||||
|
||||
@@ -70,8 +70,14 @@ onLoad((options: any) => {
|
||||
* 获取VIP信息
|
||||
*/
|
||||
const getVipInfo = async () => {
|
||||
const res = await homeApi.getVipInfo()
|
||||
vipInfo.value = res.vipInfo
|
||||
try {
|
||||
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
|
||||
isEmpty.value = false
|
||||
|
||||
const res = await homeApi.searchBooks({
|
||||
title: keyword.value.trim(),
|
||||
page: 1,
|
||||
limit: 10,
|
||||
})
|
||||
if (res.bookList && res.bookList.length > 0) {
|
||||
searchResults.value = res.bookList
|
||||
isEmpty.value = false
|
||||
} else {
|
||||
try {
|
||||
const res = await homeApi.searchBooks({
|
||||
title: keyword.value.trim(),
|
||||
page: 1,
|
||||
limit: 10,
|
||||
})
|
||||
if (res.bookList && res.bookList.length > 0) {
|
||||
searchResults.value = res.bookList
|
||||
isEmpty.value = false
|
||||
} else {
|
||||
searchResults.value = []
|
||||
isEmpty.value = true
|
||||
}
|
||||
} catch (error) {
|
||||
console.error('搜索失败:', error)
|
||||
searchResults.value = []
|
||||
isEmpty.value = true
|
||||
} finally {
|
||||
loading.value = false
|
||||
}
|
||||
loading.value = false
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -164,19 +164,23 @@ onLoad((options: any) => {
|
||||
* 加载章节详情
|
||||
*/
|
||||
const loadChapterDetail = async () => {
|
||||
const res = await courseApi.getChapterDetail(chapterId.value)
|
||||
if (res.code === 0 && res.data) {
|
||||
chapterDetail.value = res.data.detail
|
||||
videoList.value = res.data.videos || []
|
||||
try {
|
||||
const res = await courseApi.getChapterDetail(chapterId.value)
|
||||
if (res.code === 0 && res.data) {
|
||||
chapterDetail.value = res.data.detail
|
||||
videoList.value = res.data.videos || []
|
||||
|
||||
// 如果有历史播放记录,定位到对应视频
|
||||
if (res.data.current) {
|
||||
const index = videoList.value.findIndex(v => v.id === res.data.current)
|
||||
if (index !== -1) {
|
||||
currentVideoIndex.value = index
|
||||
activeVideoIndex.value = index
|
||||
// 如果有历史播放记录,定位到对应视频
|
||||
if (res.data.current) {
|
||||
const index = videoList.value.findIndex(v => v.id === res.data.current)
|
||||
if (index !== -1) {
|
||||
currentVideoIndex.value = index
|
||||
activeVideoIndex.value = index
|
||||
}
|
||||
}
|
||||
}
|
||||
} catch (error) {
|
||||
console.error('加载章节详情失败:', error)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -257,25 +257,29 @@ const handleFirstLevelClick = (item: string) => {
|
||||
* 获取课程分类数据
|
||||
*/
|
||||
const getMedicalTags = async () => {
|
||||
const res = await courseSubjectClassificationApi.getCourseMedicalTree()
|
||||
if (res && res.code === 0) {
|
||||
if (res.labels && res.labels.length > 0) {
|
||||
curseTagList.value = res.labels
|
||||
// 根据 currentIndex 设置初始选中的分类
|
||||
if (res.labels[currentIndex.value]) {
|
||||
const selectedTag = res.labels[currentIndex.value]
|
||||
if (selectedTag.isLast === 0) {
|
||||
// 非终极分类,显示子分类
|
||||
if (selectedTag.children && selectedTag.children.length > 0) {
|
||||
sbuMedicalTagsList.value = selectedTag.children
|
||||
} else {
|
||||
sbuMedicalTagsList.value = []
|
||||
try {
|
||||
const res = await courseSubjectClassificationApi.getCourseMedicalTree()
|
||||
if (res && res.code === 0) {
|
||||
if (res.labels && res.labels.length > 0) {
|
||||
curseTagList.value = res.labels
|
||||
// 根据 currentIndex 设置初始选中的分类
|
||||
if (res.labels[currentIndex.value]) {
|
||||
const selectedTag = res.labels[currentIndex.value]
|
||||
if (selectedTag.isLast === 0) {
|
||||
// 非终极分类,显示子分类
|
||||
if (selectedTag.children && selectedTag.children.length > 0) {
|
||||
sbuMedicalTagsList.value = selectedTag.children
|
||||
} 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 getSoulCateList = async () => {
|
||||
const res = await courseSubjectClassificationApi.getCourseSoulTree()
|
||||
if (res.labels&&res.labels.length>0) {
|
||||
soulCateList.value = res.labels;
|
||||
try {
|
||||
const res = await courseSubjectClassificationApi.getCourseSoulTree()
|
||||
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 getSociologyCateList = async () => {
|
||||
const res = await courseSubjectClassificationApi.getCourseSociologyTree()
|
||||
if (res.labels&&res.labels.length>0) {
|
||||
sociologyCateList.value = res.labels;
|
||||
try {
|
||||
const res = await courseSubjectClassificationApi.getCourseSociologyTree()
|
||||
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 res = await courseApi.getUserLateCourseList()
|
||||
if (res && res.code === 0) {
|
||||
if (res.page && res.page.length > 0) {
|
||||
learnList.value = res.page
|
||||
} else {
|
||||
learnList.value = []
|
||||
try {
|
||||
const res = await courseApi.getUserLateCourseList()
|
||||
if (res && res.code === 0) {
|
||||
if (res.page && res.page.length > 0) {
|
||||
learnList.value = res.page
|
||||
} else {
|
||||
learnList.value = []
|
||||
}
|
||||
}
|
||||
} catch (error) {
|
||||
console.error('获取观看记录失败:', error)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -373,13 +389,17 @@ const newsList = ref<INews[]>([]) // 新闻列表
|
||||
* 获取新闻列表
|
||||
*/
|
||||
const getNewsList = async () => {
|
||||
const res = await commonApi.getMessageList(0, 1, 0)
|
||||
if (res && res.code === 0) {
|
||||
if (res.messages && res.messages.length > 0) {
|
||||
newsList.value = res.messages
|
||||
} else {
|
||||
newsList.value = []
|
||||
try {
|
||||
const res = await commonApi.getMessageList(0, 1, 0)
|
||||
if (res && res.code === 0) {
|
||||
if (res.messages && res.messages.length > 0) {
|
||||
newsList.value = res.messages
|
||||
} else {
|
||||
newsList.value = []
|
||||
}
|
||||
}
|
||||
} catch (error) {
|
||||
console.error('获取新闻列表失败:', error)
|
||||
}
|
||||
}
|
||||
/**
|
||||
@@ -403,17 +423,21 @@ const tryListenList = ref<ICourse[]>([]) // 试听课程列表
|
||||
* 获取试听课程列表
|
||||
*/
|
||||
const getTryListenList = async () => {
|
||||
const res = await courseApi.getMarketCourseList({
|
||||
page: 1,
|
||||
limit: 6,
|
||||
id: 1
|
||||
})
|
||||
if (res && res.code === 0) {
|
||||
if (res.courseList && res.courseList.records && res.courseList.records.length > 0) {
|
||||
tryListenList.value = res.courseList.records
|
||||
} else {
|
||||
tryListenList.value = []
|
||||
try {
|
||||
const res = await courseApi.getMarketCourseList({
|
||||
page: 1,
|
||||
limit: 6,
|
||||
id: 1
|
||||
})
|
||||
if (res && res.code === 0) {
|
||||
if (res.courseList && res.courseList.records && res.courseList.records.length > 0) {
|
||||
tryListenList.value = res.courseList.records
|
||||
} else {
|
||||
tryListenList.value = []
|
||||
}
|
||||
}
|
||||
} catch (error) {
|
||||
console.error('获取试听课程失败:', error)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -52,26 +52,30 @@ const subCategoryList = ref<ICategory[]>([]) // 子级分类列表
|
||||
* 获取分类下的子级分类
|
||||
*/
|
||||
const getSubCategoryList = async () => {
|
||||
let res: any = null
|
||||
switch (subject.value) {
|
||||
case '医学':
|
||||
res = await courseSubjectClassificationApi.getCourseMedicalChildLabels(categoryId.value)
|
||||
break
|
||||
case '心理学':
|
||||
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
|
||||
try {
|
||||
let res: any = null
|
||||
switch (subject.value) {
|
||||
case '医学':
|
||||
res = await courseSubjectClassificationApi.getCourseMedicalChildLabels(categoryId.value)
|
||||
break
|
||||
case '心理学':
|
||||
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
|
||||
}
|
||||
}
|
||||
} catch (error) {
|
||||
console.error('获取分类下的子级分类失败:', error)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -191,12 +191,16 @@ const getCode = async () => {
|
||||
if (!isEmailEmpty()) return
|
||||
if (!isEmailVerified(email.value)) return
|
||||
|
||||
await commonApi.sendMailCaptcha(email.value)
|
||||
uni.showToast({
|
||||
title: t('login.sendCodeSuccess'),
|
||||
icon: 'none'
|
||||
})
|
||||
getCodeState()
|
||||
try {
|
||||
await commonApi.sendMailCaptcha(email.value)
|
||||
uni.showToast({
|
||||
title: t('login.sendCodeSuccess'),
|
||||
icon: 'none'
|
||||
})
|
||||
getCodeState()
|
||||
} catch (error) {
|
||||
console.error('Send code error:', error)
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -260,16 +264,20 @@ const onSubmit = async () => {
|
||||
if (!isConfirmPasswordEmpty()) return
|
||||
if (!isPasswordMatch()) return
|
||||
|
||||
await resetPassword(email.value, code.value, password.value)
|
||||
try {
|
||||
await resetPassword(email.value, code.value, password.value)
|
||||
|
||||
uni.showModal({
|
||||
title: t('global.tips'),
|
||||
content: t('forget.passwordChanged'),
|
||||
showCancel: false,
|
||||
success: () => {
|
||||
uni.navigateBack()
|
||||
}
|
||||
})
|
||||
uni.showModal({
|
||||
title: t('global.tips'),
|
||||
content: t('forget.passwordChanged'),
|
||||
showCancel: false,
|
||||
success: () => {
|
||||
uni.navigateBack()
|
||||
}
|
||||
})
|
||||
} catch (error) {
|
||||
console.error('Reset password error:', error)
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
|
||||
@@ -285,8 +285,13 @@ const verifyCodeLogin = async () => {
|
||||
|
||||
if (!isCodeEmpty()) return false
|
||||
|
||||
const res = await loginWithCode(email.value, code.value)
|
||||
return res || null
|
||||
try {
|
||||
const res = await loginWithCode(email.value, code.value)
|
||||
return res
|
||||
} catch (error) {
|
||||
console.error('验证码登录失败:', error)
|
||||
return null
|
||||
}
|
||||
}
|
||||
// 密码登录
|
||||
const passwordLogin = async () => {
|
||||
@@ -296,8 +301,13 @@ const passwordLogin = async () => {
|
||||
|
||||
if (!isPasswordEmpty()) return false
|
||||
|
||||
const res = await loginWithPassword(phoneEmail.value, password.value)
|
||||
return res || null
|
||||
try {
|
||||
const res = await loginWithPassword(phoneEmail.value, password.value)
|
||||
return res
|
||||
} catch (error) {
|
||||
console.error('密码登录失败:', error)
|
||||
return null
|
||||
}
|
||||
}
|
||||
// 提交登录
|
||||
const onSubmit = async () => {
|
||||
|
||||
@@ -26,8 +26,28 @@
|
||||
<!-- 商品信息 -->
|
||||
<view class="goods-info">
|
||||
<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">
|
||||
@@ -49,20 +69,25 @@
|
||||
</template>
|
||||
|
||||
<script lang="ts" setup>
|
||||
import { ref } from 'vue'
|
||||
import { ref, computed } from 'vue'
|
||||
import { onLoad } from '@dcloudio/uni-app'
|
||||
import { orderApi } from '@/api/modules/order'
|
||||
import type { IOrderGoods } from '@/types/order'
|
||||
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 res = await orderApi.getUserInfo()
|
||||
userInfo.value = res.result || {}
|
||||
try {
|
||||
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 goodsList = ref<IOrderGoods[]>([])
|
||||
const getGoodsList = async () => {
|
||||
// 获取商品详情
|
||||
const res = await orderApi.getShopProductListByIds(goodsIds.value)
|
||||
|
||||
if (res.shopProductList?.length > 0) {
|
||||
goodsList.value = res.shopProductList
|
||||
try {
|
||||
// 获取商品详情
|
||||
const res = await orderApi.getShopProductListByIds(goodsIds.value)
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
.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 {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
|
||||
@@ -23,38 +23,41 @@
|
||||
<!-- VIP订阅卡片 -->
|
||||
<view class="vip-card-section">
|
||||
<view class="vip-card">
|
||||
用户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>
|
||||
<wd-button
|
||||
v-else
|
||||
type="success"
|
||||
size="small"
|
||||
@click="goSubscribe"
|
||||
>
|
||||
{{ $t('user.subscribe') }}
|
||||
</wd-button> -->
|
||||
<view class="vip-card-title">{{ $t('user.vip') }}</view>
|
||||
<view class="vip-card-content">
|
||||
<view class="vip-item-list">
|
||||
<view v-if="vipInfo.length > 0" v-for="vip in vipInfo">{{ vipTypeDict[vip.type] }}(有效期到 {{ parseTime(vip.endTime, '{y}-{m}-{d}') }})</view>
|
||||
<view v-else>办理课程VIP,畅享更多权益</view>
|
||||
</view>
|
||||
<wd-button v-if="vipInfo.length > 0" plain type="primary" size="small" @click="goSubscribe">{{ $t('vip.renewal') }}</wd-button>
|
||||
<wd-button v-else plain type="primary" size="small" @click="goSubscribe">{{ $t('vip.openVip') }}</wd-button>
|
||||
</view>
|
||||
<view class="vip-card-content">
|
||||
<view class="vip-item-list">
|
||||
<view v-if="vipInfoEbook.length > 0" v-for="vip in vipInfoEbook">电子书VIP{{ vipTypeDict[vip.type] }}(有效期到 {{ parseTime(vip.endTime, '{y}-{m}-{d}') }})</view>
|
||||
<view v-else>办理电子书VIP,畅享更多权益</view>
|
||||
</view>
|
||||
<wd-button v-if="!vipInfoEbook.length" plain type="primary" size="small" @click="goSubscribe">{{ $t('vip.openVip') }}</wd-button>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
|
||||
<!-- 我的资产 -->
|
||||
<view class="vip-card-section wallet-section">
|
||||
<view class="vip-card wallet_l">
|
||||
<view class="assets-card-section wallet-section">
|
||||
<view class="assets-card wallet_l">
|
||||
<view class="assets">
|
||||
<view @click="goVirtualList">
|
||||
<view class="assets_row">{{ t('global.coin') }}</view>
|
||||
<view>{{userInfo.peanutCoin ?? 1}}</view>
|
||||
</view>
|
||||
<view @click="goPointsList">
|
||||
<view>
|
||||
<view class="assets_row">积分</view>
|
||||
<view>{{userInfo.jf ?? 1}}</view>
|
||||
</view>
|
||||
<!-- <view>
|
||||
<view>
|
||||
<view class="assets_row">优惠卷</view>
|
||||
<view>0</view>
|
||||
</view> -->
|
||||
</view>
|
||||
</view>
|
||||
<view class="chong_btn" @click="goRecharge">充 值</view>
|
||||
<!-- <text class="wallet_title">{{$t('my.coin')}}<uni-icons type="help" size="19" color="#666"></uni-icons></text>
|
||||
@@ -77,14 +80,15 @@
|
||||
<script setup lang="ts">
|
||||
import { ref, computed, onMounted } from 'vue'
|
||||
import { useUserStore } from '@/stores/user'
|
||||
import { useSysStore } from '@/stores/sys'
|
||||
import { getUserInfo, getVipInfo } from '@/api/modules/user'
|
||||
import type { IVipInfo } from '@/types/user'
|
||||
import { useI18n } from 'vue-i18n'
|
||||
import { getNotchHeight } from '@/utils/system'
|
||||
import { onShow } from '@dcloudio/uni-app'
|
||||
import { parseTime } from '@/utils/index'
|
||||
import { t } from '@/utils/i18n'
|
||||
|
||||
const { t } = useI18n()
|
||||
const userStore = useUserStore()
|
||||
const sysStore = useSysStore()
|
||||
|
||||
// 默认头像
|
||||
const defaultAvatar = '/static/home_icon.png'
|
||||
@@ -93,11 +97,11 @@
|
||||
const userInfo = computed(() => userStore.userInfo)
|
||||
|
||||
// VIP信息
|
||||
const vipInfo = ref<IVipInfo>({
|
||||
id: 0,
|
||||
endTime: '',
|
||||
vipType: 0
|
||||
})
|
||||
const vipInfo = computed(() => userStore.userVips)
|
||||
const vipInfoEbook = computed(() => userStore.userEbookVip)
|
||||
|
||||
// VIP类型字典
|
||||
const vipTypeDict = sysStore.vipTypeDict
|
||||
|
||||
// 平台信息
|
||||
const platform = ref('')
|
||||
@@ -148,21 +152,12 @@
|
||||
* 获取数据
|
||||
*/
|
||||
const getData = async () => {
|
||||
console.log(userInfo.value);
|
||||
try {
|
||||
// 获取用户信息
|
||||
const userRes = await getUserInfo()
|
||||
console.log(userRes, '-----userRes');
|
||||
if (userRes.result) {
|
||||
userStore.setUserInfo(userRes.result)
|
||||
}
|
||||
|
||||
// 获取VIP信息
|
||||
const vipRes = await getVipInfo()
|
||||
if (vipRes.vipInfo) {
|
||||
vipInfo.value = vipRes.vipInfo
|
||||
// 获取用户信息
|
||||
const userInfoRes = await getUserInfo()
|
||||
if (userInfoRes.result) {
|
||||
userStore.setUserInfo(userInfoRes.result)
|
||||
}
|
||||
}}
|
||||
}
|
||||
|
||||
/**
|
||||
* 跳转到设置页面
|
||||
@@ -187,7 +182,7 @@
|
||||
*/
|
||||
const goSubscribe = () => {
|
||||
uni.navigateTo({
|
||||
url: '/pages/user/wallet/index'
|
||||
url: '/pages/vip/book'
|
||||
})
|
||||
}
|
||||
|
||||
@@ -227,21 +222,11 @@
|
||||
})
|
||||
}
|
||||
|
||||
/**
|
||||
* 跳转积分列表
|
||||
*/
|
||||
const goPointsList = () => {
|
||||
uni.navigateTo({
|
||||
url: '/pages/user/points/index'
|
||||
})
|
||||
}
|
||||
|
||||
onShow(() => {
|
||||
getData()
|
||||
})
|
||||
|
||||
onMounted(() => {
|
||||
getPlatform()
|
||||
getData()
|
||||
})
|
||||
</script>
|
||||
|
||||
@@ -311,12 +296,47 @@
|
||||
}
|
||||
}
|
||||
|
||||
// vip 卡片
|
||||
.vip-card-section {
|
||||
padding: 0 20rpx;
|
||||
margin-bottom: 20rpx;
|
||||
|
||||
.vip-card {
|
||||
background: linear-gradient(135deg, #3E7EF5 0%, #9134EA 100%);
|
||||
border-radius: 15rpx;
|
||||
padding: 26rpx 30rpx 10rpx;
|
||||
box-shadow: 0 2px 5px rgba(0, 0, 0, 0.1);
|
||||
|
||||
.vip-card-title {
|
||||
font-size: 32rpx;
|
||||
color: #fff;
|
||||
font-weight: bold;
|
||||
margin-bottom: 20rpx;
|
||||
}
|
||||
|
||||
.vip-card-content {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: space-between;
|
||||
background-color: rgba(255, 255, 255, 0.2);
|
||||
border-radius: 8px;
|
||||
padding: 30rpx;
|
||||
margin-bottom: 20rpx;
|
||||
}
|
||||
.vip-item-list {
|
||||
font-size: 28rpx;
|
||||
color: #fff;
|
||||
font-weight: bold;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
.assets-card-section {
|
||||
padding: 0 20rpx;
|
||||
margin-bottom: 20rpx;
|
||||
}
|
||||
|
||||
.vip-card {
|
||||
.assets-card {
|
||||
background: #fff;
|
||||
border-radius: 15rpx;
|
||||
padding: 40rpx;
|
||||
@@ -325,7 +345,7 @@
|
||||
justify-content: space-between;
|
||||
box-shadow: 0 2rpx 10rpx rgba(0, 0, 0, 0.05);
|
||||
|
||||
.vip-info {
|
||||
.assets-info {
|
||||
text-align: center;
|
||||
|
||||
.label {
|
||||
@@ -384,7 +404,7 @@
|
||||
border-radius: 50rpx;
|
||||
color: #fffbf6;
|
||||
padding: 10rpx 32rpx;
|
||||
background-color: #007bff;
|
||||
background-image: linear-gradient(90deg, #3ab3ae 0%, #d5ecdd 200%);
|
||||
}
|
||||
|
||||
.assets {
|
||||
|
||||
@@ -27,7 +27,7 @@
|
||||
<ProductInfo v-if="order.orderType === 'abroadBook'" :data="order.bookEntity" :type="order.orderType" />
|
||||
<ProductInfo v-if="order.orderType === 'vip'" :data="order.vipBuyConfigEntity" :type="order.orderType" />
|
||||
<!-- 三种订单类型商品信息 end -->
|
||||
<view class="order-item-total-price">实付款:{{ order.orderMoney }} {{ t('global.coin') }}</view>
|
||||
<view class="order-item-total-price">实付款:{{ order.orderMoney }} 天医币</view>
|
||||
|
||||
<template #footer>
|
||||
<view>
|
||||
|
||||
@@ -1,135 +0,0 @@
|
||||
<template>
|
||||
<z-paging ref="paging" v-model="bookList" auto-show-back-to-top class="my-book-page" @query="pointsList" :default-page-size="10">
|
||||
<template #top>
|
||||
<!-- 自定义导航栏 -->
|
||||
<nav-bar :title="$t('user.consumptionRecord')"></nav-bar>
|
||||
</template>
|
||||
<view class="recharge-record" v-if="(bookList && bookList.length > 0)">
|
||||
<view class="go-gecharge" @click="goRecharge">
|
||||
<view>{{$t('order.recharge')}}</view>
|
||||
<view><wd-icon name="arrow-right" size="16px" color="#fff"/></view>
|
||||
</view>
|
||||
<view class="title">{{$t('order.rechargeConsumptionList')}}</view>
|
||||
<view class="recharge-record-block" v-for="(item, index) in bookList" :key="index">
|
||||
<view class="recharge-record-block-row">{{item.orderType}}<text class="text">{{item.changeAmount}}</text></view>
|
||||
<view class="time">{{item.createTime}}</view>
|
||||
</view>
|
||||
</view>
|
||||
</z-paging>
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
import { ref } from 'vue'
|
||||
import { useI18n } from 'vue-i18n'
|
||||
import { useUserStore } from '@/stores/user'
|
||||
import { getPointsData } from '@/api/modules/user'
|
||||
|
||||
const { t } = useI18n()
|
||||
const paging = ref<any>()
|
||||
const userStore = useUserStore()
|
||||
|
||||
// 数据状态
|
||||
const bookList = ref([])
|
||||
const loading = ref(false)
|
||||
const firstLoad = ref(true)
|
||||
|
||||
// 充值记录列表
|
||||
async function pointsList(pageNo : number, pageSize : number) {
|
||||
const userId = userStore.userInfo.id
|
||||
loading.value = true
|
||||
try {
|
||||
const res = await getPointsData(pageNo, pageSize, userId)
|
||||
console.log(res, 'res');
|
||||
paging.value.complete(res.transactionDetailsList.records)
|
||||
} catch (error) {
|
||||
paging.value.complete(false)
|
||||
console.error('Failed to load book list:', error)
|
||||
} finally {
|
||||
firstLoad.value = false
|
||||
loading.value = false
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 跳转充值页面
|
||||
*/
|
||||
const goRecharge = () => {
|
||||
uni.navigateTo({
|
||||
url: '/pages/user/recharge/index'
|
||||
})
|
||||
}
|
||||
</script>
|
||||
|
||||
<style lang="scss" scoped>
|
||||
.my-book-page {
|
||||
background: #f7faf9;
|
||||
min-height: 100vh;
|
||||
|
||||
.recharge-record {
|
||||
background: #fff;
|
||||
border-radius: 15rpx;
|
||||
overflow: hidden;
|
||||
box-shadow: 0 2rpx 10rpx rgba(0, 0, 0, 0.05);
|
||||
// padding: 20rpx;
|
||||
margin: 20rpx;
|
||||
|
||||
.go-gecharge{
|
||||
//height: 100rpx;
|
||||
background: linear-gradient(to right, #007bff, #17a2b8);
|
||||
font-size: 30rpx;
|
||||
font-weight: bold;
|
||||
color: #fff;
|
||||
padding: 20rpx;
|
||||
margin-bottom: 20rpx;
|
||||
display: flex;justify-content:space-between;align-items:center
|
||||
}
|
||||
|
||||
.title {
|
||||
font-size: 30rpx;
|
||||
padding-left:20rpx;
|
||||
margin-bottom: 30rpx;
|
||||
color: #007bff;
|
||||
font-weight: bold;
|
||||
}
|
||||
|
||||
.recharge-record-block {
|
||||
border-bottom: 1px solid #e0e0e0;
|
||||
padding: 20rpx;
|
||||
|
||||
.time{
|
||||
font-size: 20rpx;
|
||||
}
|
||||
|
||||
.recharge-record-block-row {
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
margin-bottom: 20rpx;
|
||||
|
||||
.text{
|
||||
color: #007bff;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
.empty-state {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
padding-top: 200rpx;
|
||||
|
||||
image {
|
||||
width: 400rpx;
|
||||
height: 300rpx;
|
||||
margin-bottom: 40rpx;
|
||||
}
|
||||
|
||||
.empty-text {
|
||||
font-size: 28rpx;
|
||||
color: #999;
|
||||
margin-bottom: 50rpx;
|
||||
}
|
||||
}
|
||||
|
||||
</style>
|
||||
@@ -199,10 +199,14 @@ const avatarUrl = ref('')
|
||||
*/
|
||||
const userInfo = ref<any>({}) // 用户信息
|
||||
const getData = async () => {
|
||||
const res = await getUserInfo()
|
||||
if (res.result) {
|
||||
userStore.setUserInfo(res.result)
|
||||
userInfo.value = res.result
|
||||
try {
|
||||
const res = await getUserInfo()
|
||||
if (res.result) {
|
||||
userStore.setUserInfo(res.result)
|
||||
userInfo.value = res.result
|
||||
}
|
||||
} catch (error) {
|
||||
console.error('获取用户信息失败:', error)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -320,12 +324,16 @@ const sendCode = async () => {
|
||||
return
|
||||
}
|
||||
|
||||
await sendEmailCode(editForm.value.email)
|
||||
uni.showToast({
|
||||
title: t('user.sendCodeSuccess'),
|
||||
icon: 'none'
|
||||
})
|
||||
startCountdown()
|
||||
try {
|
||||
await sendEmailCode(editForm.value.email)
|
||||
uni.showToast({
|
||||
title: t('user.sendCodeSuccess'),
|
||||
icon: 'none'
|
||||
})
|
||||
startCountdown()
|
||||
} catch (error) {
|
||||
console.error('发送验证码失败:', error)
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -390,88 +398,92 @@ const checkPasswordStrength = () => {
|
||||
const handleSubmit = async () => {
|
||||
const key = currentField.value?.key
|
||||
|
||||
// 构建更新数据对象
|
||||
let updateData: any = Object.assign({}, userInfo.value)
|
||||
try {
|
||||
// 构建更新数据对象
|
||||
let updateData: any = Object.assign({}, userInfo.value)
|
||||
|
||||
switch (key) {
|
||||
case 'email':
|
||||
// 更新邮箱
|
||||
if (!editForm.value.email || !editForm.value.code) {
|
||||
uni.showToast({
|
||||
title: t('user.pleaseInputCode'),
|
||||
icon: 'none'
|
||||
})
|
||||
return
|
||||
}
|
||||
await updateEmail(userInfo.value.id, editForm.value.email, editForm.value.code)
|
||||
break
|
||||
|
||||
case 'password':
|
||||
// 更新密码
|
||||
if (!passwordOk.value) {
|
||||
uni.showToast({
|
||||
title: passwordNote.value,
|
||||
icon: 'none'
|
||||
})
|
||||
return
|
||||
}
|
||||
if (editForm.value.password !== editForm.value.confirmPassword) {
|
||||
uni.showToast({
|
||||
title: t('user.passwordNotMatch'),
|
||||
icon: 'none'
|
||||
})
|
||||
return
|
||||
}
|
||||
await updatePassword(userInfo.value.id, editForm.value.password)
|
||||
break
|
||||
|
||||
case 'avatar':
|
||||
// 更新头像
|
||||
console.log('avatarUrl.value:', avatarUrl.value)
|
||||
if (!avatarUrl.value) {
|
||||
uni.showToast({
|
||||
title: t('common.pleaseSelect') + t('user.avatar'),
|
||||
icon: 'none'
|
||||
})
|
||||
return
|
||||
}
|
||||
|
||||
// 如果是新上传的图片,需要先上传
|
||||
updateData.avatar = avatarUrl.value
|
||||
await updateUserInfo(updateData)
|
||||
break
|
||||
|
||||
case 'sex':
|
||||
// 更新性别
|
||||
updateData.sex = editValue.value
|
||||
await updateUserInfo(updateData)
|
||||
break
|
||||
|
||||
default:
|
||||
// 更新其他字段
|
||||
if (!editValue.value) {
|
||||
uni.showToast({
|
||||
title: getPlaceholder(key),
|
||||
icon: 'none'
|
||||
})
|
||||
return
|
||||
}
|
||||
updateData[key] = editValue.value
|
||||
await updateUserInfo(updateData)
|
||||
break
|
||||
switch (key) {
|
||||
case 'email':
|
||||
// 更新邮箱
|
||||
if (!editForm.value.email || !editForm.value.code) {
|
||||
uni.showToast({
|
||||
title: t('user.pleaseInputCode'),
|
||||
icon: 'none'
|
||||
})
|
||||
return
|
||||
}
|
||||
await updateEmail(userInfo.value.id, editForm.value.email, editForm.value.code)
|
||||
break
|
||||
|
||||
case 'password':
|
||||
// 更新密码
|
||||
if (!passwordOk.value) {
|
||||
uni.showToast({
|
||||
title: passwordNote.value,
|
||||
icon: 'none'
|
||||
})
|
||||
return
|
||||
}
|
||||
if (editForm.value.password !== editForm.value.confirmPassword) {
|
||||
uni.showToast({
|
||||
title: t('user.passwordNotMatch'),
|
||||
icon: 'none'
|
||||
})
|
||||
return
|
||||
}
|
||||
await updatePassword(userInfo.value.id, editForm.value.password)
|
||||
break
|
||||
|
||||
case 'avatar':
|
||||
// 更新头像
|
||||
console.log('avatarUrl.value:', avatarUrl.value)
|
||||
if (!avatarUrl.value) {
|
||||
uni.showToast({
|
||||
title: t('common.pleaseSelect') + t('user.avatar'),
|
||||
icon: 'none'
|
||||
})
|
||||
return
|
||||
}
|
||||
|
||||
// 如果是新上传的图片,需要先上传
|
||||
updateData.avatar = avatarUrl.value
|
||||
await updateUserInfo(updateData)
|
||||
break
|
||||
|
||||
case 'sex':
|
||||
// 更新性别
|
||||
updateData.sex = editValue.value
|
||||
await updateUserInfo(updateData)
|
||||
break
|
||||
|
||||
default:
|
||||
// 更新其他字段
|
||||
if (!editValue.value) {
|
||||
uni.showToast({
|
||||
title: getPlaceholder(key),
|
||||
icon: 'none'
|
||||
})
|
||||
return
|
||||
}
|
||||
updateData[key] = editValue.value
|
||||
await updateUserInfo(updateData)
|
||||
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)
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -8,8 +8,8 @@
|
||||
<view class="recharge_block" @click="chosPric(item)"
|
||||
:class="aloneItem.priceTypeId === item.priceTypeId ? 'selected' : ''"
|
||||
v-for="item in rechargeList.bookBuyConfigList" :key="item.priceTypeId">
|
||||
<view class="recharge_money">¥{{item.realMoney}}</view>
|
||||
<view>{{item.money}}{{$t('order.virtualCoin')}}</view>
|
||||
<view class="recharge_money">¥{{item.money}}</view>
|
||||
<view>{{item.realMoney}}{{$t('order.virtualCoin')}}</view>
|
||||
<!-- 红框位置的618活动标签 -->
|
||||
<!-- <view class="activity-tag">618活动</view> -->
|
||||
<span class="activity-label" v-if="item.givejf >0">618充值活动</span>
|
||||
@@ -23,26 +23,25 @@
|
||||
<view class="cha_fangsh">
|
||||
<view class="cf_title PM_font">{{$t('user.paymentMethod')}}</view>
|
||||
<view class="cf_radio">
|
||||
<radio-group v-for="item in iosPaylist">
|
||||
<radio-group v-for="item in iosPaylist" @click="choseType(item.id)">
|
||||
<view style="width: 100%">
|
||||
<view :class="payType == item.id ? 'Tab_xf cf_xuanx' : 'cf_xuanx'">
|
||||
<!-- <image class="pay_item_img" :src="item.imgUrl" mode="aspectFil">
|
||||
</image> -->
|
||||
<text>{{ item.title }}</text>
|
||||
<radio :checked="payType === item.id" @click="choseType(item.id)"></radio>
|
||||
<radio :checked="payType === item.id"></radio>
|
||||
</view>
|
||||
</view>
|
||||
</radio-group>
|
||||
</view>
|
||||
</view>
|
||||
<view class="agree_wo flexbox">
|
||||
<radio-group class="agree" v-for="(item, index) in argee" :key="index">
|
||||
<radio-group class="agree" v-for="(item, index) in argee" :key="index" @click="radioCheck">
|
||||
<view>
|
||||
<radio class="agreeRadio" :value="item.id" :checked="state" @click="radioCheck" color="#007bff"></radio>
|
||||
<radio class="agreeRadio" :value="item.id" :checked="state" color="#007bff"></radio>
|
||||
</view>
|
||||
</radio-group>
|
||||
<view>{{$t('order.readAgree')}}<span class="highlight"
|
||||
@click="showAgreement">《{{$t('order.valueAddedServices')}}》</span></view>
|
||||
<view>{{$t('order.readAgree')}}<span class="highlight" @click="showAgreement">《{{$t('order.valueAddedServices')}}》</span></view>
|
||||
</view>
|
||||
<view class="bottom-button-container">
|
||||
<button class="recharge-button" @click="handleRecharge">{{$t('order.recharge')}}</button>
|
||||
@@ -62,15 +61,12 @@
|
||||
|
||||
<script setup lang="ts">
|
||||
import { ref, computed, onMounted, toRefs, reactive } from 'vue'
|
||||
import { useI18n } from 'vue-i18n'
|
||||
import { useI18n } from 'vue-i18n'
|
||||
import { useMessage } from '@/uni_modules/wot-design-uni'
|
||||
import { getBookBuyConfigList, getAgreement, getActivityDescription, verifyGooglePay, getPlaceOrder } from '@/api/modules/user'
|
||||
import { onLogin } from '../../../../项目/nuttyreading-hw/config/login';
|
||||
import { useUserStore } from '@/stores/user'
|
||||
const googlePay = uni.requireNativePlugin("sn-googlepay5");
|
||||
import { getBookBuyConfigList, getAgreement, getActivityDescription } from '@/api/modules/user'
|
||||
// const googlePay = uni.requireNativePlugin("sn-googlepay5");
|
||||
const { t } = useI18n()
|
||||
const message = useMessage()
|
||||
const userStore = useUserStore()
|
||||
const payType = ref('1')
|
||||
const iosPaylist = ref([
|
||||
{
|
||||
@@ -111,16 +107,13 @@
|
||||
|
||||
const remark = ref({})
|
||||
const isConnected = ref(false)
|
||||
const purchaseToken = ref()
|
||||
// 订单编号
|
||||
const orderSn = ref('')
|
||||
|
||||
|
||||
/**
|
||||
/**
|
||||
* 获取使用环境
|
||||
*/
|
||||
const getDevName = () => {
|
||||
|
||||
|
||||
if (uni.getSystemInfoSync().platform === "android") {
|
||||
qudao.value = 'Google'
|
||||
isAndroid.value = true;
|
||||
@@ -132,34 +125,9 @@
|
||||
getData()
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取订单编号
|
||||
*/
|
||||
const getPlaceOrderObj = async () => {
|
||||
const {priceTypeId, realMoney, money} = toRefs(aloneItem.value)
|
||||
const data = {
|
||||
userId: userStore.userInfo.id, // 用户di
|
||||
paymentMethod: '5', //支付方式4point 5google
|
||||
orderMoney: money.value, //订单金额
|
||||
realMoney: realMoney.value, //实际金额
|
||||
come: '10', //订单来源 2医学吴门医述 10海外读书
|
||||
orderType: 'point', //订单类型, point充值、order课程、书、vip 课vip、abroadVip 书vip、relearn 复读、trainingClass 培训班
|
||||
productId: priceTypeId.value // 商品id
|
||||
}
|
||||
try {
|
||||
const res = await getPlaceOrder(data)
|
||||
orderSn.value = res.orderSn
|
||||
console.log(orderSn.value, '获取订单号');
|
||||
getGooglePay()
|
||||
} catch (error) {
|
||||
console.error('获取订单号失败', error)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// 点击金额
|
||||
const chosPric = (item : any) => {
|
||||
console.log(item, '金额每项');
|
||||
console.log(item,'金额每项');
|
||||
aloneItem.value = item;
|
||||
};
|
||||
|
||||
@@ -168,6 +136,7 @@
|
||||
*/
|
||||
const radioCheck = () => {
|
||||
state.value = !state.value
|
||||
console.log('点击了', state.value);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -185,7 +154,6 @@
|
||||
console.log(rechargeList.value.bookBuyConfigList, '充值列表');
|
||||
// 默认选择第一个金额
|
||||
aloneItem.value = rechargeList.value.bookBuyConfigList[0]
|
||||
|
||||
} catch (error) {
|
||||
console.error('获取订单列表失败:', error)
|
||||
}
|
||||
@@ -227,17 +195,17 @@
|
||||
// payType.value = val;
|
||||
}
|
||||
|
||||
const handleRecharge = async () => {
|
||||
getPlaceOrderObj()
|
||||
if (!state.value) {
|
||||
const handleRecharge = () => {
|
||||
if(!state.value){
|
||||
uni.showToast({
|
||||
title: t('order.readAgreeServices'),
|
||||
icon: 'none'
|
||||
title: t('order.readAgreeServices'),
|
||||
icon: 'none'
|
||||
})
|
||||
return
|
||||
}
|
||||
uni.showLoading({ title: '生成订单中...' })
|
||||
|
||||
uni.showLoading({ title: '加载中...' })
|
||||
console.log('立即充值');
|
||||
getGooglePay()
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -245,102 +213,59 @@
|
||||
*/
|
||||
const getGooglePay = () => {
|
||||
googlePay.init({
|
||||
}, (e : any) => {
|
||||
}, (e:any) => {
|
||||
console.log('init', e);
|
||||
if (e.code == 0) {
|
||||
isConnected.value = true;
|
||||
getQuerySku()
|
||||
// 初始化成功
|
||||
} else {
|
||||
// 初始化失败
|
||||
isConnected.value = false;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 查询sku
|
||||
*/
|
||||
const getQuerySku = () => {
|
||||
const getQuerySku = () =>{
|
||||
const id = aloneItem.value.priceTypeId
|
||||
console.log(id, '获取每项');
|
||||
googlePay.querySku(
|
||||
{
|
||||
inapp: [id], // 与subs二选一, 参数为商品ID(字符串)数组
|
||||
},
|
||||
(e : any) => {
|
||||
if (e.code == 0) {
|
||||
// 查询成功.
|
||||
console.log('querySku查询成功', e);
|
||||
uni.hideLoading()
|
||||
getPayAll()
|
||||
} else {
|
||||
console.log('查询失败', e);
|
||||
// 查询失败
|
||||
}
|
||||
}
|
||||
{
|
||||
inapp: [id], // 与subs二选一, 参数为商品ID(字符串)数组
|
||||
},
|
||||
(e:any) => {
|
||||
if (e.code == 0) {
|
||||
// 查询成功.
|
||||
console.log('查询成功',e);
|
||||
// e.list; // 查询结果, array
|
||||
} else {
|
||||
console.log('查询失败');
|
||||
// 查询失败
|
||||
}
|
||||
}
|
||||
)
|
||||
}
|
||||
|
||||
/**
|
||||
* 发起支付
|
||||
*/
|
||||
const getPayAll = () => {
|
||||
console.log(aloneItem.value.priceTypeId, orderSn.value, '发起支付传入产品id,订单id');
|
||||
googlePay.payAll(
|
||||
{
|
||||
productId: aloneItem.value.priceTypeId, // 产品id
|
||||
accountId: orderSn.value // 订单编号
|
||||
},
|
||||
(e : any) => {
|
||||
if (e.code == 0) {
|
||||
purchaseToken.value = e.data[0].original.purchaseToken
|
||||
// 支付成功
|
||||
console.log(e, 'payAll方法成功返参');
|
||||
getConsume()
|
||||
} else {
|
||||
uni.showToast({ title: '支付失败', icon: 'success' })
|
||||
console.log(e, 'e');
|
||||
// 支付失败
|
||||
}
|
||||
},
|
||||
)
|
||||
}
|
||||
|
||||
/**
|
||||
* 消耗品 确认交易
|
||||
*/
|
||||
const getConsume = () => {
|
||||
googlePay.consume(
|
||||
{
|
||||
purchaseToken: purchaseToken.value, // 来自支付结果的original.purchaseToken (或 original.token)
|
||||
},
|
||||
(e : any) => {
|
||||
if (e.code == 0) {
|
||||
console.log(e, '确认交易成功');
|
||||
// 确认成功
|
||||
googleVerify()
|
||||
} else {
|
||||
console.log(e, '确认交易失败');
|
||||
// 确认失败
|
||||
}
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* 校验订单
|
||||
*/
|
||||
const googleVerify = async () => {
|
||||
try {
|
||||
const obj = await verifyGooglePay(aloneItem.value.priceTypeId, purchaseToken.value, orderSn.value)
|
||||
uni.switchTab({
|
||||
url: '/pages/user/index'
|
||||
})
|
||||
console.log(obj, '校验订单');
|
||||
} catch (error) {
|
||||
console.error('校验订单失败:', error)
|
||||
}
|
||||
|
||||
const getPayAll = () =>{
|
||||
googlePay.payAll(
|
||||
{
|
||||
productId: "", // 产品id
|
||||
|
||||
},
|
||||
(e) => {
|
||||
if (e.code == 0) {
|
||||
// 支付成功
|
||||
e.data; //支付结果, array [ {original:{ }, signature: ''} ]
|
||||
} else {
|
||||
// 支付失败
|
||||
}
|
||||
},
|
||||
)
|
||||
}
|
||||
|
||||
|
||||
onMounted(() => {
|
||||
getDevName();
|
||||
@@ -462,7 +387,7 @@
|
||||
border-bottom: 1px solid #ededed;
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
align-items: center;
|
||||
align-items:center;
|
||||
|
||||
image {
|
||||
width: 40rpx;
|
||||
|
||||
Reference in New Issue
Block a user