<van-list>
<van-cell v-for="(item,index) in list" :key="item.value">
<van-col style="text-align: center;padding-top: 4rem;" span="8">${item.text}</van-col>
<van-col style="text-align: center" span="10">
<van-empty :image="item.pic" image-size="100">
</van-empty>
</van-col>
<van-col style="text-align: -webkit-right;height: 3rem;line-height:1rem;border-radius: 20px;margin: 5px;padding-top: 4rem;" span="4">
{{-- <van-button size="mini" type="danger" @click="listIndexImg($event,item.value)">拍照</van-button>--}}
{{-- <van-button size="mini" type="danger" @click="takephoto($event,item.value)">拍照</van-button>--}}
<van-field name="uploader">
<template #input>
<van-uploader
:after-read="(file) => saveBaseImage(file, item)"
:before-delete="(file, detail) => beforeDelete(file, item, item.code, detail) // 删除图片
"
preview-size="50"
preview-image="true"
v-model="fileList"
capture="user"
:max-count="1"
style="width: 50px; height: 50px;">
<van-button size="mini" type="danger">拍照</van-button>
</van-uploader>
</template>
</van-field>
</van-col>
</van-cell>
</van-list>
listIndexImg(e,id)
{
if (id == undefined) {
id = ""
return
}
},
takephoto(e,id){
var that = this;
that.baseid = id;
that.showBase = true;
},
saveBaseImage(file, item) {
var that = this;
console.log(item)
that.$notify('图片上传中');
lrz(file.file)
.then(function (rst) {
var _token = '{{csrf_token()}}';
rst.formData.append('baseid', item.value);
rst.formData.append('base64img', rst.base64);
rst.formData.append('_token', _token);
$.ajax({
url:"/equipment/baseSaveImage",
type: 'POST',
dataType: 'json',
data: rst.formData,
processData: false,
contentType: false,
xhrFields: { withCredentials: true },
headers: {
'Access-Control-Allow-Origin': '*',
'Access-Control-Allow-Credentials': 'true'
},
success: function(res){
window.location.reload();
},
error: function(){
that.$notify('上传失败');
}
});
})
.catch(function (err) {
that.$notify('上传失败');
});
},
beforeDelete (file, item, name, detail) {
const urlList = item.images.split(',');
urlList.splice(detail.index, 1);
(fileList.value as any)[name].splice(detail.index, 1);
item.images = urlList.join(',');
} ,