@uxda/appkit 4.2.82 → 4.2.84

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (127) hide show
  1. package/.eslintrc.mjs +7 -7
  2. package/README.md +187 -187
  3. package/babel.config.js +12 -12
  4. package/dist/appkit.css +41 -3
  5. package/dist/index.js +994 -535
  6. package/package.json +81 -81
  7. package/project.config.json +15 -15
  8. package/project.tt.json +13 -13
  9. package/rollup.config.mjs +77 -77
  10. package/src/Appkit.ts +67 -67
  11. package/src/balance/api/endpoints.ts +133 -133
  12. package/src/balance/api/index.ts +112 -106
  13. package/src/balance/components/AccountView.vue +773 -773
  14. package/src/balance/components/BalanceCard.vue +210 -210
  15. package/src/balance/components/BalanceReminder.vue +84 -84
  16. package/src/balance/components/ConsumptionFilter.vue +218 -218
  17. package/src/balance/components/ConsumptionRules.vue +68 -68
  18. package/src/balance/components/DateFilter.vue +259 -259
  19. package/src/balance/components/DateRange.vue +111 -111
  20. package/src/balance/components/ListFilter.vue +62 -62
  21. package/src/balance/components/ListFilterPicker.vue +191 -191
  22. package/src/balance/components/PromoterCard.vue +310 -310
  23. package/src/balance/components/SecondBalance.vue +77 -77
  24. package/src/balance/components/Tip.vue +45 -45
  25. package/src/balance/components/index.ts +8 -8
  26. package/src/balance/types.ts +99 -99
  27. package/src/components/bt-cropper/index.vue +730 -730
  28. package/src/components/bt-cropper/utils/calcCropper.js +42 -42
  29. package/src/components/bt-cropper/utils/calcImagePosition.js +23 -23
  30. package/src/components/bt-cropper/utils/calcImageSize.js +37 -37
  31. package/src/components/bt-cropper/utils/calcPointDistance.js +12 -12
  32. package/src/components/bt-cropper/utils/calcRightAndBottom.js +7 -7
  33. package/src/components/bt-cropper/utils/ratio.js +3 -3
  34. package/src/components/bt-cropper/utils/tools.js +25 -25
  35. package/src/components/dd-area/index.vue +225 -225
  36. package/src/components/dd-icon/doc.md +21 -21
  37. package/src/components/dd-icon/index.vue +23 -23
  38. package/src/components/dd-notice-bar/index.vue +78 -78
  39. package/src/components/dd-search/doc.md +34 -34
  40. package/src/components/dd-search/index.vue +168 -168
  41. package/src/components/dd-selector/index.vue +124 -124
  42. package/src/components/dd-skeleton/doc.md +19 -19
  43. package/src/components/dd-skeleton/index.vue +36 -36
  44. package/src/global.ts +6 -6
  45. package/src/index.ts +93 -93
  46. package/src/main.scss +1 -1
  47. package/src/notice/api/endpoints.ts +54 -17
  48. package/src/notice/api/index.ts +115 -106
  49. package/src/notice/components/NoticeBanner.vue +247 -247
  50. package/src/notice/components/NoticeEntry.vue +99 -99
  51. package/src/notice/components/NoticeList.vue +311 -311
  52. package/src/notice/components/NoticeList2.vue +243 -0
  53. package/src/notice/components/NoticePopup.vue +163 -163
  54. package/src/notice/components/index.ts +6 -5
  55. package/src/notice/components/useCommonList.ts +86 -86
  56. package/src/notice/components/useNotice.ts +35 -35
  57. package/src/notice/index.ts +1 -1
  58. package/src/notice/types.ts +25 -25
  59. package/src/payment/api/config.ts +7 -7
  60. package/src/payment/api/endpoints.ts +95 -95
  61. package/src/payment/api/index.ts +101 -101
  62. package/src/payment/components/AmountPicker.vue +90 -90
  63. package/src/payment/components/RechargeResult.vue +69 -69
  64. package/src/payment/components/RechargeView.vue +190 -190
  65. package/src/payment/components/RightsPicker.vue +105 -105
  66. package/src/payment/components/TradeView.vue +363 -363
  67. package/src/payment/components/UserAgreement.vue +234 -234
  68. package/src/payment/components/index.ts +22 -22
  69. package/src/payment/index.ts +5 -5
  70. package/src/payment/services/index.ts +16 -16
  71. package/src/payment/services/invoke-recharge.ts +25 -25
  72. package/src/payment/services/request-payment.ts +130 -130
  73. package/src/payment/types.ts +32 -32
  74. package/src/register/components/SelfRegistration.vue +233 -233
  75. package/src/register/components/index.ts +2 -2
  76. package/src/scenarios/components/SharePoster.vue +364 -364
  77. package/src/scenarios/components/index.ts +2 -2
  78. package/src/scenarios/components/poster-paste.vue +93 -93
  79. package/src/scenarios/components/share-poster.md +273 -273
  80. package/src/shared/components/AppDrawer.vue +53 -53
  81. package/src/shared/components/AppVerify.vue +128 -128
  82. package/src/shared/components/DeviceVersion.vue +78 -78
  83. package/src/shared/components/EmptyView.vue +33 -33
  84. package/src/shared/components/OcrBusinessLicense.vue +137 -137
  85. package/src/shared/components/OcrIcon.vue +229 -229
  86. package/src/shared/components/PageHeader.vue +84 -84
  87. package/src/shared/components/index.ts +8 -8
  88. package/src/shared/composables/index.ts +9 -9
  89. package/src/shared/composables/useAmount.ts +46 -46
  90. package/src/shared/composables/useCountdown.ts +46 -46
  91. package/src/shared/composables/useCrypto.ts +76 -76
  92. package/src/shared/composables/useDeviceEnv.ts +11 -11
  93. package/src/shared/composables/useDragBox.ts +97 -97
  94. package/src/shared/composables/useEncode.ts +43 -43
  95. package/src/shared/composables/useLogger.ts +131 -131
  96. package/src/shared/composables/useSafeArea.ts +46 -46
  97. package/src/shared/composables/useTabbar.ts +24 -24
  98. package/src/shared/composables/useUpload.ts +61 -61
  99. package/src/shared/composables/useValidator.ts +32 -32
  100. package/src/shared/composables/useWxAuth.ts +48 -48
  101. package/src/shared/http/Http.ts +148 -146
  102. package/src/shared/http/index.ts +1 -1
  103. package/src/shared/http/types.ts +163 -160
  104. package/src/shared/index.ts +8 -8
  105. package/src/shared/weixin/index.ts +9 -9
  106. package/src/shared/weixin/jssdk.ts +103 -103
  107. package/src/shared/weixin/payment.ts +38 -38
  108. package/src/styles/vars.scss +3 -3
  109. package/src/user/api/endpoints.ts +17 -17
  110. package/src/user/api/index.ts +117 -111
  111. package/src/user/components/LoginSetting.vue +114 -114
  112. package/src/user/components/UserAuth.vue +220 -220
  113. package/src/user/components/UserBinding.vue +277 -277
  114. package/src/user/components/UserBindingSuccess.vue +80 -80
  115. package/src/user/components/UserEntry.vue +139 -139
  116. package/src/user/components/UserFeedback.vue +427 -427
  117. package/src/user/components/UserFeedbackEntry.vue +175 -175
  118. package/src/user/components/UserHeadCrop.vue +65 -65
  119. package/src/user/components/UserInfo.vue +708 -708
  120. package/src/user/components/UserResourceEmpty.vue +75 -75
  121. package/src/user/components/index.ts +23 -23
  122. package/src/user/index.ts +1 -1
  123. package/src/utils/utils.ts +28 -28
  124. package/tsconfig.json +30 -30
  125. package/types/global.d.ts +22 -22
  126. package/types/vue.d.ts +10 -10
  127. /package/dist/assets/{asset-DcH8Kg-2 → asset-3B_CoPto} +0 -0
