jufubao-forms 1.0.0-beta1 → 1.0.0-beta3

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.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "jufubao-forms",
3
- "version": "1.0.0-beta1",
3
+ "version": "1.0.0-beta3",
4
4
  "private": false,
5
5
  "description": "聚福宝表单业务插件库",
6
6
  "main": "index.js",
@@ -310,6 +310,8 @@
310
310
  setTimeout(() => {
311
311
  this.setFieldItemTop();
312
312
  }, 100)
313
+ }).catch(err => {
314
+ this.$xdHideLoading();
313
315
  })
314
316
  },
315
317
  setFieldItemTop(){
@@ -0,0 +1,19 @@
1
+ 'use strict';
2
+ /**
3
+ * @description 接口配置,
4
+ * 在设置方法名字当时候,别忘记加上【模块名字】:Qa
5
+ * @type {*[]}
6
+ */
7
+ module.exports = [
8
+ {
9
+ mapFnName: 'getFormContentResult',
10
+ title: '获取问卷结果',
11
+ path: '/forms/v1/sms-form-content/:form_id',
12
+ isRule: false,
13
+ params: {
14
+ form_id: ['form_id', '表单ID', 'string'],
15
+ },
16
+ isConsole: true,
17
+ disabled: true,
18
+ },
19
+ ];
@@ -0,0 +1,25 @@
1
+ 'use strict';
2
+
3
+ /**
4
+ * @description 当表单组件中有联动操作时候,使用方法进行返回
5
+ */
6
+ export default {
7
+ style: [],
8
+ content: (data) => {
9
+ return [
10
+ {
11
+ label: "返回首页跳转路径",
12
+ ele: 'xd-select-pages-path',
13
+ valueKey: 'returnHomePath',
14
+ groupKey:'advanced',
15
+ placeholder: '请选择返回首页跳转路径',
16
+ value: data['returnHomePath'] || null,
17
+ setting: {
18
+ router: XdBus.getParentApi('getPagesTree'),
19
+ },
20
+ inline: false,
21
+ },
22
+ ].filter(i=>i)
23
+ },
24
+ advanced: [],
25
+ };
@@ -0,0 +1,440 @@
1
+ <template>
2
+ <view
3
+ class="jfb-forms-qa-result"
4
+ @click="handleEditxSelect"
5
+ :class="{ editx : isEditx && active }"
6
+ >
7
+ <!--#ifdef H5-->
8
+ <view
9
+ class="jfb-forms-qa-result__edit"
10
+ :class="{ editx : isEditx && active }"
11
+ v-if="isEditx && active"
12
+ >
13
+ <view class="jfb-forms-qa-result__edit-icon" @click="delEdit">删除</view>
14
+ </view>
15
+ <!-- #endif -->
16
+ <view class="jfb-forms-qa-result__body" :style="{
17
+ '--main-color': mainColor,
18
+ '--main-color-alpha': mainColorAlpha,
19
+ }">
20
+ <view class="qa_result_box">
21
+ <view class="result_tt">答对提数</view>
22
+ <view class="result_num">{{ right_number }}</view>
23
+ <view class="result_total">共{{ formList.length }}道题</view>
24
+ <view class="btn_wrap">
25
+ <view class="btn" @click="toHomePage">返回首页</view>
26
+ <view class="btn primary" @click="isShowAnalysis=true">答案解析</view>
27
+ </view>
28
+ </view>
29
+
30
+ <template v-if="isShowAnalysis">
31
+ <view class="analysis_head">
32
+ <view class="_left">答案解析</view>
33
+ <view class="_right" :class="{active: isOnlyError}" @click="isOnlyError=!isOnlyError">仅看错题</view>
34
+ </view>
35
+
36
+ <view class="analysis_body">
37
+ <view class="analysis_title">
38
+ <view class="_left">选择题</view>
39
+ <view class="_right">共{{ formList.length }}题</view>
40
+ </view>
41
+ <view class="qa_list">
42
+ <view class="qa_item" v-for="(item,i) in showFormList" :key="item.field_id">
43
+ <view class="qa_type">【{{item.field_type_name}}】</view>
44
+ <view class="qa_title">{{ i + 1 }}.{{ item.field_name }}</view>
45
+ <view class="answer_list">
46
+ <view class="answer_item"
47
+ v-for="ans in item.options"
48
+ :key="ans.value"
49
+ :class="{
50
+ a_right : ans.is_right,
51
+ a_error : ans.is_error
52
+ }"
53
+ >
54
+ {{ans.abc}} {{ ans.label }}
55
+ <view v-if="ans.is_error" class="err_tip">
56
+ <xd-font-icon icon="iconguanbi" size="32" color="#FF7063"></xd-font-icon>
57
+ </view>
58
+ </view>
59
+ <!-- <view class="answer_item a_error a_right">ASF3244</view> -->
60
+ </view>
61
+ <view class="qa_explain">
62
+ <view class="answer_right">
63
+ <view class="flex-center">
64
+ <xd-font-icon v-if="item.isRight" icon="icondui_fill" size="32" :color="mainColor" style="margin-right: 6rpx;"></xd-font-icon>
65
+ <xd-font-icon v-else icon="iconshibai" size="32" color="#FF7063" style="margin-right: 6rpx;"></xd-font-icon>
66
+ {{ item.isRight ? '回答正确' : '回答错误' }}
67
+ </view>
68
+ <view class="is_right">正确答案: {{ item.answer_right_abc }}</view>
69
+ </view>
70
+ <view v-if="!item.isRight && item.answer_analysis" class="answer_analysis">
71
+ <view class="_title">
72
+ <xd-font-icon icon="icondanghang" size="32" style="margin-right: 6rpx;"></xd-font-icon>
73
+ 答案解析</view>
74
+ <view class="_content">{{ item.answer_analysis }}</view>
75
+ </view>
76
+ </view>
77
+ </view>
78
+ </view>
79
+ </view>
80
+ <view class="to_top_wrap">
81
+ <view class="to_top" @click="scrollToTop">返回顶部</view>
82
+ </view>
83
+ </template>
84
+ </view>
85
+ </view>
86
+ </template>
87
+
88
+ <script>
89
+ import XdFontIcon from "@/components/XdFontIcon/XdFontIcon";
90
+ import XdButton from "@/components/XdButton/XdButton";
91
+ import { jfbRootExec } from "@/utils/xd.event";
92
+ import JfbFormsQaResultMixin from "./JfbFormsQaResultMixin";
93
+ import { getContainerPropsValue } from "@/utils/xd.base";
94
+ import componentsMixins from "@/mixins/componentsMixins";
95
+ import extsMixins from "@/mixins/extsMixins";
96
+ import Color from "color"
97
+ export default {
98
+ name: "JfbFormsQaResult",
99
+ components: {
100
+ XdFontIcon,
101
+ XdButton
102
+ },
103
+ mixins: [
104
+ componentsMixins, extsMixins, JfbFormsQaResultMixin
105
+ ],
106
+ data() {
107
+ return {
108
+ mainColorAlpha: "",
109
+ form_id: "",
110
+ main_content_id: "",
111
+ formList: [],
112
+ right_number: 0,
113
+
114
+ isShowAnalysis: false, //是否显示解析
115
+ isOnlyError: false, //是否只看错题
116
+ //todo
117
+
118
+ returnHomePath: "",
119
+ }
120
+ },
121
+ computed: {
122
+ showFormList(){
123
+ return this.isOnlyError ? this.formList.filter(item => !item.isRight) : this.formList;
124
+ }
125
+ },
126
+ watch: {
127
+ container(value, oldValue) {
128
+ if (JSON.stringify(value) === JSON.stringify(oldValue)) return;
129
+ if (this.$configProject['isPreview']) this.init(value)
130
+ },
131
+ },
132
+ created() {
133
+ this.init(this.container);
134
+ this.mainColorAlpha = Color(this.mainColor).alpha(0.15).toString();
135
+ //todo
136
+ },
137
+ methods: {
138
+ onJfbLoad(options) {
139
+ this.form_id = options.form_id;
140
+ this.main_content_id = options.main_content_id;
141
+
142
+ jfbRootExec("getFormContentResult",{
143
+ vm: this,
144
+ data:{
145
+ form_id: this.form_id,
146
+ main_content_id: this.main_content_id
147
+ }
148
+ }).then(res => {
149
+ let abc = ['A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J'];
150
+ let fileTypes = {
151
+ 'radio': '单选',
152
+ 'checkbox': '多选'
153
+ }
154
+ this.formList = res.list.map(item => {
155
+ let defaultValue = JSON.parse(item.default);
156
+ item.rightValue = defaultValue;
157
+ item.isRight = this.isSameArray(defaultValue, item.answer);
158
+ item.field_type_name = fileTypes[item.field_type];
159
+
160
+ item.options = item.options.map((ans, i) => {
161
+ ans['is_error'] = item.answer.includes(ans.value) && !item.rightValue.includes(ans.value);
162
+ ans['is_right'] = item.rightValue.includes(ans.value);
163
+ ans['abc'] = abc[i];
164
+ return ans;
165
+ })
166
+ item['answer_right_abc'] = this.getRightAbc(item);
167
+
168
+ return item;
169
+ });
170
+ this.right_number = res.right_number;
171
+ })
172
+
173
+ },
174
+ /**
175
+ * @description 监听事件变化
176
+ * @param container {object} 业务组件对象自己
177
+ */
178
+ init(container) {
179
+ this.returnHomePath = getContainerPropsValue(container, 'content.returnHomePath', {value: ''}).value;
180
+ },
181
+ toHomePage(){
182
+ this.$xdUniHelper.navigateTo({
183
+ url: this.returnHomePath
184
+ })
185
+ },
186
+ //判断两个包含数组是否相同
187
+ isSameArray(arr1, arr2){
188
+ if(arr1.length != arr2.length) return false;
189
+ for (let i = 0; i < arr1.length; i++) {
190
+ if(!arr2.includes(arr1[i])){
191
+ return false;
192
+ }
193
+ }
194
+ return true;
195
+ },
196
+ getRightAbc(item){
197
+ return item.options.filter((ans) => {
198
+ return item.rightValue.includes(ans.value)
199
+ }).map(item => item.abc).join(",")
200
+ },
201
+ scrollToTop(){
202
+ uni.pageScrollTo({
203
+ scrollTop: 0,
204
+ })
205
+ },
206
+ onJfbScroll(options) {
207
+ // console.log('event.onJfbScroll', options)
208
+ },
209
+ onJfbReachBottom(options) {
210
+ console.log('event.onJfbReachBottom', options)
211
+ },
212
+ onJfbShow(options) {
213
+ console.log('event.onJfbShow', options)
214
+ },
215
+ onJfbHide(options) {
216
+ console.log('event.onJfbHide', options)
217
+ },
218
+ onJfbBack(options) {
219
+ console.log('event.onJfbBack', options)
220
+ },
221
+ onJfbUpdate(...data) {
222
+ console.log('event.onJfbUpdate', data)
223
+ },
224
+ onJfbCustomEvent(options) {
225
+ console.log('event.onJfbReachBottom', options)
226
+ },
227
+ }
228
+ }
229
+
230
+ </script>
231
+
232
+ <style scoped lang="less">
233
+ @import "./JfbFormsQaResultLess.less";
234
+
235
+ .jfb-forms-qa-result {
236
+ &__body{
237
+ padding: 0 0 40rpx;
238
+ font-size: 28rpx;
239
+ .qa_result_box{
240
+ display: flex;
241
+ flex-direction: column;
242
+ align-items: center;
243
+ background-color: #FFFFFF;
244
+ margin-bottom: 20rpx;
245
+ padding: 48rpx;
246
+ .result_tt{
247
+ color: var(--main-color);
248
+ font-size: 32rpx;
249
+ font-weight: 400;
250
+ }
251
+ .result_num{
252
+ color: var(--main-color);
253
+ font-size: 160rpx;
254
+ font-weight: 700;
255
+ }
256
+ .result_total{
257
+ color: #AAAAAA;
258
+ font-weight: 400;
259
+ font-size: 28rpx;
260
+ }
261
+ .btn_wrap{
262
+ display: flex;
263
+ margin-top: 28rpx;
264
+ justify-content: center;
265
+ .btn{
266
+ width: 230rpx;
267
+ height: 88rpx;
268
+ display: flex;
269
+ align-items: center;
270
+ justify-content: center;
271
+ border-radius: 16rpx;
272
+ background: #F0F0F0;
273
+ color: #AAAAAA;
274
+ font-size: 28rpx;
275
+ &.primary{
276
+ background: var(--main-color-alpha);
277
+ color: var(--main-color);
278
+ }
279
+
280
+ & + .btn{
281
+ margin-left: 60rpx;
282
+ }
283
+ }
284
+ }
285
+ }
286
+ .analysis_head{
287
+ display: flex;
288
+ align-items: center;
289
+ justify-content: space-between;
290
+ background-color: #FFFFFF;
291
+ margin-bottom: 20rpx;
292
+ padding: 24rpx 40rpx;
293
+ ._left{
294
+ color: #666666;
295
+ font-size: 28rpx;
296
+ }
297
+ ._right{
298
+ border: 1px solid #666666;
299
+ padding: 14rpx 24rpx;
300
+ border-radius: 12rpx;
301
+ color: #666666;
302
+ font-size: 24rpx;
303
+
304
+ &.active{
305
+ border: 1px solid var(--main-color);
306
+ color: var(--main-color);
307
+ }
308
+ }
309
+ }
310
+ .analysis_body{
311
+ .analysis_title{
312
+ display: flex;
313
+ align-items: center;
314
+ justify-content: space-between;
315
+ border-bottom: 1px solid #EEEEEE;
316
+ padding: 24rpx 40rpx;
317
+ background-color: #FFFFFF;
318
+ ._left{
319
+ color: #666666;
320
+ font-size: 28rpx;
321
+ font-weight: 400;
322
+ position: relative;
323
+ padding-left: 20rpx;
324
+ &::before{
325
+ position: absolute;
326
+ content: ' ';
327
+ width: 6rpx;
328
+ height: 32rpx;
329
+ background: var(--main-color);
330
+ left: 0;
331
+ top: 50%;
332
+ transform: translate(0, -50%);
333
+ border-radius: 2rpx;
334
+ }
335
+ }
336
+ ._right{
337
+ font-size: 24rpx;
338
+ color: #CCCCCC;
339
+ font-weight: 400
340
+ }
341
+ }
342
+ .qa_list{
343
+ .qa_item{
344
+ background-color: #FFFFFF;
345
+ padding: 40rpx;
346
+ margin-bottom: 20rpx;
347
+
348
+ .qa_type{
349
+ background: var(--main-color-alpha);
350
+ color: var(--main-color);
351
+ font-size: 20rpx;
352
+ font-weight: 400;
353
+ display: inline-block;
354
+ padding: 4rpx;
355
+ border-radius: 8rpx;
356
+ margin-bottom: 16rpx;
357
+ }
358
+ .qa_title{
359
+ color: #666666;
360
+ font-weight: 400;
361
+ }
362
+
363
+ .answer_list{
364
+ .answer_item{
365
+ background: #F7F7F7;
366
+ padding: 16rpx 32rpx;
367
+ border-radius: 12rpx;
368
+ margin: 24rpx 0;
369
+ color: #666666;
370
+ font-size: 28rpx;
371
+ font-weight: 400;
372
+ position: relative;
373
+ .err_tip{
374
+ position: absolute;
375
+ right: 32rpx;
376
+ top: 16rpx;
377
+ }
378
+
379
+ &.a_right{
380
+ color: #FFFFFF;
381
+ background: var(--main-color);
382
+ }
383
+ &.a_error{
384
+ color: #FF7063;
385
+ background: #FFE3E0;
386
+ }
387
+ }
388
+ }
389
+ .qa_explain{
390
+ .answer_right{
391
+ display: flex;
392
+ align-items: center;
393
+ justify-content: space-between;
394
+ padding: 0 24rpx;
395
+ margin-top: 36rpx;
396
+
397
+ .flex-center{
398
+ display: flex;
399
+ align-items: center;
400
+ }
401
+
402
+ .is_right{
403
+ color: var(--main-color);
404
+ }
405
+ }
406
+ .answer_analysis{
407
+ color: var(--main-color);
408
+ background-color: var(--main-color-alpha);
409
+ margin-top: 36rpx;
410
+ padding: 24rpx;
411
+ border-radius: 12rpx;
412
+ ._title{
413
+ font-size: 28rpx;
414
+ display: flex;
415
+ align-items: center;
416
+ }
417
+ ._content{
418
+ font-size: 26rpx;
419
+ padding-left: 42rpx;
420
+ margin-top: 16rpx;
421
+ }
422
+ }
423
+ }
424
+ }
425
+ }
426
+ }
427
+
428
+ .to_top_wrap{
429
+ display: flex;
430
+ justify-content: center;
431
+ .to_top{
432
+ padding: 16rpx 40rpx;
433
+ border-radius: 50rpx;
434
+ background: #F0F0F0;
435
+ color: #A6A6A6;
436
+ }
437
+ }
438
+ }
439
+ }
440
+ </style>
@@ -0,0 +1,79 @@
1
+ /**
2
+ * @desc 获取绝对路径完整地址
3
+ * @param @path
4
+ **/
5
+ //例如:https://image.jufubao.cn/20220501010108/image/bg/default_gonghui_bg.png
6
+ @basePath: 'business/';
7
+ @doMain: '//sandbox-img.jufubao.cn/';
8
+
9
+ .getBusinessImageUrl(@path, @size: 'size8') {
10
+ @url: "@{doMain}@{basePath}@{path}?x-oss-process=style/@{size}";
11
+ background-image: url(@url);
12
+ }
13
+
14
+ //start
15
+ .jfb-forms-qa-result {
16
+ box-sizing: border-box;
17
+
18
+ &__body{
19
+ position: relative;
20
+ overflow: hidden;
21
+ z-index: 2
22
+ }
23
+
24
+ &.editx,&.editx:hover {
25
+ position: relative;
26
+ min-height: unit(100, rpx);
27
+ z-index: 3;
28
+ &::after {
29
+ border: 2rpx dashed blue;
30
+ content: " ";
31
+ position: absolute;
32
+ top:0;
33
+ left:0;
34
+ bottom:0;
35
+ right:0;
36
+ z-index: var(--preview-z-index);
37
+ cursor: pointer;
38
+ }
39
+
40
+ }
41
+
42
+
43
+ &__edit {
44
+ cursor: pointer;
45
+ position: absolute;
46
+ right: unit(0, rpx);
47
+ top: unit(-52, rpx);
48
+ height: unit(50, rpx);
49
+ line-height: unit(50, rpx);
50
+ display: flex;
51
+ justify-content: center;
52
+ align-items: center;
53
+ background: rgba(0, 0, 0, .6);
54
+ border-radius: unit(10, rpx);
55
+ box-shadow: 0 0 10px rbga(0, 0, 0, 0.3);
56
+ color: #fff;
57
+ font-size: unit(22, rpx);
58
+
59
+ &-icon{
60
+ padding: 0 unit(20, rpx);
61
+ }
62
+
63
+ &.editx {
64
+ box-sizing: border-box;
65
+
66
+ }
67
+ }
68
+ }
69
+ //end
70
+
71
+
72
+ /**notPreview**/
73
+ .jfb-forms-qa-result {
74
+ //&:before {
75
+ //content: " ";
76
+ //display: table;
77
+ //}
78
+ }
79
+ /**endNotPreview**/
@@ -0,0 +1,30 @@
1
+ 'use strict';
2
+
3
+
4
+ //@AttrImport
5
+ import Attr from "./Attr";
6
+ //@EndAttrImport
7
+
8
+
9
+ export default {
10
+ data() {
11
+ return {
12
+ //#ifdef H5
13
+
14
+ //@AttrData
15
+ Attr:{}, //对外开发编辑属性
16
+ //@EndAttrData
17
+
18
+ // #endif
19
+ cssRoot: 'jfb-forms-qa-result'
20
+ }
21
+ },
22
+ created() {
23
+
24
+ //@AttrDataCreated
25
+ this.Attr = this.$xdUniHelper.customClone(Attr);
26
+ //@EndAttrDataCreated
27
+
28
+
29
+ },
30
+ }
@@ -0,0 +1,5 @@
1
+ 'use strict';
2
+
3
+ module.exports = {
4
+
5
+ }
@@ -7,7 +7,18 @@ export default {
7
7
  style: [],
8
8
  content: (data) => {
9
9
  return [
10
-
10
+ {
11
+ label: "问卷结果跳转路径",
12
+ ele: 'xd-select-pages-path',
13
+ valueKey: 'qaResultPath',
14
+ groupKey:'advanced',
15
+ placeholder: '请选择问卷详情跳转路径',
16
+ value: data['qaResultPath'] || null,
17
+ setting: {
18
+ router: XdBus.getParentApi('getPagesTree'),
19
+ },
20
+ inline: false,
21
+ },
11
22
  ].filter(i=>i)
12
23
  },
13
24
  advanced: [],
@@ -124,6 +124,8 @@
124
124
 
125
125
  curIndex: 0,
126
126
  //todo
127
+
128
+ qaResultPath: "",
127
129
  }
