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,12 +77,17 @@ ...@@ -77,12 +77,17 @@
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">
......
...@@ -16,7 +16,7 @@ window.addEventListener("load", function() { ...@@ -16,7 +16,7 @@ window.addEventListener("load", function() {
flag: 'XQ', flag: 'XQ',
flag: 'ADD', flag: 'ADD',
showStartDatePicker: false, // 开始时间选择器显示控制 showStartDatePicker: false, // 开始时间选择器显示控制
showEndDatePicker: false, // 结束时间选择器显示控制 showEndDatePicker: false, // 结束时间选择器显示控制
showDatePicker: false, // 控制日期选择器显示 showDatePicker: false, // 控制日期选择器显示
minDate: new Date(gemhoUtil.getTargetDateYMD()), // 最小可选日期 minDate: new Date(gemhoUtil.getTargetDateYMD()), // 最小可选日期
maxDate: new Date(2099, 11, 31), // 最大可选日期 maxDate: new Date(2099, 11, 31), // 最大可选日期
...@@ -26,14 +26,14 @@ window.addEventListener("load", function() { ...@@ -26,14 +26,14 @@ window.addEventListener("load", function() {
// 新增以下数据 // 新增以下数据
formData: { formData: {
merchantName: '', merchantName: '',
merchantPhone : '', merchantPhone: '',
merName: '', merName: '',
attachmentFile: [], attachmentFile: [],
workType: '', workType: '',
companyName:'', companyName: '',
workerName:'', workerName: '',
startTime: '', // 开始时间字段 startTime: '', // 开始时间字段
endTime: '' // 结束时间字段 endTime: '' // 结束时间字段
}, },
id: '' id: ''
} }
...@@ -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,19 +84,19 @@ window.addEventListener("load", function() { ...@@ -84,19 +84,19 @@ window.addEventListener("load", function() {
) )
}, 0) }, 0)
}, },
showTipPage(){ showTipPage() {
this.showTipPopup = true this.showTipPopup = true
this.detail() this.detail()
return return
// let param = { // let param = {
// type: this.formData.workType, // type: this.formData.workType,
// pageName: '_tezhongzuoye_detail', // pageName: '_tezhongzuoye_detail',
// } // }
// let url = gemhoUtil.setParameter('_tezhongzuoye_detail-text.html', param) // let url = gemhoUtil.setParameter('_tezhongzuoye_detail-text.html', param)
// console.log(url) // console.log(url)
// gemhoUtil.navigatePage(url, '跳转中...') // gemhoUtil.navigatePage(url, '跳转中...')
}, },
detail() { // 隐患详情 detail() { // 隐患详情
...@@ -124,14 +124,16 @@ window.addEventListener("load", function() { ...@@ -124,14 +124,16 @@ 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',
toolbar: false // 关键配置:禁用工具栏 readOnly: true,
modules: {
toolbar: false // 关键配置:禁用工具栏
}, },
}); });
quill.root.innerHTML = this.detailInfo || '该特种作业类型下暂无提醒事项内容,请联系管理员' quill.root.innerHTML = this.detailInfo || '该特种作业类型下暂无提醒事项内容,请联系管理员'
} }
}) })
}, },
getDict4tab1() { getDict4tab1() {
http2.post({ http2.post({
...@@ -161,8 +163,8 @@ window.addEventListener("load", function() { ...@@ -161,8 +163,8 @@ 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
...@@ -269,7 +331,7 @@ window.addEventListener("load", function() { ...@@ -269,7 +331,7 @@ window.addEventListener("load", function() {
const images = list.map((item) => { const images = list.map((item) => {
return this.previewUrl + item return this.previewUrl + item
}) })
vant.ImagePreview({ vant.ImagePreview({
images, images,
startPosition: index, startPosition: index,
...@@ -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,8 +443,9 @@ window.addEventListener("load", function() { ...@@ -381,8 +443,9 @@ 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'].split(',') : [] 'attachmentFile'] ? tempData[
'attachmentFile'].split(',') : []
} }
this.formData = tempData this.formData = tempData
......
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