Files
app-govern/pages/home/feedback.vue

163 lines
4.7 KiB
Vue

<template>
<Cn-page :loading='loading'>
<view slot='body'>
<view class='index'>
<view class="content">
<uni-forms>
<!-- <uni-forms-item label="类型">
<uni-data-select v-model="item.type" :localdata="range"></uni-data-select>
</uni-forms-item> -->
<uni-forms-item label="标题">
<uni-easyinput type="text" v-model="formData.title" placeholder="请输入问题简要"/>
</uni-forms-item>
<uni-forms-item label="描述">
<uni-easyinput type="textarea" v-model="formData.description" placeholder="请输入详细描述"/>
</uni-forms-item>
<uni-forms-item label="图片">
<uni-file-picker :auto-upload="false" @select="fileChange" @delete="delImg">
</uni-file-picker>
</uni-forms-item>
</uni-forms>
</view>
<view class="btn-wrap">
<view class="btn-wrap-item " @click="submit"> 提交</view>
</view>
<navigator url="/pages/home/service" hover-class="none" class="fixed-btn">
<image src="/static/service.png" style="height:66rpx;width:66rpx"/>
</navigator>
</view>
</view>
</Cn-page>
</template>
<script>
import {addFeedBack} from '../../common/api/feedback'
export default {
data() {
return {
loading: false,
formData: {
title: '',
description: '',
type: 1,
userId: '',
files: []
},
range: [
{value: 0, text: "DVR"},
{value: 1, text: "APF"},
],
}
},
methods: {
delImg(e) {
console.log(e);
this.formData.files = this.formData.files.filter(item => item.url !== e.tempFilePath)
},
pickerClick(){
console.log(123);
},
fileChange(e) {
console.log(e);
e.tempFilePaths.forEach(item => {
this.formData.files.push({
uri: item,
name: 'files'
})
})
console.log(this.formData.files);
},
add() {
this.formData.push({
type: '',
address: '',
})
},
submit() {
if (!this.formData.title) {
uni.showToast({
title: '请输入标题',
icon: 'none'
})
return
}
addFeedBack(this.formData).then(res => {
console.log(res)
console.log(this.formData.files.length)
if (this.formData.files.length > 0) {
res = res[1]
res = JSON.parse(res.data)
console.log(res);
}
console.log(res)
if (res.code === 'A0000') {
this.$util.toast(res.message)
setTimeout(() => {
uni.redirectTo({url: '/pages/message/feedback'})
}, 1000);
} else {
this.$util.toast(res.message)
}
}).catch(err => {
console.log(err)
})
},
},
onLoad(options) {
this.formData.userId = uni.getStorageSync('userInfo').userIndex
this.formData.engineeringId = uni.getStorageSync('engineering').id
}
}
</script>
<style lang='scss'>
.index {
padding: 20rpx;
.content {
margin-bottom: 20rpx;
padding: 34rpx;
background: $uni-theme-white;
border-radius: 12rpx;
}
.btn-wrap {
margin-top: 40rpx;
display: flex;
align-items: center;
justify-content: space-between;
.btn-wrap-item {
display: flex;
align-items: center;
justify-content: center;
flex: 1;
background: $uni-theme-color;
color: #fff;
height: 80rpx;
border-radius: 12rpx;
}
}
}
.fixed-btn {
position: fixed;
right: 80rpx;
bottom: 200rpx;
width: 126rpx;
height: 126rpx;
background: #fff;
border-radius: 50%;
display: flex;
align-items: center;
justify-content: center;
box-shadow: 0 0 10rpx rgba(0, 0, 0, 0.2);
image {
height: 66rpx;
width: 66rpx;
}
}
</style>