Showing
1 changed file
with
71 additions
and
129 deletions
| @@ -22,7 +22,7 @@ | @@ -22,7 +22,7 @@ | ||
| 22 | </u-form-item> | 22 | </u-form-item> |
| 23 | <view class="info"> | 23 | <view class="info"> |
| 24 | <view class="info-contain"> | 24 | <view class="info-contain"> |
| 25 | - <u-form-item label="反馈" prop="feedbackInfo.message" borderBottom ref="item1"> | 25 | + <u-form-item required label="反馈" prop="feedbackInfo.message" borderBottom ref="item1"> |
| 26 | <u--textarea placeholder="请输入反馈信息" v-model="feedbackData.feedbackInfo.message" count></u--textarea> | 26 | <u--textarea placeholder="请输入反馈信息" v-model="feedbackData.feedbackInfo.message" count></u--textarea> |
| 27 | </u-form-item> | 27 | </u-form-item> |
| 28 | </view> | 28 | </view> |
| @@ -77,105 +77,45 @@ export default { | @@ -77,105 +77,45 @@ export default { | ||
| 77 | }, | 77 | }, |
| 78 | fileList1: [], | 78 | fileList1: [], |
| 79 | rules: { | 79 | rules: { |
| 80 | - 'feedbackInfo.title': [ | ||
| 81 | - { | ||
| 82 | - type: 'string', | ||
| 83 | - required: true, | ||
| 84 | - message: '请填写主题', | ||
| 85 | - trigger: ['blur', 'change'] | ||
| 86 | - }, | ||
| 87 | - { | ||
| 88 | - validator: (rule, value, callback) => { | ||
| 89 | - return uni.$u.test.chinese(value); | ||
| 90 | - }, | ||
| 91 | - message: '主题必须为中文', | ||
| 92 | - trigger: ['change', 'blur'] | ||
| 93 | - } | ||
| 94 | - ], | ||
| 95 | - 'feedbackInfo.name': [ | ||
| 96 | - { | ||
| 97 | - type: 'string', | ||
| 98 | - required: true, | ||
| 99 | - message: '请填写姓名', | ||
| 100 | - trigger: ['blur', 'change'] | ||
| 101 | - }, | ||
| 102 | - { | ||
| 103 | - validator: (rule, value, callback) => { | ||
| 104 | - return uni.$u.test.chinese(value); | ||
| 105 | - }, | ||
| 106 | - message: '姓名必须为中文', | ||
| 107 | - trigger: ['change', 'blur'] | ||
| 108 | - } | ||
| 109 | - ], | ||
| 110 | - 'feedbackInfo.phone': [ | ||
| 111 | - { | ||
| 112 | - type: 'number', | ||
| 113 | - required: true, | ||
| 114 | - message: '请填写手机号码', | ||
| 115 | - trigger: ['blur', 'change'] | ||
| 116 | - }, | ||
| 117 | - { | ||
| 118 | - validator: (rule, value, callback) => { | ||
| 119 | - const pattern=/^[0-11]*$/g | ||
| 120 | - if(pattern.test(value)){ | ||
| 121 | - }else{ | ||
| 122 | - return uni.$u.toast('手机号只能是数字且为11位数') | ||
| 123 | - } | ||
| 124 | - }, | ||
| 125 | - message: '手机号码不正确', | ||
| 126 | - trigger: ['change', 'blur'] | ||
| 127 | - } | ||
| 128 | - ], | ||
| 129 | - 'feedbackInfo.qq': [ | ||
| 130 | - { | ||
| 131 | - type: 'number', | ||
| 132 | - required: true, | ||
| 133 | - message: '请填写qq号码', | ||
| 134 | - trigger: ['blur', 'change'] | ||
| 135 | - }, | ||
| 136 | - { | ||
| 137 | - validator: (rule, value, callback) => { | ||
| 138 | - const pattern=/^[0-10]*$/g | ||
| 139 | - if(pattern.test(value)){ | ||
| 140 | - }else{ | ||
| 141 | - return uni.$u.toast('qq号只能是数字') | ||
| 142 | - } | ||
| 143 | - }, | ||
| 144 | - message: 'qq号码不正确', | ||
| 145 | - trigger: ['change', 'blur'] | ||
| 146 | - } | ||
| 147 | - ], | ||
| 148 | - 'feedbackInfo.email': [ | ||
| 149 | - { | ||
| 150 | - type: 'string', | ||
| 151 | - required: true, | ||
| 152 | - message: '请填写邮箱', | ||
| 153 | - trigger: ['blur', 'change'] | ||
| 154 | - }, | ||
| 155 | - { | ||
| 156 | - validator: (rule, value, callback) => { | ||
| 157 | - return uni.$u.test.email(value); | ||
| 158 | - }, | ||
| 159 | - message: '邮箱不正确', | ||
| 160 | - trigger: ['change', 'blur'] | ||
| 161 | - } | ||
| 162 | - ], | ||
| 163 | - 'feedbackInfo.message': [ | ||
| 164 | - { | ||
| 165 | - type: 'string', | ||
| 166 | - required: true, | ||
| 167 | - message: '请填写意见反馈', | ||
| 168 | - trigger: ['blur', 'change'] | ||
| 169 | - }, | ||
| 170 | - { | ||
| 171 | - validator: (rule, value, callback) => { | ||
| 172 | - return uni.$u.test.chinese(value); | ||
| 173 | - }, | ||
| 174 | - message: '意见反馈必须为中文', | ||
| 175 | - trigger: ['change', 'blur'] | ||
| 176 | - } | ||
| 177 | - ] | ||
| 178 | - } | 80 | + 'feedbackInfo.title': { |
| 81 | + type: 'string', | ||
| 82 | + required: true, | ||
| 83 | + message: '请填写主题或者主题格式错误', | ||
| 84 | + pattern:/^[\u4e00-\u9fa5]+$/, | ||
| 85 | + trigger: ['blur', 'change'] | ||
| 86 | + }, | ||
| 87 | + 'feedbackInfo.name': { | ||
| 88 | + type: 'string', | ||
| 89 | + required: true, | ||
| 90 | + pattern:/^[\u4e00-\u9fa5]+$/, | ||
| 91 | + message: '请填写姓名或者姓名格式错误', | ||
| 92 | + trigger: ['blur', 'change'] | ||
| 93 | + }, | ||
| 94 | + 'feedbackInfo.phone': { | ||
| 95 | + type: 'number', | ||
| 96 | + min: 11, | ||
| 97 | + message: '请填写手机或者手机格式错误', | ||
| 98 | + trigger: ['blur', 'change'] | ||
| 99 | + }, | ||
| 100 | + 'feedbackInfo.qq': { | ||
| 101 | + type: 'number', | ||
| 102 | + min: 8, | ||
| 103 | + message: '请填写qq或者qq格式错误', | ||
| 104 | + trigger: ['blur', 'change'] | ||
| 105 | + }, | ||
| 106 | + 'feedbackInfo.email': { | ||
| 107 | + type: 'email', | ||
| 108 | + message: '请填写邮箱或者邮箱格式错误', | ||
| 109 | + trigger: ['blur', 'change'] | ||
| 110 | + }, | ||
| 111 | + 'feedbackInfo.message': { | ||
| 112 | + type: 'string', | ||
| 113 | + required: true, | ||
| 114 | + message: '请填写意见反馈或者意见反馈格式错误', | ||
| 115 | + trigger: ['blur', 'change'] | ||
| 116 | + }, | ||
| 117 | + | ||
| 118 | + }, | ||
| 179 | }; | 119 | }; |
| 180 | }, | 120 | }, |
| 181 | onReady() { | 121 | onReady() { |
| @@ -255,37 +195,39 @@ export default { | @@ -255,37 +195,39 @@ export default { | ||
| 255 | this.$refs.myfeedBackFormRef | 195 | this.$refs.myfeedBackFormRef |
| 256 | .validate() | 196 | .validate() |
| 257 | .then(res => { | 197 | .then(res => { |
| 258 | - let contactInfo = { | ||
| 259 | - qq: this.feedbackData.feedbackInfo?.qq, | ||
| 260 | - email: this.feedbackData.feedbackInfo?.email, | ||
| 261 | - phone: this.feedbackData.feedbackInfo?.phone | ||
| 262 | - }; | ||
| 263 | - let httpData = { | ||
| 264 | - title: this.feedbackData.feedbackInfo.title, | ||
| 265 | - name: this.feedbackData.feedbackInfo.name, | ||
| 266 | - contact: JSON.stringify(contactInfo), | ||
| 267 | - images: this.feedbackData.feedbackInfo.images.length == 0 ? '' : JSON.stringify(this.feedbackData.feedbackInfo.images), | ||
| 268 | - message: this.feedbackData.feedbackInfo.message | ||
| 269 | - }; | ||
| 270 | - uni.$u.http | ||
| 271 | - .post('/yt/opinion', httpData) | ||
| 272 | - .then(res => { | ||
| 273 | - if (res) { | ||
| 274 | - uni.showToast({ | ||
| 275 | - title: '意见反馈提交成功~', | ||
| 276 | - icon: 'none' | ||
| 277 | - }); | ||
| 278 | - setTimeout(() => { | ||
| 279 | - uni.navigateBack(); | ||
| 280 | - }, 500); | ||
| 281 | - } | ||
| 282 | - }) | ||
| 283 | - .catch(e => { | ||
| 284 | - uni.$u.toast(e.data?.message); | ||
| 285 | - }); | 198 | + if(res){ |
| 199 | + let contactInfo = { | ||
| 200 | + qq: this.feedbackData.feedbackInfo?.qq, | ||
| 201 | + email: this.feedbackData.feedbackInfo?.email, | ||
| 202 | + phone: this.feedbackData.feedbackInfo?.phone | ||
| 203 | + }; | ||
| 204 | + let httpData = { | ||
| 205 | + title: this.feedbackData.feedbackInfo.title, | ||
| 206 | + name: this.feedbackData.feedbackInfo.name, | ||
| 207 | + contact: JSON.stringify(contactInfo), | ||
| 208 | + images: this.feedbackData.feedbackInfo.images.length == 0 ? '' : JSON.stringify(this.feedbackData.feedbackInfo.images), | ||
| 209 | + message: this.feedbackData.feedbackInfo.message | ||
| 210 | + }; | ||
| 211 | + uni.$u.http | ||
| 212 | + .post('/yt/opinion', httpData) | ||
| 213 | + .then(res => { | ||
| 214 | + if (res) { | ||
| 215 | + uni.showToast({ | ||
| 216 | + title: '意见反馈提交成功~', | ||
| 217 | + icon: 'none' | ||
| 218 | + }); | ||
| 219 | + setTimeout(() => { | ||
| 220 | + uni.navigateBack(); | ||
| 221 | + }, 500); | ||
| 222 | + } | ||
| 223 | + }) | ||
| 224 | + .catch(e => { | ||
| 225 | + uni.$u.toast(e.data?.message); | ||
| 226 | + }); | ||
| 227 | + } | ||
| 286 | }) | 228 | }) |
| 287 | .catch(errors => { | 229 | .catch(errors => { |
| 288 | - uni.$u.toast('校验失败'); | 230 | + uni.$u.toast('请填写或者请填写正确格式的数据'); |
| 289 | }); | 231 | }); |
| 290 | } | 232 | } |
| 291 | } | 233 | } |