Browse Source

隐藏未开发的功能,支持上传图片/视频

fenbao
wangyx 1 month ago
parent
commit
80e1ef1357
  1. 34
      pages/tabBar/work/index.vue
  2. 28
      pagesA/checkout/detail/detail.vue
  3. 19
      pagesA/force/index/index.vue
  4. 20
      pagesA/release/detail/detail.vue
  5. 23
      pagesA/xjPage/xj.vue

34
pages/tabBar/work/index.vue

@ -22,7 +22,7 @@
</view> </view>
</view> </view>
<view class="conItem"> <view class="conItem" style="display: none;">
<view class="conItem-title">水电</view> <view class="conItem-title">水电</view>
<view class="conItem-cont"> <view class="conItem-cont">
<view class="conItem-cont-item" v-for="(item, index) in sdList" :key="index" @click="handelSdClick(item)"> <view class="conItem-cont-item" v-for="(item, index) in sdList" :key="index" @click="handelSdClick(item)">
@ -32,7 +32,7 @@
</view> </view>
</view> </view>
<view class="conItem"> <view class="conItem" style="display: none;">
<view class="conItem-title">报修</view> <view class="conItem-title">报修</view>
<view class="conItem-cont"> <view class="conItem-cont">
<view class="conItem-cont-item" v-for="(item, index) in bxList" :key="index"> <view class="conItem-cont-item" v-for="(item, index) in bxList" :key="index">
@ -42,7 +42,7 @@
</view> </view>
</view> </view>
<view class="conItem"> <view class="conItem" style="display: none;">
<view class="conItem-title">报事</view> <view class="conItem-title">报事</view>
<view class="conItem-cont"> <view class="conItem-cont">
<view class="conItem-cont-item" v-for="(item, index) in bsList" :key="index" @click="handleBsClick(item)"> <view class="conItem-cont-item" v-for="(item, index) in bsList" :key="index" @click="handleBsClick(item)">
@ -60,28 +60,28 @@ export default {
data () { data () {
return { return {
fyList: [ fyList: [
{ image: '/static/img/看房.png', text: '看房确认' }, // { image: '/static/img/.png', text: '' },
{ image: '/static/img/退房检查.png', text: '退房检查' }, { image: '/static/img/退房检查.png', text: '退房检查' },
{ image: '/static/img/释放.png', text: '释放房源检查' }, { image: '/static/img/释放.png', text: '释放房源检查' },
{ image: '/static/img/预约.png', text: '预约看房' }, // { image: '/static/img/.png', text: '' },
{ image: '/static/img/强制清退.png', text: '强制清退' }, { image: '/static/img/强制清退.png', text: '强制清退' },
], ],
xjList: [ xjList: [
{ image: '/static/img/巡查.png', text: '巡检上报' }, { image: '/static/img/巡查.png', text: '巡检上报' },
{ image: '/static/img/记录.png', text: '巡检记录' }, { image: '/static/img/记录.png', text: '巡检记录' },
], ],
sdList: [ // sdList: [
{ image: '/static/img/水费.png', text: '水量上报' }, // { image: '/static/img/.png', text: '' },
{ image: '/static/img/电费.png', text: '电量上报' }, // { image: '/static/img/.png', text: '' },
], // ],
bxList: [ // bxList: [
{ image: '/static/img/上报.png', text: '上报' }, // { image: '/static/img/.png', text: '' },
{ image: '/static/img/处理.png', text: '处理' }, // { image: '/static/img/.png', text: '' },
], // ],
bsList: [ // bsList: [
{ image: '/static/img/上报.png', text: '上报' }, // { image: '/static/img/.png', text: '' },
{ image: '/static/img/处理.png', text: '处理' }, // { image: '/static/img/.png', text: '' },
], // ],
} }
}, },

28
pagesA/checkout/detail/detail.vue

@ -105,7 +105,7 @@
@delete="onDelete" @delete="onDelete"
:disabled="true" :disabled="true"
> >
<view class="custom-upload-btn" @click.stop="chooseImage"> <view class="custom-upload-btn" @click.stop="chooseMedia">
<view class="icon-box"> <view class="icon-box">
<image <image
class="camera-icon" class="camera-icon"
@ -192,27 +192,36 @@ export default {
onDeviceChange(idx, val) { onDeviceChange(idx, val) {
this.deviceList[idx].status = val; this.deviceList[idx].status = val;
}, },
chooseImage() { chooseMedia() {
uni.chooseImage({ uni.chooseMedia({
count: 10 - this.fileList.length, count: 10 - this.fileList.length,
sizeType: ["original", "compressed"], mediaType: ["image", "video"],
sourceType: ["album", "camera"], sourceType: ["album", "camera"],
maxDuration: 60,
camera: "back",
success: async (res) => { success: async (res) => {
uni.showLoading({ title: "上传中...", mask: true }); uni.showLoading({ title: "上传中...", mask: true });
try { try {
const files = const files = res.tempFiles;
res.tempFiles || res.tempFilePaths.map((path) => ({ path }));
for (let i = 0; i < files.length; i++) { for (let i = 0; i < files.length; i++) {
const filePath = files[i].path; const file = files[i];
const filePath = file.tempFilePath;
const type = file.fileType || (filePath.match(/\.(mp4|mov|avi|wmv|flv|mkv)$/i) ? "video" : "image");
//
const uploadRes = await uploadImage(filePath); const uploadRes = await uploadImage(filePath);
this.fileList.push({ this.fileList.push({
url: uploadRes.data?.url || uploadRes.url || uploadRes.path, url: uploadRes.data?.url || uploadRes.url || uploadRes.path,
name: uploadRes.data?.name || uploadRes.name || "", name: uploadRes.data?.name || uploadRes.name || "",
type: uploadRes.data?.type || uploadRes.type || "image", type: type,
status: "success", status: "success",
}); });
} }
this.img1 = this.fileList.map((v) => v.url); // facilitiesCheckImages
this.facilitiesCheckImages = this.fileList.map((v) => ({
name: v.name || "",
format: v.type,
url: v.url,
}));
} catch (e) { } catch (e) {
uni.showToast({ title: "上传失败", icon: "none" }); uni.showToast({ title: "上传失败", icon: "none" });
} finally { } finally {
@ -229,7 +238,6 @@ export default {
this.$u.toast("请传10MB以内大小的图片/视频!"); this.$u.toast("请传10MB以内大小的图片/视频!");
return false; return false;
}, },
//
onDelete(event) { onDelete(event) {
this[`fileList${event.name}`].splice(event.index, 1); this[`fileList${event.name}`].splice(event.index, 1);
var arry = []; var arry = [];

19
pagesA/force/index/index.vue

@ -110,7 +110,7 @@
@delete="onDelete" @delete="onDelete"
:disabled="true" :disabled="true"
> >
<view class="custom-upload-btn" @click.stop="chooseImage"> <view class="custom-upload-btn" @click.stop="chooseMedia">
<view class="icon-box"> <view class="icon-box">
<image <image
class="camera-icon" class="camera-icon"
@ -230,23 +230,26 @@ export default {
(this.baseInfo.unitName = ""), (this.baseInfo.unitName = ""),
(this.baseInfo.roomTypeName = ""); (this.baseInfo.roomTypeName = "");
}, },
chooseImage() { chooseMedia() {
uni.chooseImage({ uni.chooseMedia({
count: 10 - this.fileList.length, count: 10 - this.fileList.length,
sizeType: ["original", "compressed"], mediaType: ["image", "video"],
sourceType: ["album", "camera"], sourceType: ["album", "camera"],
maxDuration: 60,
camera: "back",
success: async (res) => { success: async (res) => {
uni.showLoading({ title: "上传中...", mask: true }); uni.showLoading({ title: "上传中...", mask: true });
try { try {
const files = const files = res.tempFiles;
res.tempFiles || res.tempFilePaths.map((path) => ({ path }));
for (let i = 0; i < files.length; i++) { for (let i = 0; i < files.length; i++) {
const filePath = files[i].path; const file = files[i];
const filePath = file.tempFilePath;
const type = file.fileType || (filePath.match(/\.(mp4|mov|avi|wmv|flv|mkv)$/i) ? "video" : "image");
const uploadRes = await uploadImage(filePath); const uploadRes = await uploadImage(filePath);
this.fileList.push({ this.fileList.push({
url: uploadRes.data?.url || uploadRes.url || uploadRes.path, url: uploadRes.data?.url || uploadRes.url || uploadRes.path,
name: uploadRes.data?.name || uploadRes.name || "", name: uploadRes.data?.name || uploadRes.name || "",
type: uploadRes.data?.type || uploadRes.type || "image", type: type,
status: "success", status: "success",
}); });
} }

20
pagesA/release/detail/detail.vue

@ -86,7 +86,7 @@
@delete="onDelete" @delete="onDelete"
:disabled="true" :disabled="true"
> >
<view class="custom-upload-btn" @click.stop="chooseImage"> <view class="custom-upload-btn" @click.stop="chooseMedia">
<view class="icon-box"> <view class="icon-box">
<image <image
class="camera-icon" class="camera-icon"
@ -168,23 +168,27 @@ export default {
} }
}, },
methods: { methods: {
chooseImage() { chooseMedia() {
uni.chooseImage({ uni.chooseMedia({
count: 10 - this.fileList.length, count: 10 - this.fileList.length,
sizeType: ["original", "compressed"], mediaType: ["image", "video"],
sourceType: ["album", "camera"], sourceType: ["album", "camera"],
maxDuration: 60,
camera: "back",
success: async (res) => { success: async (res) => {
uni.showLoading({ title: "上传中...", mask: true }); uni.showLoading({ title: "上传中...", mask: true });
try { try {
const files = const files = res.tempFiles;
res.tempFiles || res.tempFilePaths.map((path) => ({ path }));
for (let i = 0; i < files.length; i++) { for (let i = 0; i < files.length; i++) {
const filePath = files[i].path; const file = files[i];
const filePath = file.tempFilePath;
const type = file.fileType || (filePath.match(/\.(mp4|mov|avi|wmv|flv|mkv)$/i) ? "video" : "image");
//
const uploadRes = await uploadImage(filePath); const uploadRes = await uploadImage(filePath);
this.fileList.push({ this.fileList.push({
url: uploadRes.data?.url || uploadRes.url || uploadRes.path, url: uploadRes.data?.url || uploadRes.url || uploadRes.path,
name: uploadRes.data?.name || uploadRes.name || "", name: uploadRes.data?.name || uploadRes.name || "",
type: uploadRes.data?.type || uploadRes.type || "image", type: type,
status: "success", status: "success",
}); });
} }

23
pagesA/xjPage/xj.vue

@ -92,7 +92,7 @@
@delete="onDelete" @delete="onDelete"
:disabled="true" :disabled="true"
> >
<view class="custom-upload-btn" @click.stop="chooseImage"> <view class="custom-upload-btn" @click.stop="chooseMedia">
<view class="icon-box"> <view class="icon-box">
<image <image
class="camera-icon" class="camera-icon"
@ -190,26 +190,27 @@ export default {
this.getDictType(); this.getDictType();
}, },
methods: { methods: {
chooseImage() { chooseMedia() {
uni.chooseImage({ uni.chooseMedia({
count: 10 - this.fileList.length, count: 10 - this.fileList.length,
sizeType: ["original", "compressed"], mediaType: ["image", "video"],
sourceType: ["album", "camera"], sourceType: ["album", "camera"],
maxDuration: 60,
camera: "back",
success: async (res) => { success: async (res) => {
uni.showLoading({ title: "上传中...", mask: true }); uni.showLoading({ title: "上传中...", mask: true });
try { try {
// H5 const files = res.tempFiles;
const files =
res.tempFiles || res.tempFilePaths.map((path) => ({ path }));
for (let i = 0; i < files.length; i++) { for (let i = 0; i < files.length; i++) {
const filePath = files[i].path; const file = files[i];
const filePath = file.tempFilePath;
const type = file.fileType || (filePath.match(/\.(mp4|mov|avi|wmv|flv|mkv)$/i) ? "video" : "image");
// //
const uploadRes = await uploadImage(filePath); const uploadRes = await uploadImage(filePath);
//
this.fileList.push({ this.fileList.push({
url: uploadRes.data?.url || uploadRes.url || uploadRes.path, // url: uploadRes.data?.url || uploadRes.url || uploadRes.path,
name: uploadRes.data?.name || uploadRes.name || "", name: uploadRes.data?.name || uploadRes.name || "",
type: uploadRes.data?.type || uploadRes.type || "image", type: type,
status: "success", status: "success",
}); });
} }

Loading…
Cancel
Save