| <template> |
| <view class="leaveMsg"> |
| <view class="leaveMsg-con"> |
| <u-input v-model="title" placeholder="请填写留言标题(14字符之内)" maxlength="14" /> |
| <u-input v-model="value" type="textarea" :border="false" height="300" :auto-height="true" placeholder="请填写您的留言内容(140字符之内)" |
| maxlength="140" /> |
| <u-upload :action="action" ref="uUpload" :max-size="2 * 1024 * 1024" max-count="4" @on-change="get" @on-remove="remove" |
| :header="header"></u-upload> |
| </view> |
| <u-button @click="submit" :custom-style="leaveMsgnBtn">提交留言</u-button> |
| </view> |
| </template> |
| |
| <script> |
| const app = getApp() |
| export default { |
| data() { |
| return { |
| title: "", |
| value: "", |
| action: "", |
| header: { |
| Authorization: "" |
| }, |
| leaveMsgnBtn: { |
| backgroundColor: ' #2FA8E1', |
| padding: '50rpx 0', |
| color: '#FFFFFF', |
| width: ' 600rpx', |
| fontSize: '30rpx', |
| border: '1px solid #2FA8E1', |
| marginTop: '50rpx' |
| }, |
| list: [] |
| } |
| }, |
| methods: { |
| get(res, index, lists) { |
| let that = this |
| let obj = { |
| minpicid: JSON.parse(res.data).minpicid, |
| picid: JSON.parse(res.data).picid |
| } |
| that.list.push(obj) |
| }, |
| submit() { |
| let that = this |
| let { |
| title, |
| value, |
| list |
| } = that |
| if (title == "") { |
| uni.showToast({ |
| icon: "none", |
| title: "请填写留言标题", |
| duration: 1500 |
| }) |
| return false |
| } |
| if (value == "") { |
| uni.showToast({ |
| icon: "none", |
| title: "请填写留言内容", |
| duration: 1500 |
| }) |
| return false |
| } |
| let version = app.globalData.version |
| let params = { |
| title, |
| content: value, |
| pictures: list, |
| version |
| } |
| that.$u.post("/v1/feedback/release", params).then(res => { |
| uni.showToast({ |
| title: "留言成功,我们将尽快给您回复", |
| icon: "none", |
| duration: 1500, |
| complete: (res) => { |
| setTimeout(() => { |
| uni.navigateBack({ |
| delta: 1 |
| }) |
| }, 1500) |
| } |
| }) |
| }) |
| }, |
| remove(index, lists) { |
| let that = this |
| that.list.splice(index, 1) |
| } |
| }, |
| onLoad() { |
| let that = this |
| let token = uni.getStorageSync("token") |
| that.action = that.$u.http.config.baseUrl + "/v1/uploadpic" |
| that.header.Authorization = "Bearer " + token |
| } |
| } |
| </script> |
| |
| <style lang="scss" scoped> |
| .leaveMsg { |
| width: 100vw; |
| height: 100vh; |
| background-color: #FFFFFF; |
| |
| &-btn { |
| background-color: #2FA8E1; |
| font-family: "PingFang-SC-Medium"; |
| color: #FFFFFF; |
| border-radius: 50rpx; |
| padding: 20rpx 30rpx; |
| font-size: 30rpx; |
| } |
| |
| &-con { |
| padding: 10rpx 30rpx; |
| } |
| } |
| </style> |