Commit 082d498a authored by xinzhedeai's avatar xinzhedeai

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

parent 4f229f15
......@@ -74,11 +74,12 @@
class="van-icon van-icon-cross van-uploader__preview-delete-icon"></i></div>
</div>
<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">
<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>
......
......@@ -135,6 +135,66 @@ window.addEventListener("load", function() {
// 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() {
if (this.flag == 'XQ') {
return
......
......@@ -65,11 +65,12 @@
class="van-icon van-icon-cross van-uploader__preview-delete-icon"></i></div>
</div>
<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">
<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>
......
......@@ -102,6 +102,66 @@ window.addEventListener("load", function() {
// 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() {
if (this.flag == 'XQ') {
return
......
......@@ -77,12 +77,17 @@
class="van-icon van-icon-cross van-uploader__preview-delete-icon"></i></div>
</div>
<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">
<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 class="form-item date-wrapper">
......
......@@ -16,7 +16,7 @@ window.addEventListener("load", function() {
flag: 'XQ',
flag: 'ADD',
showStartDatePicker: false, // 开始时间选择器显示控制
showEndDatePicker: false, // 结束时间选择器显示控制
showEndDatePicker: false, // 结束时间选择器显示控制
showDatePicker: false, // 控制日期选择器显示
minDate: new Date(gemhoUtil.getTargetDateYMD()), // 最小可选日期
maxDate: new Date(2099, 11, 31), // 最大可选日期
......@@ -26,14 +26,14 @@ window.addEventListener("load", function() {
// 新增以下数据
formData: {
merchantName: '',
merchantPhone : '',
merchantPhone: '',
merName: '',
attachmentFile: [],
workType: '',
companyName:'',
workerName:'',
startTime: '', // 开始时间字段
endTime: '' // 结束时间字段
companyName: '',
workerName: '',
startTime: '', // 开始时间字段
endTime: '' // 结束时间字段
},
id: ''
}
......@@ -53,6 +53,7 @@ window.addEventListener("load", function() {
this.getDict4tab1()
},
methods: {
getShopInfo() {
vant.Toast.loading({
message: '正在加载...',
......@@ -60,8 +61,7 @@ window.addEventListener("load", function() {
loadingType: 'spinner',
})
setTimeout(() => {
http2.post(
{
http2.post({
serviceId: API_KEY_MAP['no-page']['id'],
interfacePublicKey: API_KEY_MAP['no-page']['publicKey'],
interfacePrivateKey: API_KEY_MAP['no-page']['privateKey'],
......@@ -74,7 +74,7 @@ window.addEventListener("load", function() {
if (res) {
var result = JSON.parse(res)
console.log('商户信息', result)
if(result.data){
if (result.data) {
this.formData.merName = result.data.merName
this.formData.merchantPhone = result.data.merchantPhone
this.formData.merchantName = result.data.merchantName
......@@ -84,19 +84,19 @@ window.addEventListener("load", function() {
)
}, 0)
},
showTipPage(){
showTipPage() {
this.showTipPopup = true
this.detail()
return
// let param = {
// type: this.formData.workType,
// pageName: '_tezhongzuoye_detail',
// }
// let url = gemhoUtil.setParameter('_tezhongzuoye_detail-text.html', param)
// console.log(url)
// gemhoUtil.navigatePage(url, '跳转中...')
},
detail() { // 隐患详情
......@@ -124,14 +124,16 @@ window.addEventListener("load", function() {
this.detailInfo = JSON.parse(res).data
// 初始化编辑器
quill = new Quill('#editor-container', {
theme: 'snow', readOnly: true, modules: {
toolbar: false // 关键配置:禁用工具栏
theme: 'snow',
readOnly: true,
modules: {
toolbar: false // 关键配置:禁用工具栏
},
});
quill.root.innerHTML = this.detailInfo || '该特种作业类型下暂无提醒事项内容,请联系管理员'
}
})
},
getDict4tab1() {
http2.post({
......@@ -161,8 +163,8 @@ window.addEventListener("load", function() {
}, 0);
var result = JSON.parse(res)
this.tabList4lv2 = result.rows
if(this.flag == 'ADD'){
this.formData.workType = this.tabList4lv2[0].dictValue
if (this.flag == 'ADD') {
this.formData.workType = this.tabList4lv2[0].dictValue
}
}
})
......@@ -229,6 +231,66 @@ window.addEventListener("load", function() {
// 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() {
if (this.flag == 'XQ') {
return
......@@ -269,7 +331,7 @@ window.addEventListener("load", function() {
const images = list.map((item) => {
return this.previewUrl + item
})
vant.ImagePreview({
images,
startPosition: index,
......@@ -333,15 +395,15 @@ window.addEventListener("load", function() {
http3.post('/gq/special', reqParam).then((res) => {
console.log('添加结果', res)
if(res.code === 200){
if (res.code === 200) {
vant.Toast({
message: '操作成功',
})
setTimeout(function(){
setTimeout(function() {
history.back()
}, 300)
}else{
} else {
vant.Toast({
message: '操作失败',
})
......@@ -381,8 +443,9 @@ window.addEventListener("load", function() {
// 图片数据结构处理
let tempData = result.data
if (tempData['attachmentFile']) {
tempData['attachmentFile'] = tempData['attachmentFile'] ? tempData[
'attachmentFile'].split(',') : []
tempData['attachmentFile'] = tempData[
'attachmentFile'] ? tempData[
'attachmentFile'].split(',') : []
}
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