diff --git a/pages.json b/pages.json
index 28bf52c..9798a1a 100644
--- a/pages.json
+++ b/pages.json
@@ -58,8 +58,8 @@
{
"path": "pages/submit-task/index",
"style": {
- "navigationBarTitleText": "提交详情",
- "navigationStyle": "custom"
+ "navigationBarTitleText": "提交详情"
+
}
}
],
diff --git a/pages/submit-task/index.vue b/pages/submit-task/index.vue
index 0a47497..306b020 100644
--- a/pages/submit-task/index.vue
+++ b/pages/submit-task/index.vue
@@ -1,19 +1,17 @@
+
-
-
- ✕
- 提交详情
-
-
-
+
+
+
+
- 📄⚙️
+
+
@@ -78,7 +77,7 @@
选择任务进度
{{ progress }}%
@@ -177,9 +176,10 @@ const onProgressChange = (e) => {
tempProgress.value = e.detail.value;
};
-// 选择进度
+// 选择进度(点击按钮直接确认)
const selectProgress = (progress) => {
- tempProgress.value = progress;
+ formData.value.progress = progress;
+ showProgressPicker.value = false;
};
// 确认进度
@@ -220,57 +220,128 @@ const removeImage = (index) => {
formData.value.images.splice(index, 1);
};
-// 选择文件
+// 选择文件(安卓平台)
const chooseFiles = () => {
- // #ifdef H5 || APP-PLUS
- uni.showActionSheet({
- itemList: ['从相册选择', '拍照'],
- success: (res) => {
- if (res.tapIndex === 0) {
- // 从相册选择
- uni.chooseImage({
- count: 9,
- success: (res) => {
- // 将图片转换为文件格式
- const files = res.tempFilePaths.map((path, index) => ({
- name: `image_${Date.now()}_${index}.jpg`,
- path: path,
- size: 0
- }));
- formData.value.files = [...formData.value.files, ...files];
+ const remainingCount = 5 - formData.value.files.length;
+ if (remainingCount <= 0) {
+ uni.showToast({
+ title: '最多只能添加5个文件',
+ icon: 'none'
+ });
+ return;
+ }
+
+ // 安卓平台使用 plus API 调用原生文件选择器
+ if (typeof plus !== 'undefined') {
+ try {
+ const Intent = plus.android.importClass('android.content.Intent');
+ const main = plus.android.runtimeMainActivity();
+
+ // 创建文件选择 Intent
+ const intent = new Intent(Intent.ACTION_GET_CONTENT);
+ intent.setType('*/*');
+ intent.addCategory(Intent.CATEGORY_OPENABLE);
+ intent.putExtra(Intent.EXTRA_ALLOW_MULTIPLE, true); // 允许多选
+
+ // 启动文件选择器
+ main.startActivityForResult(intent, 1001);
+
+ // 监听文件选择结果
+ const originalOnActivityResult = main.onActivityResult;
+ main.onActivityResult = (requestCode, resultCode, data) => {
+ if (requestCode === 1001) {
+ if (resultCode === -1 && data) { // RESULT_OK = -1
+ try {
+ const clipData = data.getClipData();
+ const files = [];
+
+ // 获取文件名的方法
+ const getFileName = (uri) => {
+ try {
+ const cursor = main.getContentResolver().query(uri, null, null, null, null);
+ if (cursor && cursor.moveToFirst()) {
+ const nameIndex = cursor.getColumnIndex('_display_name');
+ if (nameIndex !== -1) {
+ const fileName = cursor.getString(nameIndex);
+ cursor.close();
+ return fileName;
+ }
+ cursor.close();
+ }
+ } catch (e) {
+ console.error('获取文件名失败:', e);
+ }
+ return null;
+ };
+
+ if (clipData) {
+ // 多选文件
+ const count = clipData.getItemCount();
+ for (let i = 0; i < count && files.length < remainingCount; i++) {
+ const item = clipData.getItemAt(i);
+ const uri = item.getUri();
+ const uriString = uri.toString();
+
+ // 获取文件名
+ let fileName = getFileName(uri) || `file_${Date.now()}_${i}`;
+
+ files.push({
+ name: fileName,
+ path: uriString, // 保存 URI 字符串
+ size: 0
+ });
+ }
+ } else {
+ // 单选文件
+ const uri = data.getData();
+ if (uri) {
+ const uriString = uri.toString();
+ let fileName = getFileName(uri) || `file_${Date.now()}`;
+
+ files.push({
+ name: fileName,
+ path: uriString, // 保存 URI 字符串
+ size: 0
+ });
+ }
+ }
+
+ if (files.length > 0) {
+ formData.value.files = [...formData.value.files, ...files];
+ }
+
+ // 恢复原始的 onActivityResult
+ if (originalOnActivityResult) {
+ main.onActivityResult = originalOnActivityResult;
+ }
+ } catch (error) {
+ console.error('处理文件选择结果失败:', error);
+ uni.showToast({
+ title: '处理文件失败',
+ icon: 'none'
+ });
+ }
}
- });
- } else {
- uni.showToast({
- title: '暂不支持文件选择',
- icon: 'none'
- });
- }
- }
- });
- // #endif
-
- // #ifdef MP
- uni.chooseFile({
- count: 5 - formData.value.files.length,
- type: 'file',
- success: (res) => {
- const files = res.tempFiles.map(file => ({
- name: file.name || `file_${Date.now()}.${file.path.split('.').pop()}`,
- path: file.path,
- size: file.size
- }));
- formData.value.files = [...formData.value.files, ...files];
- },
- fail: (err) => {
- console.error('选择文件失败:', err);
+ } else {
+ // 调用原始的 onActivityResult
+ if (originalOnActivityResult) {
+ originalOnActivityResult(requestCode, resultCode, data);
+ }
+ }
+ };
+ } catch (error) {
+ console.error('打开文件选择器失败:', error);
uni.showToast({
- title: '选择文件失败',
+ title: '文件选择功能暂不可用',
icon: 'none'
});
}
- });
- // #endif
+ } else {
+ uni.showToast({
+ title: '当前环境不支持文件选择',
+ icon: 'none'
+ });
+ }
};
// 删除文件
@@ -278,6 +349,20 @@ const removeFile = (index) => {
formData.value.files.splice(index, 1);
};
+// 格式化时间为中文格式:年月日星期几时分秒
+const formatTimeToChinese = (date) => {
+ const weekdays = ['星期日', '星期一', '星期二', '星期三', '星期四', '星期五', '星期六'];
+ const year = date.getFullYear();
+ const month = String(date.getMonth() + 1).padStart(2, '0');
+ const day = String(date.getDate()).padStart(2, '0');
+ const weekday = weekdays[date.getDay()];
+ const hour = String(date.getHours()).padStart(2, '0');
+ const minute = String(date.getMinutes()).padStart(2, '0');
+ const second = String(date.getSeconds()).padStart(2, '0');
+
+ return `${year}年${month}月${day}日 ${weekday} ${hour}:${minute}:${second}`;
+};
+
// 提交任务
const handleSubmit = () => {
if (!canSubmit.value) {
@@ -326,14 +411,7 @@ const handleSubmit = () => {
// 提交成功后,将数据传递回任务详情页
const submitRecord = {
userName: '当前用户', // TODO: 从用户信息获取
- time: new Date().toLocaleString('zh-CN', {
- year: 'numeric',
- month: '2-digit',
- day: '2-digit',
- hour: '2-digit',
- minute: '2-digit',
- second: '2-digit'
- }).replace(/\//g, '-'),
+ time: formatTimeToChinese(new Date()),
content: submitData.description || '',
progress: submitData.progress,
attachments: [
@@ -406,7 +484,7 @@ const handleSubmit = () => {
/* 内容滚动区域 */
.content-scroll {
flex: 1;
- padding: 16px;
+
}
/* 表单项 */
diff --git a/pages/task-detail/index.vue b/pages/task-detail/index.vue
index 48498c5..44b4509 100644
--- a/pages/task-detail/index.vue
+++ b/pages/task-detail/index.vue
@@ -1,5 +1,5 @@
-
+
@@ -141,7 +141,7 @@
-
+