yurong/.svn/pristine/82/8280bf6026cfe201cd40907937f...

104 lines
2.7 KiB
Plaintext

<template>
<view class="pl-20 pr-20 pt-20">
<view class="bgff w-710 br-20 fs-24" style="padding:20rpx 20rpx;">
<textarea v-model="parmas.content" class="w-670 h-124 fs-28 col999" style="padding: 10rpx 0;"
placeholder="欢迎留下您的意见和反馈~"></textarea>
<view class="pt-20 rows rowsw">
<image class="w-156 h-156 mr-12" mode="aspectFill" src="/static/tianjiatupiab.png" @tap="lookImage(2)">
</image>
<view v-for="(item,index) in onImgs" :key="index" class="ml-12 mr-12 relative">
<image class="w-156 h-156" mode="aspectFill" :src="item" :key="index"></image>
<image @tap="detImg(index)" src="/static/detIcon.png" class="w-30 h-30 absolute"
style="right: -10rpx;top: -10rpx;"></image>
</view>
</view>
</view>
<view class="rowsc rowsm pt-92">
<view @tap="confirm()" class="w-710 h-104 br-56 rowsc rowsm colfff bg">提交</view>
</view>
</view>
</template>
<script>
export default {
data() {
return {
parmas: {
images: [],
content: ''
},
saveImgs: [],
onImgs: [],
}
},
methods: {
confirm() {
if (this.parmas.content) {
this.parmas.images = this.saveImgs.join(',')
this.axiosFromToken('POST','user/feedback', this.parmas, '加载中').then(res => {
this.showtt(res.msg)
if (res.code == 1) {
setTimeout(() => {
this.goBack()
},1600)
}
})
} else {
this.showtt('请输入意见反馈')
}
},
detImg(index) { //删除图片
this.parmas.images.splice(index, 1)
this.saveImgs.splice(index, 1)
},
lookImage() { //选择图片
let that = this
uni.chooseImage({
sizeType: ['compressed'], // 可以指定是原图还是压缩图,默认二者都有
sourceType: ['album', 'camera'], // 可以指定来源是相册还是相机,默认二者都有
count: 1,
success(res) {
res.tempFilePaths.forEach((val, index) => {
that.upload(val)
})
}
})
},
upload(pathfile) { //上传文件 1=上传图片 2=上传视频
let that = this
const token = uni.getStorageSync('token')
uni.showLoading({
title: '加载中'
})
uni.uploadFile({
url: that.$tools.upload,
header: {
token: token
},
filePath: pathfile,
name: 'file',
success: (res) => {
res = JSON.parse(res.data)
if (res.code === 1) {
that.onImgs.push(pathfile)
that.saveImgs.push(res.data.url)
}
},
complete: () => {
uni.hideLoading()
},
fail: (err) => {
this.$tools.showtt('上传失败,请重试')
}
})
},
}
}
</script>
<style>
page {
background: #f7f6fa;
}
</style>