report.vue
6.57 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
<template>
<v-layout id="Report" column justify-center align-center>
<v-card flat class="ExplanationBlock" >
<h3 id="ReportTitle">违法举报</h3>
</v-card>
<v-flex>
<div class="label">举报对象</div>
<v-card flat class="ExplanationBlock" >
<div class="reportTarget">{{target}}</div>
</v-card>
<div class="label">借条编号</div>
<v-card flat class="ExplanationBlock" >
<div class="reportTarget">{{info.listNo}}</div>
</v-card>
<div class="label">举报原因</div>
<v-card flat class="ButtonBlock">
<div class="ButtonContainer">
<v-btn
depressed
v-for="(item, index) in buttons"
:key="index"
:class="chosenBtnIndex === index ? 'isChosen' : ''"
@click="usageChosen(item, index)"
class="BorrowUsageBtn">
{{item.text}}
</v-btn>
</div>
</v-card>
<div class="label">举报内容(不超过300字)</div>
<v-card flat class="ExplanationBlock" >
<textarea
v-model="form.content"
name="ExplanationTextarea"
placeholder="请输入举报内容"
maxlength="300"
id="ExplanationTextarea" cols="30" rows="5"></textarea>
</v-card>
<div class="label">图片说明(非必填,不超过9张)</div>
<v-card flat class="ImgBlock">
<ImgUploader :limit="9" @change="updateImgs"/>
</v-card>
<div class="ConfirmButtonBlock">
<v-btn depressed id="ConfirmButton" @click="submit">确认举报</v-btn>
</div>
<v-dialog v-model="dialogDisplay" persistent max-width="290">
<v-card class="hintDialog">
<v-card-title class="headline">提示</v-card-title>
<v-card-text class='dialogContent'>{{dialogInfo}}</v-card-text>
<v-card-actions>
<v-spacer></v-spacer>
<v-btn color="black" flat @click.native="dialogDisplay = false">知道了</v-btn>
</v-card-actions>
</v-card>
</v-dialog>
</v-flex>
</v-layout>
</template>
<script>
import ImgUploader from "@/components/ImgUploader"
import {wechatShareSetting} from '@/helper'
export default {
async asyncData({store, query, app, redirect}) {
let {data} = await app.$axios.get(`/iou?id=${query.id}&userId=${store.state.user.id}`)
if (data.success) {
return {info: data.info}
} else {
store.dispatch('displayMessage', data.msg)
redirect(301, '/')
}
},
data:() => ({
form: {
kind: '',
content: '',
imgs: [],
},
buttons: [{text: '骗条'}, {text: '还贷未消条'},{text: '其他'}],
chosenBtnIndex: '',
dialogDisplay: false,
dialogInfo: '',
isLoading: false
}),
head:() => ({
title: '违法举报'
}),
computed: {
target() {
let target = ''
if (this.info) {
target = this.info.borrowerId === this.$store.state.user.id ? this.info.Creditor.name : this.info.Borrower.name
}
return target
},
},
components: {
ImgUploader
},
mounted() {
wechatShareSetting(this.$axios, this.$store)
},
methods: {
showDialog(info) {
this.dialogInfo = info
this.dialogDisplay = true
},
usageChosen(item, index) {
this.chosenBtnIndex = index
this.form.kind = item.text
},
updateImgs(e) {
this.form.imgs = e
},
formCheck() {
if (!this.form.kind) {
this.showDialog('请选择举报原因!')
return false
}
return true
},
async submit() {
this.isLoading = true
const could = this.formCheck()
if (!could) return
const form = new FormData()
form.append('userId', this.$store.state.user.id)
form.append('id', this.info.id)
form.append('kind', this.form.kind)
form.append('content', this.form.content)
for (let i = 0; i < this.form.imgs.length; i++) {
const img = this.form.imgs[i]
form.append(`img${i + 1}`, img)
}
let {data} = await this.$axios.post('/report', form)
this.isLoading = false
if (data.success) {
this.$store.dispatch('setMessageRedirect', `back`)
this.$store.dispatch('displayMessage', '举报提交成功')
// this.$router.push('/')
} else {
this.$store.dispatch('displayMessage', data.msg)
}
}
}
}
</script>
<style lang="scss" scoped>
#Report {
#ReportTitle {
display: block;
font-size: 18px;
width: calc(100vw - 2rem);
color: $light-gold;
border-left: 0.25rem solid $light-gold;
padding-left: 0.75rem;
margin: 1rem;
}
.label {
width: 100vw;
height: 2.3rem;
line-height: 2.3rem;
font-size: 0.75rem;
color: #B9B9BA;
padding-left: 0.9rem;
box-sizing: border-box;
}
.reportTarget {
height: 2rem;
font-size: 1rem;
line-height: 2rem;
padding: 0 1rem;
}
.ButtonBlock {
width: 100vw;
padding: 0 1.3rem;
.ButtonContainer {
display: flex;
width: 100%;
justify-content: space-around;
align-items: center;
flex-direction: row;
flex-wrap: wrap;
.BorrowUsageBtn {
width: 6.2rem;
height: 2rem;
margin: 0.6rem 0;
color: #666;
background-color: $background-black;
&.isChosen {
color: #fff;
background-image: linear-gradient(-229deg, #DAB269 37%, #E7C78C 87%);
}
}
}
}
.ExplanationBlock {
width: 100vw;
#ExplanationTextarea {
width: 100%;
outline: none;
padding: 1rem;
}
}
.ImgBlock {
min-height: 7rem;
padding: 1rem 0.8rem;
}
.ConfirmButtonBlock {
width: 90vw;
margin: 2.5rem auto;
#ConfirmButton {
color: #484646;
background-image: linear-gradient(-213deg, #DAB269 0%, #E7C78C 92%);
border-radius: 2px;
width: 100%;
height: 2.8rem;
font-size: 18px;
margin: auto;
}
}
}
.hintDialog {
background-color: #fff;
color: #000;
.headline {
justify-content: center;
font-weight: bold;
padding-bottom: 0;
}
.dialogContent {
justify-content: center;
text-align: center;
.warningIcon {
margin-bottom: 0.5rem;
color: red;
font-size: 5rem;
}
.bold {
font-weight: bold;
}
p {
margin-bottom: 0;
}
}
.btn {
width: 100%;
}
}
</style>