128
130
  },
129
131
  computed: {
@@ -238,6 +240,8 @@
238
240
  this.loaded = true;
239
241
  this.formList = res.list;
240
242
  this.formName = res.form_name;
243
+ }).catch(err => {
244
+ this.$xdHideLoading();
241
245
  })
242
246
  },
243
247
  /**
@@ -245,10 +249,7 @@
245
249
  * @param container {object} 业务组件对象自己
246
250
  */
247
251
  init(container) {
248
-
249
- //this.bgcolor = getContainerPropsValue(container, 'content.bgcolor', '#fff');
250
-
251
- //this.height = getContainerPropsValue(container, 'content.height', 10);
252
+ this.qaResultPath = getContainerPropsValue(container, 'content.qaResultPath', {value: ''}).value;
252
253
  },
253
254
  handlePrev(){
254
255
  if(this.curIndex > 0){
@@ -283,13 +284,15 @@
283
284
  }),
284
285
  }
285
286
  }).then(res => {
286
- const { activity_id, marketing_tool, activity_page_url } = res;
287
+ const { activity_id, marketing_tool, activity_page_url, main_content_id } = res;
287
288
  this.marketing_tool = marketing_tool;
288
289
  this.activity_page_url = activity_page_url;
289
290
  this.activity_id = activity_id;
290
-
291
291
  // uni.showToast({title: '提交成功'});
292
292
  this.form_status = 'success';
293
+ this.$xdUniHelper.navigateTo({
294
+ url: this.qaResultPath + `?form_id=${this.form_id}&main_content_id=${main_content_id}`
295
+ })
293
296
  })
294
297
  }
295
298
  }