3.5提交代码
This commit is contained in:
@@ -0,0 +1,210 @@
|
||||
<template>
|
||||
<view class="detail-page">
|
||||
<navBar title="订单详情" />
|
||||
|
||||
<view class="order-card">
|
||||
<view class="order-top">
|
||||
<text class="download-no">下载课件号: {{ detail.downloadNo || "--" }}</text>
|
||||
<text class="pay-status">{{ detail.statusText || "--" }}</text>
|
||||
</view>
|
||||
|
||||
<view class="section-divider"></view>
|
||||
|
||||
<view class="course-title">{{ detail.title || "--" }}</view>
|
||||
|
||||
|
||||
|
||||
<view class="info-list">
|
||||
<view class="info-row">
|
||||
<text class="info-label">课件作者:</text>
|
||||
<text class="info-value">{{ detail.author || "--" }}</text>
|
||||
</view>
|
||||
<view class="info-row">
|
||||
<text class="info-label">金额:</text>
|
||||
<text class="info-value amount">{{ detail.amountText || "--" }}</text>
|
||||
</view>
|
||||
<view class="info-row">
|
||||
<text class="info-label">创建时间:</text>
|
||||
<text class="info-value">{{ detail.createTime || "--" }}</text>
|
||||
</view>
|
||||
<view class="info-row">
|
||||
<text class="info-label">支付方式:</text>
|
||||
<text class="info-value">{{ detail.payType || "--" }}</text>
|
||||
</view>
|
||||
<view class="info-row">
|
||||
<text class="info-label">支付时间:</text>
|
||||
<text class="info-value">{{ detail.payTime || "--" }}</text>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
</template>
|
||||
|
||||
<script setup>
|
||||
import { ref } from "vue";
|
||||
import { onLoad } from "@dcloudio/uni-app";
|
||||
import api from "@/api/api.js";
|
||||
|
||||
const coursewareId = ref("");
|
||||
const detail = ref({
|
||||
downloadNo: "",
|
||||
statusText: "",
|
||||
title: "",
|
||||
author: "",
|
||||
amountText: "",
|
||||
createTime: "",
|
||||
payType: "",
|
||||
payTime: "",
|
||||
});
|
||||
|
||||
const formatDateTime = (value) => {
|
||||
if (!value) return "";
|
||||
if (typeof value === "string" && value.includes("-")) return value;
|
||||
const timeNum = Number(value);
|
||||
if (!timeNum) return "";
|
||||
const ms = timeNum < 10000000000 ? timeNum * 1000 : timeNum;
|
||||
const d = new Date(ms);
|
||||
const y = d.getFullYear();
|
||||
const m = String(d.getMonth() + 1).padStart(2, "0");
|
||||
const day = String(d.getDate()).padStart(2, "0");
|
||||
const h = String(d.getHours()).padStart(2, "0");
|
||||
const min = String(d.getMinutes()).padStart(2, "0");
|
||||
const s = String(d.getSeconds()).padStart(2, "0");
|
||||
return `${y}-${m}-${day} ${h}:${min}:${s}`;
|
||||
};
|
||||
|
||||
const formatAmount = (value) => {
|
||||
if (value === undefined || value === null || value === "") return "";
|
||||
const num = Number(value);
|
||||
if (Number.isNaN(num)) return "";
|
||||
const amount = num > 1000 ? num / 100 : num;
|
||||
return `${amount.toFixed(2)}元`;
|
||||
};
|
||||
|
||||
const formatStatus = (raw) => {
|
||||
if (raw === undefined || raw === null) return "";
|
||||
const text = String(raw).toLowerCase();
|
||||
if (text === "paid" || text === "success" || text === "1" || text === "2") return "已支付";
|
||||
if (text === "unpaid" || text === "0" || text === "created") return "未支付";
|
||||
return String(raw);
|
||||
};
|
||||
|
||||
const formatPayType = (raw) => {
|
||||
if (raw === undefined || raw === null || raw === "") return "免费";
|
||||
const text = String(raw).toLowerCase();
|
||||
if (text === "0" || text === "free") return "免费";
|
||||
if (text === "1" || text.includes("wx") || text.includes("wechat")) return "微信";
|
||||
if (text === "2" || text.includes("ali")) return "支付宝";
|
||||
if (text === "3" || text.includes("balance")) return "余额";
|
||||
return String(raw);
|
||||
};
|
||||
|
||||
const fetchCoursewareDetail = async () => {
|
||||
if (!coursewareId.value) return;
|
||||
try {
|
||||
const res = await api.getGanDanFileOrder({
|
||||
order_id: coursewareId.value,
|
||||
});
|
||||
if (res.code !== 200 || !res.data) return;
|
||||
|
||||
const data = res.data;
|
||||
detail.value = {
|
||||
downloadNo: data.order_id || data.download_no || data.gandanfile_order_id || data.id || "",
|
||||
statusText: formatStatus(data.order_status || data.status || data.pay_status || ""),
|
||||
title: data.title || data.name || data.file_name || "",
|
||||
author: data.provider_name || data.author || data.nickname || "",
|
||||
amountText: formatAmount(data.pay_amount || data.total_fee || data.amount || data.price || 0),
|
||||
createTime: formatDateTime(data.create_date || data.create_time || data.order_time || ""),
|
||||
payType: formatPayType(data.pay_type_name || data.pay_type || data.payment_method || ""),
|
||||
payTime: formatDateTime(data.pay_date || data.pay_time || ""),
|
||||
};
|
||||
} catch (error) {
|
||||
uni.showToast({
|
||||
title: "获取详情失败",
|
||||
icon: "none",
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
onLoad((options) => {
|
||||
coursewareId.value = options.id;
|
||||
fetchCoursewareDetail();
|
||||
});
|
||||
</script>
|
||||
|
||||
<style lang="scss" scoped>
|
||||
.detail-page {
|
||||
min-height: 100vh;
|
||||
background: #f5f5f5;
|
||||
}
|
||||
|
||||
.order-card {
|
||||
background: #fff;
|
||||
margin-top: calc(var(--status-bar-height) + 44px);
|
||||
}
|
||||
|
||||
.order-top {
|
||||
min-height: 88rpx;
|
||||
padding: 0 30rpx;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: space-between;
|
||||
}
|
||||
|
||||
.download-no {
|
||||
font-size: 32rpx;
|
||||
color: #333;
|
||||
}
|
||||
|
||||
.pay-status {
|
||||
font-size: 32rpx;
|
||||
color: #8b2316;
|
||||
}
|
||||
|
||||
.section-divider {
|
||||
height: 16rpx;
|
||||
background: #f5f5f5;
|
||||
}
|
||||
|
||||
.course-title {
|
||||
padding: 20rpx 30rpx;
|
||||
color: #8b2316;
|
||||
font-size: 32rpx;
|
||||
line-height: 1.5;
|
||||
word-break: break-all;
|
||||
border-bottom: 2rpx solid #ccc;
|
||||
}
|
||||
|
||||
.info-list {
|
||||
padding: 24rpx 30rpx;
|
||||
}
|
||||
|
||||
.info-row {
|
||||
min-height: 56rpx;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: space-between;
|
||||
margin-bottom: 10rpx;
|
||||
}
|
||||
|
||||
.info-row:last-child {
|
||||
margin-bottom: 0;
|
||||
}
|
||||
|
||||
.info-label {
|
||||
font-size: 18rpx;
|
||||
color: #333;
|
||||
}
|
||||
|
||||
.info-value {
|
||||
max-width: 68%;
|
||||
font-size: 28rpx;
|
||||
color: #666;
|
||||
text-align: right;
|
||||
word-break: break-all;
|
||||
}
|
||||
|
||||
.amount {
|
||||
color:red;
|
||||
}
|
||||
</style>
|
||||
@@ -1,18 +1,7 @@
|
||||
<template>
|
||||
<navBar title="我的课件" />
|
||||
<view class="my-courseware-page">
|
||||
<!-- 顶部导航栏 -->
|
||||
<uni-nav-bar
|
||||
left-icon="left"
|
||||
title="我的课件"
|
||||
@cviewckLeft="goBack"
|
||||
fixed
|
||||
color="#8B2316"
|
||||
height="180rpx"
|
||||
:border="false"
|
||||
backgroundColor="#eeeeee"
|
||||
>
|
||||
|
||||
</uni-nav-bar>
|
||||
|
||||
<!-- 标签页导航 -->
|
||||
<view class="tab-nav">
|
||||
@@ -37,11 +26,11 @@
|
||||
<view class="summary-bar">
|
||||
<view class="summary-item">
|
||||
<up-image :src="downLoadImg" width="36rpx" height="36rpx" ></up-image>
|
||||
<text class="summary-text">{{ activeTab === 'download' ? '下载账户' : '分享账户' }}: {{ downloadCount }}</text>
|
||||
<text class="summary-text">{{ totalAmount}}</text>
|
||||
</view>
|
||||
<view class="summary-item">
|
||||
<up-image :src="moneyImg" width="36rpx" height="36rpx" ></up-image>
|
||||
<text class="summary-text">{{ activeTab === 'download' ? '文件数量' : '分享文件' }}: {{ totalAmount }}</text>
|
||||
<text class="summary-text">{{ downloadCount }}</text>
|
||||
</view>
|
||||
</view>
|
||||
|
||||
@@ -74,7 +63,7 @@
|
||||
<text class="label">时间:</text>
|
||||
<text class="value">{{ item.time }}</text>
|
||||
</view>
|
||||
<view class="courseware-status">
|
||||
<view class="courseware-status" v-if="activeTab === 'download'">
|
||||
<text class="label">状态:</text>
|
||||
<text class="value status-paid">{{ item.status }}</text>
|
||||
</view>
|
||||
@@ -97,6 +86,8 @@
|
||||
<script setup>
|
||||
import { ref, onMounted } from 'vue';
|
||||
import api from '@/api/api';
|
||||
import navTo from '@/utils/navTo.js';
|
||||
import { onLoad } from '@dcloudio/uni-app';
|
||||
import downLoadImg from "@/static/course_download.png"
|
||||
import moneyImg from "@/static/course_yuan.png"
|
||||
const activeTab = ref('download');
|
||||
@@ -105,8 +96,8 @@ const loading = ref(false);
|
||||
const noMore = ref(false);
|
||||
const page = ref(1);
|
||||
const pageSize = ref(10);
|
||||
const downloadCount = ref(4);
|
||||
const totalAmount = ref('20.00');
|
||||
const downloadCount = ref(0);
|
||||
const totalAmount = ref(0);
|
||||
|
||||
const coursewareList = ref([]);
|
||||
|
||||
@@ -118,6 +109,12 @@ const goBack = () => {
|
||||
uni.navigateBack();
|
||||
};
|
||||
|
||||
onLoad((options) => {
|
||||
if(options.from){
|
||||
//from.value = options.from;
|
||||
switchTab('share')
|
||||
}
|
||||
})
|
||||
const switchTab = (tab) => {
|
||||
activeTab.value = tab;
|
||||
// 切换标签时重置数据
|
||||
@@ -132,37 +129,10 @@ const onItemClick = (item) => {
|
||||
console.log('点击课件:', item);
|
||||
|
||||
if (activeTab.value === 'download') {
|
||||
// 下载标签页的处理逻辑
|
||||
if (item.download_path) {
|
||||
uni.downloadFile({
|
||||
url: item.download_path,
|
||||
success: (res) => {
|
||||
if (res.statusCode === 200) {
|
||||
uni.openDocument({
|
||||
filePath: res.tempFilePath,
|
||||
success: () => {
|
||||
console.log('打开文档成功');
|
||||
},
|
||||
fail: (err) => {
|
||||
console.error('打开文档失败:', err);
|
||||
uni.showToast({ title: '无法打开此文件', icon: 'none' });
|
||||
}
|
||||
});
|
||||
}
|
||||
},
|
||||
fail: (err) => {
|
||||
console.error('下载失败:', err);
|
||||
uni.showToast({ title: '下载失败', icon: 'none' });
|
||||
}
|
||||
});
|
||||
} else {
|
||||
uni.showToast({ title: `点击了下载课件: ${item.name}`, icon: 'none' });
|
||||
}
|
||||
} else {
|
||||
// 分享标签页的处理逻辑
|
||||
uni.showToast({ title: `点击了分享课件: ${item.name}`, icon: 'none' });
|
||||
// 这里可以添加分享相关的操作,比如查看分享详情、重新分享等
|
||||
}
|
||||
navTo({
|
||||
url: `/pages_app/myCourseware/coursewareDetail?id=${item.order_id}`
|
||||
})
|
||||
}
|
||||
};
|
||||
|
||||
const onRefresh = () => {
|
||||
@@ -175,7 +145,7 @@ const onRefresh = () => {
|
||||
if (res.code === 200 && res.data) {
|
||||
const data = res.data.list;
|
||||
// 更新摘要信息
|
||||
downloadCount.value = res.data.downloadTotalAccount || 0;
|
||||
downloadCount.value = (res.data.downloadTotalAccount/100).toFixed(2) || 0;
|
||||
totalAmount.value = res.data.downloadFileCount || 0;
|
||||
|
||||
// 处理课件列表数据
|
||||
@@ -203,7 +173,7 @@ const onRefresh = () => {
|
||||
if (res.code === 200 && res.data) {
|
||||
const data = res.data.list;
|
||||
// 更新摘要信息 - 分享数据使用不同的字段
|
||||
downloadCount.value = res.data.shareTotalAccount || 0;
|
||||
downloadCount.value = (res.data.shareTotalAccount/100).toFixed(2) || 0;
|
||||
totalAmount.value = res.data.shareloadFileCount || 0;
|
||||
|
||||
// 处理分享列表数据
|
||||
@@ -305,7 +275,7 @@ const onLoadMore = () => {
|
||||
background: #ffffff;
|
||||
border-bottom: 2rpx solid #f0f0f0;
|
||||
position: fixed;
|
||||
top: 180rpx;
|
||||
top: calc(var(--status-bar-height) + 44px);
|
||||
left: 0;
|
||||
right: 0;
|
||||
z-index: 10;
|
||||
@@ -332,20 +302,21 @@ const onLoadMore = () => {
|
||||
|
||||
.summary-bar {
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
|
||||
align-items: center;
|
||||
background: #8B2316;
|
||||
padding: 20rpx 30rpx;
|
||||
position: fixed;
|
||||
top: 260rpx; // 标签页导航下方
|
||||
top: calc(var(--status-bar-height) + 44px + 124rpx); // 标签页导航下方
|
||||
left: 0;
|
||||
right: 0;
|
||||
z-index: 10;
|
||||
|
||||
.summary-item {
|
||||
flex:1;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
|
||||
justify-content: flex-start;
|
||||
.summary-text {
|
||||
color: #ffffff;
|
||||
font-size: 28rpx;
|
||||
@@ -355,7 +326,7 @@ const onLoadMore = () => {
|
||||
}
|
||||
|
||||
.courseware-list {
|
||||
height: calc(100vh - 180rpx - 116rpx - 80rpx);
|
||||
// height: calc(100vh - 180rpx - 116rpx - 80rpx);
|
||||
position: fixed;
|
||||
top: 336rpx; // 调整顶部位置,为固定的摘要栏腾出空间
|
||||
bottom: 0;
|
||||
|
||||
Reference in New Issue
Block a user