2020-06-04 08:21:34 +08:00
|
|
|
|
<template>
|
|
|
|
|
<view class="write-complaints">
|
|
|
|
|
<view class="main-container">
|
2020-08-03 18:38:04 +08:00
|
|
|
|
<textarea auto-height placeholder="发表您的意见吧,我们会做得更好" maxlength="200" v-model="text" />
|
2020-06-04 08:21:34 +08:00
|
|
|
|
<u-upload
|
2020-07-07 17:47:00 +08:00
|
|
|
|
ref="uUpload"
|
2020-06-04 08:21:34 +08:00
|
|
|
|
:custom-btn="true"
|
2020-07-10 17:38:21 +08:00
|
|
|
|
:max-count="count"
|
2020-07-10 09:03:19 +08:00
|
|
|
|
:action="action"
|
2020-07-10 17:38:21 +08:00
|
|
|
|
:auto-upload="false"
|
2020-07-10 09:03:19 +08:00
|
|
|
|
:header="header"
|
|
|
|
|
:form-data="formData"
|
2020-07-10 17:38:21 +08:00
|
|
|
|
:name="name"
|
|
|
|
|
@on-uploaded="setImageList"
|
2020-08-03 18:38:04 +08:00
|
|
|
|
@on-error="uploadError"
|
2020-06-04 08:21:34 +08:00
|
|
|
|
>
|
|
|
|
|
<view slot="addBtn" class="slot-btn" hover-class="slot-btn__hover" hover-stay-time="150">
|
2020-07-29 19:01:10 +08:00
|
|
|
|
<image src="../static/mine/27.png"></image>
|
2020-06-04 08:21:34 +08:00
|
|
|
|
</view>
|
|
|
|
|
</u-upload>
|
|
|
|
|
</view>
|
|
|
|
|
<view class="write-btn" @click="submit">发表意见</view>
|
2020-07-10 17:38:21 +08:00
|
|
|
|
<u-toast ref="uToast" />
|
2020-06-04 08:21:34 +08:00
|
|
|
|
</view>
|
|
|
|
|
</template>
|
|
|
|
|
<script>
|
|
|
|
|
export default {
|
|
|
|
|
data() {
|
|
|
|
|
return {
|
2020-07-10 09:03:19 +08:00
|
|
|
|
action: this.$u.http.config.baseUrl + '/Upload/uploadfile',
|
2020-06-04 08:21:34 +08:00
|
|
|
|
count: 4, // 最大图片数量
|
2020-06-18 14:57:26 +08:00
|
|
|
|
text: '',
|
2020-07-10 09:03:19 +08:00
|
|
|
|
header: {
|
|
|
|
|
"authorization": 'Bearer' + " " + uni.getStorageSync('token')
|
|
|
|
|
},
|
2020-07-10 17:38:21 +08:00
|
|
|
|
name: 'common', // 与formData name 一样
|
2020-07-10 09:03:19 +08:00
|
|
|
|
formData: {
|
2020-07-10 17:38:21 +08:00
|
|
|
|
name: 'common', // 其他图片
|
|
|
|
|
},
|
|
|
|
|
imageList: [],
|
2020-08-03 18:38:04 +08:00
|
|
|
|
debounce: true,
|
2020-06-04 08:21:34 +08:00
|
|
|
|
}
|
|
|
|
|
},
|
2020-08-03 18:38:04 +08:00
|
|
|
|
onShow() {
|
|
|
|
|
this.debounce = true;
|
|
|
|
|
},
|
2020-06-04 08:21:34 +08:00
|
|
|
|
methods: {
|
|
|
|
|
submit() {
|
2020-08-03 18:38:04 +08:00
|
|
|
|
if(!this.debounce) return;
|
|
|
|
|
this.debounce = false;
|
2020-07-10 09:03:19 +08:00
|
|
|
|
this.$refs.uUpload.upload();
|
2020-07-10 17:38:21 +08:00
|
|
|
|
},
|
2020-08-03 18:38:04 +08:00
|
|
|
|
uploadError() {
|
|
|
|
|
this.debounce = true;
|
|
|
|
|
},
|
2020-07-10 17:38:21 +08:00
|
|
|
|
setImageList(lists) {
|
|
|
|
|
// console.log(lists);
|
|
|
|
|
let imageList = [];
|
|
|
|
|
lists.forEach(res => {
|
|
|
|
|
if(res.response.errCode == 0) imageList.push(res.response.data.file_name);
|
2020-07-07 17:47:00 +08:00
|
|
|
|
})
|
2020-07-10 17:38:21 +08:00
|
|
|
|
// console.log(imageList);
|
|
|
|
|
this.imageList = imageList;
|
|
|
|
|
this.writeFeedback();
|
2020-07-07 17:47:00 +08:00
|
|
|
|
},
|
2020-07-10 17:38:21 +08:00
|
|
|
|
verifyContent() {
|
|
|
|
|
if(this.$u.test.isEmpty(this.text)) {
|
|
|
|
|
this.$u.toast('内容不可为空');
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
return true;
|
2020-07-07 17:47:00 +08:00
|
|
|
|
},
|
|
|
|
|
writeFeedback() {
|
2020-07-10 17:38:21 +08:00
|
|
|
|
if(!this.verifyContent()) return false;
|
2020-07-07 17:47:00 +08:00
|
|
|
|
this.$u.api.writeFeedback({
|
|
|
|
|
fb_content: this.text,
|
2020-07-10 17:38:21 +08:00
|
|
|
|
fb_images: this.imageList,
|
2020-07-07 17:47:00 +08:00
|
|
|
|
}).then(res => {
|
2020-07-10 17:38:21 +08:00
|
|
|
|
if(res.errCode == 0) {
|
2020-07-14 17:43:15 +08:00
|
|
|
|
this.$refs.uToast.show({
|
|
|
|
|
title: res.message,
|
|
|
|
|
duration: 2000,
|
|
|
|
|
callback:() => {
|
|
|
|
|
this.$u.route({
|
|
|
|
|
type: "navigateBack",
|
|
|
|
|
url: '/pageE/more/Complaints',
|
|
|
|
|
})
|
|
|
|
|
}
|
2020-07-10 17:38:21 +08:00
|
|
|
|
})
|
|
|
|
|
} else {
|
2020-08-03 18:38:04 +08:00
|
|
|
|
this.debounce = true;
|
2020-07-10 17:38:21 +08:00
|
|
|
|
this.$u.toast(res.message);
|
|
|
|
|
}
|
2020-07-07 17:47:00 +08:00
|
|
|
|
})
|
2020-06-04 08:21:34 +08:00
|
|
|
|
},
|
|
|
|
|
},
|
|
|
|
|
}
|
|
|
|
|
</script>
|
|
|
|
|
<style lang="scss" scoped>
|
|
|
|
|
.write-complaints {
|
|
|
|
|
min-height: calc(100vh - var(--window-top));
|
|
|
|
|
background-color: #ECECEC;
|
|
|
|
|
.main-container {
|
|
|
|
|
background-color: #ffffff;
|
|
|
|
|
padding: 30rpx;
|
|
|
|
|
textarea {
|
|
|
|
|
width: 100% !important;
|
|
|
|
|
margin-bottom: 60rpx;
|
|
|
|
|
}
|
|
|
|
|
.slot-btn {
|
|
|
|
|
width: 140rpx;
|
|
|
|
|
height: 140rpx;
|
|
|
|
|
background: rgba(236,236,236,1);
|
|
|
|
|
border-radius: 10rpx;
|
|
|
|
|
text-align: center;
|
2020-07-29 19:01:10 +08:00
|
|
|
|
> image {
|
2020-06-04 08:21:34 +08:00
|
|
|
|
margin-top: 48rpx;
|
|
|
|
|
width: 54rpx;
|
|
|
|
|
height: 49rpx;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
.write-btn {
|
|
|
|
|
margin: 120rpx auto 0;
|
|
|
|
|
width: 690rpx;
|
|
|
|
|
height: 98rpx;
|
|
|
|
|
background: rgba(255,120,15,1);
|
|
|
|
|
border-radius: 46rpx;
|
|
|
|
|
font-size: 36rpx;
|
|
|
|
|
color: rgba(255,255,255,1);
|
|
|
|
|
text-align: center;
|
|
|
|
|
line-height: 98rpx;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
</style>
|