|
1 | 1 | <template> |
2 | | - <view class="page"> |
3 | | - <view class='feedback-title'> |
4 | | - <text>问题和意见</text> |
5 | | - <text class="feedback-quick" @tap="chooseMsg">快速键入</text> |
6 | | - </view> |
7 | | - <view class="feedback-body"> |
8 | | - <textarea placeholder="请详细描述你的问题和意见..." v-model="sendDate.content" class="feedback-textare" /> |
9 | | - </view> |
| 2 | + <view class="page"> |
| 3 | + <view class='feedback-title'> |
| 4 | + <text>问题和意见</text> |
| 5 | + <text class="feedback-quick" @tap="chooseMsg">快速键入</text> |
| 6 | + </view> |
| 7 | + <view class="feedback-body"> |
| 8 | + <textarea placeholder="请详细描述你的问题和意见..." v-model="sendDate.content" class="feedback-textare"></textarea> |
| 9 | + </view> |
10 | 10 | <view class='feedback-title'> |
11 | 11 | <text>图片(选填,提供问题截图,总大小10M以下)</text> |
12 | 12 | </view> |
|
25 | 25 | </view> |
26 | 26 | </block> |
27 | 27 | <view class="uni-uploader__input-box" v-show="imageList.length < 8"> |
28 | | - <view class="uni-uploader__input" @tap="chooseImg"></view> |
| 28 | + <view class="uni-uploader__input" @tap="chooseImg"></view> |
29 | 29 | </view> |
30 | 30 | </view> |
31 | 31 | </view> |
|
40 | 40 | <view class='feedback-title feedback-star-view'> |
41 | 41 | <text>应用评分</text> |
42 | 42 | <view class="feedback-star-view"> |
43 | | - <text class="feedback-star" v-for="(value,key) in stars" :key="key" :class="key < sendDate.score ? 'active' : ''" @tap="chooseStar(value)"></text> |
| 43 | + <text class="feedback-star" v-for="(value,key) in stars" :key="key" :class="key < sendDate.score ? 'active' : ''" |
| 44 | + @tap="chooseStar(value)"></text> |
44 | 45 | </view> |
45 | 46 | </view> |
46 | 47 | <button type="default" class="feedback-submit" @tap="send">提交</button> |
|
78 | 79 | this.sendDate = Object.assign(deviceInfo, this.sendDate); |
79 | 80 | }, |
80 | 81 | methods: { |
81 | | - close(e){ |
82 | | - this.imageList.splice(e,1); |
| 82 | + close(e) { |
| 83 | + this.imageList.splice(e, 1); |
83 | 84 | }, |
84 | 85 | chooseMsg() { //快速输入 |
85 | 86 | uni.showActionSheet({ |
|
105 | 106 | previewImage(index) { //预览图片 |
106 | 107 | uni.previewImage({ |
107 | 108 | urls: this.imageList, |
108 | | - current:this.imageList[index] |
| 109 | + current: this.imageList[index] |
109 | 110 | }); |
110 | 111 | }, |
111 | 112 | send() { //发送反馈 |
112 | 113 | console.log(JSON.stringify(this.sendDate)); |
| 114 | + if (this.imageList.length === 0) { |
| 115 | + uni.showModal({ |
| 116 | + content: '至少选择一张图片', |
| 117 | + showCancel: false |
| 118 | + }) |
| 119 | + return |
| 120 | + } |
| 121 | + if (this.sendDate.content.length === 0) { |
| 122 | + uni.showModal({ |
| 123 | + content: '请输入问题和意见', |
| 124 | + showCancel: false |
| 125 | + }) |
| 126 | + return |
| 127 | + } |
| 128 | + uni.showLoading({ |
| 129 | + title: '上传中...' |
| 130 | + }) |
113 | 131 | let imgs = this.imageList.map((value, index) => { |
114 | 132 | return { |
115 | 133 | name: "image" + index, |
|
121 | 139 | files: imgs, |
122 | 140 | formData: this.sendDate, |
123 | 141 | success: (res) => { |
124 | | - if (res.statusCode === 200) { |
125 | | - uni.showToast({ |
126 | | - title: "反馈成功!" |
127 | | - }); |
| 142 | + if (typeof res.data === 'string') { |
| 143 | + res.data = JSON.parse(res.data) |
| 144 | + } |
| 145 | + if (res.statusCode === 200 && res.data && res.data.ret === 0) { |
| 146 | + uni.showModal({ |
| 147 | + content: '反馈成功', |
| 148 | + showCancel: false |
| 149 | + }) |
128 | 150 | this.imageList = []; |
129 | 151 | this.sendDate = { |
130 | 152 | score: 0, |
131 | 153 | content: "", |
132 | 154 | contact: "" |
133 | 155 | } |
| 156 | + } else if (res.statusCode !== 200){ |
| 157 | + uni.showModal({ |
| 158 | + content: '反馈失败,错误码为:' + res.statusCode, |
| 159 | + showCancel: false |
| 160 | + }) |
| 161 | + } else { |
| 162 | + uni.showModal({ |
| 163 | + content: '反馈失败', |
| 164 | + showCancel: false |
| 165 | + }) |
134 | 166 | } |
135 | 167 | }, |
136 | 168 | fail: (res) => { |
137 | | - console.log(res) |
| 169 | + console.log(JSON.stringify(res)) |
| 170 | + }, |
| 171 | + complete() { |
| 172 | + uni.hideLoading() |
138 | 173 | } |
139 | 174 | }); |
140 | 175 | } |
|
150 | 185 | .input-view { |
151 | 186 | font-size: 28upx; |
152 | 187 | } |
153 | | - .close-view{ |
154 | | - text-align: center;line-height:14px;height: 16px;width: 16px;border-radius: 50%;background: #FF5053;color: #FFFFFF;position: absolute;top: -6px;right: -4px;font-size: 12px; |
| 188 | +
|
| 189 | + .close-view { |
| 190 | + text-align: center; |
| 191 | + line-height: 14px; |
| 192 | + height: 16px; |
| 193 | + width: 16px; |
| 194 | + border-radius: 50%; |
| 195 | + background: #FF5053; |
| 196 | + color: #FFFFFF; |
| 197 | + position: absolute; |
| 198 | + top: -6px; |
| 199 | + right: -4px; |
| 200 | + font-size: 12px; |
155 | 201 | } |
156 | 202 | </style> |
0 commit comments