Commit 082d498a authored by xinzhedeai's avatar xinzhedeai

better:图片选取+拍照功能处理

parent 4f229f15
...@@ -74,11 +74,12 @@ ...@@ -74,11 +74,12 @@
class="van-icon van-icon-cross van-uploader__preview-delete-icon"></i></div> class="van-icon van-icon-cross van-uploader__preview-delete-icon"></i></div>
</div> </div>
<div v-if="formData.images.length<6 && flag=='ADD' "> <div v-if="formData.images.length<6 && flag=='ADD' ">
<van-uploader :before-read="beforeRead" :after-read="(file) => afterRead(file, 'floorPlan')" <!-- <van-uploader :before-read="beforeRead" :after-read="(file) => afterRead(file, 'floorPlan')"
class="uploader-wrapper" :deletable="false" :preview-image="false"> class="uploader-wrapper" :deletable="false" :preview-image="false">
<img src="../image/code/upload.png" style="width:1.6rem;height: 1.6rem;" alt="" <img src="../image/code/upload.png" style="width:1.6rem;height: 1.6rem;" alt=""
srcset=""> srcset="">
</van-uploader> </van-uploader> -->
<img src="../image/code/upload.png" style="width:1.6rem;height: 1.6rem;" alt="" srcset="" @click="paizhao()">
</div> </div>
</div> </div>
......
...@@ -135,6 +135,66 @@ window.addEventListener("load", function() { ...@@ -135,6 +135,66 @@ window.addEventListener("load", function() {
// console.error('There has been a problem with your fetch operation:', error); // console.error('There has been a problem with your fetch operation:', error);
}); });
}, },
paizhao() {
var data = ["相册", "相机"];
var maxSelectNum = 6;
lightAppJssdk.notification.showMediaAlert({
arg0: data,
success: function(data) {
console.log('选择菜单的数据', data)
// formData.append('file', file.file); // 通过FormData构建要上传的文件数据
// alert(data);
var pam1 = {
"url": BASE_URL + '/common/uploads',
// url:'sdfsdfsd',
"fileKey": "files",
// "fileKey": "files",
"params": {
},
"header": {
'Authorization': gemhoUtil.getCookie('token'),
},
"chooseType": "chooseFileUpload",
"transmissionType": 0, //1-base64 0-图片地址"maxSize": 10, "maxSelectNum": 9,
"maxSize": 10,
"maxSelectNum": maxSelectNum,
}
if (data.index == 0) {
pam1.chooseType = "chooseImageUpload" // pam1.fileKey = "file"
} else if (data.index == 1) {
pam1.chooseType ="takingPicturesUpload" // pam1.fileKey = "picfile"
}
console.log('请求接口i偶路径', pam1)
chooseFileUploadTest(pam1)
// setTimeout('onHidePreloaders()', 2000);
},
fail: function(data) {
console.log(data);
}
});
function chooseFileUploadTest(pam) {
lightAppJssdk.uploadFile.chooseFileUpload({
arg0: pam,
success: function(value) {
console.log('chooseFileUpload方法', value)
if(value){
VUE.formData.images.push(...JSON.parse(value).fileNames)
if(VUE.formData.images.length > maxSelectNum){
const result = VUE.formData.images.slice(0, maxSelectNum)
VUE.formData.images = result
}
}
},
fail: function(data1) {
console.log(data1);
}
});
};
},
showDatePickerModal() { showDatePickerModal() {
if (this.flag == 'XQ') { if (this.flag == 'XQ') {
return return
......
...@@ -65,11 +65,12 @@ ...@@ -65,11 +65,12 @@
class="van-icon van-icon-cross van-uploader__preview-delete-icon"></i></div> class="van-icon van-icon-cross van-uploader__preview-delete-icon"></i></div>
</div> </div>
<div v-if="formData.images.length<6 && flag=='ADD' "> <div v-if="formData.images.length<6 && flag=='ADD' ">
<van-uploader :before-read="beforeRead" :after-read="(file) => afterRead(file, 'floorPlan')" <!-- <van-uploader :before-read="beforeRead" :after-read="(file) => afterRead(file, 'floorPlan')"
class="uploader-wrapper" :deletable="false" :preview-image="false"> class="uploader-wrapper" :deletable="false" :preview-image="false">
<img src="../image/code/upload.png" style="width:1.6rem;height: 1.6rem;" alt="" <img src="../image/code/upload.png" style="width:1.6rem;height: 1.6rem;" alt=""
srcset=""> srcset="">
</van-uploader> </van-uploader> -->
<img src="../image/code/upload.png" style="width:1.6rem;height: 1.6rem;" alt="" srcset="" @click="paizhao()">
</div> </div>
</div> </div>
......
...@@ -102,6 +102,66 @@ window.addEventListener("load", function() { ...@@ -102,6 +102,66 @@ window.addEventListener("load", function() {
// console.error('There has been a problem with your fetch operation:', error); // console.error('There has been a problem with your fetch operation:', error);
}); });
}, },
paizhao() {
var data = ["相册", "相机"];
var maxSelectNum = 6;
lightAppJssdk.notification.showMediaAlert({
arg0: data,
success: function(data) {
console.log('选择菜单的数据', data)
// formData.append('file', file.file); // 通过FormData构建要上传的文件数据
// alert(data);
var pam1 = {
"url": BASE_URL + '/common/uploads',
// url:'sdfsdfsd',
"fileKey": "files",
// "fileKey": "files",
"params": {
},
"header": {
'Authorization': gemhoUtil.getCookie('token'),
},
"chooseType": "chooseFileUpload",
"transmissionType": 0, //1-base64 0-图片地址"maxSize": 10, "maxSelectNum": 9,
"maxSize": 10,
"maxSelectNum": maxSelectNum,
}
if (data.index == 0) {
pam1.chooseType = "chooseImageUpload" // pam1.fileKey = "file"
} else if (data.index == 1) {
pam1.chooseType ="takingPicturesUpload" // pam1.fileKey = "picfile"
}
console.log('请求接口i偶路径', pam1)
chooseFileUploadTest(pam1)
// setTimeout('onHidePreloaders()', 2000);
},
fail: function(data) {
console.log(data);
}
});
function chooseFileUploadTest(pam) {
lightAppJssdk.uploadFile.chooseFileUpload({
arg0: pam,
success: function(value) {
console.log('chooseFileUpload方法', value)
if(value){
VUE.formData.images.push(...JSON.parse(value).fileNames)
if(VUE.formData.images.length > maxSelectNum){
const result = VUE.formData.images.slice(0, maxSelectNum)
VUE.formData.images = result
}
}
},
fail: function(data1) {
console.log(data1);
}
});
};
},
showDatePickerModal() { showDatePickerModal() {
if (this.flag == 'XQ') { if (this.flag == 'XQ') {
return return
......
...@@ -77,13 +77,18 @@ ...@@ -77,13 +77,18 @@
class="van-icon van-icon-cross van-uploader__preview-delete-icon"></i></div> class="van-icon van-icon-cross van-uploader__preview-delete-icon"></i></div>
</div> </div>
<div v-if="formData.attachmentFile.length<6 && flag=='ADD' "> <div v-if="formData.attachmentFile.length<6 && flag=='ADD' ">
<van-uploader :before-read="beforeRead" :after-read="(file) => afterRead(file, 'floorPlan')" <!-- <van-uploader :before-read="beforeRead" :after-read="(file) => afterRead(file, 'floorPlan')"
class="uploader-wrapper" :deletable="false" :preview-image="false"> class="uploader-wrapper" :deletable="false" :preview-image="false">
<img src="../image/code/upload.png" style="width:1.6rem;height: 1.6rem;" alt="" srcset=""> <img src="../image/code/upload.png" style="width:1.6rem;height: 1.6rem;" alt="" srcset="">
</van-uploader> </van-uploader> -->
<img src="../image/code/upload.png" style="width:1.6rem;height: 1.6rem;" alt="" srcset="" @click="paizhao()">
</div> </div>
</div> </div>
<div>
</div>
<!-- 原作业时间部分替换为 --> <!-- 原作业时间部分替换为 -->
<div class="form-item date-wrapper"> <div class="form-item date-wrapper">
<span class="form-label title_require" style="width: 2rem;">作业时间(起始)</span> <span class="form-label title_require" style="width: 2rem;">作业时间(起始)</span>
......
...@@ -26,12 +26,12 @@ window.addEventListener("load", function() { ...@@ -26,12 +26,12 @@ window.addEventListener("load", function() {
// 新增以下数据 // 新增以下数据
formData: { formData: {
merchantName: '', merchantName: '',
merchantPhone : '', merchantPhone: '',
merName: '', merName: '',
attachmentFile: [], attachmentFile: [],
workType: '', workType: '',
companyName:'', companyName: '',
workerName:'', workerName: '',
startTime: '', // 开始时间字段 startTime: '', // 开始时间字段
endTime: '' // 结束时间字段 endTime: '' // 结束时间字段
}, },
...@@ -53,6 +53,7 @@ window.addEventListener("load", function() { ...@@ -53,6 +53,7 @@ window.addEventListener("load", function() {
this.getDict4tab1() this.getDict4tab1()
}, },
methods: { methods: {
getShopInfo() { getShopInfo() {
vant.Toast.loading({ vant.Toast.loading({
message: '正在加载...', message: '正在加载...',
...@@ -60,8 +61,7 @@ window.addEventListener("load", function() { ...@@ -60,8 +61,7 @@ window.addEventListener("load", function() {
loadingType: 'spinner', loadingType: 'spinner',
}) })
setTimeout(() => { setTimeout(() => {
http2.post( http2.post({
{
serviceId: API_KEY_MAP['no-page']['id'], serviceId: API_KEY_MAP['no-page']['id'],
interfacePublicKey: API_KEY_MAP['no-page']['publicKey'], interfacePublicKey: API_KEY_MAP['no-page']['publicKey'],
interfacePrivateKey: API_KEY_MAP['no-page']['privateKey'], interfacePrivateKey: API_KEY_MAP['no-page']['privateKey'],
...@@ -74,7 +74,7 @@ window.addEventListener("load", function() { ...@@ -74,7 +74,7 @@ window.addEventListener("load", function() {
if (res) { if (res) {
var result = JSON.parse(res) var result = JSON.parse(res)
console.log('商户信息', result) console.log('商户信息', result)
if(result.data){ if (result.data) {
this.formData.merName = result.data.merName this.formData.merName = result.data.merName
this.formData.merchantPhone = result.data.merchantPhone this.formData.merchantPhone = result.data.merchantPhone
this.formData.merchantName = result.data.merchantName this.formData.merchantName = result.data.merchantName
...@@ -84,7 +84,7 @@ window.addEventListener("load", function() { ...@@ -84,7 +84,7 @@ window.addEventListener("load", function() {
) )
}, 0) }, 0)
}, },
showTipPage(){ showTipPage() {
this.showTipPopup = true this.showTipPopup = true
this.detail() this.detail()
...@@ -124,7 +124,9 @@ window.addEventListener("load", function() { ...@@ -124,7 +124,9 @@ window.addEventListener("load", function() {
this.detailInfo = JSON.parse(res).data this.detailInfo = JSON.parse(res).data
// 初始化编辑器 // 初始化编辑器
quill = new Quill('#editor-container', { quill = new Quill('#editor-container', {
theme: 'snow', readOnly: true, modules: { theme: 'snow',
readOnly: true,
modules: {
toolbar: false // 关键配置:禁用工具栏 toolbar: false // 关键配置:禁用工具栏
}, },
}); });
...@@ -161,7 +163,7 @@ window.addEventListener("load", function() { ...@@ -161,7 +163,7 @@ window.addEventListener("load", function() {
}, 0); }, 0);
var result = JSON.parse(res) var result = JSON.parse(res)
this.tabList4lv2 = result.rows this.tabList4lv2 = result.rows
if(this.flag == 'ADD'){ if (this.flag == 'ADD') {
this.formData.workType = this.tabList4lv2[0].dictValue this.formData.workType = this.tabList4lv2[0].dictValue
} }
} }
...@@ -229,6 +231,66 @@ window.addEventListener("load", function() { ...@@ -229,6 +231,66 @@ window.addEventListener("load", function() {
// console.error('There has been a problem with your fetch operation:', error); // console.error('There has been a problem with your fetch operation:', error);
}); });
}, },
paizhao() {
var data = ["相册", "相机"];
var maxSelectNum = 6;
lightAppJssdk.notification.showMediaAlert({
arg0: data,
success: function(data) {
console.log('选择菜单的数据', data)
// formData.append('file', file.file); // 通过FormData构建要上传的文件数据
// alert(data);
var pam1 = {
"url": BASE_URL + '/common/uploads',
// url:'sdfsdfsd',
"fileKey": "files",
// "fileKey": "files",
"params": {
},
"header": {
'Authorization': gemhoUtil.getCookie('token'),
},
"chooseType": "chooseFileUpload",
"transmissionType": 0, //1-base64 0-图片地址"maxSize": 10, "maxSelectNum": 9,
"maxSize": 10,
"maxSelectNum": maxSelectNum,
}
if (data.index == 0) {
pam1.chooseType = "chooseImageUpload" // pam1.fileKey = "file"
} else if (data.index == 1) {
pam1.chooseType ="takingPicturesUpload" // pam1.fileKey = "picfile"
}
console.log('请求接口i偶路径', pam1)
chooseFileUploadTest(pam1)
// setTimeout('onHidePreloaders()', 2000);
},
fail: function(data) {
console.log(data);
}
});
function chooseFileUploadTest(pam) {
lightAppJssdk.uploadFile.chooseFileUpload({
arg0: pam,
success: function(value) {
console.log('chooseFileUpload方法', value)
if(value){
VUE.formData.attachmentFile.push(...JSON.parse(value).fileNames)
if(VUE.formData.attachmentFile.length > maxSelectNum){
const result = VUE.formData.attachmentFile.slice(0, maxSelectNum)
VUE.formData.attachmentFile = result
}
}
},
fail: function(data1) {
console.log(data1);
}
});
};
},
showDatePickerModal() { showDatePickerModal() {
if (this.flag == 'XQ') { if (this.flag == 'XQ') {
return return
...@@ -333,15 +395,15 @@ window.addEventListener("load", function() { ...@@ -333,15 +395,15 @@ window.addEventListener("load", function() {
http3.post('/gq/special', reqParam).then((res) => { http3.post('/gq/special', reqParam).then((res) => {
console.log('添加结果', res) console.log('添加结果', res)
if(res.code === 200){ if (res.code === 200) {
vant.Toast({ vant.Toast({
message: '操作成功', message: '操作成功',
}) })
setTimeout(function(){ setTimeout(function() {
history.back() history.back()
}, 300) }, 300)
}else{ } else {
vant.Toast({ vant.Toast({
message: '操作失败', message: '操作失败',
}) })
...@@ -381,7 +443,8 @@ window.addEventListener("load", function() { ...@@ -381,7 +443,8 @@ window.addEventListener("load", function() {
// 图片数据结构处理 // 图片数据结构处理
let tempData = result.data let tempData = result.data
if (tempData['attachmentFile']) { if (tempData['attachmentFile']) {
tempData['attachmentFile'] = tempData['attachmentFile'] ? tempData[ tempData['attachmentFile'] = tempData[
'attachmentFile'] ? tempData[
'attachmentFile'].split(',') : [] 'attachmentFile'].split(',') : []
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment