Lufaneng 11 months ago
parent c452b83a66
commit fd4a737396

@ -6,13 +6,28 @@ import {
onError, onError,
onPageNotFound, onPageNotFound,
} from "@dcloudio/uni-app"; } from "@dcloudio/uni-app";
import { checkForUpdate } from "@/utils"; import {
checkForUpdate
} from "@/utils";
onLaunch(() => { onLaunch(() => {
console.log("App Launch"); console.log("App Launch");
// #ifdef MP-WEIXIN // #ifdef MP-WEIXIN
checkForUpdate(); checkForUpdate();
// #endif // #endif
// #ifdef H5
if (navigator.userAgent.toLowerCase().indexOf('micromessenger') !== -1) {
//
const style = document.createElement('style')
style.textContent = `
uni-page-head {
display:none !important;
}
`
document.head.appendChild(style)
}
// #endif
}); });
onShow(() => { onShow(() => {

@ -3,16 +3,34 @@
<!-- 生成记录列表 --> <!-- 生成记录列表 -->
<view class="record-list"> <view class="record-list">
<uv-swipe-action> <uv-swipe-action>
<uv-swipe-action-item @click="delItem(record)" :options="options" v-for="record in list" :key="record.id"> <uv-swipe-action-item
@click="delItem(record)"
:options="options"
v-for="record in list"
:key="record.id"
>
<view class="record-item"> <view class="record-item">
<!-- 记录信息 --> <!-- 记录信息 -->
<view class="record-info"> <view class="record-info">
<view class="record-title">{{ record.file_name }}</view> <view class="record-title">{{ record.file_name }}</view>
<view class="record-time">生成时间: {{ record.CreatedAt ? dayjs(record.CreatedAt).format('YYYY-MM-DD') : '' }}</view> <view class="record-time">
生成时间:
{{
record.CreatedAt
? dayjs(record.CreatedAt).format("YYYY-MM-DD")
: ""
}}
</view>
</view> </view>
<!-- 状态标签 --> <!-- 状态标签 -->
<view class="status-tag" :class="{completed:record.status == 4,failed:record.status == 5}"> <view
class="status-tag"
:class="{
completed: record.status == 4,
failed: record.status == 5,
}"
>
<span v-if="record.status == 4"></span> <span v-if="record.status == 4"></span>
<span v-else-if="record.status == 5">生成失败</span> <span v-else-if="record.status == 5">生成失败</span>
<span v-else></span> <span v-else></span>
@ -20,16 +38,29 @@
<!-- 操作按钮 --> <!-- 操作按钮 -->
<view class="record-actions"> <view class="record-actions">
<uv-button v-if="record.status === 4" type="primary" size="small" <uv-button
@click="downloadRecord(record)"> v-if="record.status === 4"
<uv-icon name="download" size="14" color="white" style="margin-right: 4px"></uv-icon> type="primary"
size="small"
@click="downloadRecord(record)"
>
<uv-icon
name="download"
size="14"
color="white"
style="margin-right: 4px"
></uv-icon>
下载 下载
</uv-button> </uv-button>
<uv-button v-else type="info" size="small" disabled> <uv-button v-else type="info" size="small" disabled>
<uv-icon name="download" size="14" color="#aaa" style="margin-right: 4px"></uv-icon> <uv-icon
name="download"
size="14"
color="#aaa"
style="margin-right: 4px"
></uv-icon>
下载 下载
</uv-button> </uv-button>
</view> </view>
</view> </view>
</uv-swipe-action-item> </uv-swipe-action-item>
@ -48,63 +79,94 @@
</template> </template>
<script setup> <script setup>
import { import { ref, onMounted } from "vue";
ref,
onMounted
} from "vue";
import RPC from "@/utils/request"; import RPC from "@/utils/request";
import dayjs from 'dayjs' import dayjs from "dayjs";
import { import { onShow, onPullDownRefresh, onReachBottom } from "@dcloudio/uni-app";
onShow,onPullDownRefresh,onReachBottom
} from "@dcloudio/uni-app";
const options = ref([{ const options = ref([
text: '删除', {
text: "删除",
style: { style: {
backgroundColor: '#f56c6c' backgroundColor: "#f56c6c",
} },
}]) },
const delItem = item => { ]);
console.log(item) const delItem = (item) => {
deleteRecord(item) console.log(item);
} deleteRecord(item);
};
// //
const loading = ref(false); const loading = ref(false);
const loadingStatus = ref('loadmore') const loadingStatus = ref("loadmore");
const page = ref(1) const page = ref(1);
const list = ref([]) const list = ref([]);
const count = ref(0) const count = ref(0);
// //
const downloadRecord = (record) => { const downloadRecord = (record) => {
uni.showLoading({ uni.showLoading({
title: "准备下载...", title: "准备下载...",
}); });
// #ifdef H5
// H5使
const link = document.createElement("a");
link.href = record.result_url;
link.download = record.file_name || "download";
link.target = "_blank";
document.body.appendChild(link);
link.click();
document.body.removeChild(link);
uni.hideLoading();
uni.showToast({
title: "开始下载",
icon: "success",
});
// #endif
// #ifndef H5
// App使uni.downloadFile
uni.downloadFile({ uni.downloadFile({
url: record.result_url, url: record.result_url,
// url:'https://ksdt-1255846884.cos.ap-shanghai.myqcloud.com/lift-result/2025/09/24/d6180add4cd94875a1854a4febce8966.pdf',
success: (res) => { success: (res) => {
console.log(res) console.log(res);
if (res.statusCode === 200) { if (res.statusCode === 200) {
uni.saveFile({ uni.saveFile({
tempFilePath: res.tempFilePath, tempFilePath: res.tempFilePath,
success: () => { success: () => {
uni.hideLoading();
uni.showToast({ uni.showToast({
title: '下载成功', title: "下载成功",
icon: 'success' icon: "success",
}) });
}
})
}
}, },
fail: () => { fail: () => {
uni.hideLoading();
uni.showToast({ uni.showToast({
title: '下载失败', title: "保存失败",
icon: 'none' icon: "none",
}) });
},
});
} else {
uni.hideLoading();
uni.showToast({
title: "下载失败",
icon: "none",
});
} }
}) },
fail: () => {
uni.hideLoading();
uni.showToast({
title: "下载失败",
icon: "none",
});
},
});
// #endif
}; };
// //
@ -138,57 +200,62 @@
// //
const loadRecords = async () => { const loadRecords = async () => {
loadingStatus.value === 'loading' loadingStatus.value === "loading";
RPC.post('/planned_list',{page:page.value,page_size:20}).then(res => { RPC.post("/planned_list", { page: page.value, page_size: 20 })
list.value = [...list.value, ...res.list] .then((res) => {
count.value = res.total list.value = [...list.value, ...res.list];
count.value = res.total;
if (list.value.length >= count.value) { if (list.value.length >= count.value) {
loadingStatus.value = 'nomore' loadingStatus.value = "nomore";
} else { } else {
loadingStatus.value = 'loadmore' loadingStatus.value = "loadmore";
} }
}).catch(() => {
loadingStatus.value = 'loadmore'
}) })
.catch(() => {
loadingStatus.value = "loadmore";
});
}; };
// //
onPullDownRefresh(() => { onPullDownRefresh(() => {
list.value = [] list.value = [];
page.value = 1 page.value = 1;
loadingStatus.value === 'loading' loadingStatus.value === "loading";
RPC.post('/planned_list',{page:page.value,page_size:20}).then(res => { RPC.post("/planned_list", { page: page.value, page_size: 20 })
list.value = [...list.value, ...res.list] .then((res) => {
count.value = res.total list.value = [...list.value, ...res.list];
count.value = res.total;
if (list.value.length >= count.value) { if (list.value.length >= count.value) {
loadingStatus.value = 'nomore' loadingStatus.value = "nomore";
} else { } else {
loadingStatus.value = 'loadmore' loadingStatus.value = "loadmore";
} }
}).catch(() => {
loadingStatus.value = 'loadmore'
}).finally(() => {
uni.stopPullDownRefresh()
}) })
.catch(() => {
loadingStatus.value = "loadmore";
}) })
.finally(() => {
uni.stopPullDownRefresh();
});
});
onReachBottom(() => { onReachBottom(() => {
loadmore() loadmore();
}) });
const loadmore = () => { const loadmore = () => {
if (list.value.length >= count.value || loadingStatus.value === 'loading') return if (list.value.length >= count.value || loadingStatus.value === "loading")
console.log('上拉加载:') return;
loadingStatus.value = 'loading'; console.log("上拉加载:");
loadingStatus.value = "loading";
page.value = ++page.value; page.value = ++page.value;
loadRecords() loadRecords();
} };
onShow(() => { onShow(() => {
// //
list.value = [] list.value = [];
page.value = 1 page.value = 1;
loadRecords(); loadRecords();
}); });
</script> </script>

Loading…
Cancel
Save