|
@@ -0,0 +1,309 @@
|
|
1
|
+<template>
|
|
2
|
+ <div class="feedback-wrap">
|
|
3
|
+ <div v-if="isShowForm" class="form-wrap">
|
|
4
|
+ <div class="imgs-wrap">
|
|
5
|
+ <div class="label">
|
|
6
|
+ <span>图片证据(选填)</span>
|
|
7
|
+ <span class="count">{{ fileList.length }}张/9</span>
|
|
8
|
+ </div>
|
|
9
|
+ <div class="uploader-wrap">
|
|
10
|
+ <van-uploader class="img-item" v-model="fileList" multiple :max-count="9" accept="image/*" :before-read="beforeRead" :after-read="afterRead" />
|
|
11
|
+ </div>
|
|
12
|
+ </div>
|
|
13
|
+ <van-field
|
|
14
|
+ v-model="params.content"
|
|
15
|
+ rows="3"
|
|
16
|
+ autosize
|
|
17
|
+ :label="''"
|
|
18
|
+ type="textarea"
|
|
19
|
+ maxlength="200"
|
|
20
|
+ placeholder="投诉内容(必填)"
|
|
21
|
+ show-word-limit
|
|
22
|
+ />
|
|
23
|
+ <div class="footer">
|
|
24
|
+ <van-button type="success" size="small" @click="onClickSubmit">提交</van-button>
|
|
25
|
+ </div>
|
|
26
|
+ </div>
|
|
27
|
+
|
|
28
|
+ <div v-else class="typeList-wrap">
|
|
29
|
+ <p class="notice">{{ typeList.notice }}</p>
|
|
30
|
+ <van-cell v-for="item in typeList.data" :key="item.type" :title="item.title" is-link size="large" @click="onClickTypeItem(item)" />
|
|
31
|
+ </div>
|
|
32
|
+ </div>
|
|
33
|
+</template>
|
|
34
|
+
|
|
35
|
+<script lang="ts" setup>
|
|
36
|
+import { getQueryString } from '@/utils/common'
|
|
37
|
+import { onBeforeMount, onMounted, reactive, ref } from "vue";
|
|
38
|
+import { Toast, Cell, Uploader, Button } from 'vant';
|
|
39
|
+import $axios from '@/utils/axios'
|
|
40
|
+import { useRouter } from 'vue-router'
|
|
41
|
+const $router = useRouter()
|
|
42
|
+
|
|
43
|
+interface IRes<T = any> {
|
|
44
|
+ errno: string | number
|
|
45
|
+ rst: T
|
|
46
|
+ [index: string]: any
|
|
47
|
+}
|
|
48
|
+
|
|
49
|
+const params = reactive({
|
|
50
|
+ corpid: getQueryString('corpid'),
|
|
51
|
+ user_id: getQueryString('user_id'),
|
|
52
|
+ external_userid: '',
|
|
53
|
+ type: '', // 反馈类型
|
|
54
|
+ content: '', // 反馈内容
|
|
55
|
+ attachments: [], // 反馈图片
|
|
56
|
+})
|
|
57
|
+
|
|
58
|
+
|
|
59
|
+const typeList = ref({})
|
|
60
|
+const isShowForm = ref(false)
|
|
61
|
+
|
|
62
|
+const goUrl = (url) => {
|
|
63
|
+ let link = document.createElement("a");
|
|
64
|
+ link.href = url;
|
|
65
|
+ document.body.appendChild(link);
|
|
66
|
+ link.click();
|
|
67
|
+ document.body.removeChild(link);
|
|
68
|
+}
|
|
69
|
+
|
|
70
|
+const getUserInfo = () => {
|
|
71
|
+ Toast.loading({
|
|
72
|
+ duration: 0,
|
|
73
|
+ message: '加载中...',
|
|
74
|
+ forbidClick: true,
|
|
75
|
+ });
|
|
76
|
+ $axios.get('/api/oauth2/userInfo', {
|
|
77
|
+ corpid: getQueryString('corpid'),
|
|
78
|
+ code: getQueryString('code'),
|
|
79
|
+ state: getQueryString('state')
|
|
80
|
+ }, true).then((res) => {
|
|
81
|
+ Toast.clear()
|
|
82
|
+ params.external_userid = res.rst.external_userid
|
|
83
|
+ }).catch((err) => {
|
|
84
|
+ Toast.clear()
|
|
85
|
+ Toast(err.message)
|
|
86
|
+ })
|
|
87
|
+}
|
|
88
|
+
|
|
89
|
+// 动态修改微信网页标题
|
|
90
|
+const setTitle = function (t) {
|
|
91
|
+ document.title = t;
|
|
92
|
+ var i = document.createElement("iframe");
|
|
93
|
+ i.src = "./favicon.ico";
|
|
94
|
+ i.style.display = "none";
|
|
95
|
+ i.onload = function () {
|
|
96
|
+ setTimeout(function () {
|
|
97
|
+ i.remove();
|
|
98
|
+ }, 9);
|
|
99
|
+ };
|
|
100
|
+ document.body.appendChild(i);
|
|
101
|
+};
|
|
102
|
+const changeTitleClick = () => {
|
|
103
|
+ setTimeout(function () {
|
|
104
|
+ setTitle("意见反馈");
|
|
105
|
+ }, 1);
|
|
106
|
+}
|
|
107
|
+
|
|
108
|
+const handleGetList = async () => {
|
|
109
|
+ try {
|
|
110
|
+ Toast.loading({
|
|
111
|
+ message: '加载中...',
|
|
112
|
+ duration: 0,
|
|
113
|
+ forbidClick: true,
|
|
114
|
+ })
|
|
115
|
+ const { errno, rst, err } = await $axios.get('/api/opinionFeedbackTypeList', {}) as IRes
|
|
116
|
+ if (errno == 0 && rst) {
|
|
117
|
+ typeList.value = {...rst}
|
|
118
|
+ } else {
|
|
119
|
+ Toast({ message: err || '加载失败' })
|
|
120
|
+ }
|
|
121
|
+ } catch (error) {
|
|
122
|
+ console.log('error =>', error)
|
|
123
|
+ } finally {
|
|
124
|
+ Toast.clear();
|
|
125
|
+ }
|
|
126
|
+}
|
|
127
|
+
|
|
128
|
+const onClickTypeItem = (typeItem) => {
|
|
129
|
+ if (typeItem && typeItem.child) {
|
|
130
|
+ typeList.value = {...typeItem.child}
|
|
131
|
+ } else {
|
|
132
|
+ params.type = typeItem.type
|
|
133
|
+ isShowForm.value = true
|
|
134
|
+ }
|
|
135
|
+}
|
|
136
|
+
|
|
137
|
+
|
|
138
|
+const fileList = ref([])
|
|
139
|
+const afterRead = (file) => {
|
|
140
|
+ // 此时可以自行将文件上传至服务器
|
|
141
|
+ if (file.length) { //判断是否选择了多个文件,如果是的话,循环遍历单个文件上传
|
|
142
|
+ file.forEach((f) => {
|
|
143
|
+ handleUploadFile(f);
|
|
144
|
+ });
|
|
145
|
+ } else {
|
|
146
|
+ handleUploadFile(file);
|
|
147
|
+ }
|
|
148
|
+};
|
|
149
|
+const beforeRead = (file) => {
|
|
150
|
+ const maxSize = 1000 * 1024 * 10;
|
|
151
|
+ if (file.size >= maxSize) {
|
|
152
|
+ Toast('图片大小不能超过10M');
|
|
153
|
+ return false
|
|
154
|
+ } else {
|
|
155
|
+ return true
|
|
156
|
+ }
|
|
157
|
+}
|
|
158
|
+const handleUploadFile = (file) => {
|
|
159
|
+ const formData = new FormData();
|
|
160
|
+ formData.append("file", file.file);
|
|
161
|
+ formData.append("corpid", params.corpid);
|
|
162
|
+ formData.append("type", '1');
|
|
163
|
+
|
|
164
|
+ Toast.loading({
|
|
165
|
+ duration: 0, // 持续展示 toast
|
|
166
|
+ forbidClick: true,
|
|
167
|
+ message: '上传中',
|
|
168
|
+ });
|
|
169
|
+
|
|
170
|
+ $axios.upload('/api/uploadFileToOss', formData).then((res) => {
|
|
171
|
+ Toast.clear()
|
|
172
|
+ const { url } = res.rst
|
|
173
|
+ file.url = url
|
|
174
|
+ }).catch((err) => {
|
|
175
|
+ Toast.clear()
|
|
176
|
+ Toast(err.message)
|
|
177
|
+ })
|
|
178
|
+}
|
|
179
|
+
|
|
180
|
+
|
|
181
|
+// 判断当前环境
|
|
182
|
+const isWechat = () => {
|
|
183
|
+ var ua = window.navigator.userAgent.toLowerCase();
|
|
184
|
+ if (ua.match(/micromessenger/i) == 'micromessenger') { // 判断是否在微信浏览器内
|
|
185
|
+ return true;
|
|
186
|
+ } else {
|
|
187
|
+ return false;
|
|
188
|
+ }
|
|
189
|
+}
|
|
190
|
+function closePage() {
|
|
191
|
+ // isWechat是我写的一个判断当前环境是否是微信内置浏览器 的方法
|
|
192
|
+ if (!isWechat()) return // 非微信环境下,不做处理
|
|
193
|
+ setTimeout(function() {
|
|
194
|
+ //安卓手机
|
|
195
|
+ document.addEventListener("WeixinJSBridgeReady", function() {
|
|
196
|
+ WeixinJSBridge.call("closeWindow");
|
|
197
|
+ }, false);
|
|
198
|
+ //ios手机
|
|
199
|
+ WeixinJSBridge.call("closeWindow");
|
|
200
|
+ }, 100);
|
|
201
|
+}
|
|
202
|
+
|
|
203
|
+const onClickSubmit = () => {
|
|
204
|
+ if (!params.content) {
|
|
205
|
+ Toast('请输入投诉内容')
|
|
206
|
+ return false
|
|
207
|
+ }
|
|
208
|
+
|
|
209
|
+ Toast.loading({
|
|
210
|
+ duration: 0,
|
|
211
|
+ message: '加载中...',
|
|
212
|
+ forbidClick: true,
|
|
213
|
+ });
|
|
214
|
+ $axios.post('/api/userOpinionFeedbackAction', {
|
|
215
|
+ corpid: params.corpid,
|
|
216
|
+ user_id: params.user_id,
|
|
217
|
+ external_userid: params.external_userid,
|
|
218
|
+ type: params.type,
|
|
219
|
+ content: params.content,
|
|
220
|
+ attachments: fileList.value && fileList.value.length ? fileList.value.map(f => f.url) : [],
|
|
221
|
+ }).then(res => {
|
|
222
|
+ Toast(JSON.stringify(res))
|
|
223
|
+ if (res && res.errno == 0) {
|
|
224
|
+ isShowForm.value = false
|
|
225
|
+ $router.replace('/feedback/success')
|
|
226
|
+ } else {
|
|
227
|
+ Toast(res.err || '提交失败')
|
|
228
|
+ }
|
|
229
|
+ }).catch((err) => {
|
|
230
|
+ Toast.clear()
|
|
231
|
+ Toast(err.message)
|
|
232
|
+ })
|
|
233
|
+}
|
|
234
|
+
|
|
235
|
+onBeforeMount(() => {
|
|
236
|
+ if (getQueryString('againJump')) {
|
|
237
|
+ getUserInfo()
|
|
238
|
+ } else {
|
|
239
|
+ let redirect_uri = encodeURIComponent(window.location.href + '&againJump=true')
|
|
240
|
+ let url = `https://open.weixin.qq.com/connect/oauth2/authorize?appid=${getQueryString('corpid')}&redirect_uri=${redirect_uri}&response_type=code&scope=snsapi_base&state=1&agentid=1000012#wechat_redirect`;
|
|
241
|
+ goUrl(url)
|
|
242
|
+ }
|
|
243
|
+});
|
|
244
|
+
|
|
245
|
+onMounted(() => {
|
|
246
|
+ changeTitleClick()
|
|
247
|
+ handleGetList()
|
|
248
|
+})
|
|
249
|
+</script>
|
|
250
|
+
|
|
251
|
+<style lang="scss" scoped>
|
|
252
|
+.feedback-wrap {
|
|
253
|
+ background-color: #f8f8f8;
|
|
254
|
+ min-height: 100vh;
|
|
255
|
+ .form-wrap {
|
|
256
|
+ .imgs-wrap {
|
|
257
|
+ background-color: #fff;
|
|
258
|
+ margin-bottom: 2px;
|
|
259
|
+ .label {
|
|
260
|
+ padding: 20px 14px;
|
|
261
|
+ font-size: 16px;
|
|
262
|
+ color: rgb(50, 50, 51);
|
|
263
|
+ display: flex;
|
|
264
|
+ align-items: center;
|
|
265
|
+ justify-content: space-between;
|
|
266
|
+ .count {
|
|
267
|
+ color: #999;
|
|
268
|
+ }
|
|
269
|
+ }
|
|
270
|
+ .uploader-wrap {
|
|
271
|
+ .img-item {
|
|
272
|
+ padding: 0 0 0 16px;
|
|
273
|
+ :deep(.van-uploader__preview) {
|
|
274
|
+ width: 29vw;
|
|
275
|
+ height: 29vw;
|
|
276
|
+ }
|
|
277
|
+ :deep(.van-uploader__upload) {
|
|
278
|
+ width: 29vw;
|
|
279
|
+ height: 29vw;
|
|
280
|
+ }
|
|
281
|
+ :deep(.van-uploader__preview-image) {
|
|
282
|
+ width: 29vw;
|
|
283
|
+ height: 29vw;
|
|
284
|
+ }
|
|
285
|
+ }
|
|
286
|
+ }
|
|
287
|
+ }
|
|
288
|
+
|
|
289
|
+ .footer {
|
|
290
|
+ padding: 40px;
|
|
291
|
+ display: flex;
|
|
292
|
+ justify-content: center;
|
|
293
|
+ .van-button {
|
|
294
|
+ width: 40vw;
|
|
295
|
+ font-size: 16px;
|
|
296
|
+ }
|
|
297
|
+ }
|
|
298
|
+
|
|
299
|
+ }
|
|
300
|
+ .typeList-wrap {
|
|
301
|
+ .notice {
|
|
302
|
+ padding: 20px 14px 6px;
|
|
303
|
+ font-size: 16px;
|
|
304
|
+ color: #666;
|
|
305
|
+ }
|
|
306
|
+ }
|
|
307
|
+}
|
|
308
|
+
|
|
309
|
+</style>
|