This commit is contained in:
2022-07-07 15:01:01 +08:00
parent d78b6e8bf2
commit e2a375b049
3 changed files with 145 additions and 1 deletions

View File

@@ -155,3 +155,13 @@ export const submitPackUp = (el1, el2, el3, n, flag) => {
}
return !flag
}
/**
* 拍照
*/
/* eslint-disable */
export function urlEncode () {
var url = store.getters.imgip + 'wdk?action=wdk.pub&method=attachment_upload&catacode=temp'
var url_encode = escape(url)
return url_encode
};

View File

@@ -0,0 +1,134 @@
<template>
<section>
<nav-bar :inner="true" title="拍照"></nav-bar>
<section class="content mgt186">
<div class="image_wraper">
<div v-for="e in photos" class="li_box img_box relative" :key='e.num'>
<img :src="e.data">
<div class="iconfont error_icon" @click="delPhoto(e)"></div>
</div>
<!-- <div class="li_box iconfont add_pict_icon relative">
<input
type='file'
id='H5moreUp'
ref='H5moreUp'
accept='image/*'
@change="loadImg"
/>
</div> -->
<a id="imgup" class="li_box iconfont add_pict_icon" @click="jumpUpload"></a>
</div>
</section>
<section class="submit-bar">
<button class="btn submit-button" @click="toSure">确认</button>
</section>
</section>
</template>
<script>
import NavBar from '@components/NavBar.vue'
import {urlEncode} from '@config/mUtils.js'
export default {
name: 'UploadPicts',
components: {
NavBar
},
data () {
return {
photos: [],
num: 0
}
},
mounted () {
// let _this = this
window.upimgres = ''
Object.defineProperty(window, 'upimgres', {
get () {
return ''
},
set (val) {
if (val !== '') {
// _this.upImgUrl = val.fileid
alert(typeof val)
alert(val)
alert(val.fileid)
// val = JSON.parse(val)
// if (val.code === '1') {
// _this.upImgUrl = val.fileid
// _this.unimgsrc = _this.$store.getters.imgip + 'wdk?action=wdk.pub&method=attachment_download&fileid=' + val.fileid
// document.getElementById('imgshow').setAttribute('src', _this.unimgsrc)
// }
// if (val.code === '0') {
// _this.toast('上传失败')
// }
}
}
})
},
methods: {
jumpUpload () {
var imgUrlEncode = urlEncode()
document.getElementById('imgup').href = 'imgUpload?url=' + imgUrlEncode
},
loadImg () {
// 获取文件
let file = document.getElementById('H5moreUp').files[0]
// 创建读取文件的对象
let reader = new FileReader()
// 创建文件读取相关的变量
let imgFile
// 为文件读取成功设置事件
reader.onload = (e) => {
imgFile = e.target.result
this.num = this.num + 1
let obj = {data: imgFile, file: file, num: this.num, photo: file.name}
this.photos.push(obj)
}
// 正式读取文件
reader.readAsDataURL(file)
},
delPhoto (e) {
this.photos = this.photos.filter(el => (el.num !== e.num))
},
toSure () {
if (this.photos.length) {
this.$store.dispatch('receivePlateArr', this.photos)
}
this.$router.back()
}
}
}
</script>
<style lang="stylus" scoped>
@import '~@style/mixin'
.image_wraper
width 100%
padding-top .5rem
.li_box
_fj(center)
float left
_wh(2rem, 2rem)
border .03rem dashed #c9c9c9
border-radius 3px
margin-bottom .2rem
overflow hidden
img
_wh(100%, auto)
&:nth-child(3n+2)
margin 0 calc((100% - 6rem) / 2)
.error_icon
position absolute
top .01rem
right .01rem
_wh(.5rem, .5rem)
line-height .5rem
background-color rgba(0,0,0,.7)
#H5moreUp
position absolute
top 0
left 0
_wh(100%, 100%)
opacity 0
z-index 100
</style>

View File

@@ -133,7 +133,7 @@ export default {
async _queryDevice1 (e) {
let res = await queryDevice1(e)
if (res.code === '1') {
this.devicerecordId = res.content.devicerecordId
this.devicerecordId = res.content.devicerecord_id
this.option1.map((el, i) => {
if (el.value === res.content.material_type_id) {
this.active1 = i + ''