@@ -1,427 +1,427 @@
1
- <template>
2
- <div class="user-feedback" :class="{ isSuccess }">
3
- <div v-if="!isSuccess" class="user-feedback-wrap">
4
- <img src="https://cdn.ddjf.com/static/images/customer-center/feedback-img.png"
5
- style="width: 311px;height:149.5px;margin: 0 auto;" />
6
- <div class="user-feedback-tit">补充描述</div>
7
- <div class="user-feedback-body">
8
- <editor id="myEditor" :show-img-resize="true" class="user-feedback-editor" placeholder="请输入补充描述" />
9
- <div class="user-feedback-handle">
10
- <div class="user-feedback-handle-item" v-for="(item, key) in formState.attachment" :key="key">
11
- <template v-if="item.status === 'done'">
12
- <img v-if="item.type === 'image'" class="user-feedback-handle-item-img" mode="aspectFit"
13
- :src="item.url" />
14
- <video class="user-feedback-handle-item-img" :src="item.url" v-else />
15
- <div class="user-feedback-handle-item-close" @click="onDelete(key)">
16
- <img class="user-feedback-handle-item-close-img"
17
- src="https://cdn.ddjf.com/static/images/customer-center/close-filled.png" />
18
- </div>
19
- </template>
20
- <img class="user-feedback-handle-item-loading" mode="aspectFit"
21
- src="https://cdn.ddjf.com/static/images/customer-center/loading.png" alt="" />
22
- </div>
23
- <div class="user-feedback-handle-item" @click="toUpload">+</div>
24
- </div>
25
- </div>
26
-
27
- <div class="user-feedback-footer">
28
- <nut-button class="user-feedback-footer-btn" plain type="primary" @click="onCancel">最小化</nut-button>
29
- <nut-button class="user-feedback-footer-btn" type="primary" @click="onOk">反馈</nut-button>
30
- </div>
31
- </div>
32
- <div class="user-feedback-wrap" v-else>
33
- <img class="user-feedback-success-img" mode="aspectFit"
34
- src="https://cdn.ddjf.com/static/images/customer-center/success-icon.png" />
35
- <div class="user-feedback-success-info">提交成功</div>
36
- </div>
37
- </div>
38
- </template>
39
-
40
- <script lang="ts" setup>
41
- import Taro, { showToast, showLoading, chooseMedia, uploadFile as TaroUploadFile } from '@tarojs/taro'
42
- import { onMounted, reactive, ref } from 'vue'
43
- import { useAppKitOptions } from '../../Appkit'
44
- import { useHttp } from '../api'
45
-
46
- interface FormStateType {
47
- content: string
48
- attachment: any[]
49
- }
50
-
51
- const props = withDefaults(
52
- defineProps<{
53
- app?: string
54
- traceIds: string
55
- value?: FormStateType | null
56
- captureScreen?: any
57
- }>(),
58
- {
59
- app: '',
60
- traceIds: '',
61
- value: null,
62
- captureScreen: () => { },
63
- }
64
- )
65
-
66
- onMounted(() => {
67
- setTimeout(() => {
68
- initEditor()
69
- }, 500)
70
- })
71
-
72
- const formState = reactive<FormStateType>({
73
- content: '',
74
- attachment: [],
75
- })
76
- const isSuccess = ref(false) // 反馈提交成功标记
77
-
78
- const editorCtx = ref()
79
- // 编辑器初始化
80
- function initEditor() {
81
- const query = Taro.createSelectorQuery()
82
- query
83
- .select('#myEditor')
84
- .context((res) => {
85
- editorCtx.value = res.context
86
-
87
- if (props.value) {
88
- if (props.value.content) {
89
- formState.content = props.value.content
90
- editorCtx.value.setContents({
91
- html: props.value.content,
92
- })
93
- }
94
- if (props.value.attachment && props.value.attachment.length) {
95
- formState.attachment = props.value.attachment
96
- }
97
- }
98
- })
99
- .exec()
100
- }
101
-
102
- // 上传图片、视频
103
- function toUpload() {
104
- if (formState.attachment.length >= 20) {
105
- return showToast({
106
- title: '最多上传20份附件',
107
- icon: 'none',
108
- })
109
- }
110
- chooseMedia({
111
- count: 20 - formState.attachment.length,
112
- mediaType: ['mix'],
113
- maxDuration: 60,
114
- success: async (res) => {
115
- for (const item of res.tempFiles) {
116
- if (item.fileType === 'video') {
117
- if (item.size > 1024 * 1024 * 50) {
118
- return showToast({
119
- title: '视频大小不能超过50M',
120
- icon: 'none',
121
- })
122
- }
123
- }
124
-
125
- formState.attachment.push({
126
- url: item.tempFilePath,
127
- type: item.fileType,
128
- status: 'uploading',
129
- })
130
- await uploadFile(formState.attachment[formState.attachment.length - 1])
131
- }
132
- },
133
- })
134
- }
135
-
136
- // 文件上传请求
137
- async function uploadFile(item: any) {
138
- const appkitOptions = useAppKitOptions()
139
- const token = appkitOptions.tempToken() || appkitOptions.token()
140
-
141
- let Res: any = await TaroUploadFile({
142
- url: `${appkitOptions.baseUrl()}/saas-base/file/upload`,
143
- filePath: item.url,
144
- name: 'file',
145
- formData: {
146
- objectNo: `${token}${Date.now()}`,
147
- objectTypeCode: `PROBLEM_FEEDBACK_MINI`,
148
- },
149
- header: { token },
150
- })
151
-
152
- const res = JSON.parse(Res.data)
153
- if (res.success) {
154
- item.url = res.result
155
- item.status = 'done'
156
- }
157
- }
158
-
159
- // 删除附件
160
- function onDelete(index: number) {
161
- formState.attachment.splice(index, 1)
162
- }
163
-
164
- // 点击最小化
165
- function onCancel() {
166
- editorCtx.value.getContents({
167
- success: (res) => {
168
- const html = res.html
169
- formState.content = html
170
-
171
- if (html && html !== '<p><br></p>') {
172
- formState.content = html
173
- }
174
- emits('minimize', formState)
175
- Taro.navigateBack()
176
- },
177
- })
178
- }
179
-
180
- // 点击确定反馈时
181
- function onOk() {
182
- editorCtx.value.getContents({
183
- success: (res) => {
184
- const html = res.html
185
- if (html === '<p><br></p>' || !html) {
186
- showToast({
187
- title: '请输入问题描述',
188
- icon: 'none',
189
- })
190
- } else {
191
- formState.content = html
192
- requestFeedback()
193
- }
194
- },
195
- })
196
- }
197
-
198
- // 请求反馈接口
199
- function requestFeedback() {
200
- const $http = useHttp()
201
- const appkitOptions = useAppKitOptions()
202
-
203
- showLoading({
204
- title: '反馈中...',
205
- })
206
-
207
- const attachment = JSON.parse(
208
- JSON.stringify(
209
- formState.attachment
210
- .filter((item) => item.status === 'done')
211
- .map((item) => ({ url: item.url, type: item.type }))
212
- )
213
- )
214
- if (props.captureScreen && Object.keys(props.captureScreen).length) {
215
- attachment.push({
216
- captureScreen: props.captureScreen,
217
- })
218
- }
219
-
220
- const sendData = {
221
- appCode: props.app || appkitOptions.app(),
222
- content: formState.content,
223
- id: '',
224
- remarks: '',
225
- title: '',
226
- traceIds: props.traceIds,
227
- device: 'MINI',
228
- attachment: JSON.stringify(attachment),
229
- }
230
- $http
231
- .post('/saas-base/problemFeedback/add', sendData)
232
- .then(() => {
233
- Taro.hideLoading()
234
- emits('success')
235
- isSuccess.value = true
236
- clearFormState()
237
- })
238
- .catch(() => {
239
- Taro.hideLoading()
240
- showToast({
241
- title: '反馈提交失败',
242
- icon: 'none',
243
- })
244
- })
245
- }
246
-
247
- // 反馈成功后,清空反馈内容
248
- function clearFormState() {
249
- formState.content = ''
250
- formState.attachment = []
251
- }
252
-
253
- // 父组件事件
254
- const emits = defineEmits(['minimize', 'success'])
255
- </script>
256
-
257
- <style lang="scss">
258
- .user-feedback {
259
- margin: 10px 12px;
260
- padding-bottom: calc(75px + env(safe-area-inset-bottom, 0px));
261
- min-height: 100vh;
262
- box-sizing: border-box;
263
- overflow: hidden;
264
-
265
- &.isSuccess {
266
- margin: 0;
267
- padding: 0;
268
- height: 100%;
269
-
270
- .user-feedback-wrap {
271
- height: 100vh;
272
- align-items: center;
273
- }
274
- }
275
-
276
- &-wrap {
277
- min-height: calc(100vh - calc(75px + env(safe-area-inset-bottom, 0px)));
278
- height: 100%;
279
- background: #fff;
280
- display: flex;
281
- flex-direction: column;
282
- box-sizing: border-box;
283
- padding: 10px;
284
- border-radius: 5px;
285
- }
286
-
287
- &-head {
288
- background: #f2f9ff;
289
- padding: 15px;
290
- border-radius: 2px;
291
- font-size: 12px;
292
- margin-bottom: 8px;
293
-
294
- &-info {
295
- padding-left: 9px;
296
- text-indent: -9px;
297
- }
298
- }
299
-
300
- &-tit {
301
- height: 44px;
302
- display: flex;
303
- align-items: center;
304
- color: #1a1a1a;
305
- font-weight: 500;
306
- font-size: 17px;
307
- }
308
-
309
- &-body {
310
- border-radius: 4px 4px 0px 0px;
311
- display: flex;
312
- flex-direction: column;
313
- overflow: hidden;
314
- }
315
-
316
- &-editor {
317
- padding: 10px;
318
- font-size: 14px;
319
- background: #f5f5f5;
320
- overflow-y: auto;
321
- min-height: 165px;
322
- }
323
-
324
- &-handle {
325
- display: flex;
326
- align-items: center;
327
- flex-wrap: wrap;
328
- margin-top: 10px;
329
- margin-right: -4px;
330
-
331
- &-item {
332
- position: relative;
333
- border-radius: 2px;
334
- display: flex;
335
- align-items: center;
336
- justify-content: center;
337
- width: 79px;
338
- height: 79px;
339
- background: #f5f5f5;
340
- font-size: 30px;
341
- color: rgba(53, 53, 53, 0.3);
342
- margin-right: 4px;
343
- margin-bottom: 4px;
344
-
345
- &-img {
346
- max-width: 100%;
347
- max-height: 100%;
348
- }
349
-
350
- &-close {
351
- position: absolute;
352
- top: -2px;
353
- right: -2px;
354
- width: 20px;
355
- height: 20px;
356
- display: flex;
357
- justify-content: center;
358
- align-items: center;
359
-
360
- &-img {
361
- width: 10px;
362
- height: 10px;
363
- }
364
- }
365
-
366
- &-loading {
367
- width: 17px;
368
- height: 17px;
369
- animation: rotate 2s linear infinite;
370
- }
371
- }
372
- }
373
-
374
- .ql-editor.ql-blank:before {
375
- color: rgba(0, 0, 0, 0.3);
376
- font-style: normal;
377
- }
378
-
379
- &-footer {
380
- position: fixed;
381
- z-index: 10;
382
- bottom: 0;
383
- left: 0;
384
- width: 100%;
385
- min-height: 63px;
386
- background: #ffffff;
387
- box-shadow: 0 -3px 11px 0 rgba(224, 224, 224, 0.5);
388
- padding: 10px 12px calc(8px + env(safe-area-inset-bottom, 0px));
389
- display: flex;
390
- justify-content: space-between;
391
- box-sizing: border-box;
392
-
393
- &-btn {
394
- flex: 1;
395
-
396
- &:first-child {
397
- margin-right: 10px;
398
- }
399
- }
400
- }
401
-
402
- &-success {
403
- &-img {
404
- width: 87px;
405
- height: 90px;
406
- margin-top: 110px;
407
- margin-bottom: 20px;
408
- }
409
-
410
- &-info {
411
- color: #353535;
412
- font-size: 16px;
413
- font-weight: 500;
414
- }
415
- }
416
-
417
- @keyframes rotate {
418
- from {
419
- transform: rotate(0);
420
- }
421
-
422
- to {
423
- transform: rotate(360deg);
424
- }
425
- }
426
- }
427
- </style>
1
+ <template>
2
+ <div class="user-feedback" :class="{ isSuccess }">
3
+ <div v-if="!isSuccess" class="user-feedback-wrap">
4
+ <img src="https://cdn.ddjf.com/static/images/customer-center/feedback-img.png"
5
+ style="width: 311px;height:149.5px;margin: 0 auto;" />
6
+ <div class="user-feedback-tit">补充描述</div>
7
+ <div class="user-feedback-body">
8
+ <editor id="myEditor" :show-img-resize="true" class="user-feedback-editor" placeholder="请输入补充描述" />
9
+ <div class="user-feedback-handle">
10
+ <div class="user-feedback-handle-item" v-for="(item, key) in formState.attachment" :key="key">
11
+ <template v-if="item.status === 'done'">
12
+ <img v-if="item.type === 'image'" class="user-feedback-handle-item-img" mode="aspectFit"
13
+ :src="item.url" />
14
+ <video class="user-feedback-handle-item-img" :src="item.url" v-else />
15
+ <div class="user-feedback-handle-item-close" @click="onDelete(key)">
16
+ <img class="user-feedback-handle-item-close-img"
17
+ src="https://cdn.ddjf.com/static/images/customer-center/close-filled.png" />
18
+ </div>
19
+ </template>
20
+ <img class="user-feedback-handle-item-loading" mode="aspectFit"
21
+ src="https://cdn.ddjf.com/static/images/customer-center/loading.png" alt="" />
22
+ </div>
23
+ <div class="user-feedback-handle-item" @click="toUpload">+</div>
24
+ </div>
25
+ </div>
26
+
27
+ <div class="user-feedback-footer">
28
+ <nut-button class="user-feedback-footer-btn" plain type="primary" @click="onCancel">最小化</nut-button>
29
+ <nut-button class="user-feedback-footer-btn" type="primary" @click="onOk">反馈</nut-button>
30
+ </div>
31
+ </div>
32
+ <div class="user-feedback-wrap" v-else>
33
+ <img class="user-feedback-success-img" mode="aspectFit"
34
+ src="https://cdn.ddjf.com/static/images/customer-center/success-icon.png" />
35
+ <div class="user-feedback-success-info">提交成功</div>
36
+ </div>
37
+ </div>
38
+ </template>
39
+
40
+ <script lang="ts" setup>
41
+ import Taro, { showToast, showLoading, chooseMedia, uploadFile as TaroUploadFile } from '@tarojs/taro'
42
+ import { onMounted, reactive, ref } from 'vue'
43
+ import { useAppKitOptions } from '../../Appkit'
44
+ import { useHttp } from '../api'
45
+
46
+ interface FormStateType {
47
+ content: string
48
+ attachment: any[]
49
+ }
50
+
51
+ const props = withDefaults(
52
+ defineProps<{
53
+ app?: string
54
+ traceIds: string
55
+ value?: FormStateType | null
56
+ captureScreen?: any
57
+ }>(),
58
+ {
59
+ app: '',
60
+ traceIds: '',
61
+ value: null,
62
+ captureScreen: () => { },
63
+ }
64
+ )
65
+
66
+ onMounted(() => {
67
+ setTimeout(() => {
68
+ initEditor()
69
+ }, 500)
70
+ })
71
+
72
+ const formState = reactive<FormStateType>({
73
+ content: '',
74
+ attachment: [],
75
+ })
76
+ const isSuccess = ref(false) // 反馈提交成功标记
77
+
78
+ const editorCtx = ref()
79
+ // 编辑器初始化
80
+ function initEditor() {
81
+ const query = Taro.createSelectorQuery()
82
+ query
83
+ .select('#myEditor')
84
+ .context((res) => {
85
+ editorCtx.value = res.context
86
+
87
+ if (props.value) {
88
+ if (props.value.content) {
89
+ formState.content = props.value.content
90
+ editorCtx.value.setContents({
91
+ html: props.value.content,
92
+ })
93
+ }
94
+ if (props.value.attachment && props.value.attachment.length) {
95
+ formState.attachment = props.value.attachment
96
+ }
97
+ }
98
+ })
99
+ .exec()
100
+ }
101
+
102
+ // 上传图片、视频
103
+ function toUpload() {
104
+ if (formState.attachment.length >= 20) {
105
+ return showToast({
106
+ title: '最多上传20份附件',
107
+ icon: 'none',
108
+ })
109
+ }
110
+ chooseMedia({
111
+ count: 20 - formState.attachment.length,
112
+ mediaType: ['mix'],
113
+ maxDuration: 60,
114
+ success: async (res) => {
115
+ for (const item of res.tempFiles) {
116
+ if (item.fileType === 'video') {
117
+ if (item.size > 1024 * 1024 * 50) {
118
+ return showToast({
119
+ title: '视频大小不能超过50M',
120
+ icon: 'none',
121
+ })
122
+ }
123
+ }
124
+
125
+ formState.attachment.push({
126
+ url: item.tempFilePath,
127
+ type: item.fileType,
128
+ status: 'uploading',
129
+ })
130
+ await uploadFile(formState.attachment[formState.attachment.length - 1])
131
+ }
132
+ },
133
+ })
134
+ }
135
+
136
+ // 文件上传请求
137
+ async function uploadFile(item: any) {
138
+ const appkitOptions = useAppKitOptions()
139
+ const token = appkitOptions.tempToken() || appkitOptions.token()
140
+
141
+ let Res: any = await TaroUploadFile({
142
+ url: `${appkitOptions.baseUrl()}/saas-base/file/upload`,
143
+ filePath: item.url,
144
+ name: 'file',
145
+ formData: {
146
+ objectNo: `${token}${Date.now()}`,
147
+ objectTypeCode: `PROBLEM_FEEDBACK_MINI`,
148
+ },
149
+ header: { token },
150
+ })
151
+
152
+ const res = JSON.parse(Res.data)
153
+ if (res.success) {
154
+ item.url = res.result
155
+ item.status = 'done'
156
+ }
157
+ }
158
+
159
+ // 删除附件
160
+ function onDelete(index: number) {
161
+ formState.attachment.splice(index, 1)
162
+ }
163
+
164
+ // 点击最小化
165
+ function onCancel() {
166
+ editorCtx.value.getContents({
167
+ success: (res) => {
168
+ const html = res.html
169
+ formState.content = html
170
+
171
+ if (html && html !== '<p><br></p>') {
172
+ formState.content = html
173
+ }
174
+ emits('minimize', formState)
175
+ Taro.navigateBack()
176
+ },
177
+ })
178
+ }
179
+
180
+ // 点击确定反馈时
181
+ function onOk() {
182
+ editorCtx.value.getContents({
183
+ success: (res) => {
184
+ const html = res.html
185
+ if (html === '<p><br></p>' || !html) {
186
+ showToast({
187
+ title: '请输入问题描述',
188
+ icon: 'none',
189
+ })
190
+ } else {
191
+ formState.content = html
192
+ requestFeedback()
193
+ }
194
+ },
195
+ })
196
+ }
197
+
198
+ // 请求反馈接口
199
+ function requestFeedback() {
200
+ const $http = useHttp()
201
+ const appkitOptions = useAppKitOptions()
202
+
203
+ showLoading({
204
+ title: '反馈中...',
205
+ })
206
+
207
+ const attachment = JSON.parse(
208
+ JSON.stringify(
209
+ formState.attachment
210
+ .filter((item) => item.status === 'done')
211
+ .map((item) => ({ url: item.url, type: item.type }))
212
+ )
213
+ )
214
+ if (props.captureScreen && Object.keys(props.captureScreen).length) {
215
+ attachment.push({
216
+ captureScreen: props.captureScreen,
217
+ })
218
+ }
219
+
220
+ const sendData = {
221
+ appCode: props.app || appkitOptions.app(),
222
+ content: formState.content,
223
+ id: '',
224
+ remarks: '',
225
+ title: '',
226
+ traceIds: props.traceIds,
227
+ device: 'MINI',
228
+ attachment: JSON.stringify(attachment),
229
+ }
230
+ $http
231
+ .post('/saas-base/problemFeedback/add', sendData)
232
+ .then(() => {
233
+ Taro.hideLoading()
234
+ emits('success')
235
+ isSuccess.value = true
236
+ clearFormState()
237
+ })
238
+ .catch(() => {
239
+ Taro.hideLoading()
240
+ showToast({
241
+ title: '反馈提交失败',
242
+ icon: 'none',
243
+ })
244
+ })
245
+ }
246
+
247
+ // 反馈成功后,清空反馈内容
248
+ function clearFormState() {
249
+ formState.content = ''
250
+ formState.attachment = []
251
+ }
252
+
253
+ // 父组件事件
254
+ const emits = defineEmits(['minimize', 'success'])
255
+ </script>
256
+
257
+ <style lang="scss">
258
+ .user-feedback {
259
+ margin: 10px 12px;
260
+ padding-bottom: calc(75px + env(safe-area-inset-bottom, 0px));
261
+ min-height: 100vh;
262
+ box-sizing: border-box;
263
+ overflow: hidden;
264
+
265
+ &.isSuccess {
266
+ margin: 0;
267
+ padding: 0;
268
+ height: 100%;
269
+
270
+ .user-feedback-wrap {
271
+ height: 100vh;
272
+ align-items: center;
273
+ }
274
+ }
275
+
276
+ &-wrap {
277
+ min-height: calc(100vh - calc(75px + env(safe-area-inset-bottom, 0px)));
278
+ height: 100%;
279
+ background: #fff;
280
+ display: flex;
281
+ flex-direction: column;
282
+ box-sizing: border-box;
283
+ padding: 10px;
284
+ border-radius: 5px;
285
+ }
286
+
287
+ &-head {
288
+ background: #f2f9ff;
289
+ padding: 15px;
290
+ border-radius: 2px;
291
+ font-size: 12px;
292
+ margin-bottom: 8px;
293
+
294
+ &-info {
295
+ padding-left: 9px;
296
+ text-indent: -9px;
297
+ }
298
+ }
299
+
300
+ &-tit {
301
+ height: 44px;
302
+ display: flex;
303
+ align-items: center;
304
+ color: #1a1a1a;
305
+ font-weight: 500;
306
+ font-size: 17px;
307
+ }
308
+
309
+ &-body {
310
+ border-radius: 4px 4px 0px 0px;
311
+ display: flex;
312
+ flex-direction: column;
313
+ overflow: hidden;
314
+ }
315
+
316
+ &-editor {
317
+ padding: 10px;
318
+ font-size: 14px;
319
+ background: #f5f5f5;
320
+ overflow-y: auto;
321
+ min-height: 165px;
322
+ }
323
+
324
+ &-handle {
325
+ display: flex;
326
+ align-items: center;
327
+ flex-wrap: wrap;
328
+ margin-top: 10px;
329
+ margin-right: -4px;
330
+
331
+ &-item {
332
+ position: relative;
333
+ border-radius: 2px;
334
+ display: flex;
335
+ align-items: center;
336
+ justify-content: center;
337
+ width: 79px;
338
+ height: 79px;
339
+ background: #f5f5f5;
340
+ font-size: 30px;
341
+ color: rgba(53, 53, 53, 0.3);
342
+ margin-right: 4px;
343
+ margin-bottom: 4px;
344
+
345
+ &-img {
346
+ max-width: 100%;
347
+ max-height: 100%;
348
+ }
349
+
350
+ &-close {
351
+ position: absolute;
352
+ top: -2px;
353
+ right: -2px;
354
+ width: 20px;
355
+ height: 20px;
356
+ display: flex;
357
+ justify-content: center;
358
+ align-items: center;
359
+
360
+ &-img {
361
+ width: 10px;
362
+ height: 10px;
363
+ }
364
+ }
365
+
366
+ &-loading {
367
+ width: 17px;
368
+ height: 17px;
369
+ animation: rotate 2s linear infinite;
370
+ }
371
+ }
372
+ }
373
+
374
+ .ql-editor.ql-blank:before {
375
+ color: rgba(0, 0, 0, 0.3);
376
+ font-style: normal;
377
+ }
378
+
379
+ &-footer {
380
+ position: fixed;
381
+ z-index: 10;
382
+ bottom: 0;
383
+ left: 0;
384
+ width: 100%;
385
+ min-height: 63px;
386
+ background: #ffffff;
387
+ box-shadow: 0 -3px 11px 0 rgba(224, 224, 224, 0.5);
388
+ padding: 10px 12px calc(8px + env(safe-area-inset-bottom, 0px));
389
+ display: flex;
390
+ justify-content: space-between;
391
+ box-sizing: border-box;
392
+
393
+ &-btn {
394
+ flex: 1;
395
+
396
+ &:first-child {
397
+ margin-right: 10px;
398
+ }
399
+ }
400
+ }
401
+
402
+ &-success {
403
+ &-img {
404
+ width: 87px;
405
+ height: 90px;
406
+ margin-top: 110px;
407
+ margin-bottom: 20px;
408
+ }
409
+
410
+ &-info {
411
+ color: #353535;
412
+ font-size: 16px;
413
+ font-weight: 500;
414
+ }
415
+ }
416
+
417
+ @keyframes rotate {
418
+ from {
419
+ transform: rotate(0);
420
+ }
421
+
422
+ to {
423
+ transform: rotate(360deg);
424
+ }
425
+ }
426
+ }
427
+ </style>