guangchao.xu | 070005a | 2020-12-07 09:56:40 +0800 | [diff] [blame] | 1 | <template> |
| 2 | <view class="leaveMsg"> |
| 3 | <view class="leaveMsg-con"> |
| 4 | <u-input v-model="title" placeholder="请填写留言标题(14字符之内)" maxlength="14" /> |
| 5 | <u-input v-model="value" type="textarea" :border="false" height="300" :auto-height="true" placeholder="请填写您的留言内容(140字符之内)" |
| 6 | maxlength="140" /> |
| 7 | <u-upload :action="action" ref="uUpload" :max-size="2 * 1024 * 1024" max-count="4" @on-change="get" @on-remove="remove" |
| 8 | :header="header"></u-upload> |
| 9 | </view> |
| 10 | <u-button @click="submit" :custom-style="leaveMsgnBtn">提交留言</u-button> |
| 11 | </view> |
| 12 | </template> |
| 13 | |
| 14 | <script> |
guangchao.xu | 1bc4ccc | 2021-01-19 17:09:26 +0800 | [diff] [blame] | 15 | const app = getApp() |
guangchao.xu | 070005a | 2020-12-07 09:56:40 +0800 | [diff] [blame] | 16 | export default { |
| 17 | data() { |
| 18 | return { |
| 19 | title: "", |
| 20 | value: "", |
| 21 | action: "", |
| 22 | header: { |
| 23 | Authorization: "" |
| 24 | }, |
| 25 | leaveMsgnBtn: { |
| 26 | backgroundColor: ' #2FA8E1', |
| 27 | padding: '50rpx 0', |
| 28 | color: '#FFFFFF', |
| 29 | width: ' 600rpx', |
| 30 | fontSize: '30rpx', |
| 31 | border: '1px solid #2FA8E1', |
| 32 | marginTop: '50rpx' |
| 33 | }, |
| 34 | list: [] |
| 35 | } |
| 36 | }, |
| 37 | methods: { |
| 38 | get(res, index, lists) { |
| 39 | let that = this |
| 40 | let obj = { |
| 41 | minpicid: JSON.parse(res.data).minpicid, |
| 42 | picid: JSON.parse(res.data).picid |
| 43 | } |
| 44 | that.list.push(obj) |
| 45 | }, |
| 46 | submit() { |
| 47 | let that = this |
| 48 | let { |
| 49 | title, |
| 50 | value, |
| 51 | list |
| 52 | } = that |
| 53 | if (title == "") { |
| 54 | uni.showToast({ |
| 55 | icon: "none", |
| 56 | title: "请填写留言标题", |
| 57 | duration: 1500 |
| 58 | }) |
| 59 | return false |
| 60 | } |
| 61 | if (value == "") { |
| 62 | uni.showToast({ |
| 63 | icon: "none", |
| 64 | title: "请填写留言内容", |
| 65 | duration: 1500 |
| 66 | }) |
| 67 | return false |
| 68 | } |
guangchao.xu | 1bc4ccc | 2021-01-19 17:09:26 +0800 | [diff] [blame] | 69 | let version = app.globalData.version |
guangchao.xu | 070005a | 2020-12-07 09:56:40 +0800 | [diff] [blame] | 70 | let params = { |
guangchao.xu | 1bc4ccc | 2021-01-19 17:09:26 +0800 | [diff] [blame] | 71 | title, |
guangchao.xu | 070005a | 2020-12-07 09:56:40 +0800 | [diff] [blame] | 72 | content: value, |
guangchao.xu | 1bc4ccc | 2021-01-19 17:09:26 +0800 | [diff] [blame] | 73 | pictures: list, |
| 74 | version |
guangchao.xu | 070005a | 2020-12-07 09:56:40 +0800 | [diff] [blame] | 75 | } |
| 76 | that.$u.post("/v1/feedback/release", params).then(res => { |
| 77 | uni.showToast({ |
| 78 | title: "留言成功,我们将尽快给您回复", |
guangchao.xu | 1bc4ccc | 2021-01-19 17:09:26 +0800 | [diff] [blame] | 79 | icon: "none", |
| 80 | duration: 1500, |
guangchao.xu | 070005a | 2020-12-07 09:56:40 +0800 | [diff] [blame] | 81 | complete: (res) => { |
| 82 | setTimeout(() => { |
| 83 | uni.navigateBack({ |
guangchao.xu | 1bc4ccc | 2021-01-19 17:09:26 +0800 | [diff] [blame] | 84 | delta: 1 |
guangchao.xu | 070005a | 2020-12-07 09:56:40 +0800 | [diff] [blame] | 85 | }) |
| 86 | }, 1500) |
| 87 | } |
| 88 | }) |
| 89 | }) |
| 90 | }, |
| 91 | remove(index, lists) { |
| 92 | let that = this |
| 93 | that.list.splice(index, 1) |
| 94 | } |
| 95 | }, |
| 96 | onLoad() { |
| 97 | let that = this |
| 98 | let token = uni.getStorageSync("token") |
| 99 | that.action = that.$u.http.config.baseUrl + "/v1/uploadpic" |
| 100 | that.header.Authorization = "Bearer " + token |
| 101 | } |
| 102 | } |
| 103 | </script> |
| 104 | |
| 105 | <style lang="scss" scoped> |
| 106 | .leaveMsg { |
| 107 | width: 100vw; |
| 108 | height: 100vh; |
| 109 | background-color: #FFFFFF; |
| 110 | |
| 111 | &-btn { |
| 112 | background-color: #2FA8E1; |
| 113 | font-family: "PingFang-SC-Medium"; |
| 114 | color: #FFFFFF; |
| 115 | border-radius: 50rpx; |
| 116 | padding: 20rpx 30rpx; |
| 117 | font-size: 30rpx; |
| 118 | } |
| 119 | |
| 120 | &-con { |
| 121 | padding: 10rpx 30rpx; |
| 122 | } |
| 123 | } |
| 124 | </style> |