|
|
@@ -165,21 +165,39 @@ export default {
|
|
|
pickFromChat: function() {
|
|
|
var self = this
|
|
|
this.ensureAgreed(function() {
|
|
|
- uni.chooseMessageFile({
|
|
|
- count: 1,
|
|
|
- type: 'all',
|
|
|
+ // type='all' 的选择器默认停留在图片 tab,用户难以发现可切换选文件。
|
|
|
+ // 改为先弹 actionSheet 让用户明确选择图片或文件,分别走对应 type。
|
|
|
+ uni.showActionSheet({
|
|
|
+ itemList: ['聊天中的文件(PDF等)', '聊天中的图片'],
|
|
|
success: function(res) {
|
|
|
- var files = res.tempFiles
|
|
|
- if (files && files.length > 0) {
|
|
|
- self.uploadReport(files[0].path, files[0].name || '聊天文件')
|
|
|
+ if (res.tapIndex === 0) {
|
|
|
+ self.chooseChatFile('file', '聊天文件')
|
|
|
+ } else if (res.tapIndex === 1) {
|
|
|
+ self.chooseChatFile('image', '聊天图片')
|
|
|
}
|
|
|
},
|
|
|
fail: function() {
|
|
|
- // 用户取消或失败,静默处理
|
|
|
+ // 用户取消,静默处理
|
|
|
}
|
|
|
})
|
|
|
})
|
|
|
},
|
|
|
+ chooseChatFile: function(type, fallbackName) {
|
|
|
+ var self = this
|
|
|
+ uni.chooseMessageFile({
|
|
|
+ count: 1,
|
|
|
+ type: type,
|
|
|
+ success: function(res) {
|
|
|
+ var files = res.tempFiles
|
|
|
+ if (files && files.length > 0) {
|
|
|
+ self.uploadReport(files[0].path, files[0].name || fallbackName)
|
|
|
+ }
|
|
|
+ },
|
|
|
+ fail: function() {
|
|
|
+ // 用户取消或失败,静默处理
|
|
|
+ }
|
|
|
+ })
|
|
|
+ },
|
|
|
takePhoto: function() {
|
|
|
var self = this
|
|
|
this.ensureAgreed(function() {
|