feat: 新增账期价格初审列表
This commit is contained in:
parent
531100b20d
commit
d6c01136fc
11
api/AccountPricePreliminaryRreview.js
Normal file
11
api/AccountPricePreliminaryRreview.js
Normal file
@ -0,0 +1,11 @@
|
|||||||
|
import request from '@/utils/request'
|
||||||
|
|
||||||
|
// 获取地域列表
|
||||||
|
export const getPricePreliminaryReviewList = (data, query) => {
|
||||||
|
return request({
|
||||||
|
method: 'post',
|
||||||
|
url: '/bussiness/baseusercredithistory/credit-period-initial-review-list',
|
||||||
|
data,
|
||||||
|
params: query
|
||||||
|
})
|
||||||
|
}
|
||||||
14
pages.json
14
pages.json
@ -163,6 +163,20 @@
|
|||||||
"navigationBarTitleText": "订单综合查询",
|
"navigationBarTitleText": "订单综合查询",
|
||||||
"props": true
|
"props": true
|
||||||
}
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"path": "pages/work/AccountPricePreliminaryRreview/index",
|
||||||
|
"style": {
|
||||||
|
"navigationBarTitleText": "账期价格初审",
|
||||||
|
"props": true
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"path": "pages/work/AccountPriceFinallReview/index",
|
||||||
|
"style": {
|
||||||
|
"navigationBarTitleText": "账期价格复审",
|
||||||
|
"props": true
|
||||||
|
}
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"tabBar": {
|
"tabBar": {
|
||||||
|
|||||||
84
pages/work/AccountPricePreliminaryRreview/index.vue
Normal file
84
pages/work/AccountPricePreliminaryRreview/index.vue
Normal file
@ -0,0 +1,84 @@
|
|||||||
|
<template>
|
||||||
|
<view class="container">
|
||||||
|
<MBCard>
|
||||||
|
<uni-forms ref="baseForm" :modelValue="queryParams">
|
||||||
|
<uni-forms-item label="地域">
|
||||||
|
<Area v-model="queryParams.deptId" @change="handleQuery"/>
|
||||||
|
</uni-forms-item>
|
||||||
|
<uni-forms-item label="商业公司">
|
||||||
|
<BusinessCompany
|
||||||
|
v-model="queryParams.businessName"
|
||||||
|
@change="handleQuery"
|
||||||
|
/>
|
||||||
|
</uni-forms-item>
|
||||||
|
</uni-forms>
|
||||||
|
</MBCard>
|
||||||
|
|
||||||
|
|
||||||
|
<uni-table ref="table" :loading="loading" emptyText="暂无更多数据" stripe>
|
||||||
|
<uni-tr>
|
||||||
|
<uni-th align="center" width="50">序号</uni-th>
|
||||||
|
<uni-th align="left" width="180">公司名称</uni-th>
|
||||||
|
<uni-th align="left" width="50">地域</uni-th>
|
||||||
|
<uni-th width="100">账期审核</uni-th>
|
||||||
|
<uni-th width="100">额度审核</uni-th>
|
||||||
|
<uni-th width="100">价格审核</uni-th>
|
||||||
|
</uni-tr>
|
||||||
|
<uni-tr v-for="(item, index) in tableData" :key="index">
|
||||||
|
<uni-td>{{ index + 1 }}</uni-td>
|
||||||
|
<uni-td>{{ item.userName }}</uni-td>
|
||||||
|
<uni-td>{{ item.areaName }}</uni-td>
|
||||||
|
<uni-td>
|
||||||
|
<view v-if="item.zhangqi > 0">
|
||||||
|
<button class="uni-button" size="mini" type="submit">编辑</button>
|
||||||
|
</view>
|
||||||
|
</uni-td>
|
||||||
|
<uni-td>
|
||||||
|
<view v-if="item.edu > 0">
|
||||||
|
<button class="uni-button" size="mini" type="submit">编辑</button>
|
||||||
|
</view>
|
||||||
|
</uni-td>
|
||||||
|
<uni-td>
|
||||||
|
<view v-if="item.bg > 0">
|
||||||
|
<button class="uni-button" size="mini" type="submit">编辑</button>
|
||||||
|
</view>
|
||||||
|
</uni-td>
|
||||||
|
</uni-tr>
|
||||||
|
</uni-table>
|
||||||
|
|
||||||
|
</view>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<script setup>
|
||||||
|
import {defineOptions, onMounted, ref} from "vue"
|
||||||
|
import Area from "../../../components/Area.vue";
|
||||||
|
import MBCard from "../../../components/MB/MBCard.vue";
|
||||||
|
import UniFormsItem from "../../../uni_modules/uni-forms/components/uni-forms-item/uni-forms-item.vue";
|
||||||
|
import BusinessCompany from "../../../components/BusinessCompany.vue";
|
||||||
|
import UniForms from "../../../uni_modules/uni-forms/components/uni-forms/uni-forms.vue";
|
||||||
|
import {getPricePreliminaryReviewList} from "../../../api/AccountPricePreliminaryRreview";
|
||||||
|
|
||||||
|
defineOptions({
|
||||||
|
name: "AccountPricePreliminaryRreview"
|
||||||
|
})
|
||||||
|
|
||||||
|
const loading = ref(true)
|
||||||
|
const queryParams = ref({})
|
||||||
|
const tableData = ref([])
|
||||||
|
const total = ref(0)
|
||||||
|
const paging = ref({
|
||||||
|
pageNum: 1,
|
||||||
|
pageSize: 100,
|
||||||
|
})
|
||||||
|
|
||||||
|
const handleQuery = async () => {
|
||||||
|
const data = await getPricePreliminaryReviewList(queryParams.value, paging.value)
|
||||||
|
tableData.value = data.rows
|
||||||
|
total.value = data.total
|
||||||
|
loading.value = false
|
||||||
|
}
|
||||||
|
|
||||||
|
onMounted(async () => {
|
||||||
|
await handleQuery()
|
||||||
|
})
|
||||||
|
</script>
|
||||||
126
utils/utils.js
126
utils/utils.js
@ -6,13 +6,13 @@ import {securityFileDownload} from '@/api/FileUpload/FileUpload.js'
|
|||||||
|
|
||||||
// 移动端文件预览优化版 - H5兼容修复
|
// 移动端文件预览优化版 - H5兼容修复
|
||||||
export const YuLanfile = async (filePath) => {
|
export const YuLanfile = async (filePath) => {
|
||||||
|
|
||||||
uni.showToast({
|
uni.showToast({
|
||||||
title: '预览还在开发完善中!!',
|
title: '预览还在开发完善中!!',
|
||||||
icon: 'none',
|
icon: 'none',
|
||||||
duration: 2000
|
duration: 2000
|
||||||
})
|
})
|
||||||
return false;
|
return false;
|
||||||
console.log("预览文件:", filePath)
|
console.log("预览文件:", filePath)
|
||||||
if (!filePath) {
|
if (!filePath) {
|
||||||
uni.showToast({
|
uni.showToast({
|
||||||
@ -21,25 +21,25 @@ export const YuLanfile = async (filePath) => {
|
|||||||
});
|
});
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
uni.showLoading({
|
uni.showLoading({
|
||||||
title: '正在加载文件...',
|
title: '正在加载文件...',
|
||||||
mask: true
|
mask: true
|
||||||
});
|
});
|
||||||
|
|
||||||
const response = await securityFileDownload({
|
const response = await securityFileDownload({
|
||||||
fileName: filePath,
|
fileName: filePath,
|
||||||
delete: false
|
delete: false
|
||||||
});
|
});
|
||||||
|
|
||||||
const fileExtension = filePath.split('.').pop().toLowerCase();
|
const fileExtension = filePath.split('.').pop().toLowerCase();
|
||||||
const fileName = filePath.split('\\').pop() || 'preview.' + fileExtension;
|
const fileName = filePath.split('\\').pop() || 'preview.' + fileExtension;
|
||||||
|
|
||||||
// 判断运行环境
|
// 判断运行环境
|
||||||
const platform = getPlatform();
|
const platform = getPlatform();
|
||||||
console.log('当前平台:', platform);
|
console.log('当前平台:', platform);
|
||||||
|
|
||||||
// 根据平台和文件类型选择预览方式
|
// 根据平台和文件类型选择预览方式
|
||||||
if (['jpg', 'jpeg', 'png', 'gif', 'bmp', 'webp'].includes(fileExtension)) {
|
if (['jpg', 'jpeg', 'png', 'gif', 'bmp', 'webp'].includes(fileExtension)) {
|
||||||
await previewImage(response, fileExtension, fileName, platform);
|
await previewImage(response, fileExtension, fileName, platform);
|
||||||
@ -48,9 +48,9 @@ export const YuLanfile = async (filePath) => {
|
|||||||
} else {
|
} else {
|
||||||
await handleOtherFile(response, fileName, fileExtension, platform);
|
await handleOtherFile(response, fileName, fileExtension, platform);
|
||||||
}
|
}
|
||||||
|
|
||||||
uni.hideLoading();
|
uni.hideLoading();
|
||||||
|
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error('预览失败:', error);
|
console.error('预览失败:', error);
|
||||||
uni.hideLoading();
|
uni.hideLoading();
|
||||||
@ -78,10 +78,10 @@ const getPlatform = () => {
|
|||||||
// 图片预览
|
// 图片预览
|
||||||
const previewImage = async (response, fileExtension, fileName, platform) => {
|
const previewImage = async (response, fileExtension, fileName, platform) => {
|
||||||
return new Promise((resolve, reject) => {
|
return new Promise((resolve, reject) => {
|
||||||
const blob = new Blob([response], {
|
const blob = new Blob([response], {
|
||||||
type: `image/${fileExtension === 'jpg' ? 'jpeg' : fileExtension}`
|
type: `image/${fileExtension === 'jpg' ? 'jpeg' : fileExtension}`
|
||||||
});
|
});
|
||||||
|
|
||||||
// H5环境 - 使用简单可靠的方式
|
// H5环境 - 使用简单可靠的方式
|
||||||
if (platform === 'h5') {
|
if (platform === 'h5') {
|
||||||
const blobUrl = URL.createObjectURL(blob);
|
const blobUrl = URL.createObjectURL(blob);
|
||||||
@ -89,7 +89,7 @@ const previewImage = async (response, fileExtension, fileName, platform) => {
|
|||||||
showImageModalH5(blobUrl, fileName, resolve);
|
showImageModalH5(blobUrl, fileName, resolve);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// App环境
|
// App环境
|
||||||
if (platform === 'app') {
|
if (platform === 'app') {
|
||||||
const reader = new FileReader();
|
const reader = new FileReader();
|
||||||
@ -110,7 +110,7 @@ const previewImage = async (response, fileExtension, fileName, platform) => {
|
|||||||
reader.readAsDataURL(blob);
|
reader.readAsDataURL(blob);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// 微信小程序环境
|
// 微信小程序环境
|
||||||
if (platform === 'weixin') {
|
if (platform === 'weixin') {
|
||||||
const reader = new FileReader();
|
const reader = new FileReader();
|
||||||
@ -143,7 +143,7 @@ const showImageModalH5 = (imageUrl, fileName, resolve) => {
|
|||||||
if (existingModal) {
|
if (existingModal) {
|
||||||
document.body.removeChild(existingModal);
|
document.body.removeChild(existingModal);
|
||||||
}
|
}
|
||||||
|
|
||||||
const modal = document.createElement('div');
|
const modal = document.createElement('div');
|
||||||
modal.id = 'h5-preview-modal';
|
modal.id = 'h5-preview-modal';
|
||||||
modal.style.cssText = `
|
modal.style.cssText = `
|
||||||
@ -159,7 +159,7 @@ const showImageModalH5 = (imageUrl, fileName, resolve) => {
|
|||||||
align-items: center;
|
align-items: center;
|
||||||
flex-direction: column;
|
flex-direction: column;
|
||||||
`;
|
`;
|
||||||
|
|
||||||
const header = document.createElement('div');
|
const header = document.createElement('div');
|
||||||
header.style.cssText = `
|
header.style.cssText = `
|
||||||
position: absolute;
|
position: absolute;
|
||||||
@ -179,7 +179,7 @@ const showImageModalH5 = (imageUrl, fileName, resolve) => {
|
|||||||
<span style="font-size: 16px; color: white;">${fileName}</span>
|
<span style="font-size: 16px; color: white;">${fileName}</span>
|
||||||
<span style="font-size: 30px; cursor: pointer; color: white; padding: 0 10px;">×</span>
|
<span style="font-size: 30px; cursor: pointer; color: white; padding: 0 10px;">×</span>
|
||||||
`;
|
`;
|
||||||
|
|
||||||
const img = document.createElement('img');
|
const img = document.createElement('img');
|
||||||
img.src = imageUrl;
|
img.src = imageUrl;
|
||||||
img.style.cssText = `
|
img.style.cssText = `
|
||||||
@ -187,14 +187,14 @@ const showImageModalH5 = (imageUrl, fileName, resolve) => {
|
|||||||
max-height: 100%;
|
max-height: 100%;
|
||||||
object-fit: contain;
|
object-fit: contain;
|
||||||
`;
|
`;
|
||||||
|
|
||||||
// 关闭按钮点击
|
// 关闭按钮点击
|
||||||
header.querySelector('span:last-child').onclick = () => {
|
header.querySelector('span:last-child').onclick = () => {
|
||||||
document.body.removeChild(modal);
|
document.body.removeChild(modal);
|
||||||
URL.revokeObjectURL(imageUrl);
|
URL.revokeObjectURL(imageUrl);
|
||||||
resolve();
|
resolve();
|
||||||
};
|
};
|
||||||
|
|
||||||
// 点击背景关闭
|
// 点击背景关闭
|
||||||
modal.onclick = (e) => {
|
modal.onclick = (e) => {
|
||||||
if (e.target === modal) {
|
if (e.target === modal) {
|
||||||
@ -203,7 +203,7 @@ const showImageModalH5 = (imageUrl, fileName, resolve) => {
|
|||||||
resolve();
|
resolve();
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
// 按ESC关闭
|
// 按ESC关闭
|
||||||
const escHandler = (e) => {
|
const escHandler = (e) => {
|
||||||
if (e.key === 'Escape') {
|
if (e.key === 'Escape') {
|
||||||
@ -214,7 +214,7 @@ const showImageModalH5 = (imageUrl, fileName, resolve) => {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
document.addEventListener('keydown', escHandler);
|
document.addEventListener('keydown', escHandler);
|
||||||
|
|
||||||
modal.appendChild(header);
|
modal.appendChild(header);
|
||||||
modal.appendChild(img);
|
modal.appendChild(img);
|
||||||
document.body.appendChild(modal);
|
document.body.appendChild(modal);
|
||||||
@ -223,26 +223,26 @@ const showImageModalH5 = (imageUrl, fileName, resolve) => {
|
|||||||
// PDF预览
|
// PDF预览
|
||||||
const previewPDF = async (response, fileName, platform) => {
|
const previewPDF = async (response, fileName, platform) => {
|
||||||
return new Promise((resolve, reject) => {
|
return new Promise((resolve, reject) => {
|
||||||
const blob = new Blob([response], { type: 'application/pdf' });
|
const blob = new Blob([response], {type: 'application/pdf'});
|
||||||
|
|
||||||
// H5环境
|
// H5环境
|
||||||
if (platform === 'h5') {
|
if (platform === 'h5') {
|
||||||
const blobUrl = URL.createObjectURL(blob);
|
const blobUrl = URL.createObjectURL(blob);
|
||||||
showPDFModalH5(blobUrl, fileName, resolve);
|
showPDFModalH5(blobUrl, fileName, resolve);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// App环境
|
// App环境
|
||||||
if (platform === 'app') {
|
if (platform === 'app') {
|
||||||
const reader = new FileReader();
|
const reader = new FileReader();
|
||||||
reader.onload = (e) => {
|
reader.onload = (e) => {
|
||||||
const arrayBuffer = e.target.result;
|
const arrayBuffer = e.target.result;
|
||||||
const base64Data = arrayBufferToBase64(arrayBuffer);
|
const base64Data = arrayBufferToBase64(arrayBuffer);
|
||||||
|
|
||||||
plus.io.requestFileSystem(plus.io.PRIVATE_DOC, function(fs) {
|
plus.io.requestFileSystem(plus.io.PRIVATE_DOC, function (fs) {
|
||||||
fs.root.getFile(fileName, {create: true}, function(fileEntry) {
|
fs.root.getFile(fileName, {create: true}, function (fileEntry) {
|
||||||
fileEntry.createWriter(function(writer) {
|
fileEntry.createWriter(function (writer) {
|
||||||
writer.onwrite = function() {
|
writer.onwrite = function () {
|
||||||
plus.runtime.openFile(fileEntry.toLocalURL());
|
plus.runtime.openFile(fileEntry.toLocalURL());
|
||||||
resolve();
|
resolve();
|
||||||
};
|
};
|
||||||
@ -255,14 +255,14 @@ const previewPDF = async (response, fileName, platform) => {
|
|||||||
reader.readAsArrayBuffer(blob);
|
reader.readAsArrayBuffer(blob);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// 微信小程序环境
|
// 微信小程序环境
|
||||||
if (platform === 'weixin') {
|
if (platform === 'weixin') {
|
||||||
const reader = new FileReader();
|
const reader = new FileReader();
|
||||||
reader.onload = (e) => {
|
reader.onload = (e) => {
|
||||||
const arrayBuffer = e.target.result;
|
const arrayBuffer = e.target.result;
|
||||||
const base64Data = arrayBufferToBase64(arrayBuffer);
|
const base64Data = arrayBufferToBase64(arrayBuffer);
|
||||||
|
|
||||||
wx.getFileSystemManager().writeFile({
|
wx.getFileSystemManager().writeFile({
|
||||||
filePath: wx.env.USER_DATA_PATH + '/' + fileName,
|
filePath: wx.env.USER_DATA_PATH + '/' + fileName,
|
||||||
data: base64Data,
|
data: base64Data,
|
||||||
@ -289,7 +289,7 @@ const showPDFModalH5 = (pdfUrl, fileName, resolve) => {
|
|||||||
if (existingModal) {
|
if (existingModal) {
|
||||||
document.body.removeChild(existingModal);
|
document.body.removeChild(existingModal);
|
||||||
}
|
}
|
||||||
|
|
||||||
const modal = document.createElement('div');
|
const modal = document.createElement('div');
|
||||||
modal.id = 'h5-preview-modal';
|
modal.id = 'h5-preview-modal';
|
||||||
modal.style.cssText = `
|
modal.style.cssText = `
|
||||||
@ -303,7 +303,7 @@ const showPDFModalH5 = (pdfUrl, fileName, resolve) => {
|
|||||||
display: flex;
|
display: flex;
|
||||||
flex-direction: column;
|
flex-direction: column;
|
||||||
`;
|
`;
|
||||||
|
|
||||||
const header = document.createElement('div');
|
const header = document.createElement('div');
|
||||||
header.style.cssText = `
|
header.style.cssText = `
|
||||||
height: 50px;
|
height: 50px;
|
||||||
@ -318,7 +318,7 @@ const showPDFModalH5 = (pdfUrl, fileName, resolve) => {
|
|||||||
<span style="font-size: 16px; color: #333;">${fileName}</span>
|
<span style="font-size: 16px; color: #333;">${fileName}</span>
|
||||||
<span style="font-size: 30px; color: #999; cursor: pointer; padding: 0 10px;">×</span>
|
<span style="font-size: 30px; color: #999; cursor: pointer; padding: 0 10px;">×</span>
|
||||||
`;
|
`;
|
||||||
|
|
||||||
const iframe = document.createElement('iframe');
|
const iframe = document.createElement('iframe');
|
||||||
iframe.src = pdfUrl;
|
iframe.src = pdfUrl;
|
||||||
iframe.style.cssText = `
|
iframe.style.cssText = `
|
||||||
@ -326,14 +326,14 @@ const showPDFModalH5 = (pdfUrl, fileName, resolve) => {
|
|||||||
flex: 1;
|
flex: 1;
|
||||||
border: none;
|
border: none;
|
||||||
`;
|
`;
|
||||||
|
|
||||||
// 关闭按钮
|
// 关闭按钮
|
||||||
header.querySelector('span:last-child').onclick = () => {
|
header.querySelector('span:last-child').onclick = () => {
|
||||||
document.body.removeChild(modal);
|
document.body.removeChild(modal);
|
||||||
URL.revokeObjectURL(pdfUrl);
|
URL.revokeObjectURL(pdfUrl);
|
||||||
resolve();
|
resolve();
|
||||||
};
|
};
|
||||||
|
|
||||||
// 按ESC关闭
|
// 按ESC关闭
|
||||||
const escHandler = (e) => {
|
const escHandler = (e) => {
|
||||||
if (e.key === 'Escape') {
|
if (e.key === 'Escape') {
|
||||||
@ -344,7 +344,7 @@ const showPDFModalH5 = (pdfUrl, fileName, resolve) => {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
document.addEventListener('keydown', escHandler);
|
document.addEventListener('keydown', escHandler);
|
||||||
|
|
||||||
modal.appendChild(header);
|
modal.appendChild(header);
|
||||||
modal.appendChild(iframe);
|
modal.appendChild(iframe);
|
||||||
document.body.appendChild(modal);
|
document.body.appendChild(modal);
|
||||||
@ -375,7 +375,7 @@ const handleOtherFile = async (response, fileName, fileExtension, platform) => {
|
|||||||
const openWithDefaultApp = (response, fileName, fileExtension, platform) => {
|
const openWithDefaultApp = (response, fileName, fileExtension, platform) => {
|
||||||
return new Promise((resolve, reject) => {
|
return new Promise((resolve, reject) => {
|
||||||
const blob = new Blob([response]);
|
const blob = new Blob([response]);
|
||||||
|
|
||||||
// H5环境
|
// H5环境
|
||||||
if (platform === 'h5') {
|
if (platform === 'h5') {
|
||||||
const blobUrl = URL.createObjectURL(blob);
|
const blobUrl = URL.createObjectURL(blob);
|
||||||
@ -391,18 +391,18 @@ const openWithDefaultApp = (response, fileName, fileExtension, platform) => {
|
|||||||
resolve();
|
resolve();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// App环境
|
// App环境
|
||||||
if (platform === 'app') {
|
if (platform === 'app') {
|
||||||
const reader = new FileReader();
|
const reader = new FileReader();
|
||||||
reader.onload = (e) => {
|
reader.onload = (e) => {
|
||||||
const arrayBuffer = e.target.result;
|
const arrayBuffer = e.target.result;
|
||||||
const base64Data = arrayBufferToBase64(arrayBuffer);
|
const base64Data = arrayBufferToBase64(arrayBuffer);
|
||||||
|
|
||||||
plus.io.requestFileSystem(plus.io.PRIVATE_DOC, function(fs) {
|
plus.io.requestFileSystem(plus.io.PRIVATE_DOC, function (fs) {
|
||||||
fs.root.getFile(fileName, {create: true}, function(fileEntry) {
|
fs.root.getFile(fileName, {create: true}, function (fileEntry) {
|
||||||
fileEntry.createWriter(function(writer) {
|
fileEntry.createWriter(function (writer) {
|
||||||
writer.onwrite = function() {
|
writer.onwrite = function () {
|
||||||
plus.runtime.openFile(fileEntry.toLocalURL());
|
plus.runtime.openFile(fileEntry.toLocalURL());
|
||||||
resolve();
|
resolve();
|
||||||
};
|
};
|
||||||
@ -415,14 +415,14 @@ const openWithDefaultApp = (response, fileName, fileExtension, platform) => {
|
|||||||
reader.readAsArrayBuffer(blob);
|
reader.readAsArrayBuffer(blob);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// 微信小程序环境
|
// 微信小程序环境
|
||||||
if (platform === 'weixin') {
|
if (platform === 'weixin') {
|
||||||
const reader = new FileReader();
|
const reader = new FileReader();
|
||||||
reader.onload = (e) => {
|
reader.onload = (e) => {
|
||||||
const arrayBuffer = e.target.result;
|
const arrayBuffer = e.target.result;
|
||||||
const base64Data = arrayBufferToBase64(arrayBuffer);
|
const base64Data = arrayBufferToBase64(arrayBuffer);
|
||||||
|
|
||||||
wx.getFileSystemManager().writeFile({
|
wx.getFileSystemManager().writeFile({
|
||||||
filePath: wx.env.USER_DATA_PATH + '/' + fileName,
|
filePath: wx.env.USER_DATA_PATH + '/' + fileName,
|
||||||
data: base64Data,
|
data: base64Data,
|
||||||
@ -446,7 +446,7 @@ const openWithDefaultApp = (response, fileName, fileExtension, platform) => {
|
|||||||
const saveFile = (response, fileName, platform) => {
|
const saveFile = (response, fileName, platform) => {
|
||||||
return new Promise((resolve, reject) => {
|
return new Promise((resolve, reject) => {
|
||||||
const blob = new Blob([response]);
|
const blob = new Blob([response]);
|
||||||
|
|
||||||
// H5环境
|
// H5环境
|
||||||
if (platform === 'h5') {
|
if (platform === 'h5') {
|
||||||
const blobUrl = URL.createObjectURL(blob);
|
const blobUrl = URL.createObjectURL(blob);
|
||||||
@ -462,18 +462,18 @@ const saveFile = (response, fileName, platform) => {
|
|||||||
resolve();
|
resolve();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// App环境
|
// App环境
|
||||||
if (platform === 'app') {
|
if (platform === 'app') {
|
||||||
const reader = new FileReader();
|
const reader = new FileReader();
|
||||||
reader.onload = (e) => {
|
reader.onload = (e) => {
|
||||||
const arrayBuffer = e.target.result;
|
const arrayBuffer = e.target.result;
|
||||||
const base64Data = arrayBufferToBase64(arrayBuffer);
|
const base64Data = arrayBufferToBase64(arrayBuffer);
|
||||||
|
|
||||||
plus.io.requestFileSystem(plus.io.PRIVATE_DOC, function(fs) {
|
plus.io.requestFileSystem(plus.io.PRIVATE_DOC, function (fs) {
|
||||||
fs.root.getFile(fileName, {create: true}, function(fileEntry) {
|
fs.root.getFile(fileName, {create: true}, function (fileEntry) {
|
||||||
fileEntry.createWriter(function(writer) {
|
fileEntry.createWriter(function (writer) {
|
||||||
writer.onwrite = function() {
|
writer.onwrite = function () {
|
||||||
uni.showToast({
|
uni.showToast({
|
||||||
title: '保存成功',
|
title: '保存成功',
|
||||||
icon: 'success'
|
icon: 'success'
|
||||||
@ -489,14 +489,14 @@ const saveFile = (response, fileName, platform) => {
|
|||||||
reader.readAsArrayBuffer(blob);
|
reader.readAsArrayBuffer(blob);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// 微信小程序环境
|
// 微信小程序环境
|
||||||
if (platform === 'weixin') {
|
if (platform === 'weixin') {
|
||||||
const reader = new FileReader();
|
const reader = new FileReader();
|
||||||
reader.onload = (e) => {
|
reader.onload = (e) => {
|
||||||
const arrayBuffer = e.target.result;
|
const arrayBuffer = e.target.result;
|
||||||
const base64Data = arrayBufferToBase64(arrayBuffer);
|
const base64Data = arrayBufferToBase64(arrayBuffer);
|
||||||
|
|
||||||
wx.getFileSystemManager().writeFile({
|
wx.getFileSystemManager().writeFile({
|
||||||
filePath: wx.env.USER_DATA_PATH + '/' + fileName,
|
filePath: wx.env.USER_DATA_PATH + '/' + fileName,
|
||||||
data: base64Data,
|
data: base64Data,
|
||||||
@ -542,4 +542,10 @@ const getMimeType = (extension) => {
|
|||||||
'txt': 'text/plain'
|
'txt': 'text/plain'
|
||||||
};
|
};
|
||||||
return mimeTypes[extension] || 'application/octet-stream';
|
return mimeTypes[extension] || 'application/octet-stream';
|
||||||
|
}
|
||||||
|
|
||||||
|
export const navigateTo = (path) => {
|
||||||
|
uni.navigateTo({
|
||||||
|
url: path
|
||||||
|
})
|
||||||
}
|
}
|
||||||
Loading…
x
Reference in New Issue
Block a user