From f9cad8d740f89c65e04b2917c99d2f245c3a4bc3 Mon Sep 17 00:00:00 2001 From: fuchao <2577131060@qq.com> Date: Thu, 27 Nov 2025 14:17:50 +0800 Subject: [PATCH] =?UTF-8?q?=E6=9B=B4=E6=96=B0=EF=BC=9A=E8=B0=B7=E6=AD=8C?= =?UTF-8?q?=E6=94=AF=E4=BB=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- api/modules/user.ts | 331 +++++++++++++++++++--------------- pages.json | 8 +- pages/user/index.vue | 28 ++- pages/user/recharge/index.vue | 189 +++++++++++++------ 4 files changed, 341 insertions(+), 215 deletions(-) diff --git a/api/modules/user.ts b/api/modules/user.ts index a411c7c..e808b46 100644 --- a/api/modules/user.ts +++ b/api/modules/user.ts @@ -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>({ - url: 'common/user/getUserInfo', - method: 'POST' - }) - return res + const res = await mainClient.request>({ + url: 'common/user/getUserInfo', + method: 'POST' + }) + return res } /** * 获取VIP信息 */ export async function getVipInfo() { - const res = await mainClient.request>({ - url: 'bookAbroad/home/getVipInfo', - method: 'POST' - }) - return res + const res = await mainClient.request>({ + 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 }>>({ - 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 }>>({ + 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>({ - url: 'book/sysdictdata/getData', - method: 'POST', - data: { dictLabel: 'googleVip' } - }) - return res + const res = await mainClient.request>({ + url: 'book/sysdictdata/getData', + method: 'POST', + data: { dictLabel: 'googleVip' } + }) + return res } /** * 创建订单 * @param data 订单数据 */ -export async function createOrder(data: any) { - const res = await mainClient.request>({ - url: 'bookAbroad/order/placeOrder', - method: 'POST', - data - }) - return res +export async function createOrder(data : any) { + const res = await mainClient.request>({ + url: 'bookAbroad/order/placeOrder', + method: 'POST', + data + }) + return res } /** * 获取交易记录列表 * @param userId 用户ID */ -export async function getTransactionList(userId: number) { - const res = await mainClient.request>({ - url: 'common/transactionDetails/getTransactionDetailsList', - method: 'POST', - data: { userId } - }) - return res +export async function getTransactionList(userId : number) { + const res = await mainClient.request>({ + url: 'common/transactionDetails/getTransactionDetailsList', + method: 'POST', + data: { userId } + }) + return res } /** * 更新用户基本信息 * @param data 用户信息 */ -export async function updateUserInfo(data: Partial) { - const res = await mainClient.request({ - url: 'book/user/update', - method: 'POST', - data - }) - return res +export async function updateUserInfo(data : Partial) { + const res = await mainClient.request({ + url: 'book/user/update', + method: 'POST', + data + }) + return res } /** @@ -105,13 +105,13 @@ export async function updateUserInfo(data: Partial) { * @param email 邮箱地址 * @param code 验证码 */ -export async function updateEmail(id: number, email: string, code: string) { - const res = await mainClient.request({ - 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({ + 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({ - 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({ + 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({ - 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({ + 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 { - 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 { + 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({ - url: 'common/sysFeedback/addSysFeedback', - method: 'POST', - data - }) - return res +export async function submitFeedback(data : IFeedbackForm) { + const res = await mainClient.request({ + url: 'common/sysFeedback/addSysFeedback', + method: 'POST', + data + }) + return res } /** @@ -194,26 +194,27 @@ export async function submitFeedback(data: IFeedbackForm) { * @param orderSn 订单号 * @param productId 产品ID */ -export async function verifyGooglePay(purchaseToken: string, orderSn: string, productId: string) { - const res = await mainClient.request({ - url: 'pay/googlepay/googleVerify', - method: 'POST', - data: { purchaseToken, orderSn, productId } - }) - return res +export async function verifyGooglePay(productId : number, purchaseToken : string, orderSn : string) { + console.log(productId, purchaseToken, orderSn); + const res = await mainClient.request({ + url: 'pay/googlepay/googleVerify', + method: 'POST', + data: { productId, purchaseToken, orderSn } + }) + return res } /** * 验证IAP支付 * @param data 支付数据 */ -export async function verifyIAP(data: any) { - const res = await mainClient.request({ - url: 'Ipa/veri', - method: 'POST', - data - }) - return res +export async function verifyIAP(data : any) { + const res = await mainClient.request({ + url: 'Ipa/veri', + method: 'POST', + data + }) + return res } /** @@ -221,48 +222,80 @@ export async function verifyIAP(data: any) { * @param type 固定值 point * @param qudao 支付类型 */ -export async function getBookBuyConfigList(type: string, qudao: string) { - const res = await mainClient.request({ - url: 'common/bookBuyConfig/getBookBuyConfigList', - method: 'POST', - data: {type, qudao} - }) - return res +export async function getBookBuyConfigList(type : string, qudao : string) { + const res = await mainClient.request({ + 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({ - url: '/sys/agreement/getAgreement', - method: 'POST', - data: {id} - }) - return res + const res = await mainClient.request({ + url: '/sys/agreement/getAgreement', + method: 'POST', + data: { id } + }) + return res } /** * 获取活动说明 */ export async function getActivityDescription() { - const res = await mainClient.request({ - url: 'common/bookBuyConfig/getRechargeActivity', - method: 'POST' - }) - return res + const res = await mainClient.request({ + url: 'common/bookBuyConfig/getRechargeActivity', + method: 'POST' + }) + return res } /** - * 获取充值列表 - */ -export async function getTransactionDetailsList(current: number, limit: number, userId: string,) { - const res = await mainClient.request({ - url: 'common/transactionDetails/getTransactionDetailsList', - method: 'POST', - data: { current, limit, userId, } - }) - 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({ + url: 'common/transactionDetails/getTransactionDetailsList', + method: 'POST', + data: { current, limit, userId, } + }) + return res +} + +/** + * 获取订单编号 + * @return + */ +export async function getPlaceOrder(data: object) { + + const res = await mainClient.request({ + 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({ + url: 'common/jfTransactionDetails/getJfTransactionDetailsList', + method: 'POST', + data: { current, limit, userId, } + }) + return res } \ No newline at end of file diff --git a/pages.json b/pages.json index a3e350b..a6d07df 100644 --- a/pages.json +++ b/pages.json @@ -79,7 +79,13 @@ "navigationBarTitleText": "%user.virtual%", "navigationStyle": "custom" } - }, { + },{ + "path": "pages/user/points/index", + "style": { + "navigationBarTitleText": "%user.points%", + "navigationStyle": "custom" + } + },{ "path": "pages/user/myBook/index", "style": { "navigationStyle": "custom", diff --git a/pages/user/index.vue b/pages/user/index.vue index 7823570..8ca6958 100644 --- a/pages/user/index.vue +++ b/pages/user/index.vue @@ -47,14 +47,14 @@ 天医币 {{userInfo.peanutCoin ?? 1}} - + 积分 {{userInfo.jf ?? 1}} - + 充 值 618充值活动 @@ -23,25 +23,26 @@ {{$t('user.paymentMethod')}} - + {{ item.title }} - + - + - + - {{$t('order.readAgree')}}《{{$t('order.valueAddedServices')}}》 + {{$t('order.readAgree')}}《{{$t('order.valueAddedServices')}}》 @@ -61,12 +62,15 @@