Compare commits
36 Commits
master
...
44096df651
| Author | SHA1 | Date | |
|---|---|---|---|
| 44096df651 | |||
| c2221bae4c | |||
| aa6639ad6c | |||
| fa21c7bb74 | |||
| 008bc08f81 | |||
| ca581eeca2 | |||
| 03afe41793 | |||
| 385c28428e | |||
| 677fe7436e | |||
| a53f482728 | |||
| e61ceaf5f3 | |||
| 98738a494f | |||
| 35e27753b8 | |||
| d653575d27 | |||
| fecbb79508 | |||
| 0ab55b538b | |||
| b4585c93a6 | |||
| 1049030a46 | |||
| cd54ee48de | |||
| 4b706bb811 | |||
| 23de3944dc | |||
| 299989c75a | |||
| 1d7d00b6b6 | |||
| bdf1b41098 | |||
| ef2c63784f | |||
| 3d20683d76 | |||
| 0e7952ac4e | |||
| 8f890a6802 | |||
| 8edf719431 | |||
| 3587e15e7a | |||
| 79c6fb247c | |||
| f289e927bb | |||
| 85ca0c7a28 | |||
| 12de098e10 | |||
| 878e49dc2e | |||
| 435a23f995 |
4
App.vue
4
App.vue
@@ -1,13 +1,13 @@
|
||||
<script>
|
||||
// #ifdef APP-PLUS
|
||||
import updata from "@/uni_modules/uni-upgrade-center-app/utils/check-update";
|
||||
import update from "@/uni_modules/uni-upgrade-center-app/utils/check-update";
|
||||
// #endif
|
||||
export default {
|
||||
onLaunch: function() {
|
||||
console.log('App Launch')
|
||||
// 检测自动更新
|
||||
// #ifdef APP-PLUS
|
||||
updata();
|
||||
update();
|
||||
// #endif
|
||||
},
|
||||
onShow: function() {
|
||||
|
||||
@@ -6,6 +6,8 @@ import { createRequestClient } from '../request';
|
||||
import { SERVICE_MAP } from '../config';
|
||||
|
||||
export const paymentClient = createRequestClient({
|
||||
baseURL: SERVICE_MAP.PAYMENT,
|
||||
baseURL: SERVICE_MAP.MAIN,
|
||||
// baseURL: SERVICE_MAP.PAYMENT,
|
||||
loading: false
|
||||
});
|
||||
|
||||
|
||||
@@ -34,7 +34,7 @@ export function responseInterceptor(res: UniApp.RequestSuccessCallbackResult) {
|
||||
}
|
||||
|
||||
// 可能为字符串,尝试解析(原项目也做了类似处理)
|
||||
let httpData: IApiResponse | string = res.data as any;
|
||||
let httpData: IApiResponse | string = res.data;
|
||||
if (typeof httpData === 'string') {
|
||||
try {
|
||||
httpData = JSON.parse(httpData);
|
||||
@@ -44,19 +44,20 @@ export function responseInterceptor(res: UniApp.RequestSuccessCallbackResult) {
|
||||
}
|
||||
|
||||
// 规范化 message 字段
|
||||
const message = (httpData as any).msg || (httpData as any).message || (httpData as any).errMsg || '';
|
||||
const message = (httpData as IApiResponse).msg || (httpData as IApiResponse).message || (httpData as IApiResponse).errMsg || '';
|
||||
|
||||
// 成功判断:与原项目一致的条件
|
||||
const successFlag = (httpData as any).success === true || (httpData as any).code === 0;
|
||||
const code = (httpData as IApiResponse).code;
|
||||
|
||||
// 成功判断
|
||||
const successFlag = (httpData as IApiResponse).success === true || code === 0;
|
||||
|
||||
if (successFlag) {
|
||||
// 返回原始 httpData(与原项目 dataFactory 返回 Promise.resolve(httpData) 保持一致)
|
||||
// 但大多数调用者更关心 data 字段,这里返回整个 httpData,调用者可取 .data
|
||||
// 返回原始 httpData
|
||||
// 实际数据每个接口不同,调用者需根据实际情况取 .data 字段
|
||||
return Promise.resolve(httpData);
|
||||
}
|
||||
|
||||
// 登录失效或需要强制登录的一些 code(与原项目一致)
|
||||
const code = (httpData as any).code;
|
||||
// 登录失效或需要强制登录的一些 code
|
||||
if (code === '401' || code === 401) {
|
||||
// 触发登出流程
|
||||
handleAuthExpired();
|
||||
@@ -64,7 +65,7 @@ export function responseInterceptor(res: UniApp.RequestSuccessCallbackResult) {
|
||||
}
|
||||
|
||||
// 原项目还将 1000,1001,1100,402 等视作需要强制登录
|
||||
if (code === '1000' || code === '1001' || code === 1000 || code === 1001 || code === 1100 || code === '402' || code === 402) {
|
||||
if (code == 1000 || code == 1001 || code === 1100 || code === 402) {
|
||||
handleAuthExpired();
|
||||
return Promise.reject({ statusCode: 0, errMsg: message || t('global.loginExpired'), data: httpData });
|
||||
}
|
||||
|
||||
@@ -114,7 +114,7 @@ export const courseApi = {
|
||||
},
|
||||
|
||||
/**
|
||||
* 开始学习免费课程
|
||||
* 领取免费课程
|
||||
* @param catalogueId 目录ID
|
||||
*/
|
||||
startStudyForMF(catalogueId: number) {
|
||||
|
||||
27
api/modules/news.ts
Normal file
27
api/modules/news.ts
Normal file
@@ -0,0 +1,27 @@
|
||||
import { mainClient } from '@/api/clients/main'
|
||||
import type { IApiResponse } from '@/api/types'
|
||||
|
||||
export const newsApi = {
|
||||
/**
|
||||
* 获取新闻详情
|
||||
*/
|
||||
getNewsDetail: async (newsId: string | number) => {
|
||||
const res = await mainClient.request<IApiResponse<any>>({
|
||||
url: `common/message/getMessageById?id=${newsId}`,
|
||||
method: 'POST'
|
||||
})
|
||||
return res
|
||||
},
|
||||
|
||||
/**
|
||||
* 获取太湖之光文章详情
|
||||
*/
|
||||
getTaihuWelfareArticleDetail: async (newsId: string | number) => {
|
||||
const res = await mainClient.request<IApiResponse<any>>({
|
||||
url: 'common/taihuWelfare/getTaihuWelfareArticleDetail',
|
||||
method: 'POST',
|
||||
data: { id: newsId }
|
||||
})
|
||||
return res
|
||||
}
|
||||
}
|
||||
@@ -9,7 +9,8 @@ import type {
|
||||
ICoupon,
|
||||
ICourseOrderCreateParams,
|
||||
IOrderInitData,
|
||||
IGoodsDiscountParams
|
||||
IGoodsDiscountParams,
|
||||
IOrderDetail
|
||||
} from '@/types/order'
|
||||
import type { IUserInfo } from '@/types/user'
|
||||
|
||||
@@ -30,19 +31,6 @@ export const orderApi = {
|
||||
return res
|
||||
},
|
||||
|
||||
/**
|
||||
* 验证 Google Pay 支付
|
||||
* @param params 支付验证参数
|
||||
*/
|
||||
async verifyGooglePay(params: IGooglePayVerifyParams) {
|
||||
const res = await mainClient.request<IApiResponse>({
|
||||
url: 'pay/googlepay/googleVerify',
|
||||
method: 'POST',
|
||||
data: params
|
||||
})
|
||||
return res
|
||||
},
|
||||
|
||||
/**
|
||||
* 获取用户信息(包含虚拟币余额)
|
||||
*/
|
||||
@@ -106,7 +94,7 @@ export const orderApi = {
|
||||
},
|
||||
|
||||
/**
|
||||
* 获取地区优惠金额
|
||||
* 获取活动优惠金额
|
||||
* @param productList 商品列表
|
||||
*/
|
||||
async getDistrictAmount(productList: IGoodsDiscountParams[]) {
|
||||
@@ -155,5 +143,18 @@ export const orderApi = {
|
||||
data
|
||||
})
|
||||
return res
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
* 获取订单详情
|
||||
* @param orderId 订单ID
|
||||
*/
|
||||
async getOrderDetail(orderId: string) {
|
||||
const res = await mainClient.request<IApiResponse<{ buyOrder: IOrderDetail, productInfo: IOrderGoods[] }>>({
|
||||
url: 'common/buyOrder/commonOrderDetail',
|
||||
method: 'POST',
|
||||
data: { orderId }
|
||||
})
|
||||
return res
|
||||
},
|
||||
}
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
// api/modules/user.ts
|
||||
import { mainClient } from '@/api/clients/main'
|
||||
import { paymentClient } from '@/api/clients/payment'
|
||||
import type { IApiResponse } from '@/api/types'
|
||||
import type {
|
||||
IUserInfo,
|
||||
@@ -194,11 +195,12 @@ 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<IApiResponse>({
|
||||
export async function verifyGooglePay(productId: number, purchaseToken: string, orderSn: string) {
|
||||
console.log(productId, purchaseToken, orderSn);
|
||||
const res = await paymentClient.request<IApiResponse>({
|
||||
url: 'pay/googlepay/googleVerify',
|
||||
method: 'POST',
|
||||
data: { purchaseToken, orderSn, productId }
|
||||
data: { productId, purchaseToken, orderSn }
|
||||
})
|
||||
return res
|
||||
}
|
||||
@@ -235,7 +237,6 @@ export async function getBookBuyConfigList(type: string, qudao: string) {
|
||||
* @param id 101众妙之门隐私政策
|
||||
*/
|
||||
export async function getAgreement(id: string) {
|
||||
console.log(id, 'id');
|
||||
const res = await mainClient.request<IApiResponse>({
|
||||
url: '/sys/agreement/getAgreement',
|
||||
method: 'POST',
|
||||
@@ -256,13 +257,60 @@ export async function getActivityDescription() {
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取充值列表
|
||||
*/
|
||||
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
|
||||
* 充值记录列表
|
||||
* @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 paymentClient.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
|
||||
}
|
||||
|
||||
/**
|
||||
* 迁移用户数据
|
||||
* @param tel 旧账号
|
||||
* @param code 迁移验证码
|
||||
* @return
|
||||
*/
|
||||
export async function migrateUserData(data: { tel: string, code: string }) {
|
||||
const res = await mainClient.request<IApiResponse>({
|
||||
url: 'common/user/migrationWumenData',
|
||||
method: 'POST',
|
||||
data
|
||||
})
|
||||
return res
|
||||
}
|
||||
@@ -8,6 +8,7 @@ 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
|
||||
@@ -22,15 +23,19 @@ export function createRequestClient(cfg: ICreateClientConfig) {
|
||||
const intercepted = requestInterceptor(final as IRequestOptions);
|
||||
|
||||
// 全局处理请求 loading
|
||||
const loading = !cfg.loading ? true : cfg.loading // 接口请求参数不传loading,默认显示loading
|
||||
loading && uni.showLoading()
|
||||
const loading = cfg.loading ?? true // 接口请求参数不传loading,默认显示loading
|
||||
if (loading) {
|
||||
uni.showLoading({ mask: true })
|
||||
reqCount++
|
||||
}
|
||||
|
||||
return new Promise((resolve, reject) => {
|
||||
uni.request({
|
||||
...intercepted,
|
||||
complete() {
|
||||
// 请求完成关闭 loading
|
||||
loading && uni.hideLoading()
|
||||
loading && reqCount--
|
||||
reqCount <= 0 && uni.hideLoading()
|
||||
},
|
||||
success(res: any) {
|
||||
// 委托给响应拦截器处理
|
||||
|
||||
@@ -26,7 +26,7 @@
|
||||
<text>{{ $t('book.listen') }}</text>
|
||||
</view>
|
||||
|
||||
<view
|
||||
<!-- <view
|
||||
v-if="!isIOS"
|
||||
class="action-btn review"
|
||||
@click.stop="handleReview"
|
||||
@@ -35,7 +35,7 @@
|
||||
<image src="@/static/icon/icon_pl.png" mode="aspectFit" />
|
||||
</view>
|
||||
<text>{{ $t('book.comment') }}</text>
|
||||
</view>
|
||||
</view> -->
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
|
||||
49
components/book/BookPrice.vue
Normal file
49
components/book/BookPrice.vue
Normal file
@@ -0,0 +1,49 @@
|
||||
<template>
|
||||
<view class="book-price-container">
|
||||
<view v-if="data.isBuy" class="book-flag">已购买</view>
|
||||
<view v-else-if="data.isVip == '0'" class="book-flag">免费</view>
|
||||
<view v-else-if="userHasVip && data.isVip == '1'" class="book-price">VIP免费</view>
|
||||
<view v-else class="book-price">{{ data.minPrice }} {{ $t('global.coin') }}</view>
|
||||
<view>
|
||||
<text v-if="data.readCount" class="book-flag">{{ `${data.readCount}${$t('bookHome.readingCount')}` }}</text>
|
||||
<text v-else-if="data.buyCount" class="book-flag">{{ `${data.buyCount}${$t('bookHome.purchased')}` }}</text>
|
||||
</view>
|
||||
</view>
|
||||
</template>
|
||||
|
||||
<script lang="ts" setup>
|
||||
import { computed } from 'vue'
|
||||
import type { IBook } from '@/types/book'
|
||||
import { useUserStore } from '@/stores/user'
|
||||
|
||||
const userStore = useUserStore()
|
||||
|
||||
// 检查用户是否为VIP
|
||||
const userHasVip = computed(() => userStore.userInfo?.userEbookVip?.length > 0)
|
||||
|
||||
const props = defineProps({
|
||||
data: {
|
||||
type: Object as () => IBook,
|
||||
default: () => ({})
|
||||
}
|
||||
})
|
||||
</script>
|
||||
|
||||
<style lang="scss" scoped>
|
||||
.book-price-container {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: space-between;
|
||||
}
|
||||
|
||||
.book-price {
|
||||
font-size: 28rpx;
|
||||
color: #ff4703;
|
||||
}
|
||||
|
||||
.book-flag {
|
||||
font-size: 26rpx;
|
||||
color: #999;
|
||||
}
|
||||
|
||||
</style>
|
||||
@@ -1,96 +0,0 @@
|
||||
<template>
|
||||
<view
|
||||
v-if="catalogues.length > 1"
|
||||
:class="['catalogue-list', userVip ? 'vip-style' : '']"
|
||||
>
|
||||
<view
|
||||
v-for="(catalogue, index) in catalogues"
|
||||
:key="catalogue.id"
|
||||
:class="['catalogue-item', currentIndex === index ? 'active' : '']"
|
||||
@click="handleSelect(index)"
|
||||
>
|
||||
<text class="catalogue-title">{{ catalogue.title }}</text>
|
||||
</view>
|
||||
</view>
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
import type { ICatalogue, IVipInfo } from '@/types/course'
|
||||
|
||||
interface Props {
|
||||
catalogues: ICatalogue[]
|
||||
currentIndex: number
|
||||
userVip: IVipInfo | null
|
||||
}
|
||||
|
||||
const props = defineProps<Props>()
|
||||
|
||||
const emit = defineEmits<{
|
||||
change: [index: number]
|
||||
}>()
|
||||
|
||||
/**
|
||||
* 选择目录
|
||||
*/
|
||||
const handleSelect = (index: number) => {
|
||||
if (index === props.currentIndex) return
|
||||
emit('change', index)
|
||||
}
|
||||
</script>
|
||||
|
||||
<style lang="scss" scoped>
|
||||
.catalogue-list {
|
||||
display: flex;
|
||||
align-items: flex-end;
|
||||
padding: 20rpx;
|
||||
padding-bottom: 0;
|
||||
border-radius: 20rpx 20rpx 0 0;
|
||||
margin-top: 20rpx;
|
||||
|
||||
&.vip-style {
|
||||
background: linear-gradient(90deg, #6429db 0%, #0075ed 100%);
|
||||
|
||||
.catalogue-item {
|
||||
background-color: rgba(0, 0, 0, 0.4);
|
||||
color: #fff;
|
||||
border-color: #fff;
|
||||
|
||||
&.active {
|
||||
background-color: #258feb;
|
||||
color: #fff;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
.catalogue-item {
|
||||
flex: 1;
|
||||
text-align: center;
|
||||
padding: 16rpx 0;
|
||||
margin-right: 10rpx;
|
||||
border-radius: 20rpx 20rpx 0 0;
|
||||
border: 1px solid #fff;
|
||||
border-bottom: none;
|
||||
background-color: rgba(0, 0, 0, 0.4);
|
||||
color: #fff;
|
||||
transition: all 0.3s;
|
||||
|
||||
&:last-child {
|
||||
margin-right: 0;
|
||||
}
|
||||
|
||||
&.active {
|
||||
background-color: #258feb;
|
||||
padding: 20rpx 0;
|
||||
|
||||
.catalogue-title {
|
||||
font-size: 36rpx;
|
||||
font-weight: bold;
|
||||
}
|
||||
}
|
||||
|
||||
.catalogue-title {
|
||||
font-size: 30rpx;
|
||||
}
|
||||
}
|
||||
}
|
||||
</style>
|
||||
@@ -1,323 +0,0 @@
|
||||
<template>
|
||||
<view class="chapter-list">
|
||||
<!-- 目录状态信息 -->
|
||||
<view v-if="catalogue" class="catalogue-status">
|
||||
<view v-if="catalogue.isBuy === 1 || userVip" class="purchased-info">
|
||||
<view class="info-row">
|
||||
<text v-if="userVip">
|
||||
VIP畅学权益有效期截止到:{{ userVip.endTime }}
|
||||
</text>
|
||||
<template v-else>
|
||||
<text v-if="!catalogue.startTime">
|
||||
当前目录还未开始学习
|
||||
</text>
|
||||
<text v-else>
|
||||
课程有效期截止到:{{ catalogue.endTime }}
|
||||
</text>
|
||||
<wd-button
|
||||
v-if="catalogue.startTime"
|
||||
size="small"
|
||||
@click="handleRenew"
|
||||
>
|
||||
续费
|
||||
</wd-button>
|
||||
</template>
|
||||
</view>
|
||||
</view>
|
||||
|
||||
<!-- 未购买状态 -->
|
||||
<view v-else-if="catalogue.type === 0" class="free-course">
|
||||
<wd-button type="success" @click="handleGetFreeCourse">
|
||||
{{ $t('courseDetails.free') }}
|
||||
</wd-button>
|
||||
</view>
|
||||
|
||||
<view v-else class="unpurchased-info">
|
||||
<text class="tip-text">
|
||||
{{ $t('courseDetails.unpurchasedTip') }}
|
||||
</text>
|
||||
<view class="action-btns">
|
||||
<wd-button size="small" type="warning" @click="handlePurchase">
|
||||
{{ $t('courseDetails.purchase') }}
|
||||
</wd-button>
|
||||
<wd-button
|
||||
v-if="showRenewBtn"
|
||||
size="small"
|
||||
type="success"
|
||||
@click="handleRenew"
|
||||
>
|
||||
{{ $t('courseDetails.relearn') }}
|
||||
</wd-button>
|
||||
<wd-button size="small" type="primary" @click="goToVip">
|
||||
{{ $t('courseDetails.openVip') }}
|
||||
</wd-button>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
|
||||
<view v-if="chapters.length > 0" class="chapter-content">
|
||||
<!-- VIP标识 -->
|
||||
<view v-if="userVip" class="vip-badge">
|
||||
<text>VIP畅学权益生效中</text>
|
||||
</view>
|
||||
|
||||
<!-- 章节列表 -->
|
||||
<view
|
||||
v-for="(chapter, index) in chapters"
|
||||
:key="chapter.id"
|
||||
class="chapter-item"
|
||||
@click="handleChapterClick(chapter)"
|
||||
>
|
||||
<view class="chapter-content-wrapper">
|
||||
<view :class="['chapter-info', !canAccess(chapter) ? 'locked' : '']">
|
||||
<text class="chapter-title">{{ chapter.title }}</text>
|
||||
|
||||
<!-- 试听标签 -->
|
||||
<wd-tag
|
||||
v-if="chapter.isAudition === 1 && !isPurchased && !userVip"
|
||||
type="success"
|
||||
plain
|
||||
size="small"
|
||||
custom-class="chapter-tag"
|
||||
>
|
||||
试听
|
||||
</wd-tag>
|
||||
|
||||
<!-- 学习状态标签 -->
|
||||
<template v-if="isPurchased || userVip">
|
||||
<wd-tag
|
||||
v-if="chapter.isLearned === 0"
|
||||
type="primary"
|
||||
plain
|
||||
size="small"
|
||||
custom-class="chapter-tag"
|
||||
>
|
||||
未学
|
||||
</wd-tag>
|
||||
<wd-tag
|
||||
v-else
|
||||
type="success"
|
||||
plain
|
||||
size="small"
|
||||
custom-class="chapter-tag"
|
||||
>
|
||||
已学
|
||||
</wd-tag>
|
||||
</template>
|
||||
</view>
|
||||
|
||||
<!-- 锁定图标 -->
|
||||
<view v-if="!canAccess(chapter)" class="lock-icon">
|
||||
<wd-icon name="lock-on" size="24px" color="#258feb" />
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
|
||||
<!-- 暂无章节 -->
|
||||
<view v-else class="no-chapters">
|
||||
<text>暂无章节内容</text>
|
||||
</view>
|
||||
</view>
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
import { ref, computed } from 'vue'
|
||||
import type { IChapter, ICatalogue, IVipInfo } from '@/types/course'
|
||||
|
||||
interface Props {
|
||||
chapters: IChapter[]
|
||||
catalogue: ICatalogue
|
||||
userVip: IVipInfo | null
|
||||
showRenewBtn?: boolean
|
||||
}
|
||||
|
||||
const props = defineProps<Props>()
|
||||
|
||||
const emit = defineEmits<{
|
||||
click: [chapter: IChapter],
|
||||
purchase: [catalogue: ICatalogue],
|
||||
renew: [catalogue: ICatalogue],
|
||||
toVip: [catalogue: ICatalogue],
|
||||
}>()
|
||||
|
||||
/**
|
||||
* 判断目录是否已购买
|
||||
*/
|
||||
const isPurchased = computed(() => {
|
||||
return props.catalogue.isBuy === 1
|
||||
})
|
||||
// 购买
|
||||
const handlePurchase = () => {
|
||||
emit('purchase', props.catalogue)
|
||||
}
|
||||
// 去开通vip
|
||||
const goToVip = () => {
|
||||
emit('toVip', props.catalogue)
|
||||
}
|
||||
|
||||
// 续费/复读
|
||||
const handleRenew = () => {
|
||||
emit('renew', props.catalogue)
|
||||
}
|
||||
|
||||
// 领取免费课程
|
||||
const handleGetFreeCourse = () => {
|
||||
emit('purchase', props.catalogue)
|
||||
}
|
||||
|
||||
/**
|
||||
* 判断章节是否可以访问
|
||||
*/
|
||||
const canAccess = (chapter: IChapter): boolean => {
|
||||
// VIP用户可以访问所有章节
|
||||
if (props.userVip) return true
|
||||
|
||||
// 已购买目录可以访问所有章节
|
||||
if (isPurchased.value) return true
|
||||
|
||||
// 试听章节可以访问
|
||||
if (chapter.isAudition === 1) return true
|
||||
|
||||
// 免费课程可以访问
|
||||
if (props.catalogue.type === 0) return true
|
||||
|
||||
return false
|
||||
}
|
||||
|
||||
/**
|
||||
* 点击章节
|
||||
*/
|
||||
const handleChapterClick = (chapter: IChapter) => {
|
||||
if (!canAccess(chapter)) {
|
||||
if (props.catalogue.type === 0) {
|
||||
uni.showToast({
|
||||
title: '请先领取课程',
|
||||
icon: 'none'
|
||||
})
|
||||
} else {
|
||||
uni.showToast({
|
||||
title: '请先购买课程',
|
||||
icon: 'none'
|
||||
})
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
emit('click', chapter)
|
||||
}
|
||||
</script>
|
||||
|
||||
<style lang="scss" scoped>
|
||||
.chapter-list {
|
||||
padding: 20rpx;
|
||||
}
|
||||
|
||||
.catalogue-status {
|
||||
padding: 20rpx;
|
||||
margin-bottom: 20rpx;
|
||||
background-color: #fff;
|
||||
|
||||
.purchased-info {
|
||||
.info-row {
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
align-items: center;
|
||||
font-size: 26rpx;
|
||||
line-height: 50rpx;
|
||||
}
|
||||
}
|
||||
|
||||
.free-course {
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
.unpurchased-info {
|
||||
.tip-text {
|
||||
display: block;
|
||||
font-size: 26rpx;
|
||||
color: #666;
|
||||
margin-bottom: 20rpx;
|
||||
line-height: 1.6;
|
||||
}
|
||||
|
||||
.action-btns {
|
||||
display: flex;
|
||||
gap: 20rpx;
|
||||
justify-content: center;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
.chapter-content {
|
||||
position: relative;
|
||||
padding: 20rpx;
|
||||
border: 4rpx solid #fffffc;
|
||||
background: linear-gradient(52deg, #e8f6ff 0%, #e3f2fe 50%);
|
||||
box-shadow: 0px 0px 10px 0px #89c8e9;
|
||||
border-top-right-radius: 40rpx;
|
||||
border-bottom-left-radius: 40rpx;
|
||||
|
||||
.vip-badge {
|
||||
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;
|
||||
border-radius: 0 50rpx 50rpx 0;
|
||||
z-index: 1;
|
||||
}
|
||||
|
||||
.chapter-item {
|
||||
padding: 20rpx 0;
|
||||
border-bottom: 1px solid #fff;
|
||||
|
||||
&:last-child {
|
||||
border-bottom: none;
|
||||
}
|
||||
|
||||
.chapter-content-wrapper {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: space-between;
|
||||
|
||||
.chapter-info {
|
||||
flex: 1;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 10rpx;
|
||||
|
||||
&.locked {
|
||||
opacity: 0.6;
|
||||
}
|
||||
|
||||
.chapter-title {
|
||||
flex: 1;
|
||||
font-size: 28rpx;
|
||||
color: #1e2f3e;
|
||||
line-height: 1.5;
|
||||
}
|
||||
|
||||
.chapter-tag {
|
||||
flex-shrink: 0;
|
||||
}
|
||||
}
|
||||
|
||||
.lock-icon {
|
||||
margin-left: 20rpx;
|
||||
flex-shrink: 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
.no-chapters {
|
||||
text-align: center;
|
||||
padding: 80rpx 0;
|
||||
color: #999;
|
||||
font-size: 28rpx;
|
||||
}
|
||||
</style>
|
||||
@@ -1,394 +0,0 @@
|
||||
<template>
|
||||
<div class="ali-player-wrapper" :style="{ background: '#000' }">
|
||||
<div v-if="showError" class="player-error">{{ errorText }}</div>
|
||||
|
||||
<div ref="playerContainer" class="player-container" :style="{ width: '100%', height: playerHeight }"></div>
|
||||
|
||||
<!-- 倒计时覆盖(可选,父层也可以自行实现) -->
|
||||
<div v-if="showCountDown" class="countdown-overlay">
|
||||
<div class="countdown-text">{{ countDownSeconds }} 秒后播放下一个视频</div>
|
||||
<button class="btn-cancel" @click="cancelNext">取消下一个</button>
|
||||
</div>
|
||||
|
||||
<!-- 控制按钮示例(父层应该控制 UI,我仅提供常用API按钮用于调试) -->
|
||||
<div class="player-controls" style="display:none;">
|
||||
<button @click="play()">播放</button>
|
||||
<button @click="pause()">暂停</button>
|
||||
<button @click="replay()">重播</button>
|
||||
<button @click="enterFullscreen()">全屏</button>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script lang="ts">
|
||||
import { defineComponent, ref, onMounted, onBeforeUnmount, watch, PropType, nextTick } from 'vue';
|
||||
|
||||
type Platform = 'web' | 'app-ios' | 'app-android';
|
||||
|
||||
export default defineComponent({
|
||||
name: 'AliyunPlayer',
|
||||
props: {
|
||||
// videoData: should include fields similar to original: type, m3u8Url, videoUrl, videoId, playAuth, firstTime, id...
|
||||
videoData: { type: Object as PropType<Record<string, any>>, required: true },
|
||||
// platform hint: affects screen lock behavior; default web
|
||||
platform: { type: String as PropType<Platform>, default: 'web' },
|
||||
// height for player area
|
||||
height: { type: String, default: '200px' },
|
||||
// auto start playback
|
||||
autoplay: { type: Boolean, default: true },
|
||||
// how often to auto-save progress in seconds (default 60)
|
||||
autoSaveInterval: { type: Number, default: 60 },
|
||||
// localStorage key prefix for resume data
|
||||
storageKeyPrefix: { type: String, default: 'videoOssList' },
|
||||
// flag: in APP environment should use WebView (true) or try to run player directly in page (false)
|
||||
useWebViewForApp: { type: Boolean, default: false },
|
||||
// urls for loading Aliplayer (allow overriding if needed)
|
||||
playerScriptUrl: { type: String, default: 'https://g.alicdn.com/apsara-media-box/imp-web-player/2.20.3/aliplayer-min.js' },
|
||||
playerComponentsUrl: { type: String, default: 'https://player.alicdn.com/aliplayer/presentation/js/aliplayercomponents.min.js' },
|
||||
playerCssUrl: { type: String, default: 'https://g.alicdn.com/apsara-media-box/imp-web-player/2.20.3/skins/default/aliplayer-min.css' },
|
||||
},
|
||||
emits: [
|
||||
'ready',
|
||||
'play',
|
||||
'pause',
|
||||
'timeupdate',
|
||||
'progress-save', // payload: { videoId, position }
|
||||
'ended',
|
||||
'error',
|
||||
'request-playauth', // in case parent wants to fetch playAuth separately
|
||||
'change-screen',
|
||||
'load-next' // when ended and parent should load next
|
||||
],
|
||||
setup(props, { emit, expose }) {
|
||||
const playerContainer = ref<HTMLElement | null>(null);
|
||||
const playerInstance = ref<any | null>(null);
|
||||
const scriptLoaded = ref(false);
|
||||
const timerDiff = ref(0);
|
||||
const currentSeconds = ref(0);
|
||||
const pauseTime = ref(0);
|
||||
const saveCounter = ref(0);
|
||||
const autoSaveIntervalId = ref<number | null>(null);
|
||||
const showCountDown = ref(false);
|
||||
const countDownSeconds = ref(5);
|
||||
const countdownTimerId = ref<number | null>(null);
|
||||
const showError = ref(false);
|
||||
const errorText = ref('');
|
||||
|
||||
const playerHeight = props.height;
|
||||
|
||||
// helper: localStorage save/load (simple array of {id, time})
|
||||
function loadResumeList(): Array<any> {
|
||||
try {
|
||||
const raw = localStorage.getItem(props.storageKeyPrefix);
|
||||
return raw ? JSON.parse(raw) : [];
|
||||
} catch (e) {
|
||||
return [];
|
||||
}
|
||||
}
|
||||
function saveResumeItem(videoId: any, time: number) {
|
||||
try {
|
||||
const list = loadResumeList();
|
||||
const idx = list.findIndex((i: any) => i.id === videoId);
|
||||
if (idx >= 0) list[idx].time = time;
|
||||
else list.push({ id: videoId, time });
|
||||
localStorage.setItem(props.storageKeyPrefix, JSON.stringify(list));
|
||||
} catch (e) { /* ignore */ }
|
||||
}
|
||||
|
||||
// dynamic load aliplayer script + css
|
||||
function loadAliplayer(): Promise<void> {
|
||||
if ((window as any).Aliplayer) {
|
||||
scriptLoaded.value = true;
|
||||
return Promise.resolve();
|
||||
}
|
||||
return new Promise((resolve, reject) => {
|
||||
// css
|
||||
const link = document.createElement('link');
|
||||
link.rel = 'stylesheet';
|
||||
link.href = props.playerCssUrl;
|
||||
document.head.appendChild(link);
|
||||
|
||||
// main script
|
||||
const s = document.createElement('script');
|
||||
s.src = props.playerScriptUrl;
|
||||
s.onload = () => {
|
||||
// components script
|
||||
const s2 = document.createElement('script');
|
||||
s2.src = props.playerComponentsUrl;
|
||||
s2.onload = () => {
|
||||
scriptLoaded.value = true;
|
||||
resolve();
|
||||
};
|
||||
s2.onerror = () => reject(new Error('aliplayer components load failed'));
|
||||
document.body.appendChild(s2);
|
||||
};
|
||||
s.onerror = () => reject(new Error('aliplayer load failed'));
|
||||
document.body.appendChild(s);
|
||||
});
|
||||
}
|
||||
|
||||
// initialize player with videoData
|
||||
async function initPlayer() {
|
||||
showError.value = false;
|
||||
if (props.useWebViewForApp && props.platform !== 'web') {
|
||||
// In-app recommended to use WebView. Emit event so parent can take over.
|
||||
emit('error', { message: 'App environment required WebView. Set useWebViewForApp=false to attempt in-page' });
|
||||
showError.value = true;
|
||||
errorText.value = 'App environment recommended to use WebView for Aliplayer';
|
||||
return;
|
||||
}
|
||||
|
||||
await loadAliplayer();
|
||||
|
||||
// choose options
|
||||
const v = props.videoData || {};
|
||||
let options: Record<string, any> = {
|
||||
id: (playerContainer.value as HTMLElement).id || 'ali-player-' + Math.random().toString(36).slice(2),
|
||||
width: '100%',
|
||||
height: '100%',
|
||||
autoplay: props.autoplay,
|
||||
isLive: false,
|
||||
rePlay: false,
|
||||
playsinline: true,
|
||||
controlBarVisibility: 'hover',
|
||||
useH5Prism: true,
|
||||
// skinLayout can be extended if needed
|
||||
skinLayout: [
|
||||
{ name: 'bigPlayButton', align: 'cc' },
|
||||
{ name: 'H5Loading', align: 'cc' },
|
||||
{ name: 'errorDisplay', align: 'tlabs' },
|
||||
{ name: 'controlBar', align: 'blabs', children: [
|
||||
{ name: 'progress', align: 'blabs' },
|
||||
{ name: 'playButton', align: 'tl' },
|
||||
{ name: 'timeDisplay', align: 'tl' },
|
||||
{ name: 'prism-speed-selector', align: 'tr' },
|
||||
{ name: 'volume', align: 'tr' }
|
||||
] }
|
||||
]
|
||||
};
|
||||
|
||||
// decide source mode
|
||||
if (v.type === 1) {
|
||||
if (!v.m3u8Url) {
|
||||
// private encrypted: require vid+playAuth
|
||||
if (!v.videoId || !v.playAuth) {
|
||||
// parent might need to request playAuth
|
||||
emit('request-playauth', v);
|
||||
showError.value = true;
|
||||
errorText.value = '播放凭证缺失';
|
||||
return;
|
||||
}
|
||||
options = {
|
||||
...options,
|
||||
vid: v.videoId,
|
||||
playauth: v.playAuth,
|
||||
encryptType: 1,
|
||||
playConfig: { EncryptType: 'AliyunVoDEncryption' }
|
||||
};
|
||||
} else {
|
||||
options = { ...options, source: v.m3u8Url };
|
||||
}
|
||||
} else {
|
||||
// not encrypted
|
||||
options = { ...options, source: v.videoUrl };
|
||||
}
|
||||
|
||||
// add rate component by default
|
||||
options.components = [
|
||||
{ name: 'RateComponent', type: (window as any).AliPlayerComponent?.RateComponent }
|
||||
];
|
||||
|
||||
// create player
|
||||
try {
|
||||
// ensure container has an id
|
||||
if (playerContainer.value && !(playerContainer.value as HTMLElement).id) {
|
||||
(playerContainer.value as HTMLElement).id = 'ali-player-' + Math.random().toString(36).slice(2);
|
||||
}
|
||||
const player = new (window as any).Aliplayer(options, function (p: any) {
|
||||
// ready
|
||||
});
|
||||
playerInstance.value = player;
|
||||
|
||||
// event binds
|
||||
player.on('ready', () => {
|
||||
emit('ready');
|
||||
if (props.autoplay) player.play();
|
||||
});
|
||||
|
||||
player.on('play', () => {
|
||||
emit('play');
|
||||
});
|
||||
|
||||
player.on('pause', () => {
|
||||
pauseTime.value = Math.floor(player.getCurrentTime() || 0);
|
||||
emit('pause');
|
||||
});
|
||||
|
||||
player.on('timeupdate', () => {
|
||||
const t = Math.floor(player.getCurrentTime() || 0);
|
||||
if (currentSeconds.value !== t) {
|
||||
currentSeconds.value = t;
|
||||
emit('timeupdate', { time: t, status: player.getStatus?.() });
|
||||
saveCounter.value++;
|
||||
// every autoSaveInterval seconds -> emit progress-save
|
||||
if (saveCounter.value >= props.autoSaveInterval) {
|
||||
saveCounter.value = 0;
|
||||
emit('progress-save', { videoId: props.videoData.id, position: currentSeconds.value });
|
||||
// also local save
|
||||
saveResumeItem(props.videoData.id, currentSeconds.value);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
player.on('ended', () => {
|
||||
emit('ended', { videoId: props.videoData.id });
|
||||
// default behavior: start countdown then emit load-next
|
||||
startNextCountdown();
|
||||
});
|
||||
|
||||
player.on('error', (e: any) => {
|
||||
showError.value = true;
|
||||
errorText.value = '播放出错';
|
||||
emit('error', e);
|
||||
});
|
||||
|
||||
// seek to resume pos if present
|
||||
nextTick(() => {
|
||||
const list = loadResumeList();
|
||||
const idx = list.findIndex(item => item.id === props.videoData.id);
|
||||
const resumeTime = idx >= 0 ? list[idx].time : (props.videoData.firstTime || 0);
|
||||
const dur = player.getDuration ? Math.floor(player.getDuration() || 0) : 0;
|
||||
if (resumeTime && dur && resumeTime < dur) {
|
||||
player.seek(resumeTime);
|
||||
} else if (resumeTime && !dur) {
|
||||
// if duration unknown yet, attempt seek once canplay
|
||||
player.one && player.one('canplay', () => {
|
||||
const d2 = Math.floor(player.getDuration() || 0);
|
||||
if (resumeTime < d2) player.seek(resumeTime);
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
// periodic autosave fallback (in case events miss)
|
||||
if (autoSaveIntervalId.value) window.clearInterval(autoSaveIntervalId.value);
|
||||
autoSaveIntervalId.value = window.setInterval(() => {
|
||||
if (currentSeconds.value > 0) {
|
||||
emit('progress-save', { videoId: props.videoData.id, position: currentSeconds.value });
|
||||
saveResumeItem(props.videoData.id, currentSeconds.value);
|
||||
}
|
||||
}, props.autoSaveInterval * 1000);
|
||||
|
||||
} catch (err) {
|
||||
showError.value = true;
|
||||
errorText.value = '播放器初始化失败';
|
||||
emit('error', err);
|
||||
}
|
||||
}
|
||||
|
||||
// start next countdown
|
||||
function startNextCountdown(seconds = 5) {
|
||||
showCountDown.value = true;
|
||||
countDownSeconds.value = seconds;
|
||||
if (countdownTimerId.value) window.clearInterval(countdownTimerId.value);
|
||||
countdownTimerId.value = window.setInterval(() => {
|
||||
countDownSeconds.value -= 1;
|
||||
if (countDownSeconds.value <= 0) {
|
||||
// trigger parent to load next
|
||||
window.clearInterval(countdownTimerId.value!);
|
||||
showCountDown.value = false;
|
||||
emit('load-next', { videoId: props.videoData.id });
|
||||
}
|
||||
}, 1000);
|
||||
}
|
||||
|
||||
function cancelNext() {
|
||||
showCountDown.value = false;
|
||||
if (countdownTimerId.value) window.clearInterval(countdownTimerId.value);
|
||||
emit('change-screen', { action: 'cancel-next' });
|
||||
}
|
||||
|
||||
// control API exposed
|
||||
function play() {
|
||||
playerInstance.value && playerInstance.value.play && playerInstance.value.play();
|
||||
}
|
||||
function pause() {
|
||||
playerInstance.value && playerInstance.value.pause && playerInstance.value.pause();
|
||||
}
|
||||
function seek(sec: number) {
|
||||
playerInstance.value && playerInstance.value.seek && playerInstance.value.seek(sec);
|
||||
}
|
||||
function replay() {
|
||||
if (playerInstance.value) {
|
||||
playerInstance.value.seek(0);
|
||||
playerInstance.value.play();
|
||||
}
|
||||
}
|
||||
function enterFullscreen() {
|
||||
if (!playerInstance.value) return;
|
||||
const status = playerInstance.value.fullscreenService.getIsFullScreen && playerInstance.value.fullscreenService.getIsFullScreen();
|
||||
if (status) {
|
||||
playerInstance.value.fullscreenService.cancelFullScreen && playerInstance.value.fullscreenService.cancelFullScreen();
|
||||
emit('change-screen', { status: false });
|
||||
// example: lock portrait if in app (needs plus.* or native)
|
||||
} else {
|
||||
playerInstance.value.fullscreenService.requestFullScreen && playerInstance.value.fullscreenService.requestFullScreen();
|
||||
emit('change-screen', { status: true });
|
||||
}
|
||||
}
|
||||
|
||||
// watch videoData changes
|
||||
watch(() => props.videoData, async (nv) => {
|
||||
// dispose old player
|
||||
if (playerInstance.value && playerInstance.value.dispose) {
|
||||
try { playerInstance.value.dispose(); } catch (e) { console.warn(e); }
|
||||
playerInstance.value = null;
|
||||
}
|
||||
// reset states
|
||||
currentSeconds.value = 0;
|
||||
pauseTime.value = 0;
|
||||
showError.value = false;
|
||||
// init new
|
||||
await initPlayer();
|
||||
}, { immediate: true, deep: true });
|
||||
|
||||
onMounted(() => {
|
||||
// ensure container has unique id for Aliplayer
|
||||
if (playerContainer.value && !(playerContainer.value as HTMLElement).id) {
|
||||
(playerContainer.value as HTMLElement).id = 'ali-player-' + Math.random().toString(36).slice(2);
|
||||
}
|
||||
});
|
||||
|
||||
onBeforeUnmount(() => {
|
||||
if (playerInstance.value && playerInstance.value.dispose) {
|
||||
try { playerInstance.value.dispose(); } catch (e) { /* ignore */ }
|
||||
}
|
||||
if (autoSaveIntervalId.value) window.clearInterval(autoSaveIntervalId.value);
|
||||
if (countdownTimerId.value) window.clearInterval(countdownTimerId.value);
|
||||
});
|
||||
|
||||
// expose methods to parent via ref
|
||||
expose({
|
||||
play, pause, seek, replay, startNextCountdown
|
||||
});
|
||||
|
||||
return {
|
||||
playerContainer,
|
||||
playerHeight,
|
||||
play, pause, seek, replay,
|
||||
showCountDown, countDownSeconds, cancelNext,
|
||||
showError, errorText
|
||||
};
|
||||
}
|
||||
});
|
||||
</script>
|
||||
|
||||
<style scoped>
|
||||
.ali-player-wrapper { position: relative; width: 100%; }
|
||||
.player-container { background: #000; }
|
||||
.countdown-overlay {
|
||||
position: absolute; top: 0; right: 10px; z-index: 50;
|
||||
background: rgba(0,0,0,0.6); color: #fff; padding: 10px; border-radius: 6px;
|
||||
}
|
||||
.btn-cancel { margin-top: 8px; background: #fff; color: #000; border: none; padding:6px 12px; border-radius:4px; }
|
||||
.player-error { color: #fff; text-align:center; padding: 20px; }
|
||||
</style>
|
||||
@@ -62,7 +62,7 @@
|
||||
<!-- 积分输入 -->
|
||||
<view v-if="allowPointPay && userInfo?.jf > 0" class="points-input-section">
|
||||
<text class="points-label">
|
||||
{{ $t('order.maxPoints', { max: pointsUsableMax }) }}
|
||||
{{ $t('order.maxPoints').replace('max', pointsUsableMax) }}
|
||||
</text>
|
||||
<view class="points-input-box">
|
||||
<input
|
||||
@@ -136,9 +136,9 @@ const userStore = useUserStore()
|
||||
interface Props {
|
||||
goodsList: IGoods[],
|
||||
userInfo: object,
|
||||
allowPointPay: boolean,
|
||||
orderType: string,
|
||||
backStep: number // 购买完成后返回几层页面
|
||||
allowPointPay?: boolean,
|
||||
orderType?: string,
|
||||
backStep?: number // 购买完成后返回几层页面
|
||||
}
|
||||
const props = withDefaults(defineProps<Props>(), {
|
||||
goodsList: () => [],
|
||||
@@ -290,7 +290,11 @@ const handlePointsInput = (value: any) => {
|
||||
}
|
||||
|
||||
// 重新计算实付款
|
||||
calculateFinalPrice()
|
||||
const result = Math.max(
|
||||
0,
|
||||
totalAmount.value - pointsDiscounted.value - promotionDiscounted.value - vipDiscounted.value
|
||||
)
|
||||
finalAmount.value = result
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -314,9 +318,11 @@ const calculateFinalPrice = () => {
|
||||
props?.userInfo?.jf || 0,
|
||||
Math.floor(orderAmountAfterDiscount - couponAmount)
|
||||
)
|
||||
|
||||
pointsDiscounted.value = pointsUsableMax.value
|
||||
|
||||
// 限制当前积分不超过最大值
|
||||
if (pointsDiscounted.value > pointsUsableMax.value) {
|
||||
if (pointsDiscounted.value >= pointsUsableMax.value) {
|
||||
pointsDiscounted.value = pointsUsableMax.value
|
||||
}
|
||||
|
||||
@@ -373,9 +379,11 @@ const handleSubmit = async () => {
|
||||
})
|
||||
|
||||
// 返回上一页
|
||||
uni.navigateBack({
|
||||
delta: props.backStep
|
||||
})
|
||||
setTimeout(() => {
|
||||
uni.navigateBack({
|
||||
delta: props.backStep
|
||||
})
|
||||
}, 500)
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -411,7 +419,7 @@ const createOrder = async (): Promise<string | null> => {
|
||||
|
||||
<style lang="scss" scoped>
|
||||
.confirm-order-page {
|
||||
min-height: 100vh;
|
||||
min-height: calc(100vh - 60px - 40rpx);
|
||||
background-color: #f5f5f5;
|
||||
padding: 20rpx;
|
||||
padding-bottom: 60px;
|
||||
|
||||
@@ -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('order.virtualCoin') }}</text>
|
||||
<text class="">{{ $t('global.coin') }}</text>
|
||||
<text class="text-[#7dc1f0]">
|
||||
({{ $t('order.balance') }}:{{ peanutCoin || 0 }})
|
||||
</text>
|
||||
@@ -25,19 +25,12 @@
|
||||
<view class="tip-title">{{ $t('order.paymentTipTitle') }}</view>
|
||||
<view class="tip-item">{{ $t('order.paymentTip1') }}</view>
|
||||
<view class="tip-item">
|
||||
{{ $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
|
||||
{{ $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
|
||||
</text>
|
||||
{{ $t('order.paymentTip3_1') }}
|
||||
<text class="link-text" @click="copyToClipboard('yilujiankangkefu')">
|
||||
yilujiankangkefu
|
||||
</text>
|
||||
{{ $t('order.paymentTip3_2') }}
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
@@ -53,6 +46,15 @@ const props = defineProps({
|
||||
default: 0
|
||||
}
|
||||
})
|
||||
|
||||
/**
|
||||
* 跳转到充值页面
|
||||
*/
|
||||
const goToRecharge = () => {
|
||||
uni.navigateTo({
|
||||
url: '/pages/user/recharge/index'
|
||||
})
|
||||
}
|
||||
</script>
|
||||
|
||||
<style lang="scss" scoped>
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
<template>
|
||||
<view class="order-item-content">
|
||||
<view class="order-item-content" :class="size === 'large' ? 'size-large' : ''">
|
||||
<view class="order-item-product-info">
|
||||
<image
|
||||
:src="productImg"
|
||||
@@ -18,21 +18,25 @@
|
||||
<script lang="ts" setup>
|
||||
import { computed } from 'vue'
|
||||
import { t } from '@/utils/i18n'
|
||||
import type { IGoods } from '@/types/order'
|
||||
interface Props {
|
||||
data: any
|
||||
data: IGoods
|
||||
type: string
|
||||
size?: 'small' | 'large'
|
||||
}
|
||||
const props = defineProps<Props>()
|
||||
|
||||
const productImg = computed(() => {
|
||||
|
||||
console.log(props.data)
|
||||
switch (props.type) {
|
||||
case 'order':
|
||||
return props.data[0]?.product?.productImages || ''
|
||||
return props.data?.productImages || ''
|
||||
case 'abroadBook':
|
||||
return props.data?.images || ''
|
||||
case 'vip':
|
||||
return '/static/vip.png'
|
||||
case 'abroadVip':
|
||||
return '/static/vip.png'
|
||||
case 'point':
|
||||
return '/static/jifen.png'
|
||||
default:
|
||||
@@ -42,11 +46,13 @@ const productImg = computed(() => {
|
||||
const title = computed(() => {
|
||||
switch (props.type) {
|
||||
case 'order':
|
||||
return props.data[0]?.product?.productName || ''
|
||||
return (props.data?.goodsType == '02' ? '(电子书)' : '') + props.data?.productName || ''
|
||||
case 'abroadBook':
|
||||
return props.data?.name || ''
|
||||
return '(电子书)' + props.data?.name || ''
|
||||
case 'vip':
|
||||
return props.data?.title + '<text style="color: #ff4703; font-weight: bold;">(' + props.data?.year + '年)</text>' || ''
|
||||
case 'abroadVip':
|
||||
return '电子书VIP' + props.data?.title + '<text style="color: #ff4703; font-weight: bold;">(' + props.data?.days + '天)</text>' || ''
|
||||
case 'point':
|
||||
return ''
|
||||
default:
|
||||
@@ -56,11 +62,13 @@ const title = computed(() => {
|
||||
const price = computed(() => {
|
||||
switch (props.type) {
|
||||
case 'order':
|
||||
return props.data[0]?.product?.price || 0
|
||||
return props.data?.price || 0
|
||||
case 'abroadBook':
|
||||
return props.data?.abroadPrice || 0
|
||||
case 'vip':
|
||||
return props.data?.fee || 0
|
||||
case 'abroadVip':
|
||||
return props.data?.money || 0
|
||||
case 'point':
|
||||
return ''
|
||||
default:
|
||||
@@ -101,6 +109,7 @@ const price = computed(() => {
|
||||
color: #333;
|
||||
text-align: right;
|
||||
font-size: 12px;
|
||||
white-space: nowrap;
|
||||
|
||||
.count {
|
||||
font-weight: normal;
|
||||
@@ -108,4 +117,17 @@ const price = computed(() => {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
.order-item-content.size-large {
|
||||
.order-item-product-cover {
|
||||
width: 70px;
|
||||
height: 70px;
|
||||
}
|
||||
.order-item-product-name {
|
||||
font-size: 16px;
|
||||
}
|
||||
.order-item-product-price {
|
||||
font-size: 14px;
|
||||
}
|
||||
}
|
||||
</style>
|
||||
@@ -25,7 +25,9 @@ export function useVideoProgress() {
|
||||
const localPosition = videoStorage.getVideoPosition(videoInfo.id) || 0
|
||||
|
||||
// 返回较大的值
|
||||
let position = Math.max(serverPosition, localPosition)
|
||||
// let position = Math.max(serverPosition, localPosition)
|
||||
// 采用服务器记录的播放位置
|
||||
let position = serverPosition
|
||||
|
||||
// 如果播放位置接近视频结尾(最后5秒内),则从头开始
|
||||
const videoDuration = videoInfo.duration || 0
|
||||
@@ -99,12 +101,12 @@ export function useVideoProgress() {
|
||||
*/
|
||||
const saveNow = async (videoInfo: IVideoInfo) => {
|
||||
if (currentTime.value > 0) {
|
||||
// 保存到本地
|
||||
videoStorage.saveVideoPosition(
|
||||
videoInfo.id,
|
||||
Math.floor(currentTime.value),
|
||||
videoInfo
|
||||
)
|
||||
// 保存到本地 注释掉: 不再保存到本地
|
||||
// videoStorage.saveVideoPosition(
|
||||
// videoInfo.id,
|
||||
// Math.floor(currentTime.value),
|
||||
// videoInfo
|
||||
// )
|
||||
|
||||
// 保存到服务器
|
||||
await saveToServer(videoInfo.id, Math.floor(currentTime.value))
|
||||
|
||||
@@ -134,7 +134,7 @@ onMounted(async () => {
|
||||
}
|
||||
|
||||
// 开始保存进度
|
||||
player.videoProgress.startSaving(videoInfo)
|
||||
// player.videoProgress.startSaving(videoInfo) // 注释掉 不再保存到本地
|
||||
}
|
||||
})
|
||||
|
||||
@@ -142,12 +142,12 @@ onMounted(async () => {
|
||||
onHide(() => {
|
||||
console.log('Page hidden, saving progress...')
|
||||
if (player.currentVideoData.value && player.videoProgress.currentTime.value > 0) {
|
||||
// 立即保存到本地
|
||||
videoStorage.saveVideoPosition(
|
||||
player.currentVideoData.value.id,
|
||||
Math.floor(player.videoProgress.currentTime.value),
|
||||
player.currentVideoData.value
|
||||
)
|
||||
// 立即保存到本地 注释掉: 不再保存到本地
|
||||
// videoStorage.saveVideoPosition(
|
||||
// player.currentVideoData.value.id,
|
||||
// Math.floor(player.videoProgress.currentTime.value),
|
||||
// player.currentVideoData.value
|
||||
// )
|
||||
// 保存到服务器
|
||||
player.videoProgress.saveToServer(
|
||||
player.currentVideoData.value.id,
|
||||
@@ -164,12 +164,12 @@ onUnmounted(() => {
|
||||
|
||||
// 立即保存当前播放进度(同步保存到本地,异步保存到服务器)
|
||||
if (player.currentVideoData.value && player.videoProgress.currentTime.value > 0) {
|
||||
// 立即保存到本地
|
||||
videoStorage.saveVideoPosition(
|
||||
player.currentVideoData.value.id,
|
||||
Math.floor(player.videoProgress.currentTime.value),
|
||||
player.currentVideoData.value
|
||||
)
|
||||
// 立即保存到本地 注释掉: 不再保存到本地
|
||||
// videoStorage.saveVideoPosition(
|
||||
// player.currentVideoData.value.id,
|
||||
// Math.floor(player.videoProgress.currentTime.value),
|
||||
// player.currentVideoData.value
|
||||
// )
|
||||
// 保存到服务器(不等待完成)
|
||||
player.videoProgress.saveToServer(
|
||||
player.currentVideoData.value.id,
|
||||
@@ -214,11 +214,13 @@ const pause = () => {
|
||||
|
||||
// 暂停时保存进度
|
||||
if (player.currentVideoData.value && player.videoProgress.currentTime.value > 0) {
|
||||
videoStorage.saveVideoPosition(
|
||||
player.currentVideoData.value.id,
|
||||
Math.floor(player.videoProgress.currentTime.value),
|
||||
player.currentVideoData.value
|
||||
)
|
||||
// 保存进度到本地 注释掉: 不再保存到本地
|
||||
// videoStorage.saveVideoPosition(
|
||||
// player.currentVideoData.value.id,
|
||||
// Math.floor(player.videoProgress.currentTime.value),
|
||||
// player.currentVideoData.value
|
||||
// )
|
||||
// 保存进度到服务器
|
||||
player.videoProgress.saveToServer(
|
||||
player.currentVideoData.value.id,
|
||||
Math.floor(player.videoProgress.currentTime.value)
|
||||
@@ -342,7 +344,7 @@ const playNext = async () => {
|
||||
// 获取新视频的初始播放位置
|
||||
if (player.currentVideoData.value) {
|
||||
initialTime.value = player.videoProgress.getInitialPosition(player.currentVideoData.value)
|
||||
player.videoProgress.startSaving(player.currentVideoData.value)
|
||||
// player.videoProgress.startSaving(player.currentVideoData.value) // 注释掉 不再保存到本地
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
39
hooks/useThrottle.ts
Normal file
39
hooks/useThrottle.ts
Normal file
@@ -0,0 +1,39 @@
|
||||
import { ref } from 'vue';
|
||||
|
||||
/**
|
||||
* 按钮节流Hook
|
||||
* @param callback 点击后执行的业务逻辑回调
|
||||
* @param delay 节流时间(默认1500ms)
|
||||
* @returns 节流后的点击事件函数
|
||||
* @template T 回调函数的参数类型(支持多参数元组)
|
||||
*/
|
||||
export const useThrottle = <T extends any[]>(
|
||||
callback: (...args: T) => void | Promise<void>,
|
||||
delay: number = 1500
|
||||
) => {
|
||||
// 标记是否可点击
|
||||
const isClickable = ref(true);
|
||||
|
||||
// 节流后的函数,支持传递任意参数
|
||||
const throttledFn = async (...args: T) => {
|
||||
if (!isClickable.value) return;
|
||||
|
||||
// 锁定按钮
|
||||
isClickable.value = false;
|
||||
|
||||
try {
|
||||
// 执行业务回调,支持异步函数
|
||||
await callback(...args);
|
||||
} catch (error) {
|
||||
console.error('节流回调执行失败:', error);
|
||||
throw error; // 抛出错误,方便组件内捕获
|
||||
} finally {
|
||||
// 延迟后解锁按钮(无论成功/失败都解锁)
|
||||
setTimeout(() => {
|
||||
isClickable.value = true;
|
||||
}, delay);
|
||||
}
|
||||
};
|
||||
|
||||
return throttledFn;
|
||||
};
|
||||
@@ -18,7 +18,9 @@
|
||||
"loginExpired": "Login expired. Please log in again.",
|
||||
"requestException": "Request exception",
|
||||
"coin": "Coin",
|
||||
"days": "Days"
|
||||
"days": "Days",
|
||||
"and": "and",
|
||||
"call": "Call"
|
||||
},
|
||||
"tabar.course": "COURSE",
|
||||
"tabar.book": "EBOOK",
|
||||
@@ -79,7 +81,7 @@
|
||||
"getCode": "Get Code",
|
||||
"passwordStrengthStrong": "Strong password strength.",
|
||||
"passwordStrengthMedium": "Medium password strength.",
|
||||
"passwordStrengthWeak": "please use a password consisting of at least two types: uppercase and lowercase letters, numbers, and symbols, with a length of 8 characters.",
|
||||
"passwordStrengthWeak": "please use a password consisting of at least two types: uppercase and lowercase letters, numbers, and symbols, with a length of 8-20 characters.",
|
||||
"passwordChanged": "Password changed successfully"
|
||||
},
|
||||
"common": {
|
||||
@@ -192,10 +194,6 @@
|
||||
"pleaseInputOrderSn": "Please enter order number",
|
||||
"uploadImageFailed": "Image upload failed",
|
||||
"maxImagesCount": "Maximum 4 images",
|
||||
"permissionDenied": "Permission Denied",
|
||||
"cameraPermission": "Camera permission required",
|
||||
"storagePermission": "Storage permission required",
|
||||
"phonePermission": "Phone permission required",
|
||||
"sendCodeSuccess": "Verification code sent",
|
||||
"sendCodeFailed": "Failed to send code",
|
||||
"countdown": "s to resend",
|
||||
@@ -210,7 +208,26 @@
|
||||
"yearCard": "Yearly",
|
||||
"days": "days",
|
||||
"selectPackage": "Please select a package",
|
||||
"consumptionRecord": "Consumption record"
|
||||
"consumptionRecord": "Consumption record",
|
||||
"returnMine": "I'm about to return to my page",
|
||||
"dataMigrate": "Data Migration",
|
||||
"pointsRecord": "Points consumption record",
|
||||
"migrateSubtitle": "Migrate data from Chinese account to current account",
|
||||
"oldAccount": "Chinese Account",
|
||||
"migrateCode": "Migration Code",
|
||||
"confirmMigrate": "Confirm Migration",
|
||||
"migrateSuccess": "Migration Successful",
|
||||
"migrateFailed": "Migration failed, please check if the information is correct",
|
||||
"pleaseCompleteInfo": "Please complete all information",
|
||||
"oldAccountPlaceholder": "The chinese account to migrate",
|
||||
"migrateCodePlaceholder": "The code obtained from chinese account",
|
||||
"migrateWarning": "Migration is irreversible, please proceed with caution!",
|
||||
"migrateInstructions": "Migration Instructions",
|
||||
"instruction1": "Please obtain the migration code from your chinese account, get it by going to 【我的】-【数据迁移】-【获取迁移验证码】.",
|
||||
"instruction2": "After data migration is complete, the chinese account data will be cleared, and all purchased Tianyi Coins, points, courses, E-book, VIP, certificate, and User Contribution will be transferred to the current account",
|
||||
"instruction3": "The migration process may take a few minutes, please be patient.",
|
||||
"instruction4": "If you encounter any issues, please contact customer service for assistance."
|
||||
|
||||
},
|
||||
"book": {
|
||||
"title": "My Books",
|
||||
@@ -220,7 +237,7 @@
|
||||
"comment": "Review",
|
||||
"choose": "Browse Books",
|
||||
"nullText": "No books yet, go shopping~",
|
||||
"afterPurchase": "Available after purchase",
|
||||
"afterPurchase": "Purchase to read",
|
||||
"contents": "Contents",
|
||||
"zjContents": "Chapter List",
|
||||
"set": "Settings",
|
||||
@@ -297,7 +314,9 @@
|
||||
"listen": {
|
||||
"title": "Audio Book",
|
||||
"speed": "Playback Speed",
|
||||
"chapterList": "Chapter List"
|
||||
"chapterList": "Chapter List",
|
||||
"isLast": "Last Chapter",
|
||||
"isFirst": "First Chapter"
|
||||
},
|
||||
"workOrder": {
|
||||
"submit_success": "Submitted successfully"
|
||||
@@ -391,7 +410,9 @@
|
||||
"courseInfo": "Course",
|
||||
"chapterInfo": "Chapter",
|
||||
"videoLoadFailed": "Video load failed",
|
||||
"vipBenefit": "VIP benefit active"
|
||||
"vipBenefit": "VIP benefit active",
|
||||
"audio": "Audio",
|
||||
"video": "Video"
|
||||
},
|
||||
"courseOrder": {
|
||||
"orderTitle": "Order Confirmation",
|
||||
@@ -440,7 +461,7 @@
|
||||
"notUseCoupon": "Don't use coupon",
|
||||
"reselect": "Reselect",
|
||||
"selected": "Confirm",
|
||||
"maxPoints": "Available Points ({max} pts)",
|
||||
"maxPoints": "Available Points (max pts)",
|
||||
"pointsPlaceholder": "Enter points",
|
||||
"allPoints": "Total Points",
|
||||
"insufficientBalance": "Insufficient virtual coin balance",
|
||||
@@ -474,7 +495,11 @@
|
||||
"rechargeAmount": "Recharge amount",
|
||||
"valueAddedServices": "Value-added services",
|
||||
"readAgree": "I have read and agreed",
|
||||
"readAgreeServices": "Please read and agree to the value-added services first"
|
||||
"readAgreeServices": "Please read and agree to the value-added services first",
|
||||
"orderDetails": "Order Details",
|
||||
"pointsRecord": "Points consumption record",
|
||||
"unusable": "The billing service cannot be used",
|
||||
"give": "give"
|
||||
},
|
||||
"vip": {
|
||||
"courseVip": "Course VIP",
|
||||
@@ -482,5 +507,8 @@
|
||||
"openVip": "Open Now",
|
||||
"renewal": "Renewal",
|
||||
"daily": "Daily"
|
||||
},
|
||||
"news": {
|
||||
"newsDetail": "News Detail"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3,6 +3,6 @@ import zhHans from './zh-Hans.json'
|
||||
// import zhHant from './zh-Hant.json'
|
||||
// import ja from './ja.json'
|
||||
export default {
|
||||
en,
|
||||
'zh-Hans': zhHans
|
||||
'zh-Hans': zhHans,
|
||||
en
|
||||
}
|
||||
|
||||
@@ -18,7 +18,9 @@
|
||||
"loginExpired": "登录失效,请重新登录。",
|
||||
"requestException": "请求异常",
|
||||
"coin": "天医币",
|
||||
"days": "天"
|
||||
"days": "天",
|
||||
"and": "和",
|
||||
"call": "拨打电话"
|
||||
},
|
||||
"tabar.course": "课程",
|
||||
"tabar.book": "图书",
|
||||
@@ -80,7 +82,7 @@
|
||||
"getCode": "获取验证码",
|
||||
"passwordStrengthStrong": "密码强度强",
|
||||
"passwordStrengthMedium": "密码强度中等",
|
||||
"passwordStrengthWeak": "请使用至少包含大小写字母、数字、符号中的两种类型,长度为8个字符的密码",
|
||||
"passwordStrengthWeak": "请使用至少包含大小写字母、数字、符号中的两种类型,长度为8-20个字符的密码",
|
||||
"passwordChanged": "密码修改成功"
|
||||
},
|
||||
"common": {
|
||||
@@ -193,10 +195,6 @@
|
||||
"pleaseInputOrderSn": "请输入订单编号",
|
||||
"uploadImageFailed": "图片上传失败",
|
||||
"maxImagesCount": "最多上传4张图片",
|
||||
"permissionDenied": "权限被拒绝",
|
||||
"cameraPermission": "需要相机权限",
|
||||
"storagePermission": "需要存储权限",
|
||||
"phonePermission": "需要电话权限",
|
||||
"sendCodeSuccess": "验证码发送成功",
|
||||
"sendCodeFailed": "验证码发送失败",
|
||||
"countdown": "秒后重新发送",
|
||||
@@ -211,7 +209,25 @@
|
||||
"yearCard": "年卡",
|
||||
"days": "天",
|
||||
"selectPackage": "请选择套餐",
|
||||
"consumptionRecord": "消费记录"
|
||||
"consumptionRecord": "消费记录",
|
||||
"returnMine": "即将返回我的页面",
|
||||
"pointsRecord": "积分记录",
|
||||
"dataMigrate": "数据迁移",
|
||||
"migrateSubtitle": "迁移国内账号数据到本账号",
|
||||
"oldAccount": "国内版账号",
|
||||
"migrateCode": "迁移验证码",
|
||||
"confirmMigrate": "确定迁移",
|
||||
"migrateSuccess": "迁移成功",
|
||||
"migrateFailed": "迁移失败,请检查信息是否正确",
|
||||
"pleaseCompleteInfo": "请填写完整信息",
|
||||
"oldAccountPlaceholder": "需要迁移的国内版账号",
|
||||
"migrateCodePlaceholder": "国内版账号获取的迁移验证码",
|
||||
"migrateWarning": "迁移后不可恢复,请谨慎操作!",
|
||||
"migrateInstructions": "迁移说明",
|
||||
"instruction1": "请在吴门医述、心灵空间、众妙之门、疯子读书任意APP中获取迁移验证码,获取方式【我的】-【数据迁移】-【获取迁移验证码】。",
|
||||
"instruction2": "数据迁移完成后,旧账号数据将被清空,已购买的天医币、积分、课程、电子书、VIP、证书、湖分将转移到当前账号。",
|
||||
"instruction3": "迁移过程可能需要几分钟时间,请耐心等待。",
|
||||
"instruction4": "如遇到问题,请联系客服获取帮助。"
|
||||
},
|
||||
"book": {
|
||||
"title": "我的书单",
|
||||
@@ -221,7 +237,7 @@
|
||||
"comment": "书评",
|
||||
"choose": "去选书",
|
||||
"nullText": "暂无书籍,快去选购吧~",
|
||||
"afterPurchase": "购买后即可使用此功能",
|
||||
"afterPurchase": "购买后即可阅读此章节",
|
||||
"contents": "目录",
|
||||
"zjContents": "章节目录",
|
||||
"set": "设置",
|
||||
@@ -297,7 +313,9 @@
|
||||
"listen": {
|
||||
"title": "听书",
|
||||
"speed": "播放速度",
|
||||
"chapterList": "章节列表"
|
||||
"chapterList": "章节列表",
|
||||
"isLast": "已到最后一章",
|
||||
"isFirst": "已到第一章"
|
||||
},
|
||||
"workOrder": {
|
||||
"submit_success": "提交成功"
|
||||
@@ -391,7 +409,9 @@
|
||||
"courseInfo": "课程",
|
||||
"chapterInfo": "章节",
|
||||
"videoLoadFailed": "视频加载失败",
|
||||
"vipBenefit": "VIP畅学权益生效中"
|
||||
"vipBenefit": "VIP畅学权益生效中",
|
||||
"audio": "音频",
|
||||
"video": "视频"
|
||||
},
|
||||
"courseOrder": {
|
||||
"orderTitle": "确认订单",
|
||||
@@ -440,7 +460,7 @@
|
||||
"notUseCoupon": "不使用优惠券",
|
||||
"reselect": "重新选择",
|
||||
"selected": "选好了",
|
||||
"maxPoints": "可用积分({max}分)",
|
||||
"maxPoints": "可用积分(max分)",
|
||||
"pointsPlaceholder": "请输入积分",
|
||||
"allPoints": "全部积分",
|
||||
"insufficientBalance": "天医币余额不足",
|
||||
@@ -455,7 +475,7 @@
|
||||
"customerService": "客服",
|
||||
"paymentTipTitle": "说明",
|
||||
"paymentTip1": "1. 1积分=1天医币",
|
||||
"paymentTip2-1": "2. 若有疑问请加客服微信:{ customerServiceWechat } { customerServiceEmail }",
|
||||
"paymentTip2-1": "2. 若有疑问请加客服微信:",
|
||||
"paymentTip2-2": "或邮箱联系",
|
||||
"ensureBalance": "确保您的天医币足够支付",
|
||||
"vipLabel": "VIP优惠",
|
||||
@@ -475,7 +495,11 @@
|
||||
"rechargeAmount": "充值金额",
|
||||
"valueAddedServices": "增值服务",
|
||||
"readAgree": "我已阅读并同意",
|
||||
"readAgreeServices": "请先阅读并同意增值服务"
|
||||
"readAgreeServices": "请先阅读并同意增值服务",
|
||||
"orderDetails": "订单详情",
|
||||
"pointsRecord": "积分消费记录",
|
||||
"unusable": "无法用计费服务",
|
||||
"give": "赠"
|
||||
},
|
||||
"vip": {
|
||||
"courseVip": "课程VIP",
|
||||
@@ -483,5 +507,8 @@
|
||||
"openVip": "立即开通",
|
||||
"renewal": "续费",
|
||||
"daily": "日均"
|
||||
},
|
||||
"news": {
|
||||
"newsDetail": "新闻详情"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
{
|
||||
"name" : "太湖国际",
|
||||
"name" : "吴门国际",
|
||||
"appid" : "__UNI__1250B39",
|
||||
"description" : "太湖国际",
|
||||
"versionName" : "1.0.4",
|
||||
"versionCode" : 104,
|
||||
"description" : "吴门国际",
|
||||
"versionName" : "0.1.2",
|
||||
"versionCode" : 12,
|
||||
"transformPx" : false,
|
||||
/* 5+App特有相关 */
|
||||
"app-plus" : {
|
||||
|
||||
32
pages.json
32
pages.json
@@ -1,5 +1,5 @@
|
||||
{
|
||||
"pages": [ //pages数组中第一项表示应用启动页,参考:https://uniapp.dcloud.io/collocation/pages
|
||||
"pages": [
|
||||
{
|
||||
"path": "pages/course/index",
|
||||
"style": {
|
||||
@@ -79,6 +79,12 @@
|
||||
"navigationBarTitleText": "%user.virtual%",
|
||||
"navigationStyle": "custom"
|
||||
}
|
||||
},{
|
||||
"path": "pages/user/points/index",
|
||||
"style": {
|
||||
"navigationBarTitleText": "%user.points%",
|
||||
"navigationStyle": "custom"
|
||||
}
|
||||
}, {
|
||||
"path": "pages/user/myBook/index",
|
||||
"style": {
|
||||
@@ -127,12 +133,6 @@
|
||||
"navigationStyle": "custom",
|
||||
"navigationBarTitleText": "%listen.title%"
|
||||
}
|
||||
}, {
|
||||
"path": "pages/book/order",
|
||||
"style": {
|
||||
"navigationStyle": "custom",
|
||||
"navigationBarTitleText": "%order.orderTitle%"
|
||||
}
|
||||
}, {
|
||||
"path": "pages/course/search",
|
||||
"style": {
|
||||
@@ -187,6 +187,24 @@
|
||||
"navigationStyle": "custom",
|
||||
"navigationBarTitleText": "%order.bookVip%"
|
||||
}
|
||||
}, {
|
||||
"path": "pages/user/order/details",
|
||||
"style": {
|
||||
"navigationStyle": "custom",
|
||||
"navigationBarTitleText": "%order.orderDetails%"
|
||||
}
|
||||
}, {
|
||||
"path": "pages/news/details",
|
||||
"style": {
|
||||
"navigationStyle": "custom",
|
||||
"navigationBarTitleText": "新闻详情"
|
||||
}
|
||||
}, {
|
||||
"path": "pages/user/migrate/index",
|
||||
"style": {
|
||||
"navigationStyle": "custom",
|
||||
"navigationBarTitleText": "数据迁移"
|
||||
}
|
||||
}, {
|
||||
"path": "uni_modules/uni-upgrade-center-app/pages/upgrade-popup",
|
||||
"style": {
|
||||
|
||||
@@ -40,7 +40,7 @@
|
||||
</view>
|
||||
|
||||
<!-- 书评列表 (非iOS) -->
|
||||
<view v-if="!isIOS" class="comments-section">
|
||||
<!-- <view v-if="!isIOS" class="comments-section">
|
||||
<view class="section-header">
|
||||
<text class="section-title">{{ $t('bookDetails.message') }}</text>
|
||||
<view v-if="commentList.length > 0" class="more-link" @click="goToReview">
|
||||
@@ -55,7 +55,7 @@
|
||||
/>
|
||||
<text v-else class="empty-text">{{ nullText }}</text>
|
||||
</view>
|
||||
</view>
|
||||
</view> -->
|
||||
|
||||
<!-- 相关推荐 -->
|
||||
<view class="related-books">
|
||||
@@ -79,15 +79,15 @@
|
||||
|
||||
<!-- 底部操作栏 -->
|
||||
<view class="action-bar">
|
||||
<template v-if="bookInfo.isBuy">
|
||||
<template v-if="bookInfo.isBuy || hasVip">
|
||||
<view class="action-btn read" @click="goToReader">
|
||||
<text>{{ $t('bookDetails.startReading') }}</text>
|
||||
</view>
|
||||
<view class="action-btn purchased">
|
||||
<!-- <view class="action-btn purchased">
|
||||
<wd-button disabled custom-class="purchased-btn">
|
||||
{{ $t('bookDetails.buttonText2') }}
|
||||
</wd-button>
|
||||
</view>
|
||||
</view> -->
|
||||
<view class="action-btn listen" @click="goToListen">
|
||||
<text>{{ $t('bookDetails.startListening') }}</text>
|
||||
</view>
|
||||
@@ -114,50 +114,29 @@
|
||||
@confirm="handlePurchase"
|
||||
@close="closePurchasePopup"
|
||||
/>
|
||||
<!-- <wd-popup v-model="purchaseVisible" position="bottom">
|
||||
<view class="purchase-popup">
|
||||
<view class="book-info-mini">
|
||||
<image :src="bookInfo.images" mode="aspectFill" />
|
||||
<view class="info">
|
||||
<text class="name">{{ bookInfo.name }}</text>
|
||||
<text v-if="bookInfo.priceData" class="price">
|
||||
$ {{ bookInfo.priceData.dictValue }} NZD
|
||||
</text>
|
||||
</view>
|
||||
</view>
|
||||
<view class="spec-section">
|
||||
<text class="spec-title">{{ $t('bookDetails.list') }}</text>
|
||||
<view class="spec-item active">
|
||||
<text>{{ bookInfo.name }}</text>
|
||||
<text v-if="bookInfo.priceData" class="spec-price">
|
||||
${{ bookInfo.priceData.dictValue }} NZD
|
||||
</text>
|
||||
</view>
|
||||
</view>
|
||||
<wd-button type="primary" block @click="handlePurchase">
|
||||
{{ $t('bookDetails.buy') }}
|
||||
</wd-button>
|
||||
</view>
|
||||
</wd-popup> -->
|
||||
</view>
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
import { ref, computed, onMounted } from 'vue'
|
||||
import { onLoad, onShow } from '@dcloudio/uni-app'
|
||||
import { useI18n } from 'vue-i18n'
|
||||
import { t } from '@/utils/i18n'
|
||||
import { bookApi } from '@/api/modules/book'
|
||||
import { useUserStore } from '@/stores/user'
|
||||
import type { IBookDetail, IBook, IComment } from '@/types/book'
|
||||
import type { IGoods } from '@/types/order'
|
||||
import GoodsSelector from '@/components/order/GoodsSelector.vue'
|
||||
import CommentList from '@/components/book/CommentList.vue'
|
||||
|
||||
const { t } = useI18n()
|
||||
const userStore = useUserStore()
|
||||
|
||||
// 路由参数
|
||||
const bookId = ref(0)
|
||||
const pageFrom = ref('')
|
||||
|
||||
// 会员状态
|
||||
const hasVip = computed(() => userStore.userInfo?.userEbookVip?.length > 0 || false)
|
||||
|
||||
// 数据状态
|
||||
const bookInfo = ref<IBookDetail>({
|
||||
id: 0,
|
||||
@@ -230,70 +209,43 @@ function initScrollHeight() {
|
||||
|
||||
// 加载书籍详情
|
||||
async function loadBookInfo() {
|
||||
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)
|
||||
}
|
||||
const res = await bookApi.getBookInfo(bookId.value)
|
||||
bookInfo.value = res.bookInfo
|
||||
}
|
||||
|
||||
// 加载购买商品信息
|
||||
async function loadGoodsInfo() {
|
||||
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)
|
||||
}
|
||||
const res = await bookApi.getBookGoods(bookId.value)
|
||||
goodsList.value = res.productList || []
|
||||
}
|
||||
|
||||
// 加载统计数据
|
||||
async function loadBookCount() {
|
||||
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)
|
||||
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
|
||||
}
|
||||
}
|
||||
|
||||
// 加载评论
|
||||
async function loadComments() {
|
||||
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) {
|
||||
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')
|
||||
console.error('Failed to load comments:', error)
|
||||
}
|
||||
}
|
||||
|
||||
// 加载推荐书籍
|
||||
async function loadRecommendBooks() {
|
||||
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) {
|
||||
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')
|
||||
console.error('Failed to load recommend books:', error)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -316,7 +268,7 @@ function handlePurchase(goods: IGoods) {
|
||||
|
||||
// 页面跳转
|
||||
function goToReader() {
|
||||
const isBuy = bookInfo.value.isBuy ? 0 : 1
|
||||
const isBuy = bookInfo.value.isBuy ? 1 : 0
|
||||
const count = bookInfo.value.freeChapterCount || 0
|
||||
uni.navigateTo({
|
||||
url: `/pages/book/reader?isBuy=${isBuy}&bookId=${bookId.value}&count=${count}`
|
||||
|
||||
@@ -162,10 +162,7 @@
|
||||
>
|
||||
<image :src="item.images" />
|
||||
<text class="book-text">{{ item.name }}</text>
|
||||
<text class="book-price">{{ item.minPrice }} 天医币</text>
|
||||
<text v-if="formatStats(item)" class="book-flag">{{
|
||||
formatStats(item)
|
||||
}}</text>
|
||||
<BookPrice :data="item" class="book-price-container" />
|
||||
</view>
|
||||
</view>
|
||||
<text v-else class="zanwu" style="padding: 100rpx 0">{{ $t('global.dataNull') }}</text>
|
||||
@@ -175,11 +172,12 @@
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
import { ref, onMounted } from 'vue'
|
||||
import { ref, onMounted, computed } from 'vue'
|
||||
import { onShow } from '@dcloudio/uni-app'
|
||||
import { useI18n } from 'vue-i18n'
|
||||
import { homeApi } from '@/api/modules/book_home'
|
||||
import { getNotchHeight } from '@/utils/system'
|
||||
import { useUserStore } from '@/stores/user'
|
||||
import BookPrice from '@/components/book/BookPrice.vue'
|
||||
import type {
|
||||
IBook,
|
||||
IBookWithStats,
|
||||
@@ -187,7 +185,7 @@ import type {
|
||||
IVipInfo
|
||||
} from '@/types/book'
|
||||
|
||||
const { t } = useI18n()
|
||||
const userStore = useUserStore()
|
||||
|
||||
// 状态定义
|
||||
const showMyBooks = ref(false)
|
||||
@@ -213,41 +211,23 @@ const currentLevel1Index = ref(0)
|
||||
const currentLevel2Index = ref(0)
|
||||
|
||||
// VIP信息
|
||||
const vipInfo = ref<IVipInfo | null>(null)
|
||||
|
||||
/**
|
||||
* 获取VIP信息
|
||||
*/
|
||||
const getVipInfo = async () => {
|
||||
try {
|
||||
const res = await homeApi.getVipInfo()
|
||||
if (res.vipInfo) {
|
||||
vipInfo.value = res.vipInfo
|
||||
}
|
||||
} catch (error) {
|
||||
console.error('获取VIP信息失败:', error)
|
||||
}
|
||||
}
|
||||
const vipInfo = computed(() => userStore.userInfo?.userEbookVip?.[0] || null)
|
||||
|
||||
/**
|
||||
* 获取我的书单
|
||||
*/
|
||||
const getMyBooks = async () => {
|
||||
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'
|
||||
})
|
||||
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
|
||||
}
|
||||
} catch (error) {
|
||||
console.error('获取我的书单失败:', error)
|
||||
} else {
|
||||
// 未登录,跳转到登录页
|
||||
uni.navigateTo({
|
||||
url: '/pages/login/login'
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
@@ -255,13 +235,9 @@ const getMyBooks = async () => {
|
||||
* 获取推荐图书
|
||||
*/
|
||||
const getRecommendBooks = async () => {
|
||||
try {
|
||||
const res = await homeApi.getRecommendBooks()
|
||||
if (res.books && res.books.length > 0) {
|
||||
recommendBooksList.value = res.books
|
||||
}
|
||||
} catch (error) {
|
||||
console.error('获取推荐图书失败:', error)
|
||||
const res = await homeApi.getRecommendBooks()
|
||||
if (res.books && res.books.length > 0) {
|
||||
recommendBooksList.value = res.books
|
||||
}
|
||||
}
|
||||
|
||||
@@ -269,16 +245,12 @@ const getRecommendBooks = async () => {
|
||||
* 获取活动标签列表
|
||||
*/
|
||||
const getActivityLabels = async () => {
|
||||
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)
|
||||
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')
|
||||
}
|
||||
}
|
||||
|
||||
@@ -286,16 +258,12 @@ const getActivityLabels = async () => {
|
||||
* 获取分类标签列表
|
||||
*/
|
||||
const getCategoryLabels = async () => {
|
||||
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)
|
||||
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)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -303,21 +271,17 @@ const getCategoryLabels = async () => {
|
||||
* 获取二级标签列表
|
||||
*/
|
||||
const getSubLabels = async (pid: number, index: number) => {
|
||||
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)
|
||||
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')
|
||||
}
|
||||
}
|
||||
|
||||
@@ -328,63 +292,22 @@ const getBooksByLabel = async (
|
||||
labelId: number,
|
||||
type: 'activity' | 'category'
|
||||
) => {
|
||||
try {
|
||||
const res = await homeApi.getBooksByLabel(labelId)
|
||||
if (type === 'activity') {
|
||||
if (res.bookList && res.bookList.length > 0) {
|
||||
activityList.value = res.bookList
|
||||
} else {
|
||||
activityList.value = []
|
||||
}
|
||||
const res = await homeApi.getBooksByLabel(labelId)
|
||||
if (type === 'activity') {
|
||||
if (res.bookList && res.bookList.length > 0) {
|
||||
activityList.value = res.bookList
|
||||
} else {
|
||||
if (res.bookList && res.bookList.length > 0) {
|
||||
categoryBookList.value = res.bookList
|
||||
} else {
|
||||
categoryBookList.value = []
|
||||
}
|
||||
activityList.value = []
|
||||
}
|
||||
} else {
|
||||
if (res.bookList && res.bookList.length > 0) {
|
||||
categoryBookList.value = res.bookList
|
||||
} else {
|
||||
categoryBookList.value = []
|
||||
}
|
||||
} catch (error) {
|
||||
console.error('获取图书列表失败:', error)
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 格式化价格
|
||||
*/
|
||||
const formatPrice = (book: IBookWithStats): string => {
|
||||
// 已购买不显示价格
|
||||
if (book.isBuy) return ''
|
||||
|
||||
// VIP用户且图书为VIP专享
|
||||
if (vipInfo.value?.id && book.isVip === '2') {
|
||||
const price = book.sysDictData?.dictValue
|
||||
return price ? `$ ${price} NZD` : ''
|
||||
}
|
||||
|
||||
// 普通用户
|
||||
if (!vipInfo.value?.id) {
|
||||
const price = book.sysDictData?.dictValue
|
||||
return price ? `$ ${price} NZD` : ''
|
||||
}
|
||||
|
||||
return ''
|
||||
}
|
||||
|
||||
/**
|
||||
* 格式化统计信息
|
||||
*/
|
||||
const formatStats = (book: IBookWithStats): string => {
|
||||
if (book.readCount && book.readCount > 0) {
|
||||
return `${book.readCount}${t('bookHome.readingCount')}`
|
||||
}
|
||||
|
||||
if (book.buyCount && book.buyCount > 0) {
|
||||
return `${book.buyCount}${t('bookHome.purchased')}`
|
||||
}
|
||||
|
||||
return ''
|
||||
}
|
||||
|
||||
/**
|
||||
* 处理搜索点击
|
||||
*/
|
||||
@@ -399,7 +322,7 @@ const handleSearch = ({ value }: { value: string }) => {
|
||||
*/
|
||||
const handleMyBookClick = (bookId: number) => {
|
||||
uni.navigateTo({
|
||||
url: `/pages/book/reader?isBuy=0&bookId=${bookId}`
|
||||
url: `/pages/book/reader?isBuy=1&bookId=${bookId}`
|
||||
})
|
||||
}
|
||||
|
||||
@@ -416,8 +339,8 @@ const handleBookClick = (bookId: number) => {
|
||||
* 处理更多按钮点击
|
||||
*/
|
||||
const handleMoreClick = () => {
|
||||
uni.switchTab({
|
||||
url: '/pages/book/index'
|
||||
uni.navigateTo({
|
||||
url: '/pages/user/myBook/index'
|
||||
})
|
||||
}
|
||||
|
||||
@@ -458,7 +381,6 @@ onMounted(() => {
|
||||
*/
|
||||
onShow(() => {
|
||||
// 刷新数据
|
||||
getVipInfo()
|
||||
getMyBooks()
|
||||
getRecommendBooks()
|
||||
getActivityLabels()
|
||||
@@ -807,21 +729,9 @@ onShow(() => {
|
||||
overflow: hidden;
|
||||
}
|
||||
|
||||
.book-price {
|
||||
position: absolute;
|
||||
font-size: 28rpx;
|
||||
color: #ff4703;
|
||||
left: 30rpx;
|
||||
bottom: 20rpx;
|
||||
}
|
||||
|
||||
.book-flag {
|
||||
display: block;
|
||||
font-size: 26rpx;
|
||||
color: #999;
|
||||
position: absolute;
|
||||
right: 6%;
|
||||
bottom: 20rpx;
|
||||
.book-price-container {
|
||||
width: 80%;
|
||||
margin: 15rpx auto 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -16,10 +16,10 @@
|
||||
<text class="author">{{ $t('bookDetails.authorName') }}{{ bookInfo.author?.authorName }}</text>
|
||||
</view>
|
||||
<wd-button
|
||||
v-if="!bookInfo.isBuy"
|
||||
v-if="!bookInfo.isBuy && !hasVip"
|
||||
type="primary"
|
||||
size="small"
|
||||
@click="goToPurchase"
|
||||
@click="purchaseVisible = true"
|
||||
>
|
||||
{{ $t('bookDetails.buy') }}
|
||||
</wd-button>
|
||||
@@ -42,30 +42,43 @@
|
||||
<text class="chapter-text" :class="{ locked: isLocked(index) }">
|
||||
{{ chapter.chapter }}{{ chapter.content ? ' - ' + chapter.content : '' }}
|
||||
</text>
|
||||
<wd-icon v-if="isLocked(index)" name="lock" size="20px" />
|
||||
<wd-icon v-if="isLocked(index)" name="lock-on" size="20px" />
|
||||
</view>
|
||||
</view>
|
||||
|
||||
<text v-else class="empty-text">{{ nullText }}</text>
|
||||
</view>
|
||||
</scroll-view>
|
||||
|
||||
<!-- 购买弹窗 -->
|
||||
<GoodsSelector
|
||||
:show="purchaseVisible"
|
||||
:goods="goodsList"
|
||||
@confirm="handlePurchase"
|
||||
@close="closePurchasePopup"
|
||||
/>
|
||||
</view>
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
import { ref, computed } from 'vue'
|
||||
import { onLoad } from '@dcloudio/uni-app'
|
||||
import { useI18n } from 'vue-i18n'
|
||||
import { t } from '@/utils/i18n'
|
||||
import { bookApi } from '@/api/modules/book'
|
||||
import { useUserStore } from '@/stores/user'
|
||||
import type { IBookDetail, IChapter } from '@/types/book'
|
||||
import CustomNavbar from '@/components/book/CustomNavbar.vue'
|
||||
import type { IGoods } from '@/types/order'
|
||||
import GoodsSelector from '@/components/order/GoodsSelector.vue'
|
||||
|
||||
const { t } = useI18n()
|
||||
const userStore = useUserStore()
|
||||
|
||||
// 路由参数
|
||||
const bookId = ref(0)
|
||||
const fromIndex = ref(-1)
|
||||
|
||||
// 会员状态
|
||||
const hasVip = computed(() => userStore.userInfo?.userEbookVip?.length > 0 || false)
|
||||
|
||||
// 数据状态
|
||||
const bookInfo = ref<IBookDetail>({
|
||||
id: 0,
|
||||
@@ -80,11 +93,6 @@ const activeIndex = ref(-1)
|
||||
const nullText = ref('')
|
||||
const scrollHeight = ref(0)
|
||||
|
||||
// 计算属性
|
||||
const isLocked = computed(() => (index: number) => {
|
||||
return !bookInfo.value.isBuy && index + 1 > bookInfo.value.freeChapterCount
|
||||
})
|
||||
|
||||
// 生命周期
|
||||
onLoad((options: any) => {
|
||||
if (options.bookId) {
|
||||
@@ -98,8 +106,31 @@ onLoad((options: any) => {
|
||||
initScrollHeight()
|
||||
loadBookInfo()
|
||||
loadChapterList()
|
||||
loadGoodsInfo()
|
||||
})
|
||||
|
||||
// 购买弹窗状态
|
||||
const purchaseVisible = ref(false)
|
||||
const goodsList = ref<IGoods[]>([])
|
||||
|
||||
// 关闭购买弹窗
|
||||
function closePurchasePopup() {
|
||||
purchaseVisible.value = false
|
||||
}
|
||||
// 确认购买
|
||||
function handlePurchase(goods: IGoods) {
|
||||
uni.navigateTo({
|
||||
url: `/pages/order/goodsConfirm?goods=${goods.productId}`
|
||||
})
|
||||
}
|
||||
|
||||
|
||||
// 加载购买商品信息
|
||||
async function loadGoodsInfo() {
|
||||
const res = await bookApi.getBookGoods(bookId.value)
|
||||
goodsList.value = res.productList || []
|
||||
}
|
||||
|
||||
// 初始化滚动区域高度
|
||||
function initScrollHeight() {
|
||||
const systemInfo = uni.getSystemInfoSync()
|
||||
@@ -117,38 +148,32 @@ function initScrollHeight() {
|
||||
|
||||
// 加载书籍信息
|
||||
async function loadBookInfo() {
|
||||
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)
|
||||
}
|
||||
const res = await bookApi.getBookInfo(bookId.value)
|
||||
bookInfo.value = res.bookInfo
|
||||
}
|
||||
|
||||
// 加载章节列表
|
||||
async function loadChapterList() {
|
||||
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) {
|
||||
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')
|
||||
console.error('Failed to load chapter list:', error)
|
||||
}
|
||||
}
|
||||
|
||||
// 判断章节是否锁定
|
||||
function isLocked(index: number): boolean {
|
||||
return !bookInfo.value.isBuy && index + 1 > bookInfo.value.freeChapterCount && !hasVip.value
|
||||
}
|
||||
|
||||
// 播放章节
|
||||
function playChapter(chapter: IChapter, index: number) {
|
||||
// 检查是否锁定
|
||||
if (isLocked.value(index)) {
|
||||
if (isLocked(index)) {
|
||||
uni.showToast({
|
||||
title: t('book.afterPurchase'),
|
||||
icon: 'none'
|
||||
|
||||
@@ -80,7 +80,8 @@
|
||||
:class="{ 'chapter-item-active': currentChapterIndex === index }"
|
||||
@click="selectChapter(index)"
|
||||
>
|
||||
<text class="chapter-title">{{ chapter.chapter }}</text>
|
||||
<text class="chapter-title" :class="{ locked: isLocked(index) }">{{ chapter.chapter }}</text>
|
||||
<wd-icon v-if="isLocked(index)" name="lock-on" size="20px" />
|
||||
</view>
|
||||
</scroll-view>
|
||||
</view>
|
||||
@@ -92,10 +93,15 @@
|
||||
import { ref, computed, onMounted, onUnmounted } from 'vue'
|
||||
import { onLoad, onHide, onUnload } from '@dcloudio/uni-app'
|
||||
import { useI18n } from 'vue-i18n'
|
||||
import { useUserStore } from '@/stores/user'
|
||||
import { bookApi } from '@/api/modules/book'
|
||||
import type { IBookDetail, IChapter } from '@/types/book'
|
||||
|
||||
const { t } = useI18n()
|
||||
const userStore = useUserStore()
|
||||
|
||||
// 会员状态
|
||||
const hasVip = computed(() => userStore.userInfo?.userEbookVip?.length > 0 || false)
|
||||
|
||||
// 路由参数
|
||||
const bookId = ref(0)
|
||||
@@ -245,14 +251,8 @@ function initAudioContext() {
|
||||
|
||||
// 加载书籍信息
|
||||
async function loadBookInfo() {
|
||||
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)
|
||||
}
|
||||
const res = await bookApi.getBookInfo(bookId.value)
|
||||
bookInfo.value = res.bookInfo
|
||||
}
|
||||
|
||||
// 加载章节列表
|
||||
@@ -290,6 +290,11 @@ async function loadChapterList() {
|
||||
}
|
||||
}
|
||||
|
||||
// 判断章节是否锁定
|
||||
function isLocked(index: number): boolean {
|
||||
return !bookInfo.value.isBuy && index + 1 > bookInfo.value.freeChapterCount && !hasVip.value
|
||||
}
|
||||
|
||||
// 加载章节内容(带音频时间点)
|
||||
async function loadChapterContent(chapterId: number) {
|
||||
try {
|
||||
@@ -381,13 +386,13 @@ function togglePlay() {
|
||||
|
||||
// 上一章
|
||||
async function prevChapter() {
|
||||
if (currentChapterIndex.value > 0) {
|
||||
if (currentChapterIndex.value > 0 && !isLocked(currentChapterIndex.value - 1)) {
|
||||
currentChapterIndex.value--
|
||||
await loadChapterContent(chapterList.value[currentChapterIndex.value].id)
|
||||
playChapter(chapterList.value[currentChapterIndex.value])
|
||||
} else {
|
||||
uni.showToast({
|
||||
title: t('listen.earlier'),
|
||||
title: t('listen.isFirst'),
|
||||
icon: 'none'
|
||||
})
|
||||
}
|
||||
@@ -396,19 +401,23 @@ async function prevChapter() {
|
||||
// 下一章
|
||||
async function nextChapter() {
|
||||
// 检查是否锁定
|
||||
if (isBuy.value === '1' && currentChapterIndex.value + 1 >= count.value) {
|
||||
uni.showModal({
|
||||
title: t('common.limit_title'),
|
||||
content: t('book.afterPurchase'),
|
||||
confirmText: t('common.confirm_text'),
|
||||
success: (res) => {
|
||||
if (res.confirm) {
|
||||
uni.navigateTo({
|
||||
url: `/pages/book/order?id=${bookId.value}`
|
||||
})
|
||||
}
|
||||
}
|
||||
if (isLocked(currentChapterIndex.value + 1)) {
|
||||
uni.showToast({
|
||||
title: t('book.afterPurchase'),
|
||||
icon: 'none'
|
||||
})
|
||||
// uni.showModal({
|
||||
// title: t('common.limit_title'),
|
||||
// content: t('book.afterPurchase'),
|
||||
// confirmText: t('common.confirm_text'),
|
||||
// success: (res) => {
|
||||
// if (res.confirm) {
|
||||
// uni.navigateTo({
|
||||
// url: `/pages/book/order?id=${bookId.value}`
|
||||
// })
|
||||
// }
|
||||
// }
|
||||
// })
|
||||
return
|
||||
}
|
||||
|
||||
@@ -418,7 +427,7 @@ async function nextChapter() {
|
||||
playChapter(chapterList.value[currentChapterIndex.value])
|
||||
} else {
|
||||
uni.showToast({
|
||||
title: t('listen.behind'),
|
||||
title: t('listen.isLast'),
|
||||
icon: 'none'
|
||||
})
|
||||
}
|
||||
@@ -497,7 +506,7 @@ async function selectChapter(index: number) {
|
||||
}
|
||||
|
||||
// 检查是否锁定
|
||||
if (isBuy.value === '1' && index >= count.value) {
|
||||
if (isLocked(index)) {
|
||||
uni.showToast({
|
||||
title: t('book.afterPurchase'),
|
||||
icon: 'none'
|
||||
@@ -704,6 +713,10 @@ function formatTime(seconds: number): string {
|
||||
overflow: hidden;
|
||||
text-overflow: ellipsis;
|
||||
white-space: nowrap;
|
||||
|
||||
&.locked {
|
||||
color: #999;
|
||||
}
|
||||
}
|
||||
|
||||
.chapter-item-active .chapter-title {
|
||||
|
||||
@@ -1,721 +0,0 @@
|
||||
<template>
|
||||
<view class="order-page">
|
||||
<!-- 导航栏 -->
|
||||
<nav-bar :title="$t('bookOrder.orderTitle')"></nav-bar>
|
||||
|
||||
<!-- 图书信息区域 -->
|
||||
<view class="order-block">
|
||||
<view class="order-info">
|
||||
<image :src="bookInfo.images" class="order-img" mode="aspectFill"></image>
|
||||
<text class="order-name">{{ bookInfo.name }}</text>
|
||||
</view>
|
||||
|
||||
<view class="order-price">
|
||||
<text class="order-title">{{ $t('bookOrder.amount') }}</text>
|
||||
<view v-if="paymentMethod === '5'" class="price-display">
|
||||
<image src="/static/icon/currency.png" class="coin-img"></image>
|
||||
<text class="coin-text">{{ displayPrice }} NZD</text>
|
||||
</view>
|
||||
<view v-if="paymentMethod === '4'" class="price-display">
|
||||
<image src="/static/icon/coin.png" class="coin-img"></image>
|
||||
<text class="coin-text">{{ displayPrice }}</text>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
|
||||
<!-- 支付方式选择区域 -->
|
||||
<view class="order-type">
|
||||
<text class="order-title">{{ $t('bookOrder.paymentMethod') }}</text>
|
||||
<radio-group @change="handlePaymentChange" class="radio-group">
|
||||
<label
|
||||
v-for="(item, index) in paymentOptions"
|
||||
:key="index"
|
||||
class="type-label"
|
||||
>
|
||||
<view class="type-view">
|
||||
<radio
|
||||
:value="item.value"
|
||||
:checked="paymentMethod === item.value"
|
||||
color="#54a966"
|
||||
></radio>
|
||||
<text>
|
||||
{{ item.name }}
|
||||
<text v-if="item.value === '4'" class="balance-text">
|
||||
({{ $t('bookOrder.balance') }}{{ userCoinBalance }})
|
||||
</text>
|
||||
</text>
|
||||
</view>
|
||||
</label>
|
||||
</radio-group>
|
||||
</view>
|
||||
|
||||
<!-- 底部确认按钮 -->
|
||||
<view class="order-btn">
|
||||
<view class="btn-spacer"></view>
|
||||
<button
|
||||
class="confirm-btn"
|
||||
:disabled="isSubmitting"
|
||||
@click="handleConfirmOrder"
|
||||
>
|
||||
{{ $t('bookOrder.confirm') }}
|
||||
</button>
|
||||
</view>
|
||||
</view>
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
import { ref, computed, onMounted } from 'vue'
|
||||
import { onLoad, onShow, onUnload } from '@dcloudio/uni-app'
|
||||
import { useI18n } from 'vue-i18n'
|
||||
import { useUserStore } from '@/stores/user'
|
||||
import { storeToRefs } from 'pinia'
|
||||
import { orderApi } from '@/api/modules/order'
|
||||
import { bookApi } from '@/api/modules/book'
|
||||
import type { IBookDetail } from '@/types/book'
|
||||
import type { IPaymentOption } from '@/types/order'
|
||||
|
||||
const { t } = useI18n()
|
||||
const userStore = useUserStore()
|
||||
const { userInfo } = storeToRefs(userStore)
|
||||
|
||||
// 页面参数
|
||||
const bookId = ref(0)
|
||||
|
||||
// 图书信息
|
||||
const bookInfo = ref<IBookDetail>({
|
||||
id: 0,
|
||||
name: '',
|
||||
images: '',
|
||||
author: { authorName: '', introduction: '' },
|
||||
priceData: { dictType: '', dictValue: '' },
|
||||
abroadPrice: 0,
|
||||
isBuy: false,
|
||||
freeChapterCount: 0
|
||||
})
|
||||
|
||||
// 支付相关
|
||||
const paymentMethod = ref<'4' | '5'>('5') // 默认 Google Pay
|
||||
const paymentOptions = ref<IPaymentOption[]>([])
|
||||
const userCoinBalance = ref(0)
|
||||
const orderSn = ref('')
|
||||
const isSubmitting = ref(false)
|
||||
|
||||
// Google Pay 相关
|
||||
const googlePayConnected = ref(false)
|
||||
let googlePayPlugin: any = null
|
||||
|
||||
// 计算显示价格
|
||||
const displayPrice = computed(() => {
|
||||
if (paymentMethod.value === '4') {
|
||||
// 虚拟币价格
|
||||
return (bookInfo.value.abroadPrice || 0) * 10
|
||||
} else {
|
||||
// Google Pay 价格
|
||||
return bookInfo.value.priceData?.dictValue || '0'
|
||||
}
|
||||
})
|
||||
|
||||
/**
|
||||
* 页面加载
|
||||
*/
|
||||
onLoad((options: any) => {
|
||||
if (options.id) {
|
||||
bookId.value = Number(options.id)
|
||||
}
|
||||
|
||||
// 初始化支付方式
|
||||
initPaymentOptions()
|
||||
|
||||
// 初始化 Google Pay
|
||||
initGooglePay()
|
||||
|
||||
// 加载图书信息
|
||||
loadBookInfo()
|
||||
})
|
||||
|
||||
/**
|
||||
* 页面显示
|
||||
*/
|
||||
onShow(() => {
|
||||
// 刷新用户信息
|
||||
loadUserInfo()
|
||||
})
|
||||
|
||||
/**
|
||||
* 页面卸载
|
||||
*/
|
||||
onUnload(() => {
|
||||
// 清理资源
|
||||
uni.hideLoading()
|
||||
})
|
||||
|
||||
/**
|
||||
* 初始化支付方式列表
|
||||
*/
|
||||
function initPaymentOptions() {
|
||||
const platform = uni.getSystemInfoSync().platform
|
||||
|
||||
if (platform === 'android') {
|
||||
// Android 平台显示 Google Pay
|
||||
paymentOptions.value = [
|
||||
{ value: '5', name: t('bookOrder.googlePay') }
|
||||
]
|
||||
paymentMethod.value = '5'
|
||||
} else {
|
||||
// iOS 平台暂不支持支付
|
||||
paymentOptions.value = []
|
||||
paymentMethod.value = '5'
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 初始化 Google Pay 插件
|
||||
*/
|
||||
function initGooglePay() {
|
||||
// #ifdef APP-PLUS
|
||||
try {
|
||||
googlePayPlugin = uni.requireNativePlugin('sn-googlepay5')
|
||||
if (googlePayPlugin) {
|
||||
googlePayPlugin.init({}, (result: any) => {
|
||||
console.log('[Google Pay] Init result:', result)
|
||||
if (result.code === 0) {
|
||||
googlePayConnected.value = true
|
||||
console.log('[Google Pay] Connected successfully')
|
||||
} else {
|
||||
googlePayConnected.value = false
|
||||
console.log('[Google Pay] Connection failed')
|
||||
}
|
||||
})
|
||||
}
|
||||
} catch (error) {
|
||||
console.error('[Google Pay] Init error:', error)
|
||||
googlePayConnected.value = false
|
||||
}
|
||||
// #endif
|
||||
}
|
||||
|
||||
/**
|
||||
* 加载图书信息
|
||||
*/
|
||||
async function loadBookInfo() {
|
||||
try {
|
||||
uni.showLoading({ title: t('common.loading') })
|
||||
|
||||
const res = await bookApi.getBookInfo(bookId.value)
|
||||
|
||||
uni.hideLoading()
|
||||
|
||||
if (res.bookInfo) {
|
||||
bookInfo.value = res.bookInfo
|
||||
}
|
||||
} catch (error) {
|
||||
uni.hideLoading()
|
||||
console.error('[Order] Load book info error:', error)
|
||||
uni.showToast({
|
||||
title: t('common.networkError'),
|
||||
icon: 'none'
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 加载用户信息
|
||||
*/
|
||||
async function loadUserInfo() {
|
||||
if (!userInfo.value.id) return
|
||||
|
||||
try {
|
||||
const res = await orderApi.getUserInfo()
|
||||
if (res.result) {
|
||||
userCoinBalance.value = res.result.peanutCoin || 0
|
||||
}
|
||||
} catch (error) {
|
||||
console.error('[Order] Load user info error:', error)
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 切换支付方式
|
||||
*/
|
||||
function handlePaymentChange(e: any) {
|
||||
paymentMethod.value = e.detail.value
|
||||
}
|
||||
|
||||
/**
|
||||
* 确认下单
|
||||
*/
|
||||
async function handleConfirmOrder() {
|
||||
// 防止重复提交
|
||||
if (isSubmitting.value) {
|
||||
uni.showToast({
|
||||
title: t('bookOrder.doNotRepeat'),
|
||||
icon: 'none'
|
||||
})
|
||||
return
|
||||
}
|
||||
|
||||
// 验证订单
|
||||
if (!validateOrder()) {
|
||||
return
|
||||
}
|
||||
|
||||
isSubmitting.value = true
|
||||
|
||||
try {
|
||||
// 创建订单
|
||||
await createOrder()
|
||||
} catch (error) {
|
||||
isSubmitting.value = false
|
||||
console.error('[Order] Confirm order error:', error)
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 验证订单
|
||||
*/
|
||||
function validateOrder(): boolean {
|
||||
// 检查是否登录
|
||||
if (!userInfo.value.id) {
|
||||
uni.showToast({
|
||||
title: t('login.agreeFirst'),
|
||||
icon: 'none'
|
||||
})
|
||||
return false
|
||||
}
|
||||
|
||||
// 虚拟币支付时检查余额
|
||||
if (paymentMethod.value === '4') {
|
||||
const coinPrice = (bookInfo.value.abroadPrice || 0) * 10
|
||||
if (userCoinBalance.value < coinPrice) {
|
||||
uni.showToast({
|
||||
title: t('bookOrder.insufficientBalance'),
|
||||
icon: 'none'
|
||||
})
|
||||
return false
|
||||
}
|
||||
}
|
||||
|
||||
return true
|
||||
}
|
||||
|
||||
/**
|
||||
* 创建订单
|
||||
*/
|
||||
async function createOrder() {
|
||||
try {
|
||||
uni.showLoading({ title: t('bookOrder.creating') })
|
||||
|
||||
const res = await orderApi.createOrder({
|
||||
paymentMethod: paymentMethod.value,
|
||||
orderMoney: displayPrice.value,
|
||||
abroadBookId: bookId.value,
|
||||
orderType: 'abroadBook'
|
||||
})
|
||||
|
||||
uni.hideLoading()
|
||||
|
||||
if (res.code === 0 && res.orderSn) {
|
||||
orderSn.value = res.orderSn
|
||||
|
||||
// 根据支付方式执行相应流程
|
||||
if (paymentMethod.value === '4') {
|
||||
// 虚拟币支付
|
||||
await processVirtualCoinPayment()
|
||||
} else if (paymentMethod.value === '5') {
|
||||
// Google Pay 支付
|
||||
await processGooglePayment()
|
||||
}
|
||||
} else {
|
||||
throw new Error(res.msg || t('bookOrder.orderCreateFailed'))
|
||||
}
|
||||
} catch (error: any) {
|
||||
uni.hideLoading()
|
||||
isSubmitting.value = false
|
||||
uni.showToast({
|
||||
title: error.message || t('bookOrder.orderCreateFailed'),
|
||||
icon: 'none'
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 处理虚拟币支付
|
||||
*/
|
||||
async function processVirtualCoinPayment() {
|
||||
try {
|
||||
// 虚拟币支付在订单创建时已完成
|
||||
// 刷新用户信息
|
||||
await refreshUserInfo()
|
||||
|
||||
// 显示支付成功
|
||||
uni.showToast({
|
||||
title: t('bookOrder.paymentSuccess'),
|
||||
icon: 'success'
|
||||
})
|
||||
|
||||
// 延迟跳转
|
||||
setTimeout(() => {
|
||||
navigateToBookDetail()
|
||||
}, 1000)
|
||||
} catch (error) {
|
||||
isSubmitting.value = false
|
||||
console.error('[Order] Virtual coin payment error:', error)
|
||||
uni.showToast({
|
||||
title: t('bookOrder.paymentFailed'),
|
||||
icon: 'none'
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 处理 Google Pay 支付
|
||||
*/
|
||||
async function processGooglePayment() {
|
||||
try {
|
||||
// 检查 Google Pay 连接状态
|
||||
if (!googlePayConnected.value) {
|
||||
throw new Error(t('bookOrder.googlePayNotAvailable'))
|
||||
}
|
||||
|
||||
uni.showLoading({ title: t('bookOrder.processing') })
|
||||
|
||||
// 1. 查询商品 SKU
|
||||
const skuList = await queryGooglePaySku()
|
||||
|
||||
if (skuList.length === 0) {
|
||||
throw new Error(t('bookOrder.productNotFound'))
|
||||
}
|
||||
|
||||
// 2. 调起 Google Pay 支付
|
||||
const paymentResult = await initiateGooglePayment()
|
||||
|
||||
// 3. 消费购买凭证
|
||||
await consumeGooglePayPurchase(paymentResult.purchaseToken)
|
||||
|
||||
// 4. 后端验证支付
|
||||
await verifyGooglePayment(paymentResult)
|
||||
|
||||
// 5. 支付成功处理
|
||||
await handlePaymentSuccess()
|
||||
|
||||
} catch (error: any) {
|
||||
uni.hideLoading()
|
||||
isSubmitting.value = false
|
||||
|
||||
console.error('[Order] Google Pay payment error:', error)
|
||||
|
||||
uni.showToast({
|
||||
title: error.message || t('bookOrder.paymentFailed'),
|
||||
icon: 'none',
|
||||
duration: 2000
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询 Google Pay SKU
|
||||
*/
|
||||
function queryGooglePaySku(): Promise<any[]> {
|
||||
return new Promise((resolve, reject) => {
|
||||
if (!googlePayPlugin) {
|
||||
reject(new Error(t('bookOrder.googlePayNotAvailable')))
|
||||
return
|
||||
}
|
||||
|
||||
const productId = bookInfo.value.priceData?.dictType
|
||||
if (!productId) {
|
||||
reject(new Error(t('bookOrder.productNotFound')))
|
||||
return
|
||||
}
|
||||
|
||||
googlePayPlugin.querySku(
|
||||
{ inapp: [productId] },
|
||||
(result: any) => {
|
||||
console.log('[Google Pay] Query SKU result:', result)
|
||||
|
||||
if (result.code === 0 && result.list && result.list.length > 0) {
|
||||
resolve(result.list)
|
||||
} else {
|
||||
reject(new Error(t('bookOrder.productNotFound')))
|
||||
}
|
||||
}
|
||||
)
|
||||
})
|
||||
}
|
||||
|
||||
/**
|
||||
* 调起 Google Pay 支付
|
||||
*/
|
||||
function initiateGooglePayment(): Promise<{ purchaseToken: string; productId: string }> {
|
||||
return new Promise((resolve, reject) => {
|
||||
if (!googlePayPlugin) {
|
||||
reject(new Error(t('bookOrder.googlePayNotAvailable')))
|
||||
return
|
||||
}
|
||||
|
||||
const productId = bookInfo.value.priceData?.dictType
|
||||
|
||||
googlePayPlugin.payAll(
|
||||
{
|
||||
accountId: orderSn.value,
|
||||
productId: productId
|
||||
},
|
||||
(result: any) => {
|
||||
console.log('[Google Pay] Payment result:', result)
|
||||
|
||||
if (result.code === 0 && result.data && result.data.length > 0) {
|
||||
const purchaseToken = result.data[0].original.purchaseToken
|
||||
resolve({ purchaseToken, productId })
|
||||
} else {
|
||||
// 支付失败或取消
|
||||
reject(new Error(t('bookOrder.paymentCancelled')))
|
||||
}
|
||||
}
|
||||
)
|
||||
})
|
||||
}
|
||||
|
||||
/**
|
||||
* 消费 Google Pay 购买凭证
|
||||
*/
|
||||
function consumeGooglePayPurchase(purchaseToken: string): Promise<void> {
|
||||
return new Promise((resolve, reject) => {
|
||||
if (!googlePayPlugin) {
|
||||
reject(new Error(t('bookOrder.googlePayNotAvailable')))
|
||||
return
|
||||
}
|
||||
|
||||
googlePayPlugin.consume(
|
||||
{ purchaseToken },
|
||||
(result: any) => {
|
||||
console.log('[Google Pay] Consume result:', result)
|
||||
|
||||
if (result.code === 0) {
|
||||
resolve()
|
||||
} else {
|
||||
reject(new Error(t('bookOrder.verificationFailed')))
|
||||
}
|
||||
}
|
||||
)
|
||||
})
|
||||
}
|
||||
|
||||
/**
|
||||
* 验证 Google Pay 支付
|
||||
*/
|
||||
async function verifyGooglePayment(paymentResult: { purchaseToken: string; productId: string }) {
|
||||
try {
|
||||
const res = await orderApi.verifyGooglePay({
|
||||
purchaseToken: paymentResult.purchaseToken,
|
||||
orderSn: orderSn.value,
|
||||
productId: paymentResult.productId
|
||||
})
|
||||
|
||||
if (res.code !== 0) {
|
||||
throw new Error(res.msg || t('bookOrder.verificationFailed'))
|
||||
}
|
||||
} catch (error: any) {
|
||||
throw new Error(error.message || t('bookOrder.verificationFailed'))
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 支付成功处理
|
||||
*/
|
||||
async function handlePaymentSuccess() {
|
||||
try {
|
||||
// 刷新用户信息
|
||||
await refreshUserInfo()
|
||||
|
||||
uni.hideLoading()
|
||||
|
||||
// 显示支付成功
|
||||
uni.showToast({
|
||||
title: t('bookOrder.paymentSuccess'),
|
||||
icon: 'success'
|
||||
})
|
||||
|
||||
// 延迟跳转
|
||||
setTimeout(() => {
|
||||
navigateToBookDetail()
|
||||
}, 1000)
|
||||
} catch (error) {
|
||||
console.error('[Order] Payment success handler error:', error)
|
||||
// 即使刷新用户信息失败,也跳转到详情页
|
||||
setTimeout(() => {
|
||||
navigateToBookDetail()
|
||||
}, 1000)
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 刷新用户信息
|
||||
*/
|
||||
async function refreshUserInfo() {
|
||||
if (!userInfo.value.id) return
|
||||
|
||||
try {
|
||||
const res = await orderApi.refreshUserInfo(userInfo.value.id)
|
||||
if (res.code === 0 && res.user) {
|
||||
userStore.setUserInfo(res.user)
|
||||
}
|
||||
} catch (error) {
|
||||
console.error('[Order] Refresh user info error:', error)
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 跳转到图书详情页
|
||||
*/
|
||||
function navigateToBookDetail() {
|
||||
uni.navigateTo({
|
||||
url: `/pages/book/detail?id=${bookId.value}&page=order`
|
||||
})
|
||||
}
|
||||
</script>
|
||||
|
||||
<style lang="scss" scoped>
|
||||
.order-page {
|
||||
min-height: 100vh;
|
||||
background: #f7faf9;
|
||||
}
|
||||
|
||||
.order-block {
|
||||
margin: 20rpx;
|
||||
padding: 30rpx;
|
||||
background: #fff;
|
||||
border-radius: 15rpx;
|
||||
}
|
||||
|
||||
.order-info {
|
||||
margin-top: 20rpx;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
|
||||
.order-img {
|
||||
width: 180rpx;
|
||||
height: 240rpx;
|
||||
border-radius: 10rpx;
|
||||
flex-shrink: 0;
|
||||
}
|
||||
|
||||
.order-name {
|
||||
flex: 1;
|
||||
color: #333;
|
||||
font-size: 36rpx;
|
||||
padding-left: 40rpx;
|
||||
line-height: 44rpx;
|
||||
max-height: 88rpx;
|
||||
overflow: hidden;
|
||||
display: -webkit-box;
|
||||
-webkit-line-clamp: 2;
|
||||
-webkit-box-orient: vertical;
|
||||
}
|
||||
}
|
||||
|
||||
.order-price {
|
||||
padding-top: 40rpx;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: space-between;
|
||||
|
||||
.price-display {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
}
|
||||
|
||||
.coin-img {
|
||||
width: 40rpx;
|
||||
height: 40rpx;
|
||||
margin-right: 10rpx;
|
||||
}
|
||||
|
||||
.coin-text {
|
||||
font-size: 38rpx;
|
||||
color: #ff4703;
|
||||
font-weight: bold;
|
||||
}
|
||||
}
|
||||
|
||||
.order-type {
|
||||
background: #fff;
|
||||
border-radius: 15rpx;
|
||||
margin: 20rpx;
|
||||
padding: 30rpx;
|
||||
|
||||
.radio-group {
|
||||
margin-top: 30rpx;
|
||||
padding-bottom: 10rpx;
|
||||
}
|
||||
|
||||
.type-label {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
margin-top: 10rpx;
|
||||
|
||||
.type-view {
|
||||
width: 100%;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
line-height: 30rpx;
|
||||
|
||||
radio {
|
||||
transform: scale(0.95);
|
||||
}
|
||||
|
||||
text {
|
||||
font-size: 30rpx;
|
||||
padding-left: 5rpx;
|
||||
color: #333;
|
||||
|
||||
.balance-text {
|
||||
padding-left: 10rpx;
|
||||
color: #54a966;
|
||||
font-weight: normal;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
.order-title {
|
||||
font-size: 34rpx;
|
||||
line-height: 50rpx;
|
||||
padding-bottom: 10rpx;
|
||||
color: #333;
|
||||
}
|
||||
|
||||
.order-btn {
|
||||
width: 100%;
|
||||
height: 110rpx;
|
||||
background: #fff;
|
||||
position: fixed;
|
||||
bottom: 0;
|
||||
left: 0;
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
align-items: center;
|
||||
padding: 0 20rpx;
|
||||
box-shadow: 0 -2rpx 10rpx rgba(0, 0, 0, 0.05);
|
||||
|
||||
.btn-spacer {
|
||||
flex: 1;
|
||||
}
|
||||
|
||||
.confirm-btn {
|
||||
margin: 20rpx 0;
|
||||
padding: 0 35rpx;
|
||||
height: 70rpx;
|
||||
line-height: 70rpx;
|
||||
background-color: #ff4703;
|
||||
color: #fff;
|
||||
font-size: 30rpx;
|
||||
border-radius: 10rpx;
|
||||
border: none;
|
||||
|
||||
&[disabled] {
|
||||
opacity: 0.6;
|
||||
}
|
||||
}
|
||||
}
|
||||
</style>
|
||||
@@ -102,6 +102,7 @@
|
||||
<text class="popup-title">{{ $t('book.zjContents') }}</text>
|
||||
<scroll-view scroll-y class="chapter-list">
|
||||
<view
|
||||
v-if="chapterList.length > 0"
|
||||
v-for="(chapter, index) in chapterList"
|
||||
:key="chapter.id"
|
||||
class="chapter-item"
|
||||
@@ -111,8 +112,9 @@
|
||||
<text class="chapter-text" :class="{ locked: isLocked(index) }">
|
||||
{{ chapter.chapter }}{{ chapter.content ? ' - ' + chapter.content : '' }}
|
||||
</text>
|
||||
<wd-icon v-if="isLocked(index)" name="lock" size="20px" />
|
||||
<wd-icon v-if="isLocked(index) && !hasVip" name="lock-on" size="20px" />
|
||||
</view>
|
||||
<wd-status-tip v-else image="content" :tip="$t('global.dataNull')" />
|
||||
</scroll-view>
|
||||
</view>
|
||||
</wd-popup>
|
||||
@@ -191,6 +193,7 @@
|
||||
import { ref, computed, onMounted } from 'vue'
|
||||
import { onLoad, onShow, onHide, onBackPress } from '@dcloudio/uni-app'
|
||||
import { useI18n } from 'vue-i18n'
|
||||
import { useUserStore } from '@/stores/user'
|
||||
import { useBookStore } from '@/stores/book'
|
||||
import { bookApi } from '@/api/modules/book'
|
||||
import type { IChapter, IChapterContent, IReadProgress } from '@/types/book'
|
||||
@@ -198,10 +201,14 @@ import { onPageBack } from '@/utils/index'
|
||||
|
||||
const { t } = useI18n()
|
||||
const bookStore = useBookStore()
|
||||
const userStore = useUserStore()
|
||||
|
||||
// 会员状态
|
||||
const hasVip = computed(() => userStore.userInfo?.userEbookVip?.length > 0 || false)
|
||||
|
||||
// 路由参数
|
||||
const bookId = ref(0)
|
||||
const isBuy = ref('0')
|
||||
const isBuy = ref(false)
|
||||
const count = ref(0)
|
||||
|
||||
// 数据状态
|
||||
@@ -273,7 +280,7 @@ const currentChapterTitle = computed(() => {
|
||||
|
||||
onLoad((options: any) => {
|
||||
if (options.bookId) bookId.value = Number(options.bookId)
|
||||
if (options.isBuy) isBuy.value = options.isBuy
|
||||
if (options.isBuy) isBuy.value = options.isBuy == 1 ? true : false
|
||||
if (options.count) count.value = Number(options.count)
|
||||
|
||||
// 获取刘海高度
|
||||
@@ -430,7 +437,7 @@ async function switchChapter(chapter: IChapter, index: number) {
|
||||
|
||||
// 判断章节是否锁定
|
||||
function isLocked(index: number): boolean {
|
||||
return isBuy.value === '1' && index + 1 > count.value
|
||||
return !isBuy.value && index + 1 > count.value && !hasVip.value
|
||||
}
|
||||
|
||||
// 判断是否是图片
|
||||
@@ -604,10 +611,9 @@ function changeReadMode(mode: 'scroll' | 'page') {
|
||||
|
||||
// 语言配置
|
||||
const bookLanguages = ref([])
|
||||
const currentLanguage = ref('')
|
||||
const currentLanguage = ref('中文')
|
||||
onMounted(() => {
|
||||
currentLanguage.value = uni.getStorageSync('currentBookLanguage') || ''
|
||||
console.log('currentLanguage', currentLanguage.value)
|
||||
currentLanguage.value = uni.getStorageSync('currentBookLanguage') || '中文'
|
||||
})
|
||||
const getBookLanguages = async () => {
|
||||
const res = await bookApi.getBookLanguages(bookId.value)
|
||||
@@ -658,7 +664,7 @@ async function saveProgress() {
|
||||
position: fixed;
|
||||
left: 0;
|
||||
right: 0;
|
||||
z-index: 999;
|
||||
z-index: 90;
|
||||
background: inherit;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
|
||||
@@ -164,13 +164,9 @@ function initScrollHeight() {
|
||||
|
||||
// 加载书籍信息
|
||||
async function loadBookInfo() {
|
||||
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)
|
||||
const res = await bookApi.getBookInfo(bookId.value)
|
||||
if (res.bookInfo) {
|
||||
bookInfo.value = res.bookInfo
|
||||
}
|
||||
}
|
||||
|
||||
@@ -180,20 +176,15 @@ async function loadComments() {
|
||||
return
|
||||
}
|
||||
|
||||
try {
|
||||
const res = await bookApi.getBookComments(bookId.value, page.value.current, page.value.limit)
|
||||
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) {
|
||||
nullText.value = t('common.data_null')
|
||||
}
|
||||
} catch (error) {
|
||||
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')
|
||||
console.error('Failed to load comments:', error)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -275,33 +266,29 @@ function handleEmj(i: any) {
|
||||
|
||||
// 提交评论
|
||||
async function submitComment() {
|
||||
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)
|
||||
const content = await getEditorContent()
|
||||
|
||||
if (!content || content === '<p><br></p>') {
|
||||
uni.showToast({
|
||||
title: t('workOrder.submit_success'),
|
||||
icon: 'success',
|
||||
duration: 500
|
||||
title: t('bookDetails.enterText'),
|
||||
icon: 'none'
|
||||
})
|
||||
|
||||
setTimeout(() => {
|
||||
editorCtx.value?.clear()
|
||||
resetComments()
|
||||
}, 500)
|
||||
} catch (error) {
|
||||
console.error('Failed to submit comment:', error)
|
||||
return
|
||||
}
|
||||
|
||||
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)
|
||||
}
|
||||
|
||||
// 点赞/取消点赞
|
||||
@@ -314,29 +301,25 @@ async function handleLike(comment: IComment) {
|
||||
return
|
||||
}
|
||||
|
||||
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)
|
||||
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)
|
||||
}
|
||||
|
||||
// 删除评论
|
||||
@@ -348,20 +331,16 @@ function handleDelete(comment: IComment) {
|
||||
confirmText: t('common.confirm_text'),
|
||||
success: async (res) => {
|
||||
if (res.confirm) {
|
||||
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)
|
||||
}
|
||||
await bookApi.deleteComment(comment.id)
|
||||
uni.showToast({
|
||||
title: t('bookDetails.deleteSuccess'),
|
||||
icon: 'success',
|
||||
duration: 500
|
||||
})
|
||||
|
||||
setTimeout(() => {
|
||||
resetComments()
|
||||
}, 500)
|
||||
}
|
||||
}
|
||||
})
|
||||
|
||||
@@ -27,12 +27,7 @@
|
||||
>
|
||||
<image :src="item.images" />
|
||||
<text class="book-text">{{ item.name }}</text>
|
||||
<text v-if="formatPrice(item)" class="book-price">{{
|
||||
formatPrice(item)
|
||||
}}</text>
|
||||
<text v-if="formatStats(item)" class="book-flag">{{
|
||||
formatStats(item)
|
||||
}}</text>
|
||||
<BookPrice :data="item" class="book-price-container" />
|
||||
</view>
|
||||
</view>
|
||||
<view v-else-if="isEmpty" class="empty-wrapper">
|
||||
@@ -47,6 +42,7 @@ import { ref, onMounted } from 'vue'
|
||||
import { onLoad } from '@dcloudio/uni-app'
|
||||
import { useI18n } from 'vue-i18n'
|
||||
import { homeApi } from '@/api/modules/book_home'
|
||||
import BookPrice from '@/components/book/BookPrice.vue'
|
||||
import type { IBookWithStats, IVipInfo } from '@/types/home'
|
||||
|
||||
const { t } = useI18n()
|
||||
@@ -70,14 +66,8 @@ onLoad((options: any) => {
|
||||
* 获取VIP信息
|
||||
*/
|
||||
const getVipInfo = async () => {
|
||||
try {
|
||||
const res = await homeApi.getVipInfo()
|
||||
if (res.vipInfo) {
|
||||
vipInfo.value = res.vipInfo
|
||||
}
|
||||
} catch (error) {
|
||||
console.error('获取VIP信息失败:', error)
|
||||
}
|
||||
const res = await homeApi.getVipInfo()
|
||||
vipInfo.value = res.vipInfo
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -91,26 +81,19 @@ const handleSearch = async () => {
|
||||
loading.value = true
|
||||
isEmpty.value = false
|
||||
|
||||
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)
|
||||
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
|
||||
} finally {
|
||||
loading.value = false
|
||||
}
|
||||
loading.value = false
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -273,21 +256,9 @@ onMounted(async () => {
|
||||
overflow: hidden;
|
||||
}
|
||||
|
||||
.book-price {
|
||||
position: absolute;
|
||||
font-size: 28rpx;
|
||||
color: #ff4703;
|
||||
left: 30rpx;
|
||||
bottom: 20rpx;
|
||||
}
|
||||
|
||||
.book-flag {
|
||||
display: block;
|
||||
font-size: 26rpx;
|
||||
color: #999;
|
||||
position: absolute;
|
||||
right: 6%;
|
||||
bottom: 20rpx;
|
||||
.book-price-container {
|
||||
width: 80%;
|
||||
margin: 15rpx auto 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
<nav-bar :title="$t('courseDetails.chapter')" />
|
||||
|
||||
<!-- 页面内容 -->
|
||||
<view class="page-content" :style="{ height: contentHeight }">
|
||||
<view class="page-content">
|
||||
<!-- 视频播放器 -->
|
||||
<view v-if="videoList.length > 0" class="video-section">
|
||||
<VideoPlayer
|
||||
@@ -13,19 +13,13 @@
|
||||
:video-list="videoList"
|
||||
:countdown-seconds="5"
|
||||
/>
|
||||
<!-- <AliyunPlayer
|
||||
ref="videoPlayerRef"
|
||||
:currentVideo="videoList[currentVideoIndex]"
|
||||
:currentVideoList="videoList"
|
||||
@unlockChangeVideo="changeVideoLock = false"
|
||||
/> -->
|
||||
</view>
|
||||
|
||||
<!-- 课程和章节信息 -->
|
||||
<view class="info-section">
|
||||
<view class="info-item">
|
||||
<text class="label">{{ $t('courseDetails.courseInfo') }}:</text>
|
||||
<text class="value">{{ navTitle }}</text>
|
||||
<text class="value">{{ courseTitle }}</text>
|
||||
</view>
|
||||
<view class="info-item">
|
||||
<text class="label">{{ $t('courseDetails.chapterInfo') }}:</text>
|
||||
@@ -36,126 +30,74 @@
|
||||
<!-- 视频列表 -->
|
||||
<view v-if="videoList.length > 0" class="video-list-section">
|
||||
<view class="section-title">{{ $t('courseDetails.videoTeaching') }}</view>
|
||||
<view class="video-list">
|
||||
<view
|
||||
v-for="(video, index) in videoList"
|
||||
:key="video.id"
|
||||
:class="['video-item', currentVideoIndex === index ? 'active' : '']"
|
||||
@click="selectVideo(index)"
|
||||
>
|
||||
<view class="video-info">
|
||||
<text class="video-title">【{{ video.type == "2" ? "音频" : "视频" }}】{{ index + 1 }}</text>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
<wd-radio-group v-model="currentVideoIndex" shape="button" >
|
||||
<wd-radio v-for="(video, index) in videoList" :key="video.id" :value="index" class="mb-2!">
|
||||
【{{ video.type == "2" ? $t('courseDetails.audio') : $t('courseDetails.video') }}】{{ index + 1 }}
|
||||
</wd-radio>
|
||||
</wd-radio-group>
|
||||
</view>
|
||||
|
||||
<!-- 选项卡 -->
|
||||
<view v-if="tabList.length > 0" class="tabs-section">
|
||||
<view class="tabs">
|
||||
<view
|
||||
v-for="(tab, index) in tabList"
|
||||
:key="tab.id"
|
||||
:class="['tab-item', currentTab === index ? 'active' : '']"
|
||||
@click="switchTab(index)"
|
||||
>
|
||||
<text>{{ tab.name }}</text>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
|
||||
<!-- 选项卡内容 -->
|
||||
<view class="tab-content">
|
||||
<wd-tabs v-model="currentTab" class="tabs-section" lineWidth="30">
|
||||
<!-- 章节介绍 -->
|
||||
<view v-show="currentTab === 0" class="intro-content">
|
||||
<view class="section-title">{{ $t('courseDetails.chapterIntro') }}</view>
|
||||
<view class="intro-wrapper">
|
||||
<!-- 章节封面 -->
|
||||
<image
|
||||
v-if="chapterDetail?.imgUrl"
|
||||
:src="chapterDetail.imgUrl"
|
||||
mode="widthFix"
|
||||
class="chapter-image"
|
||||
@click="previewImage(chapterDetail.imgUrl)"
|
||||
/>
|
||||
|
||||
<!-- 章节内容 -->
|
||||
<view v-if="chapterDetail?.content" class="chapter-content" v-html="chapterDetail.content"></view>
|
||||
</view>
|
||||
<wd-tab name="chapterIntro" :title="$t('courseDetails.chapterIntro')">
|
||||
<!-- 章节封面 -->
|
||||
<image
|
||||
v-if="chapterDetail?.imgUrl"
|
||||
:src="chapterDetail.imgUrl"
|
||||
mode="widthFix"
|
||||
class="chapter-image"
|
||||
@click="previewImage(chapterDetail.imgUrl)"
|
||||
/>
|
||||
|
||||
<!-- 章节内容 -->
|
||||
<view v-if="chapterDetail?.content" v-html="chapterDetail.content"></view>
|
||||
|
||||
<view class="copyright">
|
||||
<text>{{ $t('courseDetails.copyright') }}</text>
|
||||
</view>
|
||||
</view>
|
||||
|
||||
</wd-tab>
|
||||
<!-- 思考题 -->
|
||||
<view v-show="currentTab === 1" class="question-content">
|
||||
<view class="section-title">{{ $t('courseDetails.thinkingQuestion') }}</view>
|
||||
<view v-if="chapterDetail?.questions" class="question-wrapper">
|
||||
<view class="question-html" v-html="chapterDetail.questions"></view>
|
||||
</view>
|
||||
<view v-else class="no-question">
|
||||
<wd-tab v-if="chapterDetail?.questions" name="thinkingQuestion" :title="$t('courseDetails.thinkingQuestion')">
|
||||
<view v-html="chapterDetail.questions"></view>
|
||||
<!-- <view v-else class="no-question">
|
||||
<wd-divider>{{ $t('courseDetails.noQuestion') }}</wd-divider>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
</view> -->
|
||||
</wd-tab>
|
||||
</wd-tabs>
|
||||
</view>
|
||||
</view>
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
import { ref, computed } from 'vue'
|
||||
import { onLoad, onShow, onHide } from '@dcloudio/uni-app'
|
||||
import { ref } from 'vue'
|
||||
import { onLoad } from '@dcloudio/uni-app'
|
||||
import { courseApi } from '@/api/modules/course'
|
||||
import VideoPlayer from '@/components/video-player/index.vue'
|
||||
import type { IChapterDetail, IVideo } from '@/types/course'
|
||||
|
||||
// 页面参数
|
||||
const chapterId = ref<number>(0)
|
||||
const courseId = ref<number>(0)
|
||||
const navTitle = ref('')
|
||||
const courseTitle = ref('')
|
||||
const chapterTitle = ref('')
|
||||
const noRecored = ref(false)
|
||||
|
||||
// 页面数据
|
||||
const chapterDetail = ref<IChapterDetail | null>(null)
|
||||
const videoList = ref<IVideo[]>([])
|
||||
const currentVideoIndex = ref(0)
|
||||
const activeVideoIndex = ref(0)
|
||||
const currentTab = ref(0)
|
||||
const isFullScreen = ref(false)
|
||||
const currentTab = ref('chapterIntro')
|
||||
|
||||
// 视频播放器引用
|
||||
const videoPlayerRef = ref<any>(null)
|
||||
|
||||
// 选项卡列表
|
||||
const tabList = computed(() => {
|
||||
const tabs = [
|
||||
{ id: '0', name: '章节介绍' }
|
||||
]
|
||||
|
||||
// 如果有思考题,添加思考题选项卡
|
||||
if (chapterDetail.value?.questions) {
|
||||
tabs.push({ id: '1', name: '思考题' })
|
||||
}
|
||||
|
||||
return tabs
|
||||
})
|
||||
|
||||
// 内容高度(全屏时调整)
|
||||
const contentHeight = computed(() => {
|
||||
return isFullScreen.value ? '100vh' : 'auto'
|
||||
})
|
||||
|
||||
/**
|
||||
* 页面加载
|
||||
*/
|
||||
onLoad((options: any) => {
|
||||
chapterId.value = parseInt(options.id)
|
||||
courseId.value = parseInt(options.courseId)
|
||||
navTitle.value = options.navTitle || ''
|
||||
courseTitle.value = options.courseTitle || ''
|
||||
chapterTitle.value = options.title || ''
|
||||
noRecored.value = options.noRecored === 'true'
|
||||
|
||||
loadChapterDetail()
|
||||
})
|
||||
@@ -164,41 +106,22 @@ onLoad((options: any) => {
|
||||
* 加载章节详情
|
||||
*/
|
||||
const loadChapterDetail = async () => {
|
||||
try {
|
||||
const res = await courseApi.getChapterDetail(chapterId.value)
|
||||
if (res.code === 0 && res.data) {
|
||||
chapterDetail.value = res.data.detail
|
||||
videoList.value = res.data.videos || []
|
||||
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:any) => v.id === res.data.current)
|
||||
if (index !== -1) {
|
||||
currentVideoIndex.value = index
|
||||
activeVideoIndex.value = index
|
||||
}
|
||||
}
|
||||
} catch (error) {
|
||||
console.error('加载章节详情失败:', error)
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 选择视频
|
||||
*/
|
||||
const selectVideo = async (index: number) => {
|
||||
if (index === currentVideoIndex.value) return
|
||||
currentVideoIndex.value = index
|
||||
}
|
||||
|
||||
/**
|
||||
* 切换选项卡
|
||||
*/
|
||||
const switchTab = (index: number) => {
|
||||
currentTab.value = index
|
||||
}
|
||||
|
||||
/**
|
||||
* 预览图片
|
||||
*/
|
||||
@@ -216,10 +139,6 @@ const previewImage = (url: string) => {
|
||||
background-color: #f5f5f5;
|
||||
}
|
||||
|
||||
.page-content {
|
||||
padding-bottom: 100rpx;
|
||||
}
|
||||
|
||||
.video-section {
|
||||
background-color: #000;
|
||||
}
|
||||
@@ -258,135 +177,45 @@ const previewImage = (url: string) => {
|
||||
color: #2979ff;
|
||||
margin-bottom: 20rpx;
|
||||
}
|
||||
|
||||
.video-list {
|
||||
display: flex;
|
||||
flex-wrap: wrap;
|
||||
justify-content: flex-start;
|
||||
align-items: center;
|
||||
gap: 10rpx;
|
||||
|
||||
.video-item {
|
||||
padding: 18rpx;
|
||||
margin-bottom: 10rpx;
|
||||
background-color: #f7f8f9;
|
||||
border-radius: 8rpx;
|
||||
border: 2rpx solid transparent;
|
||||
transition: all 0.3s;
|
||||
|
||||
&.active {
|
||||
background-color: #e8f4ff;
|
||||
border-color: #258feb;
|
||||
}
|
||||
|
||||
.video-info {
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
align-items: center;
|
||||
|
||||
.video-title {
|
||||
flex: 1;
|
||||
font-size: 28rpx;
|
||||
color: #333;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
.tabs-section {
|
||||
background-color: #fff;
|
||||
margin-top: 20rpx;
|
||||
border-bottom: 2rpx solid #2979ff;
|
||||
|
||||
.tabs {
|
||||
display: flex;
|
||||
|
||||
.tab-item {
|
||||
flex: 1;
|
||||
text-align: center;
|
||||
padding: 25rpx 0;
|
||||
font-size: 30rpx;
|
||||
color: #666;
|
||||
position: relative;
|
||||
transition: all 0.3s;
|
||||
|
||||
&.active {
|
||||
color: #2979ff;
|
||||
font-weight: 500;
|
||||
|
||||
&::after {
|
||||
content: '';
|
||||
position: absolute;
|
||||
bottom: 0;
|
||||
left: 50%;
|
||||
transform: translateX(-50%);
|
||||
width: 60rpx;
|
||||
height: 4rpx;
|
||||
background-color: #2979ff;
|
||||
border-radius: 2rpx;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
:deep(.wd-tabs__nav) {
|
||||
border-bottom: 1px solid #2979ff;
|
||||
}
|
||||
:deep(.wd-tab__body) {
|
||||
padding: 30rpx;
|
||||
font-size: 28rpx;
|
||||
line-height: 1.8;
|
||||
color: #666;
|
||||
word-break: break-all;
|
||||
}
|
||||
:deep(.wd-tabs__line) {
|
||||
bottom: 0;
|
||||
}
|
||||
}
|
||||
|
||||
.tab-content {
|
||||
background-color: #fff;
|
||||
padding: 20rpx;
|
||||
|
||||
.section-title {
|
||||
font-size: 32rpx;
|
||||
font-weight: 500;
|
||||
color: #333;
|
||||
margin-bottom: 20rpx;
|
||||
}
|
||||
|
||||
.intro-content {
|
||||
.intro-wrapper {
|
||||
.chapter-image {
|
||||
width: 100%;
|
||||
display: block;
|
||||
margin-bottom: 20rpx;
|
||||
border-radius: 8rpx;
|
||||
}
|
||||
|
||||
.chapter-content {
|
||||
font-size: 28rpx;
|
||||
line-height: 1.8;
|
||||
color: #666;
|
||||
text-align: justify;
|
||||
word-break: break-all;
|
||||
}
|
||||
}
|
||||
|
||||
.copyright {
|
||||
margin-top: 40rpx;
|
||||
padding-top: 20rpx;
|
||||
border-top: 1px solid #f0f0f0;
|
||||
text-align: center;
|
||||
|
||||
text {
|
||||
font-size: 24rpx;
|
||||
color: #ff4444;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
.question-content {
|
||||
.question-wrapper {
|
||||
.question-html {
|
||||
font-size: 28rpx;
|
||||
line-height: 1.8;
|
||||
color: #666;
|
||||
word-break: break-all;
|
||||
}
|
||||
}
|
||||
|
||||
.no-question {
|
||||
padding: 80rpx 0;
|
||||
text-align: center;
|
||||
}
|
||||
}
|
||||
.chapter-image {
|
||||
width: 100%;
|
||||
display: block;
|
||||
margin-bottom: 20rpx;
|
||||
border-radius: 8rpx;
|
||||
}
|
||||
|
||||
.copyright {
|
||||
margin-top: 20rpx;
|
||||
padding-top: 20rpx;
|
||||
border-top: 1px solid #f0f0f0;
|
||||
text-align: center;
|
||||
font-size: 24rpx;
|
||||
color: #ff4444;
|
||||
}
|
||||
|
||||
.no-question {
|
||||
padding: 80rpx 0;
|
||||
text-align: center;
|
||||
}
|
||||
</style>
|
||||
|
||||
450
pages/course/details/components/CatalogueList.vue
Normal file
450
pages/course/details/components/CatalogueList.vue
Normal file
@@ -0,0 +1,450 @@
|
||||
<template>
|
||||
<view class="course-content-wrapper">
|
||||
<view
|
||||
v-if="catalogues.length > 1"
|
||||
:class="['catalogue-list', userVip ? 'vip-style' : '']"
|
||||
>
|
||||
<view
|
||||
v-for="(catalogue, index) in catalogues"
|
||||
:key="catalogue.id"
|
||||
:class="['catalogue-item', currentCatalogueIndex === index ? 'active' : '']"
|
||||
@click="handleSelect(index)"
|
||||
>
|
||||
<text class="catalogue-title">{{ catalogue.title }}</text>
|
||||
</view>
|
||||
</view>
|
||||
|
||||
<view class="chapter-list">
|
||||
<!-- 目录状态信息 -->
|
||||
<view class="catalogue-status">
|
||||
<view v-if="currentCatalogue?.isBuy === 1 || userVip" class="purchased-info">
|
||||
<view class="info-row">
|
||||
<text v-if="userVip">
|
||||
VIP畅学权益有效期截止到:{{ userVip.endTime }}
|
||||
</text>
|
||||
<template v-else>
|
||||
<text v-if="!currentCatalogue.startTime">
|
||||
当前目录还未开始学习
|
||||
</text>
|
||||
<text v-else>
|
||||
课程有效期截止到:{{ currentCatalogue.endTime }}
|
||||
</text>
|
||||
<!-- <wd-button
|
||||
v-if="currentCatalogue.startTime"
|
||||
size="small"
|
||||
@click="handleRenew"
|
||||
>
|
||||
续费
|
||||
</wd-button> -->
|
||||
</template>
|
||||
</view>
|
||||
</view>
|
||||
|
||||
<!-- 未购买状态 -->
|
||||
<view v-else-if="currentCatalogue?.type === 0" class="free-course">
|
||||
<wd-button type="success" @click="handleGetFreeCourse">
|
||||
{{ $t('courseDetails.free') }}
|
||||
</wd-button>
|
||||
</view>
|
||||
|
||||
<view v-else class="unpurchased-info">
|
||||
<text class="tip-text">
|
||||
{{ $t('courseDetails.unpurchasedTip') }}
|
||||
</text>
|
||||
<view class="action-btns">
|
||||
<wd-button size="small" type="warning" @click="handlePurchase">
|
||||
{{ $t('courseDetails.purchase') }}
|
||||
</wd-button>
|
||||
<wd-button
|
||||
v-if="showRenewBtn"
|
||||
size="small"
|
||||
type="success"
|
||||
@click="handleRenew"
|
||||
>
|
||||
{{ $t('courseDetails.relearn') }}
|
||||
</wd-button>
|
||||
<wd-button size="small" type="primary" @click="goToVip">
|
||||
{{ $t('courseDetails.openVip') }}
|
||||
</wd-button>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
|
||||
<view v-if="chapterList.length > 0" class="chapter-content">
|
||||
<!-- VIP标识 -->
|
||||
<view v-if="userVip" class="vip-badge">
|
||||
<text>VIP畅学权益生效中</text>
|
||||
</view>
|
||||
|
||||
<!-- 章节列表 -->
|
||||
<view
|
||||
v-for="(chapter, index) in chapterList"
|
||||
:key="chapter.id"
|
||||
class="chapter-item"
|
||||
@click="handleChapterClick(chapter)"
|
||||
>
|
||||
<view class="chapter-content-wrapper">
|
||||
<view :class="['chapter-info', !canAccess(chapter) ? 'locked' : '']">
|
||||
<text class="chapter-title">{{ chapter.title }}</text>
|
||||
|
||||
<!-- 试听标签 -->
|
||||
<wd-tag
|
||||
v-if="chapter.isAudition === 1 && !isPurchased && !userVip"
|
||||
type="success"
|
||||
plain
|
||||
size="small"
|
||||
custom-class="chapter-tag"
|
||||
>
|
||||
试听
|
||||
</wd-tag>
|
||||
|
||||
<!-- 学习状态标签 -->
|
||||
<template v-if="isPurchased || userVip">
|
||||
<wd-tag
|
||||
v-if="chapter.isLearned === 0"
|
||||
type="primary"
|
||||
plain
|
||||
size="small"
|
||||
custom-class="chapter-tag"
|
||||
>
|
||||
未学
|
||||
</wd-tag>
|
||||
<wd-tag
|
||||
v-else
|
||||
type="success"
|
||||
plain
|
||||
size="small"
|
||||
custom-class="chapter-tag"
|
||||
>
|
||||
已学
|
||||
</wd-tag>
|
||||
</template>
|
||||
</view>
|
||||
|
||||
<!-- 锁定图标 -->
|
||||
<view v-if="!canAccess(chapter) && currentCatalogue.type != 0" class="lock-icon">
|
||||
<wd-icon name="lock-on" size="24px" color="#258feb" />
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
|
||||
<!-- 暂无章节 -->
|
||||
<view v-else class="no-chapters">
|
||||
<text>暂无章节内容</text>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
import { ref, computed, watch } from 'vue'
|
||||
import { courseApi } from '@/api/modules/course'
|
||||
import type { IChapter, ICatalogue, IVipInfo } from '@/types/course'
|
||||
|
||||
interface Props {
|
||||
catalogues: ICatalogue[]
|
||||
userVip: IVipInfo | null
|
||||
showRenewBtn?: boolean
|
||||
}
|
||||
|
||||
const props = defineProps<Props>()
|
||||
|
||||
const emit = defineEmits<{
|
||||
click: [chapter: IChapter],
|
||||
purchase: [catalogue: ICatalogue],
|
||||
renew: [catalogue: ICatalogue],
|
||||
toVip: [catalogue: ICatalogue],
|
||||
change: [index: number]
|
||||
}>()
|
||||
|
||||
// 当前目录索引
|
||||
const currentCatalogueIndex = ref<number>(0)
|
||||
// 当前目录
|
||||
const currentCatalogue = computed(() => {
|
||||
return props.catalogues[currentCatalogueIndex.value]
|
||||
})
|
||||
// 当前目录的章节
|
||||
const chapterList = ref<IChapter[]>([])
|
||||
|
||||
// 显示续费按钮
|
||||
const showRenewBtn = ref<boolean>(false)
|
||||
|
||||
// 判断目录是否已购买
|
||||
const isPurchased = computed(() => {
|
||||
return currentCatalogue.value.isBuy === 1
|
||||
})
|
||||
|
||||
/**
|
||||
* 选择目录
|
||||
*/
|
||||
const handleSelect = (index: number) => {
|
||||
if (index === currentCatalogueIndex.value) return
|
||||
|
||||
currentCatalogueIndex.value = index
|
||||
|
||||
getChapters() // 获取章节列表
|
||||
checkRenewPayment() // 检查是否支持复读
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取当前目录的章节
|
||||
*/
|
||||
const getChapters = async () => {
|
||||
const res = await courseApi.getCatalogueChapterList(currentCatalogue.value.id)
|
||||
chapterList.value = res.chapterList || []
|
||||
}
|
||||
|
||||
/**
|
||||
* 检查目录是否支持复读
|
||||
*/
|
||||
const checkRenewPayment = async () => {
|
||||
if (currentCatalogue.value.isBuy === 0 && !props.userVip) {
|
||||
const renewRes = await courseApi.checkRenewPayment(currentCatalogue.value.id)
|
||||
showRenewBtn.value = renewRes.canRelearn || false
|
||||
} else {
|
||||
showRenewBtn.value = false
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 监听目录变化
|
||||
*/
|
||||
watch(() => props.catalogues, (newVal: ICatalogue[]) => {
|
||||
if (newVal.length > 0) {
|
||||
currentCatalogueIndex.value = 0
|
||||
getChapters()
|
||||
checkRenewPayment()
|
||||
}
|
||||
}, { immediate: true, deep: true })
|
||||
|
||||
// 购买
|
||||
const handlePurchase = () => {
|
||||
emit('purchase', currentCatalogue.value)
|
||||
}
|
||||
|
||||
// 去开通vip
|
||||
const goToVip = () => {
|
||||
emit('toVip', currentCatalogue.value)
|
||||
}
|
||||
|
||||
// 续费/复读
|
||||
const handleRenew = () => {
|
||||
emit('renew', currentCatalogue.value)
|
||||
}
|
||||
|
||||
// 领取免费课程
|
||||
const handleGetFreeCourse = async () => {
|
||||
emit('getFreeCourse', currentCatalogue.value)
|
||||
}
|
||||
|
||||
/**
|
||||
* 判断章节是否可以访问
|
||||
*/
|
||||
const canAccess = (chapter: IChapter): boolean => {
|
||||
// VIP用户可以访问所有章节
|
||||
if (props.userVip) return true
|
||||
|
||||
// 已购买目录可以访问所有章节
|
||||
if (isPurchased.value) return true
|
||||
|
||||
// 试听章节可以访问
|
||||
if (chapter.isAudition === 1) return true
|
||||
|
||||
// 免费课程可以访问
|
||||
// if (currentCatalogue.value.type === 0) return true
|
||||
|
||||
return false
|
||||
}
|
||||
|
||||
/**
|
||||
* 点击章节
|
||||
*/
|
||||
const handleChapterClick = (chapter: IChapter, catalogue: ICatalogue) => {
|
||||
if (!canAccess(chapter)) {
|
||||
if (currentCatalogue.value.type === 0) {
|
||||
uni.showToast({
|
||||
title: '请先领取课程',
|
||||
icon: 'none'
|
||||
})
|
||||
} else {
|
||||
uni.showToast({
|
||||
title: '请先购买课程',
|
||||
icon: 'none'
|
||||
})
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
emit('toDetail', chapter, currentCatalogue.value)
|
||||
}
|
||||
</script>
|
||||
|
||||
<style lang="scss" scoped>
|
||||
.course-content-wrapper {
|
||||
background: linear-gradient(108deg, #c3e7ff 0%, #59bafe 100%);
|
||||
}
|
||||
.catalogue-list {
|
||||
display: flex;
|
||||
align-items: flex-end;
|
||||
padding: 20rpx;
|
||||
padding-bottom: 0;
|
||||
border-radius: 20rpx 20rpx 0 0;
|
||||
margin-top: 20rpx;
|
||||
|
||||
&.vip-style {
|
||||
background: linear-gradient(90deg, #6429db 0%, #0075ed 100%);
|
||||
|
||||
.catalogue-item {
|
||||
background-color: rgba(0, 0, 0, 0.4);
|
||||
color: #fff;
|
||||
border-color: #fff;
|
||||
|
||||
&.active {
|
||||
background-color: #258feb;
|
||||
color: #fff;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
.catalogue-item {
|
||||
flex: 1;
|
||||
text-align: center;
|
||||
padding: 16rpx 0;
|
||||
margin-right: 10rpx;
|
||||
border-radius: 20rpx 20rpx 0 0;
|
||||
border: 1px solid #fff;
|
||||
border-bottom: none;
|
||||
background-color: rgba(0, 0, 0, 0.4);
|
||||
color: #fff;
|
||||
transition: all 0.3s;
|
||||
|
||||
&:last-child {
|
||||
margin-right: 0;
|
||||
}
|
||||
|
||||
&.active {
|
||||
background-color: #258feb;
|
||||
padding: 20rpx 0;
|
||||
|
||||
.catalogue-title {
|
||||
font-size: 36rpx;
|
||||
font-weight: bold;
|
||||
}
|
||||
}
|
||||
|
||||
.catalogue-title {
|
||||
font-size: 30rpx;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
.chapter-list {
|
||||
padding: 20rpx;
|
||||
}
|
||||
|
||||
.catalogue-status {
|
||||
padding: 20rpx;
|
||||
margin-bottom: 20rpx;
|
||||
background-color: #fff;
|
||||
|
||||
.purchased-info {
|
||||
.info-row {
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
align-items: center;
|
||||
font-size: 26rpx;
|
||||
line-height: 50rpx;
|
||||
}
|
||||
}
|
||||
|
||||
.free-course {
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
.unpurchased-info {
|
||||
.tip-text {
|
||||
display: block;
|
||||
font-size: 26rpx;
|
||||
color: #666;
|
||||
margin-bottom: 20rpx;
|
||||
line-height: 1.6;
|
||||
}
|
||||
|
||||
.action-btns {
|
||||
display: flex;
|
||||
gap: 20rpx;
|
||||
justify-content: center;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
.chapter-content {
|
||||
position: relative;
|
||||
padding: 20rpx;
|
||||
border: 4rpx solid #fffffc;
|
||||
background: linear-gradient(52deg, #e8f6ff 0%, #e3f2fe 50%);
|
||||
box-shadow: 0px 0px 10px 0px #89c8e9;
|
||||
border-top-right-radius: 40rpx;
|
||||
border-bottom-left-radius: 40rpx;
|
||||
|
||||
.vip-badge {
|
||||
display: inline-block;
|
||||
font-size: 24rpx;
|
||||
background: linear-gradient(90deg, #6429db 0%, #0075ed 100%);
|
||||
color: #fff;
|
||||
padding: 10rpx 20rpx;
|
||||
border-radius: 0 50rpx 50rpx 0;
|
||||
z-index: 1;
|
||||
}
|
||||
|
||||
.chapter-item {
|
||||
padding: 20rpx 0;
|
||||
border-bottom: 1px solid #fff;
|
||||
|
||||
&:last-child {
|
||||
border-bottom: none;
|
||||
}
|
||||
|
||||
.chapter-content-wrapper {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: space-between;
|
||||
|
||||
.chapter-info {
|
||||
flex: 1;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 10rpx;
|
||||
|
||||
&.locked {
|
||||
opacity: 0.6;
|
||||
}
|
||||
|
||||
.chapter-title {
|
||||
flex: 1;
|
||||
font-size: 28rpx;
|
||||
color: #1e2f3e;
|
||||
line-height: 1.5;
|
||||
}
|
||||
|
||||
.chapter-tag {
|
||||
flex-shrink: 0;
|
||||
}
|
||||
}
|
||||
|
||||
.lock-icon {
|
||||
margin-left: 20rpx;
|
||||
flex-shrink: 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
.no-chapters {
|
||||
text-align: center;
|
||||
padding: 80rpx 0;
|
||||
color: #999;
|
||||
font-size: 28rpx;
|
||||
}
|
||||
</style>
|
||||
@@ -16,40 +16,23 @@
|
||||
<CourseInfo v-if="courseDetail" :course="courseDetail" :class="{'pt-10': !!vipTip}" />
|
||||
|
||||
<!-- 课程内容包装器 -->
|
||||
<view class="course-content-wrapper">
|
||||
<!-- 目录列表 -->
|
||||
<CatalogueList
|
||||
v-if="catalogueList.length > 0"
|
||||
:catalogues="catalogueList"
|
||||
:currentIndex="currentCatalogueIndex"
|
||||
:userVip="userVip"
|
||||
@change="handleCatalogueChange"
|
||||
/>
|
||||
|
||||
<!-- 章节列表 -->
|
||||
<ChapterList
|
||||
v-if="chapterList.length > 0"
|
||||
:chapters="chapterList"
|
||||
:catalogue="currentCatalogue"
|
||||
:userVip="userVip"
|
||||
:showRenewBtn="showRenewBtn"
|
||||
@purchase="handlePurchase"
|
||||
@toVip="goToVip"
|
||||
@renew="handleRenew"
|
||||
@click="handleChapterClick"
|
||||
/>
|
||||
</view>
|
||||
<CatalogueList
|
||||
v-if="catalogueList.length > 0"
|
||||
:catalogues="catalogueList"
|
||||
:userVip="userVip"
|
||||
@getFreeCourse="handleGetFreeCourse"
|
||||
@purchase="handlePurchase"
|
||||
@toVip="goToVip"
|
||||
@renew="handleRenew"
|
||||
@toDetail="handleToDetail"
|
||||
/>
|
||||
|
||||
<!-- 学习进度 -->
|
||||
<view class="learning-progress">
|
||||
<view class="progress-title">
|
||||
<text>{{ $t('courseDetails.progress') }}</text>
|
||||
</view>
|
||||
<wd-progress
|
||||
:percentage="learningProgress"
|
||||
show-text
|
||||
stroke-width="6"
|
||||
/>
|
||||
<wd-progress :percentage="learningProgress" show-text stroke-width="6" />
|
||||
</view>
|
||||
|
||||
<!-- 相关书籍 -->
|
||||
@@ -130,6 +113,15 @@
|
||||
<text>
|
||||
本课程一经购买,暂不支持退款,敬请谅解。
|
||||
</text>
|
||||
<view style="color: red; font-weight: bold"> 注: </view>
|
||||
<view>
|
||||
1.手机、pad、电脑均为可登陆电子设备,均有唯一标识码,一个用户名仅允许在一个手机或一个ipad或一个电脑登陆,请根据您的使用习惯自行选择。<br />
|
||||
2.如若申请变更登陆设备请联系客服,<br />
|
||||
客服电话:021-08371305<br />
|
||||
客服微信号:yilujiankangkefu<br />
|
||||
3.如因违反上述使用规定...概不退款,本公司保留追究用户相关法律责任的权利。<br />
|
||||
4.点击“同意”按钮即表示您同意遵守以上条款。
|
||||
</view>
|
||||
</view>
|
||||
<view class="protocol-actions">
|
||||
<wd-button type="info" plain @click="showProtocol = false">不同意</wd-button>
|
||||
@@ -156,31 +148,25 @@
|
||||
|
||||
<script setup lang="ts">
|
||||
import { ref, computed } from 'vue'
|
||||
import { onLoad, onPageScroll, onPullDownRefresh, onReachBottom } from '@dcloudio/uni-app'
|
||||
import { useCourseStore } from '@/stores/course'
|
||||
import { onLoad, onPageScroll, onPullDownRefresh, onReachBottom, onShow } from '@dcloudio/uni-app'
|
||||
import { useUserStore } from '@/stores/user'
|
||||
import { courseApi } from '@/api/modules/course'
|
||||
import CourseInfo from '@/components/course/CourseInfo.vue'
|
||||
import CatalogueList from '@/components/course/CatalogueList.vue'
|
||||
import ChapterList from '@/components/course/ChapterList.vue'
|
||||
import CourseInfo from './components/CourseInfo.vue'
|
||||
import CatalogueList from './components/CatalogueList.vue'
|
||||
import GoodsSelector from '@/components/order/GoodsSelector.vue'
|
||||
import CommentList from '@/components/comment/CommentList.vue'
|
||||
import CommentEditor from '@/components/comment/CommentEditor.vue'
|
||||
import NavBar from '@/components/nav-bar/nav-bar.vue'
|
||||
import type { ICourseDetail, ICatalogue, IChapter, IVipInfo } from '@/types/course'
|
||||
import type { IGoods } from '@/types/order'
|
||||
import type { IComment } from '@/types/comment'
|
||||
|
||||
// Stores
|
||||
const courseStore = useCourseStore()
|
||||
const userStore = useUserStore()
|
||||
|
||||
// 页面数据
|
||||
const courseId = ref<number>(0)
|
||||
const courseDetail = ref<ICourseDetail | null>(null)
|
||||
const catalogueList = ref<ICatalogue[]>([])
|
||||
const currentCatalogueIndex = ref(0)
|
||||
const chapterList = ref<IChapter[]>([])
|
||||
const userVip = ref<IVipInfo | null>(null)
|
||||
const vipModuleList = ref<string[]>([])
|
||||
const learningProgress = ref(0)
|
||||
@@ -193,7 +179,6 @@ const selectedGoods = ref<IGoods | null>(null)
|
||||
const showProtocol = ref(false)
|
||||
const isFudu = ref(false)
|
||||
const fuduCatalogueId = ref<number>(0)
|
||||
const showRenewBtn = ref(false)
|
||||
|
||||
// 评论相关
|
||||
const commentList = ref<IComment[]>([])
|
||||
@@ -206,14 +191,6 @@ const replyComment = ref<IComment | undefined>(undefined)
|
||||
// UI状态
|
||||
const scrollTop = ref(0)
|
||||
|
||||
/**
|
||||
* 当前目录
|
||||
*/
|
||||
const currentCatalogue = computed(() => {
|
||||
if (catalogueList.value.length === 0) return null
|
||||
return catalogueList.value[currentCatalogueIndex.value] || null
|
||||
})
|
||||
|
||||
/**
|
||||
* VIP提示文案
|
||||
*/
|
||||
@@ -252,6 +229,12 @@ const vipTip = computed(() => {
|
||||
*/
|
||||
onLoad(async (options: any) => {
|
||||
courseId.value = parseInt(options.id)
|
||||
})
|
||||
|
||||
/**
|
||||
* 页面显示
|
||||
*/
|
||||
onShow(async () => {
|
||||
await loadPageData()
|
||||
})
|
||||
|
||||
@@ -271,11 +254,6 @@ const loadPageData = async () => {
|
||||
const totalProgress = catalogueList.value.reduce((sum, cat) => sum + cat.completion, 0)
|
||||
learningProgress.value = Number((totalProgress / catalogueList.value.length).toFixed(2))
|
||||
}
|
||||
|
||||
// 默认选择第一个目录
|
||||
if (catalogueList.value.length > 0) {
|
||||
await switchCatalogue(0)
|
||||
}
|
||||
}
|
||||
|
||||
// 检查VIP权益
|
||||
@@ -303,69 +281,50 @@ const checkVipStatus = async () => {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 切换目录
|
||||
*/
|
||||
const switchCatalogue = async (index: number) => {
|
||||
currentCatalogueIndex.value = index
|
||||
const catalogue = catalogueList.value[index]
|
||||
|
||||
// 获取章节列表
|
||||
const res = await courseApi.getCatalogueChapterList(catalogue.id)
|
||||
if (res.code === 0) {
|
||||
chapterList.value = res.chapterList || []
|
||||
}
|
||||
|
||||
// 检查是否支持复读
|
||||
if (catalogue.isBuy === 0 && !userVip.value) {
|
||||
const renewRes = await courseApi.checkRenewPayment(catalogue.id)
|
||||
showRenewBtn.value = renewRes.canRelearn || false
|
||||
} else {
|
||||
showRenewBtn.value = false
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 目录切换事件
|
||||
*/
|
||||
const handleCatalogueChange = (index: number) => {
|
||||
switchCatalogue(index)
|
||||
}
|
||||
|
||||
/**
|
||||
* 点击章节
|
||||
*/
|
||||
const handleChapterClick = (chapter: IChapter) => {
|
||||
const noRecored = chapter.isAudition === 1 && currentCatalogue.value?.isBuy === 0 && !userVip.value
|
||||
const handleToDetail = (chapter: IChapter, catalogue: ICatalogue) => {
|
||||
const noRecored = chapter.isAudition === 1 && catalogue.isBuy === 0 && !userVip.value
|
||||
|
||||
uni.navigateTo({
|
||||
url: `/pages/course/details/chapter?id=${chapter.id}&courseId=${courseId.value}&navTitle=${courseDetail.value?.title}&title=${chapter.title}&noRecored=${noRecored}`
|
||||
url: `/pages/course/details/chapter?id=${chapter.id}&courseId=${courseId.value}&courseTitle=${courseDetail.value?.title}&title=${chapter.title}&noRecored=${noRecored}`
|
||||
})
|
||||
}
|
||||
|
||||
/**
|
||||
* 去开通vip
|
||||
*/
|
||||
const goToVip = () => {
|
||||
uni.navigateTo({
|
||||
url: '/pages/vip/course'
|
||||
})
|
||||
}
|
||||
|
||||
/**
|
||||
* 领取免费课程
|
||||
*/
|
||||
const handleGetFreeCourse = async () => {
|
||||
if (!currentCatalogue.value) return
|
||||
const handleGetFreeCourse = async (catalogue: ICatalogue) => {
|
||||
if (!catalogue) return
|
||||
|
||||
uni.showLoading({ title: '领取中...' })
|
||||
const res = await courseApi.startStudyForMF(currentCatalogue.value.id)
|
||||
const res = await courseApi.startStudyForMF(catalogue.id)
|
||||
if (res.code === 0) {
|
||||
uni.showToast({ title: '领取成功', icon: 'success' })
|
||||
// 刷新页面数据
|
||||
await loadPageData()
|
||||
loadPageData()
|
||||
} else {
|
||||
uni.showToast({ title: res.msg || '领取失败', icon: 'none' })
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 购买课程
|
||||
*/
|
||||
const handlePurchase = async () => {
|
||||
if (!currentCatalogue.value) return
|
||||
const handlePurchase = async (catalogue: ICatalogue) => {
|
||||
if (!catalogue) return
|
||||
|
||||
isFudu.value = false
|
||||
const res = await courseApi.getProductListForCourse(currentCatalogue.value.id)
|
||||
const res = await courseApi.getProductListForCourse(catalogue.id)
|
||||
if (res.code === 0 && res.productList.length > 0) {
|
||||
goodsList.value = res.productList
|
||||
showGoodsSelector.value = true
|
||||
@@ -378,17 +337,17 @@ const handlePurchase = async () => {
|
||||
* 续费/复读
|
||||
*/
|
||||
const handleRenew = async () => {
|
||||
if (!currentCatalogue.value) return
|
||||
// if (!currentCatalogue.value) return
|
||||
|
||||
isFudu.value = true
|
||||
fuduCatalogueId.value = currentCatalogue.value.id
|
||||
const res = await courseApi.getRenewProductList(currentCatalogue.value.id)
|
||||
if (res.code === 0 && res.productList.length > 0) {
|
||||
goodsList.value = res.productList
|
||||
showGoodsSelector.value = true
|
||||
} else {
|
||||
uni.showToast({ title: '暂无复读方案', icon: 'none' })
|
||||
}
|
||||
// isFudu.value = true
|
||||
// fuduCatalogueId.value = currentCatalogue.value.id
|
||||
// const res = await courseApi.getRenewProductList(currentCatalogue.value.id)
|
||||
// if (res.code === 0 && res.productList.length > 0) {
|
||||
// goodsList.value = res.productList
|
||||
// showGoodsSelector.value = true
|
||||
// } else {
|
||||
// uni.showToast({ title: '暂无复读方案', icon: 'none' })
|
||||
// }
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -428,15 +387,6 @@ const confirmPurchase = () => {
|
||||
})
|
||||
}
|
||||
|
||||
/**
|
||||
* 跳转到VIP页面
|
||||
*/
|
||||
const goToVip = () => {
|
||||
uni.navigateTo({
|
||||
url: '/pages/vip/course'
|
||||
})
|
||||
}
|
||||
|
||||
/**
|
||||
* 跳转到书籍详情
|
||||
*/
|
||||
@@ -683,10 +633,6 @@ onReachBottom(() => {
|
||||
}
|
||||
}
|
||||
|
||||
.course-content-wrapper {
|
||||
background: linear-gradient(108deg, #c3e7ff 0%, #59bafe 100%);
|
||||
}
|
||||
|
||||
.learning-progress {
|
||||
padding: 20rpx;
|
||||
background-color: #fff;
|
||||
@@ -809,7 +755,7 @@ onReachBottom(() => {
|
||||
}
|
||||
|
||||
.protocol-content {
|
||||
max-height: 500rpx;
|
||||
max-height: 60vh;
|
||||
overflow-y: auto;
|
||||
font-size: 26rpx;
|
||||
line-height: 1.8;
|
||||
|
||||
@@ -48,7 +48,7 @@
|
||||
<view
|
||||
class="fourBox"
|
||||
style="padding: 0; padding-bottom: 8rpx"
|
||||
v-if="sbuMedicalTagsList && sbuMedicalTagsList.length > 0"
|
||||
v-if="sbuMedicalTagsList?.length > 0"
|
||||
>
|
||||
<view
|
||||
class="childrenBox fourIcon flexbox"
|
||||
@@ -257,29 +257,24 @@ const handleFirstLevelClick = (item: string) => {
|
||||
* 获取课程分类数据
|
||||
*/
|
||||
const getMedicalTags = async () => {
|
||||
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 = []
|
||||
}
|
||||
sbuMedicalTagsList.value = []
|
||||
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 {
|
||||
curseTagList.value = []
|
||||
}
|
||||
} else {
|
||||
curseTagList.value = []
|
||||
}
|
||||
} catch (error) {
|
||||
console.error('获取医学课程分类失败:', error)
|
||||
}
|
||||
}
|
||||
/**
|
||||
@@ -309,13 +304,9 @@ const curseClick = (item: IMedicalTag, index: number) => {
|
||||
*/
|
||||
const soulCateList = ref<IMedicalTag[]>([])
|
||||
const getSoulCateList = async () => {
|
||||
try {
|
||||
const res = await courseSubjectClassificationApi.getCourseSoulTree()
|
||||
if (res.labels&&res.labels.length>0) {
|
||||
soulCateList.value = res.labels;
|
||||
}
|
||||
} catch (error) {
|
||||
console.error('获取心理学课程分类失败:', error)
|
||||
const res = await courseSubjectClassificationApi.getCourseSoulTree()
|
||||
if (res.labels&&res.labels.length>0) {
|
||||
soulCateList.value = res.labels;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -325,13 +316,9 @@ const getSoulCateList = async () => {
|
||||
*/
|
||||
const sociologyCateList = ref<IMedicalTag[]>([])
|
||||
const getSociologyCateList = async () => {
|
||||
try {
|
||||
const res = await courseSubjectClassificationApi.getCourseSociologyTree()
|
||||
if (res.labels&&res.labels.length>0) {
|
||||
sociologyCateList.value = res.labels;
|
||||
}
|
||||
} catch (error) {
|
||||
console.error('获取国学课程分类失败:', error)
|
||||
const res = await courseSubjectClassificationApi.getCourseSociologyTree()
|
||||
if (res.labels&&res.labels.length>0) {
|
||||
sociologyCateList.value = res.labels;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -339,10 +326,6 @@ const getSociologyCateList = async () => {
|
||||
* 终极分类点击处理
|
||||
*/
|
||||
const curseClickJump = (item: IMedicalTag) => {
|
||||
// uni.showToast({
|
||||
// title: '课程分类列表正在开发中,现在还不能跳转',
|
||||
// icon: 'none'
|
||||
// })
|
||||
uni.navigateTo({
|
||||
url: `/pages/course/list/category?id=${item.id}&title=${item.title}&pid=${item.pid}&subject=${selectedFirstLevel.value}`
|
||||
})
|
||||
@@ -369,17 +352,13 @@ const learnList = ref<ICourse[]>([]) // 观看记录列表
|
||||
* 获取观看记录
|
||||
*/
|
||||
const getLearnCourse = async () => {
|
||||
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 = []
|
||||
}
|
||||
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)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -389,32 +368,22 @@ const newsList = ref<INews[]>([]) // 新闻列表
|
||||
* 获取新闻列表
|
||||
*/
|
||||
const getNewsList = async () => {
|
||||
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 = []
|
||||
}
|
||||
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)
|
||||
}
|
||||
}
|
||||
/**
|
||||
* 新闻点击处理
|
||||
*/
|
||||
const newsClick = (item: INews) => {
|
||||
if (item.type === 1 && item.url) {
|
||||
uni.navigateTo({
|
||||
url: `/pages/news/newsForwebview?newsId=${item.id}&url=${item.url}&type=${item.type}`
|
||||
})
|
||||
} else {
|
||||
uni.navigateTo({
|
||||
url: `/pages/news/news?newsId=${item.id}&url=${item.url}&type=${item.type}`
|
||||
})
|
||||
}
|
||||
uni.navigateTo({
|
||||
url: `/pages/news/details?newsId=${item.id}&url=${item.url}&type=${item.type}`
|
||||
})
|
||||
}
|
||||
|
||||
// 精彩试听
|
||||
@@ -423,21 +392,17 @@ const tryListenList = ref<ICourse[]>([]) // 试听课程列表
|
||||
* 获取试听课程列表
|
||||
*/
|
||||
const getTryListenList = async () => {
|
||||
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 = []
|
||||
}
|
||||
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)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -871,7 +836,7 @@ $border-color: #eeeeee;
|
||||
// 观看记录和试听样式
|
||||
.learnBox {
|
||||
background-color: #fff;
|
||||
margin: 10px 5px 20px;
|
||||
margin: 10px 5px;
|
||||
border-radius: 20rpx;
|
||||
padding: 10px;
|
||||
box-shadow: 0px 0px 10px 0px rgba(167, 187, 228, 0.3);
|
||||
|
||||
@@ -52,30 +52,26 @@ const subCategoryList = ref<ICategory[]>([]) // 子级分类列表
|
||||
* 获取分类下的子级分类
|
||||
*/
|
||||
const getSubCategoryList = async () => {
|
||||
try {
|
||||
let res: any = null
|
||||
switch (subject.value) {
|
||||
case '医学':
|
||||
res = await courseSubjectClassificationApi.getCourseMedicalChildLabels(categoryId.value)
|
||||
break
|
||||
case '心理学':
|
||||
res = await courseSubjectClassificationApi.getCourseSoulChildLabels(categoryId.value)
|
||||
break
|
||||
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
|
||||
}
|
||||
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)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1,25 +0,0 @@
|
||||
<template>
|
||||
<view class="container">
|
||||
<view class="title bg-[transparent] text-center text-[#000]">这是一个等待开发的首页</view>
|
||||
<view class="title bg-[blue] text-center text-[#fff]">这是一个等待开发的首页</view>
|
||||
<view class="description bg-[red]">首页的内容是在线课程</view>
|
||||
</view>
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
|
||||
</script>
|
||||
|
||||
<style>
|
||||
.title {
|
||||
font-size: 16px;
|
||||
font-weight: bold;
|
||||
margin-bottom: 15px;
|
||||
}
|
||||
|
||||
.description {
|
||||
font-size: 14px;
|
||||
opacity: 0.6;
|
||||
margin-bottom: 15px;
|
||||
}
|
||||
</style>
|
||||
@@ -1,6 +1,6 @@
|
||||
<template>
|
||||
<view class="page">
|
||||
<view class="title">{{ $t('forget.title') }}</view>
|
||||
<view class="title" :style="{ 'margin-top': getNotchHeight() + 'px' }">{{ $t('forget.title') }}</view>
|
||||
|
||||
<!-- 邮箱输入 -->
|
||||
<view class="input-box">
|
||||
@@ -23,7 +23,7 @@
|
||||
:placeholder="$t('login.codePlaceholder')"
|
||||
/>
|
||||
<wd-button type="info" :class="['code-btn', { active: !readonly }]" @click="getCode">
|
||||
{{ t('login.getCode') }}
|
||||
{{ codeText }}
|
||||
</wd-button>
|
||||
</view>
|
||||
|
||||
@@ -53,7 +53,8 @@
|
||||
<text class="input-tit">{{ $t('forget.passwordAgain') }}</text>
|
||||
<input
|
||||
class="input-text"
|
||||
type="password"
|
||||
type="password"
|
||||
minlength="8"
|
||||
maxlength="20"
|
||||
v-model="confirmPassword"
|
||||
:placeholder="$t('forget.passwordAgainPlaceholder')"
|
||||
@@ -69,12 +70,11 @@
|
||||
|
||||
<script setup lang="ts">
|
||||
import { ref } from 'vue'
|
||||
import { useI18n } from 'vue-i18n'
|
||||
import { t } from '@/utils/i18n'
|
||||
import { commonApi } from '@/api/modules/common'
|
||||
import { resetPassword } from '@/api/modules/auth'
|
||||
import { validateEmail, checkPasswordStrength } from '@/utils/validator'
|
||||
|
||||
const { t } = useI18n()
|
||||
import { getNotchHeight } from '@/utils/system'
|
||||
|
||||
// 表单数据
|
||||
const email = ref('')
|
||||
@@ -83,7 +83,7 @@ const password = ref('')
|
||||
const confirmPassword = ref('')
|
||||
|
||||
// 验证码相关
|
||||
const codeText = ref('Get Code')
|
||||
const codeText = ref(t('login.getCode'))
|
||||
const readonly = ref(false)
|
||||
|
||||
// 密码强度相关
|
||||
@@ -191,16 +191,12 @@ const getCode = async () => {
|
||||
if (!isEmailEmpty()) return
|
||||
if (!isEmailVerified(email.value)) return
|
||||
|
||||
try {
|
||||
await commonApi.sendMailCaptcha(email.value)
|
||||
uni.showToast({
|
||||
title: t('login.sendCodeSuccess'),
|
||||
icon: 'none'
|
||||
})
|
||||
getCodeState()
|
||||
} catch (error) {
|
||||
console.error('Send code error:', error)
|
||||
}
|
||||
await commonApi.sendMailCaptcha(email.value)
|
||||
uni.showToast({
|
||||
title: t('login.sendCodeSuccess'),
|
||||
icon: 'none'
|
||||
})
|
||||
getCodeState()
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -264,20 +260,16 @@ const onSubmit = async () => {
|
||||
if (!isConfirmPasswordEmpty()) return
|
||||
if (!isPasswordMatch()) return
|
||||
|
||||
try {
|
||||
await resetPassword(email.value, code.value, password.value)
|
||||
await resetPassword(email.value, code.value, password.value)
|
||||
|
||||
uni.showModal({
|
||||
title: t('global.tips'),
|
||||
content: t('forget.passwordChanged'),
|
||||
showCancel: false,
|
||||
success: () => {
|
||||
uni.navigateBack()
|
||||
}
|
||||
})
|
||||
} catch (error) {
|
||||
console.error('Reset password error:', error)
|
||||
}
|
||||
uni.showModal({
|
||||
title: t('global.tips'),
|
||||
content: t('forget.passwordChanged'),
|
||||
showCancel: false,
|
||||
success: () => {
|
||||
uni.navigateBack()
|
||||
}
|
||||
})
|
||||
}
|
||||
</script>
|
||||
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
<view class="login-page">
|
||||
<!-- Logo 背景区域 -->
|
||||
<view class="logo-bg">
|
||||
<text class="welcome-text">Hello! Welcome to<br>Amazing Limited</text>
|
||||
<text class="welcome-text">Hello! Welcome to<br>WU'S INTERNATIONAL</text>
|
||||
<image src="@/static/icon/login_icon.png" mode="aspectFit" class="icon-hua-1"></image>
|
||||
<image src="@/static/icon/login_icon.png" mode="aspectFit" class="icon-hua-2"></image>
|
||||
</view>
|
||||
@@ -37,8 +37,8 @@
|
||||
maxlength="6"
|
||||
@confirm="onSubmit"
|
||||
/>
|
||||
<wd-button type="info" :class="['code-btn', { active: !readonly }]" @click="onSetCode">
|
||||
{{ t('login.getCode') }}
|
||||
<wd-button type="info" :class="['code-btn', { 'active': !readonly }]" @click="onSetCode">
|
||||
{{ codeText }}
|
||||
</wd-button>
|
||||
</view>
|
||||
</view>
|
||||
@@ -83,18 +83,18 @@
|
||||
|
||||
<!-- 协议同意 -->
|
||||
<view class="protocol-box">
|
||||
<view class="select" :class="{ active: agree }" @click="agreeAgreements"></view>
|
||||
<view class="select" :class="{ 'active': agree }" @click="agreeAgreements"></view>
|
||||
<view class="protocol-text">
|
||||
{{ $t('login.agree') }}
|
||||
<text class="highlight" @click="yhxy">《{{ $t('login.userAgreement') }}》</text>
|
||||
and
|
||||
{{ $t('global.and') }}
|
||||
<text class="highlight" @click="yszc">《{{ $t('login.privacyPolicy') }}》</text>
|
||||
</view>
|
||||
</view>
|
||||
|
||||
<!-- 登录按钮 -->
|
||||
<view class="btn-box">
|
||||
<button @click="onSubmit" class="login-btn" :class="{ active: btnShow }">
|
||||
<button @click="onSubmit" class="login-btn" :class="{ 'active': btnShow }">
|
||||
{{ $t('login.goLogin') }}
|
||||
</button>
|
||||
</view>
|
||||
@@ -148,8 +148,7 @@ import { commonApi } from '@/api/modules/common'
|
||||
import { validateEmail } from '@/utils/validator'
|
||||
import { onPageJump } from '@/utils'
|
||||
|
||||
import { useI18n } from 'vue-i18n'
|
||||
const { t } = useI18n()
|
||||
import { t } from '@/utils/i18n'
|
||||
|
||||
const userStore = useUserStore()
|
||||
|
||||
@@ -165,7 +164,7 @@ const agree = ref(false)
|
||||
const isSee = ref(false)
|
||||
|
||||
// 验证码相关
|
||||
const codeText = ref('Get Code')
|
||||
const codeText = ref(t('login.getCode'))
|
||||
const readonly = ref(false)
|
||||
const btnShow = ref(true)
|
||||
|
||||
@@ -285,13 +284,8 @@ const verifyCodeLogin = async () => {
|
||||
|
||||
if (!isCodeEmpty()) return false
|
||||
|
||||
try {
|
||||
const res = await loginWithCode(email.value, code.value)
|
||||
return res
|
||||
} catch (error) {
|
||||
console.error('验证码登录失败:', error)
|
||||
return null
|
||||
}
|
||||
const res = await loginWithCode(email.value, code.value)
|
||||
return res || null
|
||||
}
|
||||
// 密码登录
|
||||
const passwordLogin = async () => {
|
||||
@@ -301,13 +295,8 @@ const passwordLogin = async () => {
|
||||
|
||||
if (!isPasswordEmpty()) return false
|
||||
|
||||
try {
|
||||
const res = await loginWithPassword(phoneEmail.value, password.value)
|
||||
return res
|
||||
} catch (error) {
|
||||
console.error('密码登录失败:', error)
|
||||
return null
|
||||
}
|
||||
const res = await loginWithPassword(phoneEmail.value, password.value)
|
||||
return res || null
|
||||
}
|
||||
// 提交登录
|
||||
const onSubmit = async () => {
|
||||
@@ -434,11 +423,11 @@ const getAgreements = async (id: number) => {
|
||||
}
|
||||
const loadAgreements = async () => {
|
||||
// 获取用户协议
|
||||
const yhxyRes = await getAgreements(111)
|
||||
const yhxyRes = await getAgreements(116)
|
||||
yhxyText.value = yhxyRes
|
||||
|
||||
// 获取隐私政策
|
||||
const yszcRes = await getAgreements(112)
|
||||
const yszcRes = await getAgreements(117)
|
||||
yszcText.value = yszcRes
|
||||
}
|
||||
|
||||
|
||||
124
pages/news/details.vue
Normal file
124
pages/news/details.vue
Normal file
@@ -0,0 +1,124 @@
|
||||
<template>
|
||||
<view>
|
||||
<!-- 自定义导航栏 -->
|
||||
<nav-bar :title="$t('news.newsDetail')" />
|
||||
|
||||
<view v-if="urlVisible" class="web-view-container"><web-view :webview-styles="{ progress: { color: '#55aaff' } }" :src="surl"></web-view></view>
|
||||
<view v-else class="box">
|
||||
<view class="title">{{ news.title }}</view>
|
||||
<view
|
||||
class="content"
|
||||
v-html="formattedContent"
|
||||
></view>
|
||||
</view>
|
||||
</view>
|
||||
</template>
|
||||
|
||||
<script lang="ts" setup>
|
||||
import { ref, computed } from 'vue'
|
||||
import { onLoad } from '@dcloudio/uni-app'
|
||||
import { newsApi } from '@/api/modules/news'
|
||||
|
||||
const newsId = ref<string | number | null>(null)
|
||||
const type = ref<number | null>(null)
|
||||
const urlVisible = ref(false)
|
||||
const surl = ref('')
|
||||
const source = ref('')
|
||||
|
||||
onLoad((e: any) => {
|
||||
newsId.value = e.newsId
|
||||
type.value = Number(e.type)
|
||||
surl.value = e.url || ''
|
||||
source.value = e.source || ''
|
||||
if(type.value == 1 && surl.value != ''){
|
||||
urlVisible.value = true
|
||||
// APP 设置导航栏按钮
|
||||
// #ifdef APP-PLUS
|
||||
const pages = getCurrentPages()
|
||||
const page = pages[pages.length - 1]
|
||||
const currentWebview = page.$getAppWebview()
|
||||
|
||||
currentWebview.setStyle({
|
||||
titleNView: {
|
||||
buttons: [{
|
||||
float: 'right',
|
||||
type: 'close',
|
||||
onclick: () => {
|
||||
uni.navigateBack({ delta: 1 })
|
||||
}
|
||||
}]
|
||||
}
|
||||
})
|
||||
// #endif
|
||||
} else {
|
||||
getData()
|
||||
}
|
||||
})
|
||||
|
||||
// 新闻详情
|
||||
const news = ref({
|
||||
title: '',
|
||||
content: ''
|
||||
})
|
||||
// 获取新闻详情
|
||||
const getData = async () => {
|
||||
let res = null
|
||||
if (source.value === 'taihuzhiguang') {
|
||||
res = await newsApi.getTaihuWelfareArticleDetail(newsId.value)
|
||||
} else {
|
||||
res = await newsApi.getNewsDetail(newsId.value)
|
||||
}
|
||||
news.value.title = res.result?.title || ''
|
||||
news.value.content = res.result?.content || ''
|
||||
}
|
||||
|
||||
// 格式化富文本内容
|
||||
const formatRichText = (html: string) => {
|
||||
if (!html) return ""
|
||||
|
||||
let newContent = html.replace(/<img[^>]*>/gi, (match) => {
|
||||
match = match.replace(/style="[^"]+"/gi, '')
|
||||
match = match.replace(/width="[^"]+"/gi, '')
|
||||
match = match.replace(/height="[^"]+"/gi, '')
|
||||
return match
|
||||
})
|
||||
|
||||
newContent = newContent.replace(/style="[^"]+"/gi, (match) => {
|
||||
match = match.replace(/width:[^;]+;/gi, 'max-width:100%;')
|
||||
return match
|
||||
})
|
||||
|
||||
newContent = newContent.replace(/<br[^>]*\/>/gi, '')
|
||||
newContent = newContent.replace(
|
||||
/\<img/gi,
|
||||
'<img style="max-width:100%;height:auto;display:inline-block;margin:10rpx auto;"'
|
||||
)
|
||||
|
||||
return newContent
|
||||
}
|
||||
// 格式化后内容
|
||||
const formattedContent = computed(() => formatRichText(news.value.content))
|
||||
</script>
|
||||
|
||||
<style lang="scss" scoped>
|
||||
.web-view-container {
|
||||
padding-top: 60px;
|
||||
}
|
||||
.box {
|
||||
background-color: #fff;
|
||||
padding: 10px;
|
||||
min-height: calc(100vh - 270rpx);
|
||||
}
|
||||
|
||||
.title {
|
||||
font-size: 32rpx;
|
||||
font-weight: bold;
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
.content {
|
||||
font-size: 26rpx;
|
||||
line-height: 48rpx;
|
||||
margin-top: 10rpx;
|
||||
}
|
||||
</style>
|
||||
@@ -4,7 +4,7 @@
|
||||
<nav-bar :title="$t('order.confirmTitle')" />
|
||||
|
||||
<!-- 确认订单组件 -->
|
||||
<Confirm :goodsList="goodsList" :userInfo="userInfo">
|
||||
<Confirm :goodsList="goodsList" :userInfo="userInfo" :orderType="orderType">
|
||||
<template #goodsList>
|
||||
<!-- 商品列表内容 -->
|
||||
<view
|
||||
@@ -26,28 +26,8 @@
|
||||
<!-- 商品信息 -->
|
||||
<view class="goods-info">
|
||||
<text class="goods-name">{{ item.productName }}</text>
|
||||
|
||||
<!-- 价格信息 -->
|
||||
<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>
|
||||
<!-- 商品价格组件 -->
|
||||
<GoodsPrice :goods="item" />
|
||||
|
||||
<!-- 数量 -->
|
||||
<!-- <view class="quantity-row">
|
||||
@@ -72,22 +52,17 @@
|
||||
import { ref, computed } from 'vue'
|
||||
import { onLoad } from '@dcloudio/uni-app'
|
||||
import { orderApi } from '@/api/modules/order'
|
||||
import Confirm from '@/components/order/Confirm.vue';
|
||||
import type { IOrderGoods } from '@/types/order'
|
||||
import Confirm from '@/components/order/Confirm.vue';
|
||||
import GoodsPrice from '@/components/order/GoodsPrice.vue';
|
||||
|
||||
/**
|
||||
* 获取用户信息
|
||||
*/
|
||||
const userInfo = ref(null)
|
||||
const userInfo = ref({})
|
||||
const getUserInfo = async () => {
|
||||
try {
|
||||
const res = await orderApi.getUserInfo()
|
||||
if (res.code === 0) {
|
||||
userInfo.value = res.result || {}
|
||||
}
|
||||
} catch (error) {
|
||||
console.error('获取用户信息失败:', error)
|
||||
}
|
||||
const res = await orderApi.getUserInfo()
|
||||
userInfo.value = res.result || {}
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -96,18 +71,22 @@ const getUserInfo = async () => {
|
||||
const goodsIds = ref<string>('')
|
||||
const goodsList = ref<IOrderGoods[]>([])
|
||||
const getGoodsList = async () => {
|
||||
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)
|
||||
// 获取商品详情
|
||||
const res = await orderApi.getShopProductListByIds(goodsIds.value)
|
||||
|
||||
if (res.shopProductList?.length > 0) {
|
||||
goodsList.value = res.shopProductList
|
||||
}
|
||||
}
|
||||
|
||||
// 复读
|
||||
const isRelearn = ref<boolean>(false)
|
||||
|
||||
// 订单类型
|
||||
const orderType = computed(() => {
|
||||
return isRelearn.value ? 'relearn' : 'order'
|
||||
})
|
||||
|
||||
/**
|
||||
* 页面加载
|
||||
*/
|
||||
@@ -119,6 +98,7 @@ onLoad(async (options: any) => {
|
||||
|
||||
// 根据商品ID获取商品详细信息
|
||||
goodsIds.value = options.goods || ''
|
||||
isRelearn.value = options.isRelearn == '1'
|
||||
getGoodsList()
|
||||
} catch (error) {
|
||||
console.error('解析商品数据失败:', error)
|
||||
@@ -181,43 +161,6 @@ 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;
|
||||
|
||||
@@ -36,7 +36,7 @@
|
||||
</view>
|
||||
</view> -->
|
||||
<wd-cell-group border class="contact-info">
|
||||
<wd-cell :title="$t('user.hotline')" clickable icon="call" value="022-24142321" @click="handlePhoneCall"></wd-cell>
|
||||
<wd-cell :title="$t('user.hotline')" clickable icon="call" value="021-08371305" @click="handlePhoneCall"></wd-cell>
|
||||
<!-- <wd-cell :title="$t('user.wechat')" value="yilujiankangkefu" clickable @click="handlePhoneCall" /> -->
|
||||
</wd-cell-group>
|
||||
|
||||
@@ -83,7 +83,7 @@ const getAppVersion = () => {
|
||||
* 拨打电话
|
||||
*/
|
||||
const handlePhoneCall = () => {
|
||||
makePhoneCall('022-24142321', t('user.hotline'))
|
||||
makePhoneCall('021-08371305', t('user.hotline'))
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -89,6 +89,8 @@
|
||||
|
||||
<script setup lang="ts">
|
||||
import { ref, computed } from 'vue'
|
||||
import { onLoad } from '@dcloudio/uni-app'
|
||||
|
||||
import { useUserStore } from '@/stores/user'
|
||||
import { submitFeedback } from '@/api/modules/user'
|
||||
import type { IFeedbackForm } from '@/types/user'
|
||||
@@ -97,6 +99,14 @@ import { useI18n } from 'vue-i18n'
|
||||
const { t } = useI18n()
|
||||
const userStore = useUserStore()
|
||||
|
||||
onLoad((options: any) => {
|
||||
const orderSn = options.orderSn
|
||||
if (orderSn) {
|
||||
form.value.relation = orderSn
|
||||
form.value.type = '3'
|
||||
}
|
||||
})
|
||||
|
||||
// 问题类型选项
|
||||
const issueTypeOptions = computed(() => [
|
||||
{ label: t('user.issueTypeAccount'), value: '1' },
|
||||
|
||||
@@ -13,9 +13,6 @@
|
||||
<view class="user-details">
|
||||
<text class="nickname">{{ userInfo.nickname || $t('user.notSet') }}</text>
|
||||
<text v-if="userInfo.email" class="email">{{ userInfo.email }}</text>
|
||||
<text v-if="vipInfo.endTime && platform === 'ios'" class="vip-time">
|
||||
VIP {{ vipInfo.endTime.split(' ')[0] }} {{ $t('user.vipExpireTime') }}
|
||||
</text>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
@@ -26,18 +23,18 @@
|
||||
<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-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>
|
||||
<wd-button v-if="vipInfo?.length > 0" plain type="primary" size="small" @click="goCourseVipSub">{{ $t('vip.renewal') }}</wd-button>
|
||||
<wd-button v-else plain type="primary" size="small" @click="goCourseVipSub">{{ $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-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>
|
||||
<wd-button v-if="!vipInfoEbook?.length" plain type="primary" size="small" @click="goSubscribe">{{ $t('vip.openVip') }}</wd-button>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
@@ -50,14 +47,14 @@
|
||||
<view class="assets_row">{{ t('global.coin') }}</view>
|
||||
<view>{{userInfo.peanutCoin ?? 1}}</view>
|
||||
</view>
|
||||
<view>
|
||||
<view @click="goPointsList">
|
||||
<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>
|
||||
@@ -67,12 +64,9 @@
|
||||
|
||||
<!-- 功能菜单列表 -->
|
||||
<view class="menu-section">
|
||||
<view class="menu-list">
|
||||
<view v-for="item in menuItems" :key="item.id" class="menu-item" @click="handleMenuClick(item)">
|
||||
<text class="menu-text">{{ item.name }}</text>
|
||||
<wd-icon name="arrow-right" size="16px" color="#aaa" />
|
||||
</view>
|
||||
</view>
|
||||
<wd-cell-group border class="menu-list">
|
||||
<wd-cell v-for="item in menuItems" :key="item.id" :title="item.name" :label="item.desc" is-link @click="handleMenuClick(item)" />
|
||||
</wd-cell-group>
|
||||
</view>
|
||||
</view>
|
||||
</template>
|
||||
@@ -86,6 +80,7 @@
|
||||
import { getNotchHeight } from '@/utils/system'
|
||||
import { parseTime } from '@/utils/index'
|
||||
import { t } from '@/utils/i18n'
|
||||
import { onShow } from '@dcloudio/uni-app'
|
||||
|
||||
const userStore = useUserStore()
|
||||
const sysStore = useSysStore()
|
||||
@@ -99,7 +94,7 @@
|
||||
// VIP信息
|
||||
const vipInfo = computed(() => userStore.userVips)
|
||||
const vipInfoEbook = computed(() => userStore.userEbookVip)
|
||||
|
||||
|
||||
// VIP类型字典
|
||||
const vipTypeDict = sysStore.vipTypeDict
|
||||
|
||||
@@ -137,7 +132,14 @@
|
||||
name: t('user.feedback'),
|
||||
url: '/pages/user/feedback/index',
|
||||
type: 'pageJump'
|
||||
}
|
||||
},
|
||||
// {
|
||||
// id: 6,
|
||||
// name: t('user.dataMigrate'),
|
||||
// url: '/pages/user/migrate/index',
|
||||
// desc: t('user.migrateSubtitle'),
|
||||
// type: 'pageJump'
|
||||
// }
|
||||
])
|
||||
|
||||
/**
|
||||
@@ -178,7 +180,7 @@
|
||||
}
|
||||
|
||||
/**
|
||||
* 跳转到订阅页面
|
||||
* 跳转到电子书vip订阅页面
|
||||
*/
|
||||
const goSubscribe = () => {
|
||||
uni.navigateTo({
|
||||
@@ -186,6 +188,15 @@
|
||||
})
|
||||
}
|
||||
|
||||
/**
|
||||
* 跳转到课程vip订阅页面
|
||||
*/
|
||||
const goCourseVipSub = () => {
|
||||
uni.navigateTo({
|
||||
url: '/pages/vip/course'
|
||||
})
|
||||
}
|
||||
|
||||
/**
|
||||
* 处理菜单点击
|
||||
*/
|
||||
@@ -212,7 +223,7 @@
|
||||
url: '/pages/user/recharge/index'
|
||||
})
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 跳转虚拟币页面
|
||||
*/
|
||||
@@ -221,12 +232,22 @@
|
||||
url: '/pages/user/virtual/index'
|
||||
})
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* 跳转积分列表
|
||||
*/
|
||||
const goPointsList = () => {
|
||||
uni.navigateTo({
|
||||
url: '/pages/user/points/index'
|
||||
})
|
||||
}
|
||||
|
||||
onShow(() => {
|
||||
getData()
|
||||
})
|
||||
|
||||
onMounted(() => {
|
||||
getPlatform()
|
||||
getData()
|
||||
})
|
||||
</script>
|
||||
|
||||
@@ -306,14 +327,14 @@
|
||||
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;
|
||||
@@ -323,6 +344,7 @@
|
||||
padding: 30rpx;
|
||||
margin-bottom: 20rpx;
|
||||
}
|
||||
|
||||
.vip-item-list {
|
||||
font-size: 28rpx;
|
||||
color: #fff;
|
||||
@@ -364,7 +386,7 @@
|
||||
}
|
||||
|
||||
.menu-section {
|
||||
padding: 20rpx 20rpx 0;
|
||||
padding: 20rpx 20rpx;
|
||||
}
|
||||
|
||||
.menu-list {
|
||||
@@ -374,37 +396,13 @@
|
||||
box-shadow: 0 2rpx 10rpx rgba(0, 0, 0, 0.05);
|
||||
}
|
||||
|
||||
.menu-item {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: space-between;
|
||||
padding: 30rpx;
|
||||
border-bottom: 1px solid #e0e0e0;
|
||||
|
||||
&:last-child {
|
||||
border-bottom: none;
|
||||
}
|
||||
|
||||
&:active {
|
||||
background-color: #f5f5f5;
|
||||
}
|
||||
|
||||
.menu-text {
|
||||
font-size: 30rpx;
|
||||
color: #333;
|
||||
line-height: 40rpx;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
.chong_btn {
|
||||
font-size: 26rpx;
|
||||
display: block;
|
||||
border-radius: 50rpx;
|
||||
color: #fffbf6;
|
||||
padding: 10rpx 32rpx;
|
||||
background-image: linear-gradient(90deg, #3ab3ae 0%, #d5ecdd 200%);
|
||||
background: #007bff;
|
||||
}
|
||||
|
||||
.assets {
|
||||
@@ -412,7 +410,7 @@
|
||||
flex: 1;
|
||||
justify-content: space-around;
|
||||
text-align: center;
|
||||
transform:translateX(-20px);
|
||||
transform: translateX(-20px);
|
||||
|
||||
.assets_row {
|
||||
margin-bottom: 20rpx;
|
||||
|
||||
195
pages/user/migrate/index.vue
Normal file
195
pages/user/migrate/index.vue
Normal file
@@ -0,0 +1,195 @@
|
||||
<template>
|
||||
<view class="page-wrap">
|
||||
<!-- 自定义导航栏 -->
|
||||
<nav-bar :title="$t('user.dataMigrate')"></nav-bar>
|
||||
|
||||
<view class="text-red-500 text-center mb-[20rpx]! font-bold">{{ $t('user.migrateWarning') }}</view>
|
||||
|
||||
<!-- 主要内容区域 -->
|
||||
<wd-form ref="migrateForm" :model="formData" :rules="rules" :label-width="120" class="migrate-card p-[10rpx]">
|
||||
<wd-cell-group border>
|
||||
<wd-input
|
||||
v-model="formData.tel"
|
||||
prop="tel"
|
||||
clearable
|
||||
:label="$t('user.oldAccount')"
|
||||
:placeholder="$t('user.oldAccountPlaceholder')"
|
||||
/>
|
||||
<wd-input
|
||||
v-model="formData.code"
|
||||
prop="code"
|
||||
clearable
|
||||
:label="$t('user.migrateCode')"
|
||||
:placeholder="$t('user.migrateCodePlaceholder')"
|
||||
/>
|
||||
<view class="pb-[20rpx] pt-[10rpx]">
|
||||
<wd-button type="primary" size="medium" @click="handleSubmit" block>{{ $t('user.confirmMigrate') }}</wd-button>
|
||||
</view>
|
||||
</wd-cell-group>
|
||||
</wd-form>
|
||||
|
||||
<!-- 迁移说明 -->
|
||||
<view class="migrate-card p-[30rpx]">
|
||||
<view class="instructions-title">{{ $t('user.migrateInstructions') }}</view>
|
||||
|
||||
<view class="instructions-content">
|
||||
<view class="instruction-item">
|
||||
<text class="instruction-number">1.</text>
|
||||
<text class="instruction-text">{{ $t('user.instruction1') }}</text>
|
||||
</view>
|
||||
|
||||
<view class="instruction-item">
|
||||
<text class="instruction-number">2.</text>
|
||||
<text class="instruction-text">{{ $t('user.instruction2') }}</text>
|
||||
</view>
|
||||
|
||||
<view class="instruction-item">
|
||||
<text class="instruction-number">3.</text>
|
||||
<text class="instruction-text">{{ $t('user.instruction3') }}</text>
|
||||
</view>
|
||||
|
||||
<view class="instruction-item">
|
||||
<text class="instruction-number">4.</text>
|
||||
<text class="instruction-text">{{ $t('user.instruction4') }}</text>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
|
||||
<wd-message-box />
|
||||
</view>
|
||||
</template>
|
||||
|
||||
<script lang="ts" setup>
|
||||
import { ref } from 'vue'
|
||||
import { t } from '@/utils/i18n'
|
||||
import { migrateUserData } from '@/api/modules/user'
|
||||
import { useMessage } from '@/uni_modules/wot-design-uni'
|
||||
|
||||
const message = useMessage()
|
||||
|
||||
// 表单引用
|
||||
const migrateForm = ref()
|
||||
|
||||
// 表单数据
|
||||
const formData = ref({
|
||||
tel: '',
|
||||
code: ''
|
||||
})
|
||||
|
||||
// 表单验证规则
|
||||
const rules = ref({
|
||||
tel: [
|
||||
{ required: true, message: t('common.pleaseInput') + t('user.oldAccountPlaceholder'), trigger: 'blur' }
|
||||
],
|
||||
code: [
|
||||
{ required: true, message: t('common.pleaseInput') + t('user.migrateCodePlaceholder'), trigger: 'blur' }
|
||||
]
|
||||
})
|
||||
|
||||
// 提交表单
|
||||
const handleSubmit = async () => {
|
||||
migrateForm.value.validate().then(({ valid, errors }: any) => {
|
||||
if (valid) {
|
||||
message.confirm({
|
||||
title: t('global.tips'),
|
||||
msg: t('user.instruction2'),
|
||||
}).then(() => {
|
||||
message.confirm({
|
||||
title: t('global.tips'),
|
||||
msg: t('user.migrateWarning'),
|
||||
}).then(() => {
|
||||
submitMigrate()
|
||||
}).catch(() => {
|
||||
// 取消数据迁移
|
||||
})
|
||||
}).catch(() => {
|
||||
// 取消数据迁移
|
||||
})
|
||||
}
|
||||
})
|
||||
.catch((error: any) => {
|
||||
console.log(error)
|
||||
})
|
||||
}
|
||||
// 处理迁移
|
||||
const submitMigrate = async () => {
|
||||
await migrateUserData(formData.value)
|
||||
uni.showToast({
|
||||
title: t('user.migrateSuccess'),
|
||||
icon: 'success'
|
||||
})
|
||||
|
||||
// 清空表单
|
||||
formData.value.tel = ''
|
||||
formData.value.code = ''
|
||||
}
|
||||
</script>
|
||||
|
||||
<style lang="scss" scoped>
|
||||
.page-wrap {
|
||||
padding: 20rpx;
|
||||
background-color: #F8F9FA;
|
||||
min-height: 100vh;
|
||||
}
|
||||
|
||||
.migrate-card {
|
||||
background: #ffffff;
|
||||
border-radius: 16rpx;
|
||||
margin-bottom: 30rpx;
|
||||
box-shadow: 0 4rpx 12rpx rgba(0, 0, 0, 0.05);
|
||||
}
|
||||
|
||||
.migrate-btn {
|
||||
width: 100%;
|
||||
height: 88rpx;
|
||||
background: linear-gradient(135deg, #007aff 0%, #0051d5 100%);
|
||||
border-radius: 12rpx;
|
||||
color: #ffffff;
|
||||
font-size: 32rpx;
|
||||
font-weight: 500;
|
||||
margin-top: 40rpx;
|
||||
|
||||
&:not([disabled]):active {
|
||||
opacity: 0.8;
|
||||
}
|
||||
|
||||
&[disabled] {
|
||||
background: #cccccc;
|
||||
color: #ffffff;
|
||||
}
|
||||
}
|
||||
|
||||
.instructions-title {
|
||||
font-size: 32rpx;
|
||||
font-weight: 600;
|
||||
color: #333333;
|
||||
margin-bottom: 30rpx;
|
||||
}
|
||||
|
||||
.instructions-content {
|
||||
.instruction-item {
|
||||
display: flex;
|
||||
align-items: flex-start;
|
||||
margin-bottom: 20rpx;
|
||||
line-height: 1.6;
|
||||
|
||||
&:last-child {
|
||||
margin-bottom: 0;
|
||||
}
|
||||
}
|
||||
|
||||
.instruction-number {
|
||||
font-size: 28rpx;
|
||||
color: #007aff;
|
||||
font-weight: 600;
|
||||
margin-right: 16rpx;
|
||||
min-width: 40rpx;
|
||||
}
|
||||
|
||||
.instruction-text {
|
||||
font-size: 28rpx;
|
||||
color: #666666;
|
||||
flex: 1;
|
||||
}
|
||||
}
|
||||
</style>
|
||||
@@ -68,7 +68,7 @@ function goToDetail(bookId: number) {
|
||||
|
||||
function goToReader(bookId: number) {
|
||||
uni.navigateTo({
|
||||
url: `/pages/book/reader?isBuy=0&bookId=${bookId}`
|
||||
url: `/pages/book/reader?isBuy=1&bookId=${bookId}`
|
||||
})
|
||||
}
|
||||
|
||||
|
||||
153
pages/user/order/details.vue
Normal file
153
pages/user/order/details.vue
Normal file
@@ -0,0 +1,153 @@
|
||||
<template>
|
||||
<view class="page-wrapper">
|
||||
<!-- 自定义导航栏 -->
|
||||
<nav-bar :title="$t('order.orderDetails')"></nav-bar>
|
||||
|
||||
<!-- 订单信息 -->
|
||||
<view class="order-info">
|
||||
<view class="order-status">{{ sysStore.orderStatusMap[order.orderStatus] }}</view>
|
||||
<!-- 三种订单类型商品信息 -->
|
||||
<ProductInfo v-if="order.orderType === 'order'" size="large" :data="productList[0]" :type="order.orderType" />
|
||||
<ProductInfo v-if="order.orderType === 'vip'" size="large" :data="order.vipBuyConfigEntity" :type="order.orderType" />
|
||||
<ProductInfo v-if="order.orderType === 'abroadVip'" size="large" :data="order.ebookvipBuyConfig" :type="order.orderType" />
|
||||
<!-- 三种订单类型商品信息 end -->
|
||||
|
||||
<wd-divider class="p-0!" />
|
||||
|
||||
<!-- 付款信息 -->
|
||||
<wd-cell-group>
|
||||
<wd-cell title="商品总价" :value="`${order.orderMoney} ${$t('global.coin')}`" />
|
||||
<wd-cell v-if="order.districtMoney > 0" title="活动优惠" :value="`- ${order.districtMoney} ${$t('global.coin')}`" />
|
||||
<wd-cell v-if="order.vipDiscountAmount > 0" title="VIP专享立减" :value="`- ${order.vipDiscountAmount} ${$t('global.coin')}`" />
|
||||
<wd-cell v-if="order.jfDeduction > 0" title="积分抵扣">
|
||||
<text class="text-red-500 text-lg font-bold">{{ `- ${order.jfDeduction}` }}</text>
|
||||
</wd-cell>
|
||||
<wd-cell title="实付金额">
|
||||
<text class="text-red-500 text-lg font-bold">{{ `${order.realMoney}` }}</text> {{ $t('global.coin') }}
|
||||
</wd-cell>
|
||||
</wd-cell-group>
|
||||
|
||||
<wd-divider class="p-0!" />
|
||||
|
||||
<!-- 下单信息 -->
|
||||
<wd-cell-group>
|
||||
<wd-cell title="订单编号" title-width="4em">
|
||||
<text class="text-xs">{{ order.orderSn }}</text>
|
||||
<wd-icon name="file-copy" size="14px" color="#65A1FA" class="ml-1!" @click="copyToClipboard(order.orderSn)"></wd-icon>
|
||||
</wd-cell>
|
||||
<wd-cell title="创建时间" :value="order.createTime" />
|
||||
<wd-cell title="付款时间" :value="order.paymentDate" />
|
||||
</wd-cell-group>
|
||||
</view>
|
||||
|
||||
<view class="text-center">
|
||||
<text @click="toWorkOrder" class="text-[cadetblue] text-sm">订单有问题?去申诉</text>
|
||||
</view>
|
||||
|
||||
<view class="contact-customer" @click="makePhoneCall(sysStore.customerServicePhone)">
|
||||
<wd-icon name="service" size="30px"></wd-icon>
|
||||
<view class="text-sm">联系客服</view>
|
||||
</view>
|
||||
</view>
|
||||
</template>
|
||||
|
||||
<script lang="ts" setup>
|
||||
import { ref } from 'vue'
|
||||
import { onLoad } from '@dcloudio/uni-app'
|
||||
import { useSysStore } from '@/stores/sys'
|
||||
import { orderApi } from '@/api/modules/order'
|
||||
import type { IOrderDetail, IOrderGoods } from '@/types/order'
|
||||
import ProductInfo from '@/components/order/ProductInfo.vue'
|
||||
import { copyToClipboard, makePhoneCall } from '@/utils/index'
|
||||
|
||||
const sysStore = useSysStore()
|
||||
// 订单详情
|
||||
const order = ref<IOrderDetail>({
|
||||
orderMoney: 0,
|
||||
districtMoney: 0,
|
||||
vipDiscountAmount: 0,
|
||||
jfDeduction: 0,
|
||||
realMoney: 0,
|
||||
})
|
||||
const productList = ref<IOrderGoods[]>([])
|
||||
|
||||
onLoad(async (options: { orderId: string }) => {
|
||||
const orderId = options.orderId
|
||||
if (orderId) {
|
||||
const res = await orderApi.getOrderDetail(orderId)
|
||||
const orderDetails = res.data.buyOrder
|
||||
order.value = orderDetails
|
||||
switch (orderDetails.orderType) {
|
||||
case 'order':
|
||||
productList.value = res.data.productInfo
|
||||
break
|
||||
case 'vip':
|
||||
productList.value = orderDetails.vipBuyConfigEntity
|
||||
break
|
||||
case 'abroadVip':
|
||||
productList.value = orderDetails
|
||||
break
|
||||
default:
|
||||
break
|
||||
}
|
||||
}
|
||||
})
|
||||
|
||||
const toWorkOrder = () => {
|
||||
uni.navigateTo({
|
||||
url: '/pages/user/feedback/index?orderSn=' + order.value.orderSn
|
||||
})
|
||||
}
|
||||
</script>
|
||||
|
||||
<style lang="scss" scoped>
|
||||
body {
|
||||
background-color: #F8F9FA;
|
||||
}
|
||||
.page-wrapper {
|
||||
padding: 20rpx;
|
||||
}
|
||||
|
||||
.order-info {
|
||||
padding: 30rpx;
|
||||
background-color: #fff;
|
||||
border-radius: 10px;
|
||||
margin-bottom: 15px;
|
||||
box-shadow: 0 0 10px rgba(0, 0, 0, 0.1);
|
||||
|
||||
.order-status {
|
||||
margin-bottom: 20rpx;
|
||||
padding: 10rpx 0;
|
||||
width: 6em;
|
||||
background-color: #34D19D;
|
||||
color: #fff;
|
||||
border-radius: 0 10px 10px 0;
|
||||
text-align: center;
|
||||
font-size: 16px;
|
||||
font-weight: bold;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
:deep(.wd-cell-group) {
|
||||
padding: 0 !important;
|
||||
|
||||
.wd-cell__wrapper {
|
||||
padding: 0 !important;
|
||||
}
|
||||
}
|
||||
|
||||
.contact-customer {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
background-color: #fff;
|
||||
border-radius: 50%;
|
||||
width: 80px;
|
||||
height: 80px;
|
||||
margin: 40rpx auto 0;
|
||||
box-shadow: 0 0 10px rgba(0, 0, 0, 0.05);
|
||||
line-height: 1;
|
||||
}
|
||||
</style>
|
||||
@@ -3,14 +3,14 @@
|
||||
<template #top>
|
||||
<!-- 自定义导航栏 -->
|
||||
<nav-bar :title="$t('user.myOrders')"></nav-bar>
|
||||
<wd-tabs v-model="orderStatus" @change="handleOrderStatusTabChange">
|
||||
<!-- <wd-tabs v-model="orderStatus" @change="handleOrderStatusTabChange">
|
||||
<wd-tab v-for="item in ordersTabs" :key="item.value" :title="item.name" :name="item.value"></wd-tab>
|
||||
</wd-tabs>
|
||||
</wd-tabs> -->
|
||||
</template>
|
||||
|
||||
<!-- 订单列表 -->
|
||||
<view class="order-list">
|
||||
<wd-card v-for="order in orderList" :key="order.id" type="rectangle" custom-class="order-item">
|
||||
<wd-card v-for="order in orderList" :key="order.id" type="rectangle" custom-class="order-item" @click="toDetails(order)">
|
||||
<template #title>
|
||||
<view class="order-item-title">
|
||||
<view class="order-item-sn">
|
||||
@@ -23,11 +23,11 @@
|
||||
</template>
|
||||
|
||||
<!-- 三种订单类型商品信息 -->
|
||||
<ProductInfo v-if="order.orderType === 'order'" :data="order.productList" :type="order.orderType" />
|
||||
<ProductInfo v-if="order.orderType === 'abroadBook'" :data="order.bookEntity" :type="order.orderType" />
|
||||
<ProductInfo v-if="order.orderType === 'order'" :data="order.productList[0].product" :type="order.orderType" />
|
||||
<ProductInfo v-if="order.orderType === 'vip'" :data="order.vipBuyConfigEntity" :type="order.orderType" />
|
||||
<ProductInfo v-if="order.orderType === 'abroadVip'" :data="order.ebookvipBuyConfig" :type="order.orderType" />
|
||||
<!-- 三种订单类型商品信息 end -->
|
||||
<view class="order-item-total-price">实付款:{{ order.orderMoney }} 天医币</view>
|
||||
<view class="order-item-total-price">实付款:{{ order.realMoney }} {{ t('global.coin') }}</view>
|
||||
|
||||
<template #footer>
|
||||
<view>
|
||||
@@ -47,12 +47,16 @@ import type { IOrder } from '@/types/order'
|
||||
import { useI18n } from 'vue-i18n'
|
||||
import { copyToClipboard } from '@/utils/index'
|
||||
import ProductInfo from '@/components/order/ProductInfo.vue'
|
||||
import { useSysStore } from '@/stores/sys'
|
||||
|
||||
const { t } = useI18n()
|
||||
const paging = ref<any>(null)
|
||||
|
||||
// 订单状态映射
|
||||
const orderStatusMap = useSysStore().orderStatusMap
|
||||
|
||||
// 订单状态
|
||||
const orderStatus = ref<string>('-1')
|
||||
const orderStatus = ref<string>('3')
|
||||
const ordersTabs = [
|
||||
{
|
||||
name: "全部",
|
||||
@@ -71,12 +75,6 @@ const ordersTabs = [
|
||||
},
|
||||
]
|
||||
|
||||
// 订单状态映射
|
||||
const orderStatusMap = {
|
||||
'0': '待付款',
|
||||
'3': '已完成',
|
||||
}
|
||||
|
||||
/**
|
||||
* 处理订单状态切换
|
||||
*/
|
||||
@@ -121,22 +119,17 @@ const getOrderImage = (order: IOrder) => {
|
||||
}
|
||||
}
|
||||
|
||||
const getOrderTitle = (order: IOrder) => {
|
||||
switch (order.orderType) {
|
||||
case 'order':
|
||||
return order.productList[0]?.product?.productName || ''
|
||||
case 'abroadBook':
|
||||
return order.bookEntity?.name || ''
|
||||
case 'vip':
|
||||
return order.vipBuyConfigEntity?.title || ''
|
||||
case 'point':
|
||||
return ''
|
||||
default:
|
||||
return ''
|
||||
}
|
||||
/**
|
||||
* 跳转订单详情
|
||||
*/
|
||||
const toDetails = (order: IOrder) => {
|
||||
uni.navigateTo({
|
||||
url: '/pages/user/order/details?orderId=' + order.orderId
|
||||
})
|
||||
}
|
||||
|
||||
|
||||
|
||||
</script>
|
||||
|
||||
<style lang="scss" scoped>
|
||||
|
||||
148
pages/user/points/index.vue
Normal file
148
pages/user/points/index.vue
Normal file
@@ -0,0 +1,148 @@
|
||||
<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.pointsRecord')}}</view>
|
||||
<view class="recharge-record-block" v-for="(item, index) in bookList" :key="index">
|
||||
<view class="recharge-record-block-row">{{item.remark.slice(0, (item.remark.indexOf(':')))}}<text
|
||||
:class="item.actType === 1 ? 'text1' : 'text2'">{{item.actType === 1 ? '' : '+'}}{{item.changeAmount}}</text>
|
||||
</view>
|
||||
<view class="time">{{item.createTime}}</view>
|
||||
<view style="font-size: 24rpx;">{{item.remark.slice((item.remark.indexOf(','))+1)}}<wd-icon name="file-copy"
|
||||
size="14px" color="#65A1FA" style="margin-left: 10rpx;" @click="copyToClipboard()"></wd-icon></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'
|
||||
import { copyToClipboard } from '@/utils/index'
|
||||
|
||||
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)
|
||||
} 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: 24rpx;
|
||||
margin-bottom: 20rpx;
|
||||
}
|
||||
|
||||
.recharge-record-block-row {
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
margin-bottom: 20rpx;
|
||||
font-weight: 700;
|
||||
.text1 {
|
||||
color: #ff0000;
|
||||
}
|
||||
|
||||
.text2 {
|
||||
color: #228B22;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
.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>
|
||||
@@ -7,7 +7,7 @@
|
||||
<!-- 头像区域 -->
|
||||
<view class="avatar-section">
|
||||
<image
|
||||
:src="userInfo.avatar || defaultAvatar"
|
||||
:src="userInfo.avatar"
|
||||
class="avatar"
|
||||
@click="editAvatar"
|
||||
/>
|
||||
@@ -148,7 +148,7 @@ const { t } = useI18n()
|
||||
const userStore = useUserStore()
|
||||
|
||||
// 默认头像
|
||||
const defaultAvatar = '/static/home_icon.png'
|
||||
const defaultAvatar = '/static/logo.png'
|
||||
|
||||
// 字段列表
|
||||
const fields = computed(() => [
|
||||
@@ -199,15 +199,10 @@ const avatarUrl = ref('')
|
||||
*/
|
||||
const userInfo = ref<any>({}) // 用户信息
|
||||
const getData = async () => {
|
||||
try {
|
||||
const res = await getUserInfo()
|
||||
if (res.result) {
|
||||
userStore.setUserInfo(res.result)
|
||||
userInfo.value = res.result
|
||||
}
|
||||
} catch (error) {
|
||||
console.error('获取用户信息失败:', error)
|
||||
}
|
||||
const res = await getUserInfo()
|
||||
userStore.setUserInfo(res.result)
|
||||
userInfo.value = res.result
|
||||
userInfo.value.avatar = res.result.avatar || defaultAvatar
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -324,16 +319,12 @@ const sendCode = async () => {
|
||||
return
|
||||
}
|
||||
|
||||
try {
|
||||
await sendEmailCode(editForm.value.email)
|
||||
uni.showToast({
|
||||
title: t('user.sendCodeSuccess'),
|
||||
icon: 'none'
|
||||
})
|
||||
startCountdown()
|
||||
} catch (error) {
|
||||
console.error('发送验证码失败:', error)
|
||||
}
|
||||
await sendEmailCode(editForm.value.email)
|
||||
uni.showToast({
|
||||
title: t('user.sendCodeSuccess'),
|
||||
icon: 'none'
|
||||
})
|
||||
startCountdown()
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -398,92 +389,88 @@ const checkPasswordStrength = () => {
|
||||
const handleSubmit = async () => {
|
||||
const key = currentField.value?.key
|
||||
|
||||
try {
|
||||
// 构建更新数据对象
|
||||
let updateData: any = Object.assign({}, userInfo.value)
|
||||
// 构建更新数据对象
|
||||
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
|
||||
}
|
||||
|
||||
uni.showToast({
|
||||
title: t('user.updateSuccess'),
|
||||
icon: 'success'
|
||||
})
|
||||
|
||||
closeModal()
|
||||
|
||||
// 刷新数据
|
||||
setTimeout(() => {
|
||||
getData()
|
||||
}, 500)
|
||||
} catch (error) {
|
||||
console.error('更新失败:', error)
|
||||
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)
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -8,12 +8,12 @@
|
||||
<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.money}}</view>
|
||||
<view>{{item.realMoney}}{{$t('order.virtualCoin')}}</view>
|
||||
<view class="recharge_money">¥{{item.realMoney}}</view>
|
||||
<view style="font-size: 26rpx;">{{item.money}}{{ $t('global.coin') }}</view>
|
||||
<!-- 红框位置的618活动标签 -->
|
||||
<!-- <view class="activity-tag">618活动</view> -->
|
||||
<span class="activity-label" v-if="item.givejf >0">618充值活动</span>
|
||||
<text class="recharge_give" v-if="item.givejf >0">(赠{{item.givejf}}币)</text>
|
||||
<span class="activity-label" v-if="item.givejf >0">{{item.description}}</span>
|
||||
<text class="recharge_give" v-if="item.givejf >0">({{$t('order.give')}}{{item.givejf}}{{$t('order.points')}})</text>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
@@ -21,27 +21,28 @@
|
||||
<view v-html="remark.remark"></view>
|
||||
</view>
|
||||
<view class="cha_fangsh">
|
||||
<view class="cf_title PM_font">{{$t('user.paymentMethod')}}</view>
|
||||
<view class="cf_title">{{$t('user.paymentMethod')}}</view>
|
||||
<view class="cf_radio">
|
||||
<radio-group v-for="item in iosPaylist" @click="choseType(item.id)">
|
||||
<view style="width: 100%">
|
||||
<radio-group v-for="item in iosPaylist">
|
||||
<view>
|
||||
<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"></radio>
|
||||
<radio :checked="payType === item.id" @click="choseType(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" @click="radioCheck">
|
||||
<view class="agree_wo">
|
||||
<radio-group class="agree" v-for="(item, index) in argee" :key="index">
|
||||
<view>
|
||||
<radio class="agreeRadio" :value="item.id" :checked="state" color="#007bff"></radio>
|
||||
<radio class="agreeRadio" :value="item.id" :checked="state" color="#007bff" @click="radioCheck"></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>
|
||||
@@ -61,10 +62,14 @@
|
||||
|
||||
<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 } from '@/api/modules/user'
|
||||
// const googlePay = uni.requireNativePlugin("sn-googlepay5");
|
||||
import { getBookBuyConfigList, getAgreement, getActivityDescription, verifyGooglePay, getPlaceOrder } from '@/api/modules/user'
|
||||
import { useUserStore } from '@/stores/user'
|
||||
import { useThrottle } from '@/hooks/useThrottle';
|
||||
|
||||
const googlePay = uni.requireNativePlugin("sn-googlepay5");
|
||||
const userStore = useUserStore()
|
||||
const { t } = useI18n()
|
||||
const message = useMessage()
|
||||
const payType = ref('1')
|
||||
@@ -107,13 +112,15 @@
|
||||
|
||||
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;
|
||||
@@ -125,9 +132,66 @@
|
||||
getData()
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取充值列表数据
|
||||
*/
|
||||
const getData = async () => {
|
||||
try {
|
||||
rechargeList.value = await getBookBuyConfigList(type.value, qudao.value)
|
||||
console.log(rechargeList.value.bookBuyConfigList, '充值列表');
|
||||
// 默认选择第一个金额
|
||||
aloneItem.value = rechargeList.value.bookBuyConfigList[0]
|
||||
} catch (error) {
|
||||
console.error('获取订单列表失败:', error)
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 点击支付按钮
|
||||
*/
|
||||
|
||||
const paymentButton = async () => {
|
||||
if (!state.value) {
|
||||
uni.showToast({
|
||||
title: t('order.readAgreeServices'),
|
||||
icon: 'none'
|
||||
})
|
||||
return
|
||||
}
|
||||
getPlaceOrderObj()
|
||||
}
|
||||
// 节流支付按钮
|
||||
const handleRecharge = useThrottle(paymentButton);
|
||||
|
||||
/**
|
||||
* 获取订单编号
|
||||
*/
|
||||
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 {
|
||||
// uni.hideLoading()
|
||||
const res = await getPlaceOrder(data)
|
||||
orderSn.value = res.orderSn
|
||||
console.log(orderSn.value, '获取订单号');
|
||||
uni.showLoading({ title: t('order.orderCreating') })
|
||||
getGooglePay()
|
||||
} catch (error) {
|
||||
console.error('获取订单号失败', error)
|
||||
}
|
||||
}
|
||||
|
||||
// 点击金额
|
||||
const chosPric = (item : any) => {
|
||||
console.log(item,'金额每项');
|
||||
console.log(item, '金额每项');
|
||||
aloneItem.value = item;
|
||||
};
|
||||
|
||||
@@ -145,17 +209,119 @@
|
||||
const showAgreement = () => {
|
||||
agreemenState.value = true
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取充值列表数据
|
||||
* 初始化
|
||||
*/
|
||||
const getData = async () => {
|
||||
const getGooglePay = () => {
|
||||
googlePay.init({
|
||||
}, (e : any) => {
|
||||
console.log('init', e);
|
||||
if (e.code == 0) {
|
||||
isConnected.value = true;
|
||||
console.log('init成功了');
|
||||
getQuerySku()
|
||||
// 初始化成功
|
||||
} else {
|
||||
console.log('init失败了/谷歌商店没有登录');
|
||||
uni.showToast({
|
||||
title: t('order.unusable'),
|
||||
icon: 'fail'
|
||||
})
|
||||
// 初始化失败
|
||||
isConnected.value = false;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询sku
|
||||
*/
|
||||
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);
|
||||
getPayAll()
|
||||
uni.hideLoading()
|
||||
} else {
|
||||
console.log('查询失败\网络连接失败', e);
|
||||
uni.showToast({
|
||||
title: t('global.networkConnectionError'),
|
||||
icon: 'error'
|
||||
})
|
||||
}
|
||||
}
|
||||
)
|
||||
}
|
||||
|
||||
/**
|
||||
* 发起支付
|
||||
*/
|
||||
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: t('user.paymentFailed'), icon: 'error' })
|
||||
console.log(e, 'e');
|
||||
// 支付失败
|
||||
}
|
||||
},
|
||||
)
|
||||
}
|
||||
|
||||
/**
|
||||
* 消耗品 确认交易
|
||||
*/
|
||||
const getConsume = () => {
|
||||
googlePay.consume(
|
||||
{
|
||||
purchaseToken: purchaseToken.value, // 来自支付结果的original.purchaseToken (或 original.token)
|
||||
},
|
||||
(e : any) => {
|
||||
if (e.code == 0) {
|
||||
console.log(e, '确认交易成功');
|
||||
uni.showToast({ title: t('user.returnMine'), icon: 'none' })
|
||||
// 确认成功
|
||||
googleVerify()
|
||||
} else {
|
||||
console.log(e, '确认交易失败');
|
||||
// 确认失败
|
||||
}
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* 校验订单
|
||||
*/
|
||||
const googleVerify = async () => {
|
||||
uni.hideLoading()
|
||||
console.log(typeof aloneItem.value.priceTypeId, typeof purchaseToken.value, typeof orderSn.value);
|
||||
try {
|
||||
rechargeList.value = await getBookBuyConfigList(type.value, qudao.value)
|
||||
console.log(rechargeList.value.bookBuyConfigList, '充值列表');
|
||||
// 默认选择第一个金额
|
||||
aloneItem.value = rechargeList.value.bookBuyConfigList[0]
|
||||
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)
|
||||
console.error('校验订单失败:', error)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -195,78 +361,6 @@
|
||||
// payType.value = val;
|
||||
}
|
||||
|
||||
const handleRecharge = () => {
|
||||
if(!state.value){
|
||||
uni.showToast({
|
||||
title: t('order.readAgreeServices'),
|
||||
icon: 'none'
|
||||
})
|
||||
return
|
||||
}
|
||||
uni.showLoading({ title: '加载中...' })
|
||||
console.log('立即充值');
|
||||
getGooglePay()
|
||||
}
|
||||
|
||||
/**
|
||||
* 初始化
|
||||
*/
|
||||
const getGooglePay = () => {
|
||||
googlePay.init({
|
||||
}, (e:any) => {
|
||||
console.log('init', e);
|
||||
if (e.code == 0) {
|
||||
isConnected.value = true;
|
||||
getQuerySku()
|
||||
// 初始化成功
|
||||
} else {
|
||||
// 初始化失败
|
||||
isConnected.value = false;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询sku
|
||||
*/
|
||||
const getQuerySku = () =>{
|
||||
const id = aloneItem.value.priceTypeId
|
||||
console.log(id, '获取每项');
|
||||
googlePay.querySku(
|
||||
{
|
||||
inapp: [id], // 与subs二选一, 参数为商品ID(字符串)数组
|
||||
},
|
||||
(e:any) => {
|
||||
if (e.code == 0) {
|
||||
// 查询成功.
|
||||
console.log('查询成功',e);
|
||||
// e.list; // 查询结果, array
|
||||
} else {
|
||||
console.log('查询失败');
|
||||
// 查询失败
|
||||
}
|
||||
}
|
||||
)
|
||||
}
|
||||
|
||||
const getPayAll = () =>{
|
||||
googlePay.payAll(
|
||||
{
|
||||
productId: "", // 产品id
|
||||
|
||||
},
|
||||
(e) => {
|
||||
if (e.code == 0) {
|
||||
// 支付成功
|
||||
e.data; //支付结果, array [ {original:{ }, signature: ''} ]
|
||||
} else {
|
||||
// 支付失败
|
||||
}
|
||||
},
|
||||
)
|
||||
}
|
||||
|
||||
|
||||
onMounted(() => {
|
||||
getDevName();
|
||||
getActivityDescriptionData()
|
||||
@@ -283,9 +377,10 @@
|
||||
}
|
||||
|
||||
.text {
|
||||
font-size: 30rpx;
|
||||
font-size: 45rpx;
|
||||
font-weight: bold;
|
||||
color: #007bff;
|
||||
padding: 30rpx 0 20rpx 20rpx;
|
||||
padding: 30rpx 0 20rpx 30rpx;
|
||||
}
|
||||
|
||||
.recharge {
|
||||
@@ -305,13 +400,12 @@
|
||||
height: 160rpx;
|
||||
|
||||
.recharge_money {
|
||||
font-size: 30rpx;
|
||||
margin-bottom: 10rpx;
|
||||
|
||||
font-size: 50rpx;
|
||||
font-weight: bold;
|
||||
}
|
||||
|
||||
.recharge_give {
|
||||
font-size: 16rpx;
|
||||
font-size: 22rpx;
|
||||
color: #FF0033;
|
||||
}
|
||||
}
|
||||
@@ -327,20 +421,20 @@
|
||||
bottom: 0;
|
||||
left: 0;
|
||||
right: 0;
|
||||
padding: 30rpx;
|
||||
padding: 20rpx;
|
||||
background-color: #ffffff;
|
||||
border-top: 1px solid #f0f0f0;
|
||||
z-index: 999;
|
||||
}
|
||||
|
||||
.recharge-button {
|
||||
width: 100%;
|
||||
height: 50rpx;
|
||||
line-height: 50rpx;
|
||||
width: 60%;
|
||||
height: 100rpx;
|
||||
line-height: 100rpx;
|
||||
background-color: #007bff;
|
||||
color: #ffffff;
|
||||
font-size: 18rpx;
|
||||
border-radius: 25rpx;
|
||||
font-size: 40rpx;
|
||||
border-radius: 50rpx;
|
||||
border: none;
|
||||
}
|
||||
|
||||
@@ -349,7 +443,7 @@
|
||||
}
|
||||
|
||||
.activity-container {
|
||||
margin: 0 20rpx 20rpx 20rpx;
|
||||
margin: 0 30rpx 20rpx 30rpx;
|
||||
padding: 15rpx;
|
||||
background-color: #e6f4ff;
|
||||
border-radius: 8rpx;
|
||||
@@ -360,7 +454,7 @@
|
||||
position: absolute;
|
||||
top: -10rpx;
|
||||
right: -6rpx;
|
||||
font-size: 16rpx;
|
||||
font-size: 20rpx;
|
||||
font-weight: 600;
|
||||
color: #ffffff;
|
||||
background-color: #007bff;
|
||||
@@ -370,10 +464,11 @@
|
||||
}
|
||||
|
||||
.cha_fangsh {
|
||||
padding: 20rpx 20rpx 60rpx 20rpx;
|
||||
padding: 30rpx;
|
||||
|
||||
.cf_title {
|
||||
font-size: 30rpx;
|
||||
font-size: 45rpx;
|
||||
font-weight: bold;
|
||||
color: #007bff;
|
||||
}
|
||||
|
||||
@@ -381,13 +476,13 @@
|
||||
margin-top: 20rpx;
|
||||
|
||||
.cf_xuanx {
|
||||
font-size: 24rpx;
|
||||
font-size: 36rpx;
|
||||
padding: 10rpx 0;
|
||||
margin-bottom: 20rpx;
|
||||
border-bottom: 1px solid #ededed;
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
align-items:center;
|
||||
align-items: center;
|
||||
|
||||
image {
|
||||
width: 40rpx;
|
||||
@@ -414,9 +509,9 @@
|
||||
|
||||
.agree_wo {
|
||||
display: flex;
|
||||
padding: 20rpx 20rpx 160rpx 20rpx;
|
||||
padding: 20rpx 20rpx 180rpx 20rpx;
|
||||
color: #aaa;
|
||||
font-size: 18rpx;
|
||||
font-size: 30rpx;
|
||||
align-items: center;
|
||||
|
||||
.highlight {
|
||||
|
||||
@@ -66,12 +66,15 @@
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
import { ref, computed, onMounted } from 'vue'
|
||||
import { ref, computed } from 'vue'
|
||||
import { useSysStore } from '@/stores/sys'
|
||||
import { useUserStore } from '@/stores/user'
|
||||
import { useI18n } from 'vue-i18n'
|
||||
import { useMessage } from '@/uni_modules/wot-design-uni'
|
||||
import { makePhoneCall, copyToClipboard } from '@/utils/index'
|
||||
// #ifdef APP-PLUS
|
||||
import update from "@/uni_modules/uni-upgrade-center-app/utils/check-update";
|
||||
// #endif
|
||||
|
||||
const { t, locale } = useI18n()
|
||||
const sysStore = useSysStore()
|
||||
@@ -81,7 +84,6 @@ const message = useMessage()
|
||||
|
||||
// 导航栏高度
|
||||
const statusBarHeight = ref(0)
|
||||
const navbarHeight = ref('44px')
|
||||
|
||||
// 弹窗状态
|
||||
const showQrCode = ref(false)
|
||||
@@ -89,8 +91,8 @@ const showLanguageSelect = ref(false)
|
||||
|
||||
// 可选语言列表
|
||||
const availableLanguages = computed(() => [
|
||||
{ code: 'en', name: t('locale.en') },
|
||||
{ code: 'zh-Hans', name: t('locale.zh-hans') }
|
||||
{ code: 'zh-Hans', name: t('locale.zh-hans') },
|
||||
{ code: 'en', name: t('locale.en') }
|
||||
])
|
||||
|
||||
// 获取当前语言名称
|
||||
@@ -102,22 +104,22 @@ const getCurrentLanguageName = () => {
|
||||
|
||||
// 设置项列表
|
||||
const settingItems = computed(() => [
|
||||
{
|
||||
id: 0,
|
||||
label: t('user.language'),
|
||||
value: getCurrentLanguageName(),
|
||||
type: 'language'
|
||||
},
|
||||
// {
|
||||
// id: 0,
|
||||
// label: t('user.language'),
|
||||
// value: getCurrentLanguageName(),
|
||||
// type: 'language'
|
||||
// },
|
||||
{
|
||||
id: 1,
|
||||
label: t('user.hotline'),
|
||||
value: '022-24142321',
|
||||
value: '021-08371305',
|
||||
type: 'tel'
|
||||
},
|
||||
{
|
||||
id: 2,
|
||||
label: t('user.customerEmail'),
|
||||
value: 'appyilujiankang@sina.com',
|
||||
value: 'AmazingLimited@163.com',
|
||||
type: 'email'
|
||||
},
|
||||
{
|
||||
@@ -134,22 +136,6 @@ const settingItems = computed(() => [
|
||||
}
|
||||
])
|
||||
|
||||
/**
|
||||
* 获取导航栏高度
|
||||
*/
|
||||
const getNavbarHeight = () => {
|
||||
const systemInfo = uni.getSystemInfoSync()
|
||||
statusBarHeight.value = systemInfo.statusBarHeight || 0
|
||||
|
||||
let navBarHeight = 44
|
||||
if (systemInfo.model.indexOf('iPhone') !== -1 && parseInt(systemInfo.model.slice(-2)) >= 11) {
|
||||
navBarHeight = 48
|
||||
}
|
||||
|
||||
const totalHeight = statusBarHeight.value + navBarHeight
|
||||
navbarHeight.value = totalHeight + 'px'
|
||||
}
|
||||
|
||||
/**
|
||||
* 处理设置项点击
|
||||
*/
|
||||
@@ -221,13 +207,16 @@ const selectLanguage = (languageCode: string) => {
|
||||
/**
|
||||
* 检查版本更新
|
||||
*/
|
||||
const checkVersion = () => {
|
||||
const checkVersion = async () => {
|
||||
// #ifdef APP-PLUS
|
||||
// TODO: 集成 uni-upgrade-center-app 插件
|
||||
uni.showToast({
|
||||
title: '当前已是最新版本',
|
||||
icon: 'none'
|
||||
})
|
||||
var info = await update();
|
||||
console.log('版本检测信息', info)
|
||||
if(info.result.code == 0){
|
||||
uni.showToast({
|
||||
title:info.result.message,
|
||||
icon:'none'
|
||||
})
|
||||
}
|
||||
// #endif
|
||||
|
||||
// #ifndef APP-PLUS
|
||||
@@ -283,10 +272,6 @@ const performLogout = () => {
|
||||
url: '/pages/login/login'
|
||||
})
|
||||
}
|
||||
|
||||
onMounted(() => {
|
||||
getNavbarHeight()
|
||||
})
|
||||
</script>
|
||||
|
||||
<style lang="scss" scoped>
|
||||
|
||||
@@ -1,17 +1,27 @@
|
||||
<template>
|
||||
<z-paging ref="paging" v-model="bookList" auto-show-back-to-top class="my-book-page" @query="rechargeList" :default-page-size="10">
|
||||
<z-paging ref="paging" v-model="bookList" auto-show-back-to-top class="my-book-page" @query="rechargeList"
|
||||
:default-page-size="10">
|
||||
<template #top>
|
||||
<!-- 自定义导航栏 -->
|
||||
<nav-bar :title="$t('user.consumptionRecord')"></nav-bar>
|
||||
</template>
|
||||
<view style="padding: 20rpx;background-color:#FFF3CD">
|
||||
<text style="font-size: 26rpx; color: #FFA500;">{{goBuyTitle}}</text>
|
||||
</view>
|
||||
<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><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="recharge-record-block-row">{{item.orderType}}<text
|
||||
:class="item.orderType !== '充值' ? 'text1' : 'text2'">{{item.orderType !== '充值' ? '' : '+'}}{{item.changeAmount}}</text>
|
||||
</view>
|
||||
<view class="recharge-record-block-row_">{{item.productName}}</view>
|
||||
<view class="recharge-record-block-row_">{{$t('user.orderSn')}}:{{item.payNo}}<wd-icon name="file-copy"
|
||||
size="14px" color="#65A1FA" style="margin-left: 10rpx;" @click="copyToClipboard()"></wd-icon>
|
||||
</view>
|
||||
<view class="time">{{item.createTime}}</view>
|
||||
</view>
|
||||
</view>
|
||||
@@ -23,6 +33,7 @@
|
||||
import { useI18n } from 'vue-i18n'
|
||||
import { useUserStore } from '@/stores/user'
|
||||
import { getTransactionDetailsList } from '@/api/modules/user'
|
||||
import { copyToClipboard } from '@/utils/index'
|
||||
|
||||
const { t } = useI18n()
|
||||
const paging = ref<any>()
|
||||
@@ -32,6 +43,7 @@
|
||||
const bookList = ref([])
|
||||
const loading = ref(false)
|
||||
const firstLoad = ref(true)
|
||||
const goBuyTitle = ref('【天医币】仅为我平台支付使用币种,仅为了方便用户支付使用。【天医币】可以用于在我平台支付书籍或课程使用。【天医币】这个名称是为适应我们平台的定位属性,所起名称。与区块链虚拟货币无任何关系。')
|
||||
|
||||
// 充值记录列表
|
||||
async function rechargeList(pageNo : number, pageSize : number) {
|
||||
@@ -49,7 +61,7 @@
|
||||
loading.value = false
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 跳转充值页面
|
||||
*/
|
||||
@@ -72,8 +84,8 @@
|
||||
box-shadow: 0 2rpx 10rpx rgba(0, 0, 0, 0.05);
|
||||
// padding: 20rpx;
|
||||
margin: 20rpx;
|
||||
|
||||
.go-gecharge{
|
||||
|
||||
.go-gecharge {
|
||||
//height: 100rpx;
|
||||
background: linear-gradient(to right, #007bff, #17a2b8);
|
||||
font-size: 30rpx;
|
||||
@@ -81,12 +93,14 @@
|
||||
color: #fff;
|
||||
padding: 20rpx;
|
||||
margin-bottom: 20rpx;
|
||||
display: flex;justify-content:space-between;align-items:center
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
align-items: center
|
||||
}
|
||||
|
||||
|
||||
.title {
|
||||
font-size: 30rpx;
|
||||
padding-left:20rpx;
|
||||
padding-left: 20rpx;
|
||||
margin-bottom: 30rpx;
|
||||
color: #007bff;
|
||||
font-weight: bold;
|
||||
@@ -95,41 +109,50 @@
|
||||
.recharge-record-block {
|
||||
border-bottom: 1px solid #e0e0e0;
|
||||
padding: 20rpx;
|
||||
|
||||
.time{
|
||||
font-size: 20rpx;
|
||||
|
||||
.recharge-record-block-row_ {
|
||||
font-size: 24rpx;
|
||||
margin-bottom: 20rpx;
|
||||
}
|
||||
|
||||
.time {
|
||||
font-size: 22rpx;
|
||||
}
|
||||
|
||||
.recharge-record-block-row {
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
margin-bottom: 20rpx;
|
||||
|
||||
.text{
|
||||
color: #007bff;
|
||||
font-weight: 700;
|
||||
.text1 {
|
||||
color: #ff0000;
|
||||
}
|
||||
|
||||
.text2 {
|
||||
color: #228B22;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
.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;
|
||||
}
|
||||
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>
|
||||
@@ -73,15 +73,6 @@ const getVipList = async () => {
|
||||
vipList.value = res.lableList || []
|
||||
}
|
||||
|
||||
// 选择套餐
|
||||
const selectPackage = (vip: any) => {
|
||||
// 这里可以添加跳转到订单确认页面的逻辑
|
||||
uni.showToast({
|
||||
title: `已选择: ${vip.title}`,
|
||||
icon: 'none'
|
||||
})
|
||||
}
|
||||
|
||||
// 处理购买
|
||||
const handlePurchase = (vip: any) => {
|
||||
const selectedGoods = {
|
||||
|
||||
BIN
static/logo.png
BIN
static/logo.png
Binary file not shown.
|
Before Width: | Height: | Size: 72 KiB After Width: | Height: | Size: 208 KiB |
BIN
static/nobg.jpg
Normal file
BIN
static/nobg.jpg
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 4.9 KiB |
142
stores/course.ts
142
stores/course.ts
@@ -1,142 +0,0 @@
|
||||
// stores/course.ts
|
||||
import { defineStore } from 'pinia'
|
||||
import { courseApi } from '@/api/modules/course'
|
||||
import type { ICourseDetail, ICatalogue, IChapter, IVipInfo } from '@/types/course'
|
||||
|
||||
interface CourseState {
|
||||
currentCourse: ICourseDetail | null
|
||||
catalogueList: ICatalogue[]
|
||||
currentCatalogueIndex: number
|
||||
chapterList: IChapter[]
|
||||
userVip: IVipInfo | null
|
||||
learningProgress: number
|
||||
}
|
||||
|
||||
export const useCourseStore = defineStore('course', {
|
||||
state: (): CourseState => ({
|
||||
currentCourse: null,
|
||||
catalogueList: [],
|
||||
currentCatalogueIndex: 0,
|
||||
chapterList: [],
|
||||
userVip: null,
|
||||
learningProgress: 0,
|
||||
}),
|
||||
|
||||
getters: {
|
||||
/**
|
||||
* 获取当前选中的目录
|
||||
*/
|
||||
currentCatalogue: (state): ICatalogue | null => {
|
||||
if (state.catalogueList.length === 0) return null
|
||||
return state.catalogueList[state.currentCatalogueIndex] || null
|
||||
},
|
||||
|
||||
/**
|
||||
* 判断当前目录是否已购买
|
||||
*/
|
||||
isCurrentCataloguePurchased: (state): boolean => {
|
||||
const catalogue = state.catalogueList[state.currentCatalogueIndex]
|
||||
return catalogue ? catalogue.isBuy === 1 : false
|
||||
},
|
||||
|
||||
/**
|
||||
* 判断用户是否为VIP
|
||||
*/
|
||||
isVip: (state): boolean => {
|
||||
return state.userVip !== null
|
||||
},
|
||||
},
|
||||
|
||||
actions: {
|
||||
/**
|
||||
* 获取课程详情
|
||||
* @param courseId 课程ID
|
||||
*/
|
||||
async fetchCourseDetail(courseId: number) {
|
||||
try {
|
||||
const res = await courseApi.getCourseDetail(courseId)
|
||||
if (res.code === 0 && res.data) {
|
||||
this.currentCourse = res.data.course
|
||||
this.catalogueList = res.data.catalogues || []
|
||||
|
||||
// 计算学习进度
|
||||
if (this.catalogueList.length > 0) {
|
||||
const totalProgress = this.catalogueList.reduce((sum, cat) => sum + cat.completion, 0)
|
||||
this.learningProgress = Number((totalProgress / this.catalogueList.length).toFixed(2))
|
||||
} else {
|
||||
this.learningProgress = 0
|
||||
}
|
||||
}
|
||||
return res
|
||||
} catch (error) {
|
||||
console.error('获取课程详情失败:', error)
|
||||
throw error
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
* 切换目录
|
||||
* @param index 目录索引
|
||||
*/
|
||||
async switchCatalogue(index: number) {
|
||||
if (index < 0 || index >= this.catalogueList.length) {
|
||||
console.warn('目录索引超出范围')
|
||||
return
|
||||
}
|
||||
|
||||
this.currentCatalogueIndex = index
|
||||
const catalogue = this.catalogueList[index]
|
||||
|
||||
// 获取该目录的章节列表
|
||||
await this.fetchChapterList(catalogue.id)
|
||||
},
|
||||
|
||||
/**
|
||||
* 获取章节列表
|
||||
* @param catalogueId 目录ID
|
||||
*/
|
||||
async fetchChapterList(catalogueId: number) {
|
||||
try {
|
||||
const res = await courseApi.getCatalogueChapterList(catalogueId)
|
||||
if (res.code === 0) {
|
||||
this.chapterList = res.chapterList || []
|
||||
}
|
||||
return res
|
||||
} catch (error) {
|
||||
console.error('获取章节列表失败:', error)
|
||||
this.chapterList = []
|
||||
throw error
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
* 检查用户VIP权益
|
||||
* @param courseId 课程ID
|
||||
*/
|
||||
async checkVipStatus(courseId: number) {
|
||||
try {
|
||||
const res = await courseApi.checkCourseVip(courseId)
|
||||
if (res.code === 0) {
|
||||
this.userVip = res.userVip || null
|
||||
}
|
||||
return res
|
||||
} catch (error) {
|
||||
console.error('检查VIP权益失败:', error)
|
||||
this.userVip = null
|
||||
throw error
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
* 重置课程状态
|
||||
*/
|
||||
resetCourseState() {
|
||||
this.currentCourse = null
|
||||
this.catalogueList = []
|
||||
this.currentCatalogueIndex = 0
|
||||
this.chapterList = []
|
||||
this.userVip = null
|
||||
this.learningProgress = 0
|
||||
},
|
||||
},
|
||||
})
|
||||
@@ -15,6 +15,11 @@ export const useSysStore = defineStore('sys', {
|
||||
7: '国学VIP',
|
||||
8: '心理学VIP',
|
||||
9: '中西汇通学VIP',
|
||||
},
|
||||
customerServicePhone: '021-08371305',
|
||||
orderStatusMap: {
|
||||
'0': '待付款',
|
||||
'3': '已完成',
|
||||
}
|
||||
}),
|
||||
|
||||
|
||||
@@ -9,6 +9,12 @@
|
||||
"Courier New", monospace;
|
||||
--color-red-500: oklch(63.7% 0.237 25.331);
|
||||
--spacing: 0.25rem;
|
||||
--text-xs: 0.75rem;
|
||||
--text-xs--line-height: calc(1 / 0.75);
|
||||
--text-sm: 0.875rem;
|
||||
--text-sm--line-height: calc(1.25 / 0.875);
|
||||
--text-lg: 1.125rem;
|
||||
--text-lg--line-height: calc(1.75 / 1.125);
|
||||
--font-weight-bold: 700;
|
||||
--ease-in-out: cubic-bezier(0.4, 0, 0.2, 1);
|
||||
--default-transition-duration: 150ms;
|
||||
@@ -205,18 +211,15 @@
|
||||
max-width: 96rem;
|
||||
}
|
||||
}
|
||||
.mr-1 {
|
||||
margin-right: calc(var(--spacing) * 1);
|
||||
.mb-2\! {
|
||||
margin-bottom: calc(var(--spacing) * 2) !important;
|
||||
}
|
||||
.ml-1 {
|
||||
margin-left: calc(var(--spacing) * 1);
|
||||
.mb-\[20rpx\]\! {
|
||||
margin-bottom: 20rpx !important;
|
||||
}
|
||||
.ml-1\! {
|
||||
margin-left: calc(var(--spacing) * 1) !important;
|
||||
}
|
||||
.ml-2 {
|
||||
margin-left: calc(var(--spacing) * 2);
|
||||
}
|
||||
.ml-2\.5\! {
|
||||
margin-left: calc(var(--spacing) * 2.5) !important;
|
||||
}
|
||||
@@ -253,9 +256,6 @@
|
||||
.flex-shrink {
|
||||
flex-shrink: 1;
|
||||
}
|
||||
.border-collapse {
|
||||
border-collapse: collapse;
|
||||
}
|
||||
.transform {
|
||||
transform: var(--tw-rotate-x,) var(--tw-rotate-y,) var(--tw-rotate-z,) var(--tw-skew-x,) var(--tw-skew-y,);
|
||||
}
|
||||
@@ -269,14 +269,14 @@
|
||||
border-style: var(--tw-border-style);
|
||||
border-width: 1px;
|
||||
}
|
||||
.bg-\[blue\] {
|
||||
background-color: blue;
|
||||
.p-0\! {
|
||||
padding: calc(var(--spacing) * 0) !important;
|
||||
}
|
||||
.bg-\[red\] {
|
||||
background-color: red;
|
||||
.p-\[10rpx\] {
|
||||
padding: 10rpx;
|
||||
}
|
||||
.bg-\[transparent\] {
|
||||
background-color: transparent;
|
||||
.p-\[30rpx\] {
|
||||
padding: 30rpx;
|
||||
}
|
||||
.pt-1 {
|
||||
padding-top: calc(var(--spacing) * 1);
|
||||
@@ -284,37 +284,49 @@
|
||||
.pt-10 {
|
||||
padding-top: calc(var(--spacing) * 10);
|
||||
}
|
||||
.pt-\[40px\] {
|
||||
padding-top: 40px;
|
||||
}
|
||||
.pb-0 {
|
||||
padding-bottom: calc(var(--spacing) * 0);
|
||||
.pt-\[10rpx\] {
|
||||
padding-top: 10rpx;
|
||||
}
|
||||
.pb-0\! {
|
||||
padding-bottom: calc(var(--spacing) * 0) !important;
|
||||
}
|
||||
.pb-\[20rpx\] {
|
||||
padding-bottom: 20rpx;
|
||||
}
|
||||
.text-center {
|
||||
text-align: center;
|
||||
}
|
||||
.text-right {
|
||||
text-align: right;
|
||||
}
|
||||
.text-lg {
|
||||
font-size: var(--text-lg);
|
||||
line-height: var(--tw-leading, var(--text-lg--line-height));
|
||||
}
|
||||
.text-sm {
|
||||
font-size: var(--text-sm);
|
||||
line-height: var(--tw-leading, var(--text-sm--line-height));
|
||||
}
|
||||
.text-xs {
|
||||
font-size: var(--text-xs);
|
||||
line-height: var(--tw-leading, var(--text-xs--line-height));
|
||||
}
|
||||
.font-bold {
|
||||
--tw-font-weight: var(--font-weight-bold);
|
||||
font-weight: var(--font-weight-bold);
|
||||
}
|
||||
.text-\[\#000\] {
|
||||
color: #000;
|
||||
}
|
||||
.text-\[\#7dc1f0\] {
|
||||
color: #7dc1f0;
|
||||
}
|
||||
.text-\[\#fff\] {
|
||||
color: #fff;
|
||||
.text-\[cadetblue\] {
|
||||
color: cadetblue;
|
||||
}
|
||||
.text-\[red\] {
|
||||
color: red;
|
||||
}
|
||||
.text-red-500 {
|
||||
color: var(--color-red-500);
|
||||
}
|
||||
.lowercase {
|
||||
text-transform: lowercase;
|
||||
}
|
||||
@@ -325,9 +337,6 @@
|
||||
--tw-ordinal: ordinal;
|
||||
font-variant-numeric: var(--tw-ordinal,) var(--tw-slashed-zero,) var(--tw-numeric-figure,) var(--tw-numeric-spacing,) var(--tw-numeric-fraction,);
|
||||
}
|
||||
.underline {
|
||||
text-decoration-line: underline;
|
||||
}
|
||||
.ring {
|
||||
--tw-ring-shadow: var(--tw-ring-inset,) 0 0 0 calc(1px + var(--tw-ring-offset-width)) var(--tw-ring-color, currentcolor);
|
||||
box-shadow: var(--tw-inset-shadow), var(--tw-inset-ring-shadow), var(--tw-ring-offset-shadow), var(--tw-ring-shadow), var(--tw-shadow);
|
||||
|
||||
@@ -109,13 +109,18 @@ uni-textarea {
|
||||
|
||||
// popup
|
||||
.wd-popup {
|
||||
z-index: 9999 !important;
|
||||
z-index: 99 !important;
|
||||
}
|
||||
.wd-overlay {
|
||||
z-index: 9998 !important;
|
||||
z-index: 98 !important;
|
||||
}
|
||||
.wd-popup-wrapper .wd-popup {
|
||||
border-radius: 15px 15px 0 0 !important;
|
||||
.wd-popup-wrapper {
|
||||
.wd-popup {
|
||||
border-radius: 15px !important;
|
||||
}
|
||||
.wd-popup--bottom {
|
||||
border-radius: 15px 15px 0 0 !important;
|
||||
}
|
||||
}
|
||||
|
||||
// uni-ui form
|
||||
@@ -139,4 +144,9 @@ uni-textarea {
|
||||
font-size: var(--wot-fs-tertiary) !important;
|
||||
border-radius: 4px !important;
|
||||
padding: 2px 6px !important;
|
||||
}
|
||||
}
|
||||
|
||||
// 缺省
|
||||
.wd-status-tip__text {
|
||||
margin: 0px auto 20px !important;
|
||||
}
|
||||
|
||||
22
types/order.d.ts
vendored
22
types/order.d.ts
vendored
@@ -11,6 +11,7 @@ export interface IGoods {
|
||||
isVipPrice?: number // 是否有VIP优惠 0-否 1-是
|
||||
productAmount?: number // 购买数量
|
||||
delFlag?: number // 删除标记 -1-已下架
|
||||
goodsType?: string // 商品类型 "05": 课程 "02": 电子书
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -138,3 +139,24 @@ export interface IPaymentOption {
|
||||
value: '4' | '5'
|
||||
name: string
|
||||
}
|
||||
|
||||
/**
|
||||
* 订单详情
|
||||
*/
|
||||
export interface IOrderDetail {
|
||||
id: number
|
||||
orderSn: string
|
||||
orderMoney: number
|
||||
realMoney: number
|
||||
paymentDate: string
|
||||
createTime: string
|
||||
orderType: string
|
||||
districtMoney?: number
|
||||
vipDiscountAmount?: number
|
||||
couponId?: number
|
||||
couponName?: string
|
||||
couponAmount?: number
|
||||
jfDeduction?: number
|
||||
remark?: string
|
||||
[key: string]: any
|
||||
}
|
||||
|
||||
@@ -2,7 +2,6 @@ export default function() {
|
||||
// #ifdef APP-PLUS
|
||||
return new Promise((resolve, reject) => {
|
||||
plus.runtime.getProperty(plus.runtime.appid, function(widgetInfo) {
|
||||
console.log('哈哈哈哈', widgetInfo)
|
||||
let data = {
|
||||
action: 'checkVersion',
|
||||
appid: plus.runtime.appid,
|
||||
@@ -13,7 +12,6 @@ export default function() {
|
||||
name: 'uni-upgrade-center',
|
||||
data,
|
||||
success: (e) => {
|
||||
console.log("e: ", e);
|
||||
resolve(e)
|
||||
},
|
||||
fail: (error) => {
|
||||
|
||||
@@ -7,7 +7,6 @@ export default function() {
|
||||
// #ifdef APP-PLUS
|
||||
return new Promise((resolve, reject) => {
|
||||
callCheckVersion().then(async (e) => {
|
||||
console.log('hhhhhhhhhhhh', e)
|
||||
if (!e.result) return;
|
||||
const {
|
||||
code,
|
||||
|
||||
@@ -21,7 +21,7 @@ export const onPageBack = () => {
|
||||
* @param {string} phoneNumber - 要拨打的电话号码
|
||||
* @param {string} title - 拨打电话提示的标题,默认值为空字符串
|
||||
*/
|
||||
export const makePhoneCall = (phoneNumber: string, title: string = '') => {
|
||||
export const makePhoneCall = (phoneNumber: string, title: string = t('global.call')) => {
|
||||
uni.showModal({
|
||||
title: title,
|
||||
content: phoneNumber,
|
||||
|
||||
Reference in New Issue
Block a user