jufubao-forms 1.0.0-beta2 → 1.0.0-beta4

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-beta2",
3
+ "version": "1.0.0-beta4",
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(){
@@ -5,5 +5,15 @@
5
5
  * @type {*[]}
6
6
  */
7
7
  module.exports = [
8
-
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
+ },
9
19
  ];
@@ -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: 'returnHomePath',
14
+ groupKey:'advanced',
15
+ placeholder: '请选择返回首页跳转路径',
16
+ value: data['returnHomePath'] || null,
17
+ setting: {
18
+ router: XdBus.getParentApi('getPagesTree'),
19
+ },
20
+ inline: false,
21
+ },
11
22
  ].filter(i=>i)
12
23
  },
13
24
  advanced: [],
@@ -13,33 +13,114 @@
13
13
  <view class="jfb-forms-qa-result__edit-icon" @click="delEdit">删除</view>
14
14
  </view>
15
15
  <!-- #endif -->
16
- <view class="jfb-forms-qa-result__body">
17
- <view class="qa_box">
18
- <view>答对提数</view>
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>
19
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>
20
84
  </view>
21
85
  </view>
22
86
  </template>
23
87
 
24
88
  <script>
25
89
  import XdFontIcon from "@/components/XdFontIcon/XdFontIcon";
90
+ import XdButton from "@/components/XdButton/XdButton";
26
91
  import { jfbRootExec } from "@/utils/xd.event";
27
92
  import JfbFormsQaResultMixin from "./JfbFormsQaResultMixin";
28
93
  import { getContainerPropsValue } from "@/utils/xd.base";
29
94
  import componentsMixins from "@/mixins/componentsMixins";
30
95
  import extsMixins from "@/mixins/extsMixins";
96
+ import Color from "color"
31
97
  export default {
32
98
  name: "JfbFormsQaResult",
33
99
  components: {
34
- XdFontIcon
100
+ XdFontIcon,
101
+ XdButton
35
102
  },
36
103
  mixins: [
37
104
  componentsMixins, extsMixins, JfbFormsQaResultMixin
38
105
  ],
39
106
  data() {
40
107
  return {
108
+ mainColorAlpha: "",
109
+ form_id: "",
110
+ main_content_id: "",
111
+ formList: [],
112
+ right_number: 0,
41
113
 
114
+ isShowAnalysis: false, //是否显示解析
115
+ isOnlyError: false, //是否只看错题
42
116
  //todo
117
+
118
+ returnHomePath: "",
119
+ }
120
+ },
121
+ computed: {
122
+ showFormList(){
123
+ return this.isOnlyError ? this.formList.filter(item => !item.isRight) : this.formList;
43
124
  }
44
125
  },
45
126
  watch: {
@@ -50,34 +131,80 @@
50
131
  },
51
132
  created() {
52
133
  this.init(this.container);
53
-
134
+ this.mainColorAlpha = Color(this.mainColor).alpha(0.15).toString();
54
135
  //todo
55
136
  },
56
137
  methods: {
57
138
  onJfbLoad(options) {
139
+ this.form_id = options.form_id;
140
+ this.main_content_id = options.main_content_id;
58
141
 
59
- // jfbRootExec('baiduUserLogin', {
60
-
61
- // vm: this,// data: {
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];
62
159
 
63
- // account: 'gaoshiyong',// password: '123456789',// type: 3,// ...options
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);
64
167
 
65
- // }
168
+ return item;
169
+ });
170
+ this.right_number = res.right_number;
171
+ })
66
172
 
67
- // }).then().catch()
68
173
  },
69
174
  /**
70
175
  * @description 监听事件变化
71
176
  * @param container {object} 业务组件对象自己
72
177
  */
73
178
  init(container) {
74
-
75
- //this.bgcolor = getContainerPropsValue(container, 'content.bgcolor', '#fff');
76
-
77
- //this.height = getContainerPropsValue(container, 'content.height', 10);
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
+ })
78
205
  },
79
206
  onJfbScroll(options) {
80
- console.log('event.onJfbScroll', options)
207
+ // console.log('event.onJfbScroll', options)
81
208
  },
82
209
  onJfbReachBottom(options) {
83
210
  console.log('event.onJfbReachBottom', options)
@@ -107,7 +234,207 @@
107
234
 
108
235
  .jfb-forms-qa-result {
109
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
+ }
110
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
+ }
111
438
  }
112
439
  }
113
440
  </style>
@@ -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: [],
@@ -77,6 +77,11 @@
77
77
  >{{ marketToolText }}</view>
78
78
  </view>
79
79
  </view>
80
+ <view v-if="form_status === 'error'" class="form_status form_error">
81
+ <xd-font-icon icon="iconshibai" color="#ff5235" :size="64"></xd-font-icon>
82
+ <view class="status_tip error_tip">{{ err_msg }}</view>
83
+ <view class="status_name">{{ formName }}</view>
84
+ </view>
80
85
  </view>
81
86
 
82
87
  </view>
@@ -111,6 +116,7 @@
111
116
  loaded: false,
112
117
  isPreview: false,
113
118
  form_status: "content",
119
+ err_msg: "",
114
120
  formName: "",
115
121
  marketing_tool: "",
116
122
  activity_page_url: "",
@@ -124,6 +130,8 @@
124
130
 
125
131
  curIndex: 0,
126
132
  //todo
133
+
134
+ qaResultPath: "",
127
135
  }
128
136
  },
129
137
  computed: {
@@ -238,6 +246,13 @@
238
246
  this.loaded = true;
239
247
  this.formList = res.list;
240
248
  this.formName = res.form_name;
249
+ this.err_msg = res.message;
250
+ if(res.message){
251
+ this.form_status = "error";
252
+ return;
253
+ }
254
+ }).catch(err => {
255
+ this.$xdHideLoading();
241
256
  })
242
257
  },
243
258
  /**
@@ -245,10 +260,7 @@
245
260
  * @param container {object} 业务组件对象自己
246
261
  */
247
262
  init(container) {
248
-
249
- //this.bgcolor = getContainerPropsValue(container, 'content.bgcolor', '#fff');
250
-
251
- //this.height = getContainerPropsValue(container, 'content.height', 10);
263
+ this.qaResultPath = getContainerPropsValue(container, 'content.qaResultPath', {value: ''}).value;
252
264
  },
253
265
  handlePrev(){
254
266
  if(this.curIndex > 0){
@@ -283,13 +295,15 @@
283
295
  }),
284
296
  }
285
297
  }).then(res => {
286
- const { activity_id, marketing_tool, activity_page_url } = res;
298
+ const { activity_id, marketing_tool, activity_page_url, main_content_id } = res;
287
299
  this.marketing_tool = marketing_tool;
288
300
  this.activity_page_url = activity_page_url;
289
301
  this.activity_id = activity_id;
290
-
291
302
  // uni.showToast({title: '提交成功'});
292
303
  this.form_status = 'success';
304
+ this.$xdUniHelper.navigateTo({
305
+ url: this.qaResultPath + `?form_id=${this.form_id}&main_content_id=${main_content_id}`
306
+ })
293
307
  })
294
308
  }
295
309
  }