Lufaneng 11 months ago
parent c452b83a66
commit fd4a737396

@ -6,13 +6,28 @@ import {
onError,
onPageNotFound,
} from "@dcloudio/uni-app";
import { checkForUpdate } from "@/utils";
import {
checkForUpdate
} from "@/utils";
onLaunch(() => {
console.log("App Launch");
// #ifdef MP-WEIXIN
checkForUpdate();
// #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(() => {

@ -3,16 +3,34 @@
<!-- 生成记录列表 -->
<view class="record-list">
<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-info">
<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 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-else-if="record.status == 5">生成失败</span>
<span v-else></span>
@ -20,16 +38,29 @@
<!-- 操作按钮 -->
<view class="record-actions">
<uv-button v-if="record.status === 4" type="primary" size="small"
@click="downloadRecord(record)">
<uv-icon name="download" size="14" color="white" style="margin-right: 4px"></uv-icon>
<uv-button
v-if="record.status === 4"
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 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>
</view>
</view>
</uv-swipe-action-item>
@ -48,63 +79,94 @@
</template>
<script setup>
import {
ref,
onMounted
} from "vue";
import { ref, onMounted } from "vue";
import RPC from "@/utils/request";
import dayjs from 'dayjs'
import {
onShow,onPullDownRefresh,onReachBottom
} from "@dcloudio/uni-app";
import dayjs from "dayjs";
import { onShow, onPullDownRefresh, onReachBottom } from "@dcloudio/uni-app";
const options = ref([{
text: '删除',
const options = ref([
{
text: "删除",
style: {
backgroundColor: '#f56c6c'
}
}])
const delItem = item => {
console.log(item)
deleteRecord(item)
}
backgroundColor: "#f56c6c",
},
},
]);
const delItem = (item) => {
console.log(item);
deleteRecord(item);
};
//
const loading = ref(false);
const loadingStatus = ref('loadmore')
const page = ref(1)
const list = ref([])
const count = ref(0)
const loadingStatus = ref("loadmore");
const page = ref(1);
const list = ref([]);
const count = ref(0);
//
const downloadRecord = (record) => {
uni.showLoading({
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({
url: record.result_url,
// url:'https://ksdt-1255846884.cos.ap-shanghai.myqcloud.com/lift-result/2025/09/24/d6180add4cd94875a1854a4febce8966.pdf',
success: (res) => {
console.log(res)
console.log(res);
if (res.statusCode === 200) {
uni.saveFile({
tempFilePath: res.tempFilePath,
success: () => {
uni.hideLoading();
uni.showToast({
title: '下载成功',
icon: 'success'
})
}
})
}
title: "下载成功",
icon: "success",
});
},
fail: () => {
uni.hideLoading();
uni.showToast({
title: '下载失败',
icon: 'none'
})
title: "保存失败",
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 () => {
loadingStatus.value === 'loading'
RPC.post('/planned_list',{page:page.value,page_size:20}).then(res => {
list.value = [...list.value, ...res.list]
count.value = res.total
loadingStatus.value === "loading";
RPC.post("/planned_list", { page: page.value, page_size: 20 })
.then((res) => {
list.value = [...list.value, ...res.list];
count.value = res.total;
if (list.value.length >= count.value) {
loadingStatus.value = 'nomore'
loadingStatus.value = "nomore";
} else {
loadingStatus.value = 'loadmore'
loadingStatus.value = "loadmore";
}
}).catch(() => {
loadingStatus.value = 'loadmore'
})
.catch(() => {
loadingStatus.value = "loadmore";
});
};
//
onPullDownRefresh(() => {
list.value = []
page.value = 1
loadingStatus.value === 'loading'
RPC.post('/planned_list',{page:page.value,page_size:20}).then(res => {
list.value = [...list.value, ...res.list]
count.value = res.total
list.value = [];
page.value = 1;
loadingStatus.value === "loading";
RPC.post("/planned_list", { page: page.value, page_size: 20 })
.then((res) => {
list.value = [...list.value, ...res.list];
count.value = res.total;
if (list.value.length >= count.value) {
loadingStatus.value = 'nomore'
loadingStatus.value = "nomore";
} else {
loadingStatus.value = 'loadmore'
loadingStatus.value = "loadmore";
}
}).catch(() => {
loadingStatus.value = 'loadmore'
}).finally(() => {
uni.stopPullDownRefresh()
})
.catch(() => {
loadingStatus.value = "loadmore";
})
.finally(() => {
uni.stopPullDownRefresh();
});
});
onReachBottom(() => {
loadmore()
})
loadmore();
});
const loadmore = () => {
if (list.value.length >= count.value || loadingStatus.value === 'loading') return
console.log('上拉加载:')
loadingStatus.value = 'loading';
if (list.value.length >= count.value || loadingStatus.value === "loading")
return;
console.log("上拉加载:");
loadingStatus.value = "loading";
page.value = ++page.value;
loadRecords()
}
loadRecords();
};
onShow(() => {
//
list.value = []
page.value = 1
list.value = [];
page.value = 1;
loadRecords();
});
</script>

Loading…
Cancel
Save