|
@@ -20,17 +20,25 @@
|
|
|
图片上传
|
|
图片上传
|
|
|
<text class="font-10">最多5张图片</text>
|
|
<text class="font-10">最多5张图片</text>
|
|
|
</view>
|
|
</view>
|
|
|
- <!-- 上传图片 -->
|
|
|
|
|
|
|
+ <!-- 上传文件 -->
|
|
|
<view class="ui-upload" id="descripImg">
|
|
<view class="ui-upload" id="descripImg">
|
|
|
|
|
|
|
|
<view class="ui-upload_file" v-for="(item,index) in imgList" :key="index">
|
|
<view class="ui-upload_file" v-for="(item,index) in imgList" :key="index">
|
|
|
|
|
+ <uni-icons class="close" type="clear" @click="removeFile('image',0)" size="30" color="#333">
|
|
|
|
|
+ </uni-icons>
|
|
|
<image :src="item" @click="previewImage(index)" class="ui-upload_img" mode="aspectFill">
|
|
<image :src="item" @click="previewImage(index)" class="ui-upload_img" mode="aspectFill">
|
|
|
</image>
|
|
</image>
|
|
|
</view>
|
|
</view>
|
|
|
|
|
+ <view class="ui-upload_file" v-if="aftersale.errorvideo">
|
|
|
|
|
+ <uni-icons class="close" type="clear" @click="removeFile('video',0)" size="30" color="#333">
|
|
|
|
|
+ </uni-icons>
|
|
|
|
|
+ <video :src="aftersale.errorvideo" :show-center-play-btn="false" :controls="false"
|
|
|
|
|
+ preload="metadata" poster="" :muted="true"></video>
|
|
|
|
|
+ </view>
|
|
|
<view class="ui-upload_input" @click="uploadFile('image')">
|
|
<view class="ui-upload_input" @click="uploadFile('image')">
|
|
|
<image src="@/static/img/image.png" class="ui-upload_img" mode="aspectFill"></image>
|
|
<image src="@/static/img/image.png" class="ui-upload_img" mode="aspectFill"></image>
|
|
|
</view>
|
|
</view>
|
|
|
- <view class="ui-upload_input" @click="uploadFile('video')">
|
|
|
|
|
|
|
+ <view class="ui-upload_input" @click="uploadFile('video')" v-if="!this.aftersale.errorvideo">
|
|
|
<image src="@/static/img/video.png" class="ui-upload_img" mode="aspectFill"></image>
|
|
<image src="@/static/img/video.png" class="ui-upload_img" mode="aspectFill"></image>
|
|
|
</view>
|
|
</view>
|
|
|
</view>
|
|
</view>
|
|
@@ -67,27 +75,41 @@
|
|
|
saveLoading: false,
|
|
saveLoading: false,
|
|
|
}
|
|
}
|
|
|
},
|
|
},
|
|
|
|
|
+ onLoad(options) {
|
|
|
|
|
+ this.aftersale.device_id=options.deviceId
|
|
|
|
|
+ },
|
|
|
methods: {
|
|
methods: {
|
|
|
/**
|
|
/**
|
|
|
* 上传图片
|
|
* 上传图片
|
|
|
* @param {String} type image:图片,video 视频
|
|
* @param {String} type image:图片,video 视频
|
|
|
*/
|
|
*/
|
|
|
async uploadFile(type) {
|
|
async uploadFile(type) {
|
|
|
- let res = await this.uploadImageSync();
|
|
|
|
|
- if (res) {
|
|
|
|
|
- uploadFile({
|
|
|
|
|
- file: res
|
|
|
|
|
- });
|
|
|
|
|
|
|
+ if (type == 'image' && this.imgList.length == 5) {
|
|
|
|
|
+ return this.$api.msg('图片最多上传5张');
|
|
|
}
|
|
}
|
|
|
|
|
+ let file = type == 'image' ? await this.chooseImage() : await this.chooseVideo();
|
|
|
|
|
+ this.$api.loading('上传中...');
|
|
|
|
|
+ let res = await uploadFile(file);
|
|
|
|
|
+ this.$api.hide();
|
|
|
|
|
+ if(!res){
|
|
|
|
|
+ return;
|
|
|
|
|
+ }
|
|
|
|
|
+ this.$api.msg('上传成功','success');
|
|
|
|
|
+ // baseUrl 图片根据 img_url
|
|
|
|
|
+ if (type == 'image') {
|
|
|
|
|
+ return this.imgList.push(res)
|
|
|
|
|
+ }
|
|
|
|
|
+ this.aftersale.errorvideo = res;
|
|
|
},
|
|
},
|
|
|
- uploadImageSync() {
|
|
|
|
|
|
|
+ // 选择图片
|
|
|
|
|
+ chooseImage() {
|
|
|
return new Promise((resolve, reject) => {
|
|
return new Promise((resolve, reject) => {
|
|
|
uni.chooseImage({
|
|
uni.chooseImage({
|
|
|
count: 1, // 默认9
|
|
count: 1, // 默认9
|
|
|
sizeType: ['compressed'], // 可以指定是原图还是压缩图,默认二者都有
|
|
sizeType: ['compressed'], // 可以指定是原图还是压缩图,默认二者都有
|
|
|
sourceType: ['album', 'camera'], // 可以指定来源是相册还是相机,默认二者都有
|
|
sourceType: ['album', 'camera'], // 可以指定来源是相册还是相机,默认二者都有
|
|
|
success(res) {
|
|
success(res) {
|
|
|
- resolve(res.tempFiles[0]);
|
|
|
|
|
|
|
+ resolve(res.tempFilePaths[0]);
|
|
|
},
|
|
},
|
|
|
fail(e) {
|
|
fail(e) {
|
|
|
resolve(null);
|
|
resolve(null);
|
|
@@ -95,12 +117,16 @@
|
|
|
})
|
|
})
|
|
|
})
|
|
})
|
|
|
},
|
|
},
|
|
|
- uploadVideoSync() {
|
|
|
|
|
|
|
+ // 选择视频
|
|
|
|
|
+ chooseVideo() {
|
|
|
return new Promise((resolve, reject) => {
|
|
return new Promise((resolve, reject) => {
|
|
|
uni.chooseVideo({
|
|
uni.chooseVideo({
|
|
|
sourceType: ['camera', 'album'],
|
|
sourceType: ['camera', 'album'],
|
|
|
success(res) {
|
|
success(res) {
|
|
|
- self.src = res.tempFilePath;
|
|
|
|
|
|
|
+ resolve(res.tempFilePath);
|
|
|
|
|
+ },
|
|
|
|
|
+ fail(e) {
|
|
|
|
|
+ resolve(null);
|
|
|
}
|
|
}
|
|
|
});
|
|
});
|
|
|
})
|
|
})
|
|
@@ -109,12 +135,37 @@
|
|
|
async submitAftersaleInfo(e) {
|
|
async submitAftersaleInfo(e) {
|
|
|
this.$api.loading("上报中...");
|
|
this.$api.loading("上报中...");
|
|
|
this.saveLoading = true;
|
|
this.saveLoading = true;
|
|
|
|
|
+ this.aftersale.errorimg = this.imgList.join(',');
|
|
|
let res = await saveAftersaleInfo(this.aftersale);
|
|
let res = await saveAftersaleInfo(this.aftersale);
|
|
|
this.saveLoading = false;
|
|
this.saveLoading = false;
|
|
|
this.$api.hide();
|
|
this.$api.hide();
|
|
|
if (res) {
|
|
if (res) {
|
|
|
this.$api.msg('上报成功', 'success');
|
|
this.$api.msg('上报成功', 'success');
|
|
|
}
|
|
}
|
|
|
|
|
+ },
|
|
|
|
|
+ // 预览图片
|
|
|
|
|
+ previewImage(index) {
|
|
|
|
|
+ uni.previewImage({
|
|
|
|
|
+ current: index,
|
|
|
|
|
+ urls: this.imgList
|
|
|
|
|
+ });
|
|
|
|
|
+ },
|
|
|
|
|
+ /**
|
|
|
|
|
+ * 删除文件
|
|
|
|
|
+ * @param {String} type image:图片,video 视频
|
|
|
|
|
+ * @param {Number} index 文件坐标
|
|
|
|
|
+ */
|
|
|
|
|
+ async removeFile(type, index) {
|
|
|
|
|
+ const confirm = await this.$api.showModal(`是否确定删除当前${type=='image'?'图片':'视频'}`);
|
|
|
|
|
+ if (!confirm) {
|
|
|
|
|
+ return;
|
|
|
|
|
+ }
|
|
|
|
|
+ if (type == 'image') {
|
|
|
|
|
+ this.imgList.splice(index, 1)
|
|
|
|
|
+ } else {
|
|
|
|
|
+ this.aftersale.errorvideo = '';
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|