Compare commits
8 Commits
master
...
8edf719431
| Author | SHA1 | Date | |
|---|---|---|---|
| 8edf719431 | |||
| 3587e15e7a | |||
| 79c6fb247c | |||
| f289e927bb | |||
| 85ca0c7a28 | |||
| 12de098e10 | |||
| 878e49dc2e | |||
| 435a23f995 |
@@ -7,8 +7,8 @@ export const ENV = process.env.NODE_ENV || 'development';
|
||||
*/
|
||||
const BASE_URL_MAP = {
|
||||
development: {
|
||||
MAIN: 'http://192.168.110.100:9300/pb/', // 张川川
|
||||
// MAIN: 'https://global.nuttyreading.com/', // 线上
|
||||
// MAIN: 'http://192.168.110.100:9300/pb/', // 张川川
|
||||
MAIN: 'https://global.nuttyreading.com/', // 线上
|
||||
// PAYMENT: 'https://dev-pay.example.com', // 暂时用不到
|
||||
// CDN: 'https://cdn-dev.example.com', // 暂时用不到
|
||||
},
|
||||
|
||||
@@ -194,11 +194,12 @@ export async function submitFeedback(data: IFeedbackForm) {
|
||||
* @param orderSn 订单号
|
||||
* @param productId 产品ID
|
||||
*/
|
||||
export async function verifyGooglePay(purchaseToken: string, orderSn: string, productId: string) {
|
||||
export async function verifyGooglePay(productId: number, purchaseToken: string, orderSn: string) {
|
||||
console.log(productId, purchaseToken, orderSn);
|
||||
const res = await mainClient.request<IApiResponse>({
|
||||
url: 'pay/googlepay/googleVerify',
|
||||
method: 'POST',
|
||||
data: { purchaseToken, orderSn, productId }
|
||||
data: { productId, purchaseToken, orderSn }
|
||||
})
|
||||
return res
|
||||
}
|
||||
@@ -256,13 +257,45 @@ 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 mainClient.request<IApiResponse>({
|
||||
url: '/book/buyOrder/placeOrder',
|
||||
method: 'POST',
|
||||
data: data
|
||||
})
|
||||
return res
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取积分数据
|
||||
* @return
|
||||
*/
|
||||
export async function getPointsData(current : number, limit : number, userId : string,) {
|
||||
|
||||
const res = await mainClient.request<IApiResponse>({
|
||||
url: 'common/jfTransactionDetails/getJfTransactionDetailsList',
|
||||
method: 'POST',
|
||||
data: { current, limit, userId, }
|
||||
})
|
||||
return res
|
||||
}
|
||||
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">{{ item.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>
|
||||
@@ -14,13 +14,13 @@
|
||||
<text v-else>
|
||||
课程有效期截止到:{{ catalogue.endTime }}
|
||||
</text>
|
||||
<wd-button
|
||||
<!-- <wd-button
|
||||
v-if="catalogue.startTime"
|
||||
size="small"
|
||||
@click="handleRenew"
|
||||
>
|
||||
续费
|
||||
</wd-button>
|
||||
</wd-button> -->
|
||||
</template>
|
||||
</view>
|
||||
</view>
|
||||
|
||||
@@ -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: () => [],
|
||||
@@ -373,9 +373,11 @@ const handleSubmit = async () => {
|
||||
})
|
||||
|
||||
// 返回上一页
|
||||
uni.navigateBack({
|
||||
delta: props.backStep
|
||||
})
|
||||
setTimeout(() => {
|
||||
uni.navigateBack({
|
||||
delta: props.backStep
|
||||
})
|
||||
}, 500)
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -52,7 +52,7 @@ const props = defineProps({
|
||||
*/
|
||||
const goToRecharge = () => {
|
||||
uni.navigateTo({
|
||||
url: '/pages/user/wallet/recharge/index?source=order'
|
||||
url: '/pages/user/recharge/index'
|
||||
})
|
||||
}
|
||||
</script>
|
||||
|
||||
@@ -33,6 +33,8 @@ const productImg = computed(() => {
|
||||
return props.data?.images || ''
|
||||
case 'vip':
|
||||
return '/static/vip.png'
|
||||
case 'abroadVip':
|
||||
return '/static/vip.png'
|
||||
case 'point':
|
||||
return '/static/jifen.png'
|
||||
default:
|
||||
@@ -47,6 +49,8 @@ const title = computed(() => {
|
||||
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:
|
||||
@@ -61,6 +65,8 @@ const price = computed(() => {
|
||||
return props.data?.abroadPrice || 0
|
||||
case 'vip':
|
||||
return props.data?.fee || 0
|
||||
case 'abroadVip':
|
||||
return props.data?.money || 0
|
||||
case 'point':
|
||||
return ''
|
||||
default:
|
||||
|
||||
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,8 @@
|
||||
"loginExpired": "Login expired. Please log in again.",
|
||||
"requestException": "Request exception",
|
||||
"coin": "Coin",
|
||||
"days": "Days"
|
||||
"days": "Days",
|
||||
"and": "and"
|
||||
},
|
||||
"tabar.course": "COURSE",
|
||||
"tabar.book": "EBOOK",
|
||||
@@ -79,7 +80,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": {
|
||||
@@ -297,7 +298,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 +394,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 +445,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",
|
||||
|
||||
@@ -18,7 +18,8 @@
|
||||
"loginExpired": "登录失效,请重新登录。",
|
||||
"requestException": "请求异常",
|
||||
"coin": "天医币",
|
||||
"days": "天"
|
||||
"days": "天",
|
||||
"and": "和"
|
||||
},
|
||||
"tabar.course": "课程",
|
||||
"tabar.book": "图书",
|
||||
@@ -80,7 +81,7 @@
|
||||
"getCode": "获取验证码",
|
||||
"passwordStrengthStrong": "密码强度强",
|
||||
"passwordStrengthMedium": "密码强度中等",
|
||||
"passwordStrengthWeak": "请使用至少包含大小写字母、数字、符号中的两种类型,长度为8个字符的密码",
|
||||
"passwordStrengthWeak": "请使用至少包含大小写字母、数字、符号中的两种类型,长度为8-20个字符的密码",
|
||||
"passwordChanged": "密码修改成功"
|
||||
},
|
||||
"common": {
|
||||
@@ -297,7 +298,9 @@
|
||||
"listen": {
|
||||
"title": "听书",
|
||||
"speed": "播放速度",
|
||||
"chapterList": "章节列表"
|
||||
"chapterList": "章节列表",
|
||||
"isLast": "已到最后一章",
|
||||
"isFirst": "已到第一章"
|
||||
},
|
||||
"workOrder": {
|
||||
"submit_success": "提交成功"
|
||||
@@ -391,7 +394,9 @@
|
||||
"courseInfo": "课程",
|
||||
"chapterInfo": "章节",
|
||||
"videoLoadFailed": "视频加载失败",
|
||||
"vipBenefit": "VIP畅学权益生效中"
|
||||
"vipBenefit": "VIP畅学权益生效中",
|
||||
"audio": "音频",
|
||||
"video": "视频"
|
||||
},
|
||||
"courseOrder": {
|
||||
"orderTitle": "确认订单",
|
||||
@@ -440,7 +445,7 @@
|
||||
"notUseCoupon": "不使用优惠券",
|
||||
"reselect": "重新选择",
|
||||
"selected": "选好了",
|
||||
"maxPoints": "可用积分({max}分)",
|
||||
"maxPoints": "可用积分(max分)",
|
||||
"pointsPlaceholder": "请输入积分",
|
||||
"allPoints": "全部积分",
|
||||
"insufficientBalance": "天医币余额不足",
|
||||
@@ -455,7 +460,7 @@
|
||||
"customerService": "客服",
|
||||
"paymentTipTitle": "说明",
|
||||
"paymentTip1": "1. 1积分=1天医币",
|
||||
"paymentTip2-1": "2. 若有疑问请加客服微信:{ customerServiceWechat } { customerServiceEmail }",
|
||||
"paymentTip2-1": "2. 若有疑问请加客服微信:",
|
||||
"paymentTip2-2": "或邮箱联系",
|
||||
"ensureBalance": "确保您的天医币足够支付",
|
||||
"vipLabel": "VIP优惠",
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
{
|
||||
"name" : "太湖国际",
|
||||
"name" : "吴门国际",
|
||||
"appid" : "__UNI__1250B39",
|
||||
"description" : "太湖国际",
|
||||
"description" : "吴门国际",
|
||||
"versionName" : "1.0.4",
|
||||
"versionCode" : 104,
|
||||
"transformPx" : false,
|
||||
|
||||
14
pages.json
14
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": {
|
||||
|
||||
@@ -114,31 +114,6 @@
|
||||
@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>
|
||||
|
||||
|
||||
@@ -162,10 +162,7 @@
|
||||
>
|
||||
<image :src="item.images" />
|
||||
<text class="book-text">{{ item.name }}</text>
|
||||
<text class="book-price">{{ item.minPrice }} {{ t('global.coin') }}</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>
|
||||
@@ -177,9 +174,9 @@
|
||||
<script setup lang="ts">
|
||||
import { ref, onMounted } 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 BookPrice from '@/components/book/BookPrice.vue'
|
||||
import type {
|
||||
IBook,
|
||||
IBookWithStats,
|
||||
@@ -187,8 +184,6 @@ import type {
|
||||
IVipInfo
|
||||
} from '@/types/book'
|
||||
|
||||
const { t } = useI18n()
|
||||
|
||||
// 状态定义
|
||||
const showMyBooks = ref(false)
|
||||
const showActivity = ref(false)
|
||||
@@ -320,43 +315,6 @@ const getBooksByLabel = async (
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 格式化价格
|
||||
*/
|
||||
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 ''
|
||||
}
|
||||
|
||||
/**
|
||||
* 处理搜索点击
|
||||
*/
|
||||
@@ -388,8 +346,8 @@ const handleBookClick = (bookId: number) => {
|
||||
* 处理更多按钮点击
|
||||
*/
|
||||
const handleMoreClick = () => {
|
||||
uni.switchTab({
|
||||
url: '/pages/book/index'
|
||||
uni.navigateTo({
|
||||
url: '/pages/user/myBook/index'
|
||||
})
|
||||
}
|
||||
|
||||
@@ -779,21 +737,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;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -381,7 +381,7 @@ async function prevChapter() {
|
||||
playChapter(chapterList.value[currentChapterIndex.value])
|
||||
} else {
|
||||
uni.showToast({
|
||||
title: t('listen.earlier'),
|
||||
title: t('listen.isFirst'),
|
||||
icon: 'none'
|
||||
})
|
||||
}
|
||||
@@ -412,7 +412,7 @@ async function nextChapter() {
|
||||
playChapter(chapterList.value[currentChapterIndex.value])
|
||||
} else {
|
||||
uni.showToast({
|
||||
title: t('listen.behind'),
|
||||
title: t('listen.isLast'),
|
||||
icon: 'none'
|
||||
})
|
||||
}
|
||||
|
||||
@@ -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>
|
||||
@@ -606,7 +606,7 @@ function changeReadMode(mode: 'scroll' | 'page') {
|
||||
const bookLanguages = ref([])
|
||||
const currentLanguage = ref('')
|
||||
onMounted(() => {
|
||||
currentLanguage.value = uni.getStorageSync('currentBookLanguage') || ''
|
||||
currentLanguage.value = uni.getStorageSync('currentBookLanguage') || '中文'
|
||||
console.log('currentLanguage', currentLanguage.value)
|
||||
})
|
||||
const getBookLanguages = async () => {
|
||||
|
||||
@@ -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">
|
||||
【{{ 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()
|
||||
})
|
||||
@@ -171,7 +113,7 @@ const loadChapterDetail = async () => {
|
||||
|
||||
// 如果有历史播放记录,定位到对应视频
|
||||
if (res.data.current) {
|
||||
const index = videoList.value.findIndex(v => v.id === res.data.current)
|
||||
const index = videoList.value.findIndex((v:any) => v.id === res.data.current)
|
||||
if (index !== -1) {
|
||||
currentVideoIndex.value = index
|
||||
activeVideoIndex.value = index
|
||||
@@ -188,13 +130,6 @@ const selectVideo = async (index: number) => {
|
||||
currentVideoIndex.value = index
|
||||
}
|
||||
|
||||
/**
|
||||
* 切换选项卡
|
||||
*/
|
||||
const switchTab = (index: number) => {
|
||||
currentTab.value = index
|
||||
}
|
||||
|
||||
/**
|
||||
* 预览图片
|
||||
*/
|
||||
@@ -212,10 +147,6 @@ const previewImage = (url: string) => {
|
||||
background-color: #f5f5f5;
|
||||
}
|
||||
|
||||
.page-content {
|
||||
padding-bottom: 100rpx;
|
||||
}
|
||||
|
||||
.video-section {
|
||||
background-color: #000;
|
||||
}
|
||||
@@ -254,135 +185,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>
|
||||
|
||||
@@ -130,6 +130,15 @@
|
||||
<text>
|
||||
本课程一经购买,暂不支持退款,敬请谅解。
|
||||
</text>
|
||||
<view style="color: red; font-weight: bold"> 注: </view>
|
||||
<view>
|
||||
1.手机、pad、电脑均为可登陆电子设备,均有唯一标识码,一个用户名仅允许在一个手机或一个ipad或一个电脑登陆,请根据您的使用习惯自行选择。<br />
|
||||
2.如若申请变更登陆设备请联系客服,<br />
|
||||
客服电话:13110039505;022-24142321<br />
|
||||
客服微信号:yilujiankangkefu<br />
|
||||
3.如因违反上述使用规定...概不退款,本公司保留追究用户相关法律责任的权利。<br />
|
||||
4.点击“同意”按钮即表示您同意遵守以上条款。
|
||||
</view>
|
||||
</view>
|
||||
<view class="protocol-actions">
|
||||
<wd-button type="info" plain @click="showProtocol = false">不同意</wd-button>
|
||||
@@ -156,7 +165,7 @@
|
||||
|
||||
<script setup lang="ts">
|
||||
import { ref, computed } from 'vue'
|
||||
import { onLoad, onPageScroll, onPullDownRefresh, onReachBottom } from '@dcloudio/uni-app'
|
||||
import { onLoad, onPageScroll, onPullDownRefresh, onReachBottom, onShow } from '@dcloudio/uni-app'
|
||||
import { useCourseStore } from '@/stores/course'
|
||||
import { useUserStore } from '@/stores/user'
|
||||
import { courseApi } from '@/api/modules/course'
|
||||
@@ -252,6 +261,12 @@ const vipTip = computed(() => {
|
||||
*/
|
||||
onLoad(async (options: any) => {
|
||||
courseId.value = parseInt(options.id)
|
||||
})
|
||||
|
||||
/**
|
||||
* 页面显示
|
||||
*/
|
||||
onShow(async () => {
|
||||
await loadPageData()
|
||||
})
|
||||
|
||||
@@ -339,7 +354,7 @@ const handleChapterClick = (chapter: IChapter) => {
|
||||
const noRecored = chapter.isAudition === 1 && currentCatalogue.value?.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}`
|
||||
})
|
||||
}
|
||||
|
||||
@@ -809,7 +824,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,6 +257,7 @@ const handleFirstLevelClick = (item: string) => {
|
||||
* 获取课程分类数据
|
||||
*/
|
||||
const getMedicalTags = async () => {
|
||||
sbuMedicalTagsList.value = []
|
||||
const res = await courseSubjectClassificationApi.getCourseMedicalTree()
|
||||
if (res && res.code === 0) {
|
||||
if (res.labels && res.labels.length > 0) {
|
||||
@@ -268,8 +269,6 @@ const getMedicalTags = async () => {
|
||||
// 非终极分类,显示子分类
|
||||
if (selectedTag.children && selectedTag.children.length > 0) {
|
||||
sbuMedicalTagsList.value = selectedTag.children
|
||||
} else {
|
||||
sbuMedicalTagsList.value = []
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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">
|
||||
@@ -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')"
|
||||
@@ -73,6 +74,7 @@ import { useI18n } from 'vue-i18n'
|
||||
import { commonApi } from '@/api/modules/common'
|
||||
import { resetPassword } from '@/api/modules/auth'
|
||||
import { validateEmail, checkPasswordStrength } from '@/utils/validator'
|
||||
import { getNotchHeight } from '@/utils/system'
|
||||
|
||||
const { t } = useI18n()
|
||||
|
||||
|
||||
@@ -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>太湖国际</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>
|
||||
@@ -87,7 +87,7 @@
|
||||
<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>
|
||||
@@ -424,11 +424,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
|
||||
}
|
||||
|
||||
|
||||
@@ -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
|
||||
@@ -49,7 +49,7 @@
|
||||
</template>
|
||||
|
||||
<script lang="ts" setup>
|
||||
import { ref } from 'vue'
|
||||
import { ref, computed } from 'vue'
|
||||
import { onLoad } from '@dcloudio/uni-app'
|
||||
import { orderApi } from '@/api/modules/order'
|
||||
import type { IOrderGoods } from '@/types/order'
|
||||
@@ -79,6 +79,14 @@ const getGoodsList = async () => {
|
||||
}
|
||||
}
|
||||
|
||||
// 复读
|
||||
const isRelearn = ref<boolean>(false)
|
||||
|
||||
// 订单类型
|
||||
const orderType = computed(() => {
|
||||
return isRelearn.value ? 'relearn' : 'order'
|
||||
})
|
||||
|
||||
/**
|
||||
* 页面加载
|
||||
*/
|
||||
@@ -90,6 +98,7 @@ onLoad(async (options: any) => {
|
||||
|
||||
// 根据商品ID获取商品详细信息
|
||||
goodsIds.value = options.goods || ''
|
||||
isRelearn.value = options.isRelearn == '1'
|
||||
getGoodsList()
|
||||
} catch (error) {
|
||||
console.error('解析商品数据失败:', error)
|
||||
|
||||
@@ -26,15 +26,15 @@
|
||||
<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>
|
||||
@@ -50,14 +50,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>
|
||||
@@ -86,6 +86,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 +100,7 @@
|
||||
// VIP信息
|
||||
const vipInfo = computed(() => userStore.userVips)
|
||||
const vipInfoEbook = computed(() => userStore.userEbookVip)
|
||||
|
||||
|
||||
// VIP类型字典
|
||||
const vipTypeDict = sysStore.vipTypeDict
|
||||
|
||||
@@ -178,7 +179,7 @@
|
||||
}
|
||||
|
||||
/**
|
||||
* 跳转到订阅页面
|
||||
* 跳转到电子书vip订阅页面
|
||||
*/
|
||||
const goSubscribe = () => {
|
||||
uni.navigateTo({
|
||||
@@ -186,6 +187,15 @@
|
||||
})
|
||||
}
|
||||
|
||||
/**
|
||||
* 跳转到课程vip订阅页面
|
||||
*/
|
||||
const goCourseVipSub = () => {
|
||||
uni.navigateTo({
|
||||
url: '/pages/vip/course'
|
||||
})
|
||||
}
|
||||
|
||||
/**
|
||||
* 处理菜单点击
|
||||
*/
|
||||
@@ -212,7 +222,7 @@
|
||||
url: '/pages/user/recharge/index'
|
||||
})
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 跳转虚拟币页面
|
||||
*/
|
||||
@@ -221,12 +231,22 @@
|
||||
url: '/pages/user/virtual/index'
|
||||
})
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* 跳转积分列表
|
||||
*/
|
||||
const goPointsList = () => {
|
||||
uni.navigateTo({
|
||||
url: '/pages/user/points/index'
|
||||
})
|
||||
}
|
||||
|
||||
onShow(() => {
|
||||
getData()
|
||||
})
|
||||
|
||||
onMounted(() => {
|
||||
getPlatform()
|
||||
getData()
|
||||
})
|
||||
</script>
|
||||
|
||||
@@ -306,14 +326,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 +343,7 @@
|
||||
padding: 30rpx;
|
||||
margin-bottom: 20rpx;
|
||||
}
|
||||
|
||||
.vip-item-list {
|
||||
font-size: 28rpx;
|
||||
color: #fff;
|
||||
@@ -412,7 +433,7 @@
|
||||
flex: 1;
|
||||
justify-content: space-around;
|
||||
text-align: center;
|
||||
transform:translateX(-20px);
|
||||
transform: translateX(-20px);
|
||||
|
||||
.assets_row {
|
||||
margin-bottom: 20rpx;
|
||||
|
||||
@@ -26,6 +26,7 @@
|
||||
<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 === '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 }} {{ t('global.coin') }}</view>
|
||||
|
||||
|
||||
135
pages/user/points/index.vue
Normal file
135
pages/user/points/index.vue
Normal file
@@ -0,0 +1,135 @@
|
||||
<template>
|
||||
<z-paging ref="paging" v-model="bookList" auto-show-back-to-top class="my-book-page" @query="pointsList" :default-page-size="10">
|
||||
<template #top>
|
||||
<!-- 自定义导航栏 -->
|
||||
<nav-bar :title="$t('user.consumptionRecord')"></nav-bar>
|
||||
</template>
|
||||
<view class="recharge-record" v-if="(bookList && bookList.length > 0)">
|
||||
<view class="go-gecharge" @click="goRecharge">
|
||||
<view>{{$t('order.recharge')}}</view>
|
||||
<view><wd-icon name="arrow-right" size="16px" color="#fff"/></view>
|
||||
</view>
|
||||
<view class="title">{{$t('order.rechargeConsumptionList')}}</view>
|
||||
<view class="recharge-record-block" v-for="(item, index) in bookList" :key="index">
|
||||
<view class="recharge-record-block-row">{{item.orderType}}<text class="text">{{item.changeAmount}}</text></view>
|
||||
<view class="time">{{item.createTime}}</view>
|
||||
</view>
|
||||
</view>
|
||||
</z-paging>
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
import { ref } from 'vue'
|
||||
import { useI18n } from 'vue-i18n'
|
||||
import { useUserStore } from '@/stores/user'
|
||||
import { getPointsData } from '@/api/modules/user'
|
||||
|
||||
const { t } = useI18n()
|
||||
const paging = ref<any>()
|
||||
const userStore = useUserStore()
|
||||
|
||||
// 数据状态
|
||||
const bookList = ref([])
|
||||
const loading = ref(false)
|
||||
const firstLoad = ref(true)
|
||||
|
||||
// 充值记录列表
|
||||
async function pointsList(pageNo : number, pageSize : number) {
|
||||
const userId = userStore.userInfo.id
|
||||
loading.value = true
|
||||
try {
|
||||
const res = await getPointsData(pageNo, pageSize, userId)
|
||||
console.log(res, 'res');
|
||||
paging.value.complete(res.transactionDetailsList.records)
|
||||
} catch (error) {
|
||||
paging.value.complete(false)
|
||||
console.error('Failed to load book list:', error)
|
||||
} finally {
|
||||
firstLoad.value = false
|
||||
loading.value = false
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 跳转充值页面
|
||||
*/
|
||||
const goRecharge = () => {
|
||||
uni.navigateTo({
|
||||
url: '/pages/user/recharge/index'
|
||||
})
|
||||
}
|
||||
</script>
|
||||
|
||||
<style lang="scss" scoped>
|
||||
.my-book-page {
|
||||
background: #f7faf9;
|
||||
min-height: 100vh;
|
||||
|
||||
.recharge-record {
|
||||
background: #fff;
|
||||
border-radius: 15rpx;
|
||||
overflow: hidden;
|
||||
box-shadow: 0 2rpx 10rpx rgba(0, 0, 0, 0.05);
|
||||
// padding: 20rpx;
|
||||
margin: 20rpx;
|
||||
|
||||
.go-gecharge{
|
||||
//height: 100rpx;
|
||||
background: linear-gradient(to right, #007bff, #17a2b8);
|
||||
font-size: 30rpx;
|
||||
font-weight: bold;
|
||||
color: #fff;
|
||||
padding: 20rpx;
|
||||
margin-bottom: 20rpx;
|
||||
display: flex;justify-content:space-between;align-items:center
|
||||
}
|
||||
|
||||
.title {
|
||||
font-size: 30rpx;
|
||||
padding-left:20rpx;
|
||||
margin-bottom: 30rpx;
|
||||
color: #007bff;
|
||||
font-weight: bold;
|
||||
}
|
||||
|
||||
.recharge-record-block {
|
||||
border-bottom: 1px solid #e0e0e0;
|
||||
padding: 20rpx;
|
||||
|
||||
.time{
|
||||
font-size: 20rpx;
|
||||
}
|
||||
|
||||
.recharge-record-block-row {
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
margin-bottom: 20rpx;
|
||||
|
||||
.text{
|
||||
color: #007bff;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
.empty-state {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
padding-top: 200rpx;
|
||||
|
||||
image {
|
||||
width: 400rpx;
|
||||
height: 300rpx;
|
||||
margin-bottom: 40rpx;
|
||||
}
|
||||
|
||||
.empty-text {
|
||||
font-size: 28rpx;
|
||||
color: #999;
|
||||
margin-bottom: 50rpx;
|
||||
}
|
||||
}
|
||||
|
||||
</style>
|
||||
@@ -8,8 +8,8 @@
|
||||
<view class="recharge_block" @click="chosPric(item)"
|
||||
:class="aloneItem.priceTypeId === item.priceTypeId ? 'selected' : ''"
|
||||
v-for="item in rechargeList.bookBuyConfigList" :key="item.priceTypeId">
|
||||
<view class="recharge_money">¥{{item.money}}</view>
|
||||
<view>{{item.realMoney}}{{ t('global.coin') }}</view>
|
||||
<view class="recharge_money">¥{{item.realMoney}}</view>
|
||||
<view>{{item.money}}{{ t('global.coin') }}</view>
|
||||
<!-- 红框位置的618活动标签 -->
|
||||
<!-- <view class="activity-tag">618活动</view> -->
|
||||
<span class="activity-label" v-if="item.givejf >0">618充值活动</span>
|
||||
@@ -23,25 +23,26 @@
|
||||
<view class="cha_fangsh">
|
||||
<view class="cf_title PM_font">{{$t('user.paymentMethod')}}</view>
|
||||
<view class="cf_radio">
|
||||
<radio-group v-for="item in iosPaylist" @click="choseType(item.id)">
|
||||
<radio-group v-for="item in iosPaylist">
|
||||
<view style="width: 100%">
|
||||
<view :class="payType == item.id ? 'Tab_xf cf_xuanx' : 'cf_xuanx'">
|
||||
<!-- <image class="pay_item_img" :src="item.imgUrl" mode="aspectFil">
|
||||
</image> -->
|
||||
<text>{{ item.title }}</text>
|
||||
<radio :checked="payType === item.id"></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">
|
||||
<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,40 @@
|
||||
|
||||
const remark = ref({})
|
||||
const isConnected = ref(false)
|
||||
const purchaseToken = ref()
|
||||
// 订单编号
|
||||
const orderSn = ref('')
|
||||
|
||||
|
||||
/**
|
||||
/**
|
||||
* 获取订单编号
|
||||
*/
|
||||
const getPlaceOrderObj = async () => {
|
||||
const { priceTypeId, realMoney, money } = toRefs(aloneItem.value)
|
||||
const data = {
|
||||
userId: userStore.userInfo.id, // 用户di
|
||||
paymentMethod: '5', //支付方式4point 5google
|
||||
orderMoney: money.value, //订单金额
|
||||
realMoney: realMoney.value, //实际金额
|
||||
come: '10', //订单来源 2医学吴门医述 10海外读书
|
||||
orderType: 'point', //订单类型, point充值、order课程、书、vip 课vip、abroadVip 书vip、relearn 复读、trainingClass 培训班
|
||||
productId: priceTypeId.value // 商品id
|
||||
}
|
||||
try {
|
||||
const res = await getPlaceOrder(data)
|
||||
orderSn.value = res.orderSn
|
||||
console.log(orderSn.value, '获取订单号');
|
||||
getGooglePay()
|
||||
} catch (error) {
|
||||
console.error('获取订单号失败', error)
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取使用环境
|
||||
*/
|
||||
const getDevName = () => {
|
||||
|
||||
|
||||
if (uni.getSystemInfoSync().platform === "android") {
|
||||
qudao.value = 'Google'
|
||||
isAndroid.value = true;
|
||||
@@ -127,7 +159,7 @@
|
||||
|
||||
// 点击金额
|
||||
const chosPric = (item : any) => {
|
||||
console.log(item,'金额每项');
|
||||
console.log(item, '金额每项');
|
||||
aloneItem.value = item;
|
||||
};
|
||||
|
||||
@@ -195,25 +227,30 @@
|
||||
// payType.value = val;
|
||||
}
|
||||
|
||||
const handleRecharge = () => {
|
||||
if(!state.value){
|
||||
/**
|
||||
* 点击支付按钮
|
||||
*/
|
||||
|
||||
const paymentButton = async () => {
|
||||
if (!state.value) {
|
||||
uni.showToast({
|
||||
title: t('order.readAgreeServices'),
|
||||
icon: 'none'
|
||||
title: t('order.readAgreeServices'),
|
||||
icon: 'none'
|
||||
})
|
||||
return
|
||||
}
|
||||
uni.showLoading({ title: '加载中...' })
|
||||
console.log('立即充值');
|
||||
getGooglePay()
|
||||
getPlaceOrderObj()
|
||||
uni.showLoading({ title: '生成订单中...' })
|
||||
}
|
||||
// 节流支付按钮
|
||||
const handleRecharge = useThrottle(paymentButton);
|
||||
|
||||
/**
|
||||
* 初始化
|
||||
*/
|
||||
const getGooglePay = () => {
|
||||
googlePay.init({
|
||||
}, (e:any) => {
|
||||
}, (e : any) => {
|
||||
console.log('init', e);
|
||||
if (e.code == 0) {
|
||||
isConnected.value = true;
|
||||
@@ -225,47 +262,99 @@
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 查询sku
|
||||
*/
|
||||
const getQuerySku = () =>{
|
||||
const getQuerySku = () => {
|
||||
const id = aloneItem.value.priceTypeId
|
||||
console.log(id, '获取每项');
|
||||
googlePay.querySku(
|
||||
{
|
||||
inapp: [id], // 与subs二选一, 参数为商品ID(字符串)数组
|
||||
},
|
||||
(e:any) => {
|
||||
if (e.code == 0) {
|
||||
// 查询成功.
|
||||
console.log('查询成功',e);
|
||||
// e.list; // 查询结果, array
|
||||
} else {
|
||||
console.log('查询失败');
|
||||
// 查询失败
|
||||
}
|
||||
}
|
||||
)
|
||||
}
|
||||
|
||||
const getPayAll = () =>{
|
||||
googlePay.payAll(
|
||||
{
|
||||
productId: "", // 产品id
|
||||
|
||||
},
|
||||
(e) => {
|
||||
if (e.code == 0) {
|
||||
// 支付成功
|
||||
e.data; //支付结果, array [ {original:{ }, signature: ''} ]
|
||||
} else {
|
||||
// 支付失败
|
||||
}
|
||||
},
|
||||
{
|
||||
inapp: [id], // 与subs二选一, 参数为商品ID(字符串)数组
|
||||
},
|
||||
(e : any) => {
|
||||
if (e.code == 0) {
|
||||
// 查询成功.
|
||||
console.log('querySku查询成功', e);
|
||||
uni.hideLoading()
|
||||
getPayAll()
|
||||
} else {
|
||||
console.log('查询失败', e);
|
||||
uni.showToast({
|
||||
title: 'No product found.',
|
||||
icon: 'none',
|
||||
duration: 2000
|
||||
})
|
||||
// 查询失败
|
||||
}
|
||||
}
|
||||
)
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 发起支付
|
||||
*/
|
||||
const getPayAll = () => {
|
||||
console.log(aloneItem.value.priceTypeId, orderSn.value, '发起支付传入产品id,订单id');
|
||||
googlePay.payAll(
|
||||
{
|
||||
productId: aloneItem.value.priceTypeId, // 产品id
|
||||
accountId: orderSn.value // 订单编号
|
||||
},
|
||||
(e : any) => {
|
||||
if (e.code == 0) {
|
||||
purchaseToken.value = e.data[0].original.purchaseToken
|
||||
// 支付成功
|
||||
console.log(e, 'payAll方法成功返参');
|
||||
getConsume()
|
||||
} else {
|
||||
uni.showToast({ title: '支付失败', icon: 'success' })
|
||||
console.log(e, 'e');
|
||||
// 支付失败
|
||||
}
|
||||
},
|
||||
)
|
||||
}
|
||||
|
||||
/**
|
||||
* 消耗品 确认交易
|
||||
*/
|
||||
const getConsume = () => {
|
||||
googlePay.consume(
|
||||
{
|
||||
purchaseToken: purchaseToken.value, // 来自支付结果的original.purchaseToken (或 original.token)
|
||||
},
|
||||
(e : any) => {
|
||||
if (e.code == 0) {
|
||||
console.log(e, '确认交易成功');
|
||||
// 确认成功
|
||||
googleVerify()
|
||||
} else {
|
||||
console.log(e, '确认交易失败');
|
||||
// 确认失败
|
||||
}
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* 校验订单
|
||||
*/
|
||||
const googleVerify = async () => {
|
||||
console.log(typeof aloneItem.value.priceTypeId, typeof purchaseToken.value, typeof orderSn.value);
|
||||
try {
|
||||
const obj = await verifyGooglePay(aloneItem.value.priceTypeId, purchaseToken.value, orderSn.value)
|
||||
uni.switchTab({
|
||||
url: '/pages/user/index'
|
||||
})
|
||||
console.log(obj, '校验订单');
|
||||
} catch (error) {
|
||||
console.error('校验订单失败:', error)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
onMounted(() => {
|
||||
getDevName();
|
||||
@@ -387,7 +476,7 @@
|
||||
border-bottom: 1px solid #ededed;
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
align-items:center;
|
||||
align-items: center;
|
||||
|
||||
image {
|
||||
width: 40rpx;
|
||||
|
||||
@@ -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 |
@@ -114,8 +114,13 @@ uni-textarea {
|
||||
.wd-overlay {
|
||||
z-index: 9998 !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
|
||||
|
||||
@@ -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,
|
||||
|
||||
Reference in New Issue
Block a user