jufubao-forms 1.0.0-beta1
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/README.md +27 -0
- package/commands.js +84 -0
- package/commands.update.change.js +176 -0
- package/file.config.js +16 -0
- package/get.package.path.js +22 -0
- package/get.package.path.js.tpl +22 -0
- package/package.json +119 -0
- package/src/CreateClientID.js +16 -0
- package/src/ICONS.js +1148 -0
- package/src/common/authorize.js +261 -0
- package/src/common/getBusinessImageUrl.js +39 -0
- package/src/common/getServiceUrl.js +38 -0
- package/src/common/paysdk/jweixin.js +98 -0
- package/src/components/CusCouponChose/CusCouponChose.vue +1024 -0
- package/src/components/CusCouponItem/CusCouponItem.vue +298 -0
- package/src/components/CusEnter/CusEnter.vue +333 -0
- package/src/components/CusPoster/CusPoster.vue +213 -0
- package/src/components/CusPoster/CusSwiperDot.vue +234 -0
- package/src/components/CusProduct/CusProduct.vue +362 -0
- package/src/components/CusSwiperDot/CusSwiperDot.vue +234 -0
- package/src/components/CusTab/CusTab.vue +411 -0
- package/src/components/CusVideo/CusVideo.vue +170 -0
- package/src/components/JfbFormsDynamicForm/Api.js +66 -0
- package/src/components/JfbFormsDynamicForm/Attr.js +35 -0
- package/src/components/JfbFormsDynamicForm/JfbFormsDynamicForm.vue +767 -0
- package/src/components/JfbFormsDynamicForm/JfbFormsDynamicFormLess.less +79 -0
- package/src/components/JfbFormsDynamicForm/JfbFormsDynamicFormMixin.js +30 -0
- package/src/components/JfbFormsDynamicForm/Mock.js +194 -0
- package/src/components/JfbFormsDynamicForm/XdFormDate.vue +71 -0
- package/src/components/JfbFormsDynamicForm/ld-select/ld-select.vue +329 -0
- package/src/components/JfbFormsDynamicForm/uni-datetime-picker/calendar-item.vue +177 -0
- package/src/components/JfbFormsDynamicForm/uni-datetime-picker/calendar.vue +930 -0
- package/src/components/JfbFormsDynamicForm/uni-datetime-picker/i18n/en.json +22 -0
- package/src/components/JfbFormsDynamicForm/uni-datetime-picker/i18n/index.js +8 -0
- package/src/components/JfbFormsDynamicForm/uni-datetime-picker/i18n/zh-Hans.json +22 -0
- package/src/components/JfbFormsDynamicForm/uni-datetime-picker/i18n/zh-Hant.json +22 -0
- package/src/components/JfbFormsDynamicForm/uni-datetime-picker/time-picker.vue +934 -0
- package/src/components/JfbFormsDynamicForm/uni-datetime-picker/uni-datetime-picker.vue +1042 -0
- package/src/components/JfbFormsDynamicForm/uni-datetime-picker/util.js +403 -0
- package/src/components/JfbFormsList/Api.js +20 -0
- package/src/components/JfbFormsList/Attr.js +70 -0
- package/src/components/JfbFormsList/JfbFormsList.vue +228 -0
- package/src/components/JfbFormsList/JfbFormsListLess.less +79 -0
- package/src/components/JfbFormsList/JfbFormsListMixin.js +30 -0
- package/src/components/JfbFormsList/Mock.js +38 -0
- package/src/components/JfbFormsQuestionAndAnswer/Api.js +43 -0
- package/src/components/JfbFormsQuestionAndAnswer/Attr.js +14 -0
- package/src/components/JfbFormsQuestionAndAnswer/JfbFormsQuestionAndAnswer.vue +506 -0
- package/src/components/JfbFormsQuestionAndAnswer/JfbFormsQuestionAndAnswerLess.less +79 -0
- package/src/components/JfbFormsQuestionAndAnswer/JfbFormsQuestionAndAnswerMixin.js +30 -0
- package/src/components/JfbFormsQuestionAndAnswer/Mock.js +144 -0
- package/src/components/SkeProduct/SkeProduct.vue +241 -0
- package/src/config.app.plus.js +6 -0
- package/src/config.h5.js +13 -0
- package/src/config.mp.weixin.js +13 -0
- package/src/config.project.js +15 -0
- package/src/mixins/cardListMixins.js +187 -0
- package/src/mixins/colorCardMixins.js +122 -0
- package/src/mixins/componentsMixins.js +900 -0
- package/src/mixins/extsMixins.js +3 -0
- package/src/mixins/locationMixins.js +119 -0
- package/src/mixins/newLocaltionMixins.js +754 -0
- package/src/mixins/openDebuggerMixins.js +74 -0
- package/src/mixins/pageEditx.js +347 -0
- package/src/mixins/pageEvent.js +311 -0
- package/src/mixins/pageMain.js +120 -0
- package/src/mixins/pageUitls.js +738 -0
- package/src/mixins/posterMixins.js +122 -0
- package/src/mixins/scrollListFixedHeigthMixins.js +174 -0
- package/src/mocks.js +4 -0
|
@@ -0,0 +1,767 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<view
|
|
3
|
+
class="jfb-forms-dynamic-form"
|
|
4
|
+
@click="handleEditxSelect"
|
|
5
|
+
:class="{ editx : isEditx && active }"
|
|
6
|
+
>
|
|
7
|
+
<!--#ifdef H5-->
|
|
8
|
+
<view
|
|
9
|
+
class="jfb-forms-dynamic-form__edit"
|
|
10
|
+
:class="{ editx : isEditx && active }"
|
|
11
|
+
v-if="isEditx && active"
|
|
12
|
+
>
|
|
13
|
+
<view class="jfb-forms-dynamic-form__edit-icon" @click="delEdit">删除</view>
|
|
14
|
+
</view>
|
|
15
|
+
<!-- #endif -->
|
|
16
|
+
<view class="jfb-forms-dynamic-form__body">
|
|
17
|
+
<view v-if="loaded">
|
|
18
|
+
<view v-if="form_status === 'content'" class="form_content">
|
|
19
|
+
<view class="jfb-forms-dynamic-form__title">{{ formName }}</view>
|
|
20
|
+
<xd-form labelPosition="top" labelAlign="left" :model="form" :paddingBetween="0" :key="renderForm">
|
|
21
|
+
<xd-form-item v-for="(item, i) in dynamicFormList" :key="item.created_time"
|
|
22
|
+
:id="item.field_value"
|
|
23
|
+
:subTitle="item.explain"
|
|
24
|
+
:label="(i+1) + '、' + item.field_name" :prop="item.field_value" contentAlign="left"
|
|
25
|
+
:errorMessage="item.error" :required="item.required">
|
|
26
|
+
<view class="align-center" v-if="item.field_type === 'text'">
|
|
27
|
+
<image :src="item.icon" v-if="item.icon" class="input_icon" mode="widthFix"></image>
|
|
28
|
+
<xd-form-input
|
|
29
|
+
v-model="form[item.field_value]"
|
|
30
|
+
:placeholder="item.placeholder"
|
|
31
|
+
@focus="handleClearError(item)"
|
|
32
|
+
@blur="handleValidItem(item)"
|
|
33
|
+
></xd-form-input>
|
|
34
|
+
</view>
|
|
35
|
+
<xd-form-input v-if="item.field_type === 'textarea'"
|
|
36
|
+
type="textarea"
|
|
37
|
+
v-model="form[item.field_value]"
|
|
38
|
+
:placeholder="item.placeholder"
|
|
39
|
+
@focus="handleClearError(item)"
|
|
40
|
+
></xd-form-input>
|
|
41
|
+
<ld-select v-if="item.field_type === 'select'"
|
|
42
|
+
v-model="form[item.field_value]"
|
|
43
|
+
:list="item.options"
|
|
44
|
+
:multiple="item.validate_type === 'Y'"
|
|
45
|
+
:placeholder="item.placeholder || '请选择'"
|
|
46
|
+
clearable
|
|
47
|
+
@change="handleClearError(item)"
|
|
48
|
+
>
|
|
49
|
+
</ld-select>
|
|
50
|
+
<xd-form-checkbox v-if="item.field_type === 'checkbox' || item.field_type === 'radio'"
|
|
51
|
+
v-model="form[item.field_value]"
|
|
52
|
+
:localdata="item.options.map(item => ({value: item.value, text: item.label}))"
|
|
53
|
+
:multiple="item.field_type === 'checkbox'"
|
|
54
|
+
@change="handleClearError(item)"
|
|
55
|
+
:class="'mySelf' + item.field_type"
|
|
56
|
+
></xd-form-checkbox>
|
|
57
|
+
<template v-if="item.field_type === 'date'">
|
|
58
|
+
<picker v-if="item.validate_type === 'month' || item.validate_type === 'year'"
|
|
59
|
+
v-model="form[item.field_value]"
|
|
60
|
+
:value="form[item.field_value]"
|
|
61
|
+
mode="date"
|
|
62
|
+
:start="item.start_time"
|
|
63
|
+
:end="item.end_time"
|
|
64
|
+
:fields="item.validate_type"
|
|
65
|
+
@change="e => handleDatepicker(e, item)">
|
|
66
|
+
<view class="align-center">
|
|
67
|
+
<!-- <xd-font-icon icon="iconriqi" color="#5C5C66"></xd-font-icon> -->
|
|
68
|
+
<image src="//img6.jufubao.cn/common/form/icon_date.png" mode="widthFix" class="input_icon"></image>
|
|
69
|
+
<view class="form_datepicker">{{form[item.field_value] || '请选择日期'}}</view>
|
|
70
|
+
</view>
|
|
71
|
+
</picker>
|
|
72
|
+
<uni-datetime-picker v-else
|
|
73
|
+
v-model="form[item.field_value]"
|
|
74
|
+
:type="item.validate_type"
|
|
75
|
+
:start="item.start_time"
|
|
76
|
+
:end="item.end_time"
|
|
77
|
+
:border="false"
|
|
78
|
+
placeholder="请选择日期"
|
|
79
|
+
@change="handleClearError(item)">
|
|
80
|
+
</uni-datetime-picker>
|
|
81
|
+
</template>
|
|
82
|
+
<!-- <xd-form-date v-if="item.field_type === 'calendar'"
|
|
83
|
+
v-model="form[item.field_value]"
|
|
84
|
+
:type="item.validate_type"
|
|
85
|
+
:start="item.start_time"
|
|
86
|
+
:end="item.end_time"
|
|
87
|
+
:rules="item.validate_rules"
|
|
88
|
+
@change="handleClearError(item)"
|
|
89
|
+
>
|
|
90
|
+
{{ form[item.field_value] || "请选择日期" }}
|
|
91
|
+
</xd-form-date> -->
|
|
92
|
+
</xd-form-item>
|
|
93
|
+
</xd-form>
|
|
94
|
+
<!-- <view class="description">{{ description }}</view> -->
|
|
95
|
+
<view class="footer_btn">
|
|
96
|
+
<xd-button style="width: 460rpx;" type="primary" @click="doShowDialog">提交表单</xd-button>
|
|
97
|
+
</view>
|
|
98
|
+
</view>
|
|
99
|
+
<view v-if="form_status === 'success'" class="form_status form_success">
|
|
100
|
+
<xd-font-icon icon="iconchenggong" color="#06bc85" :size="64"></xd-font-icon>
|
|
101
|
+
<view class="status_tip">您已成功提交</view>
|
|
102
|
+
<view class="status_name">{{ formName }}</view>
|
|
103
|
+
<view class="status_btn" @click="doClose">关闭</view>
|
|
104
|
+
</view>
|
|
105
|
+
<view v-if="form_status === 'error'" class="form_status form_error">
|
|
106
|
+
<xd-font-icon icon="iconshibai" color="#ff5235" :size="64"></xd-font-icon>
|
|
107
|
+
<view class="status_tip error_tip">{{ err_msg }}</view>
|
|
108
|
+
<view class="status_name">{{ formName }}</view>
|
|
109
|
+
</view>
|
|
110
|
+
</view>
|
|
111
|
+
|
|
112
|
+
|
|
113
|
+
<xd-dialog :show.sync="isShowDialog" title="请输入验证码" :showCloseIcon="false">
|
|
114
|
+
<xd-form
|
|
115
|
+
label-align="left"
|
|
116
|
+
content-align="left"
|
|
117
|
+
label-position="left"
|
|
118
|
+
:paddingBetween="0"
|
|
119
|
+
>
|
|
120
|
+
<xd-form-item label="" :labelWidth="1" content-align="left" :paddingBetween="0">
|
|
121
|
+
<view class="valid_wrap">
|
|
122
|
+
<xd-form-input v-model="valid_code" placeholder="请输入验证码" style="width: 300rpx;"></xd-form-input>
|
|
123
|
+
<view class="capture" @click="switchValidToken">
|
|
124
|
+
<image
|
|
125
|
+
style="width: 100%;height:100%"
|
|
126
|
+
:src="validImageAPIUrl + '?image_width=180&image_height=80&token='+ valid_token"
|
|
127
|
+
/>
|
|
128
|
+
</view>
|
|
129
|
+
</view>
|
|
130
|
+
</xd-form-item>
|
|
131
|
+
</xd-form>
|
|
132
|
+
|
|
133
|
+
<view slot="btn">
|
|
134
|
+
<xd-button type="primary" width="400rpx" @click="doCheckValidCode">提交</xd-button>
|
|
135
|
+
</view>
|
|
136
|
+
</xd-dialog>
|
|
137
|
+
</view>
|
|
138
|
+
</view>
|
|
139
|
+
</template>
|
|
140
|
+
|
|
141
|
+
<script>
|
|
142
|
+
import XdFontIcon from "@/components/XdFontIcon/XdFontIcon";
|
|
143
|
+
import XdForm from "@/components/XdForm/XdForm"
|
|
144
|
+
import XdFormItem from "@/components/XdFormItem/XdFormItem"
|
|
145
|
+
import XdButton from "@/components/XdButton/XdButton"
|
|
146
|
+
import XdFormInput from "@/components/XdFormInput/XdFormInput"
|
|
147
|
+
import XdFormCheckbox from "@/components/XdFormCheckbox/XdFormCheckbox"
|
|
148
|
+
import XdFormSelect from "@/components/XdFormSelect/XdFormSelect"
|
|
149
|
+
import XdFormDate from "./XdFormDate"
|
|
150
|
+
import LdSelect from "./ld-select/ld-select"
|
|
151
|
+
import XdDownDrawer from "@/components/XdDownDrawer/XdDownDrawer"
|
|
152
|
+
import UniDatetimePicker from "./uni-datetime-picker/uni-datetime-picker"
|
|
153
|
+
import XdDialog from "@/components/XdDailog/XdDailog"
|
|
154
|
+
import { jfbRootExec } from "@/utils/xd.event";
|
|
155
|
+
import JfbFormsDynamicFormMixin from "./JfbFormsDynamicFormMixin";
|
|
156
|
+
import { getContainerPropsValue } from "@/utils/xd.base";
|
|
157
|
+
import componentsMixins from "@/mixins/componentsMixins";
|
|
158
|
+
import extsMixins from "@/mixins/extsMixins";
|
|
159
|
+
import { mapState } from "vuex";
|
|
160
|
+
export default {
|
|
161
|
+
name: "JfbFormsDynamicForm",
|
|
162
|
+
components: {
|
|
163
|
+
XdFontIcon,
|
|
164
|
+
XdForm,
|
|
165
|
+
XdFormItem,
|
|
166
|
+
XdButton,
|
|
167
|
+
XdFormInput,
|
|
168
|
+
XdFormCheckbox,
|
|
169
|
+
XdFormSelect,
|
|
170
|
+
XdFormDate,
|
|
171
|
+
XdDownDrawer,
|
|
172
|
+
UniDatetimePicker,
|
|
173
|
+
LdSelect,
|
|
174
|
+
XdDialog
|
|
175
|
+
},
|
|
176
|
+
mixins: [
|
|
177
|
+
componentsMixins, extsMixins, JfbFormsDynamicFormMixin
|
|
178
|
+
],
|
|
179
|
+
data() {
|
|
180
|
+
return {
|
|
181
|
+
formName: "",
|
|
182
|
+
form: {},
|
|
183
|
+
dynamicFormList: [],
|
|
184
|
+
renderForm: "renderForm",
|
|
185
|
+
form_id: "",
|
|
186
|
+
isShowDialog: false,
|
|
187
|
+
validImageAPIUrl: "",
|
|
188
|
+
valid_token: "",
|
|
189
|
+
valid_code: "",
|
|
190
|
+
form_status: "content", //content, success, error
|
|
191
|
+
err_msg: "",
|
|
192
|
+
loaded: false,
|
|
193
|
+
isPreview: false,
|
|
194
|
+
|
|
195
|
+
//面板
|
|
196
|
+
submitPagePath: "",
|
|
197
|
+
formBe: "1",
|
|
198
|
+
// description: "",
|
|
199
|
+
}
|
|
200
|
+
},
|
|
201
|
+
computed: {
|
|
202
|
+
...mapState({
|
|
203
|
+
brandInfo: state => state.brandInfo
|
|
204
|
+
}),
|
|
205
|
+
},
|
|
206
|
+
watch: {
|
|
207
|
+
container(value, oldValue) {
|
|
208
|
+
if (JSON.stringify(value) === JSON.stringify(oldValue)) return;
|
|
209
|
+
if (this.$configProject['isPreview']) this.init(value)
|
|
210
|
+
},
|
|
211
|
+
},
|
|
212
|
+
created() {
|
|
213
|
+
this.isPreview = this.$configProject['isPreview'];
|
|
214
|
+
this.init(this.container);
|
|
215
|
+
this.validImageAPIUrl = this.brandInfo['api_host'] + '/common/v1/valid_code/image/show'
|
|
216
|
+
this.valid_token = this.$xdUniHelper.randomChar(20);
|
|
217
|
+
//todo
|
|
218
|
+
},
|
|
219
|
+
methods: {
|
|
220
|
+
onJfbLoad(options) {
|
|
221
|
+
if (!this.isPreview){
|
|
222
|
+
if(!options.form_id) {
|
|
223
|
+
return uni.showToast({
|
|
224
|
+
title: '请配置表单id',
|
|
225
|
+
duration: 2000
|
|
226
|
+
});
|
|
227
|
+
}
|
|
228
|
+
this.form_id = options.form_id;
|
|
229
|
+
}else{
|
|
230
|
+
this.form_id = 1;
|
|
231
|
+
}
|
|
232
|
+
let getFormFn = "getDynamicForm"; //加盟商营销动态表单fn
|
|
233
|
+
if(this.formBe == 2) getFormFn = "getSaasDynamicForm"
|
|
234
|
+
|
|
235
|
+
|
|
236
|
+
this.$xdShowLoading({});
|
|
237
|
+
jfbRootExec(getFormFn, {
|
|
238
|
+
vm: this,
|
|
239
|
+
data: {
|
|
240
|
+
form_id: this.form_id,
|
|
241
|
+
}
|
|
242
|
+
}).then(res => {
|
|
243
|
+
this.$xdHideLoading();
|
|
244
|
+
this.loaded = true;
|
|
245
|
+
this.formName = res.form_name;
|
|
246
|
+
this.err_msg = res.message;
|
|
247
|
+
if(res.message){
|
|
248
|
+
this.form_status = "error";
|
|
249
|
+
return;
|
|
250
|
+
}
|
|
251
|
+
this.dynamicFormList = res.list.map((item, i) => {
|
|
252
|
+
item.error = "";
|
|
253
|
+
|
|
254
|
+
if(item.is_show_explain !== 'Y'){
|
|
255
|
+
item.explain = "";
|
|
256
|
+
}
|
|
257
|
+
|
|
258
|
+
if(item.field_type === 'text' || item.field_type === 'textarea'){
|
|
259
|
+
try{
|
|
260
|
+
let itemRule = JSON.parse(item.validate_rules);
|
|
261
|
+
let { rule, limit } = itemRule;
|
|
262
|
+
if(rule.value === 'phone'){
|
|
263
|
+
item['icon'] = '//img6.jufubao.cn/common/form/icon_phone.png';
|
|
264
|
+
}else if(rule.value === 'email'){
|
|
265
|
+
item['icon'] = '//img6.jufubao.cn/common/form/icon_email.png';
|
|
266
|
+
}else if(rule.value === 'idCard'){
|
|
267
|
+
item['icon'] = '//img6.jufubao.cn/common/form/icon_idcard.png';
|
|
268
|
+
}else if(rule.value === 'url'){
|
|
269
|
+
item['icon'] = '//img6.jufubao.cn/common/form/icon_net.png';
|
|
270
|
+
}else if(rule.value === 'english'){
|
|
271
|
+
item['icon'] = '//img6.jufubao.cn/common/form/icon_en.png';
|
|
272
|
+
}
|
|
273
|
+
|
|
274
|
+
if(limit.showDefaultValue){
|
|
275
|
+
this.form[item.field_value] = item.default;
|
|
276
|
+
}
|
|
277
|
+
}catch(e){}
|
|
278
|
+
}else if(item.default){
|
|
279
|
+
if(item.field_type === 'checkbox'){
|
|
280
|
+
this.form[item.field_value] = item.default.split(",");
|
|
281
|
+
}else{
|
|
282
|
+
this.form[item.field_value] = item.default;
|
|
283
|
+
}
|
|
284
|
+
}
|
|
285
|
+
if(item.field_type === 'calendar' || item.field_type === 'date'){
|
|
286
|
+
try{
|
|
287
|
+
let monthOrYear = item.validate_type === 'month' || item.validate_type === 'year'
|
|
288
|
+
let dateRule = JSON.parse(item.validate_rules);
|
|
289
|
+
if(dateRule.showRange){
|
|
290
|
+
let date_range = dateRule.date_range; //all, before, after
|
|
291
|
+
if(date_range === 'before'){
|
|
292
|
+
if(monthOrYear){
|
|
293
|
+
item['end_time'] = this.getTimeFormat();
|
|
294
|
+
}else{
|
|
295
|
+
item['end_time'] = new Date().getTime();
|
|
296
|
+
}
|
|
297
|
+
}else if(date_range === 'after'){
|
|
298
|
+
if(monthOrYear){
|
|
299
|
+
item['start_time'] = this.getTimeFormat();
|
|
300
|
+
}else{
|
|
301
|
+
item['start_time'] = new Date().getTime();
|
|
302
|
+
}
|
|
303
|
+
}
|
|
304
|
+
}
|
|
305
|
+
}catch(e){}
|
|
306
|
+
}
|
|
307
|
+
console.log(item, "item")
|
|
308
|
+
return item;
|
|
309
|
+
});
|
|
310
|
+
setTimeout(() => {
|
|
311
|
+
this.setFieldItemTop();
|
|
312
|
+
}, 100)
|
|
313
|
+
})
|
|
314
|
+
},
|
|
315
|
+
setFieldItemTop(){
|
|
316
|
+
const query = uni.createSelectorQuery().in(this);
|
|
317
|
+
this.dynamicFormList = this.dynamicFormList.map(item => {
|
|
318
|
+
let id = item.field_value;
|
|
319
|
+
query.select('#'+id).boundingClientRect(data => {
|
|
320
|
+
// console.log("得到布局位置信息" + JSON.stringify(data));
|
|
321
|
+
item['top'] = data.top;
|
|
322
|
+
}).exec();
|
|
323
|
+
return item;
|
|
324
|
+
})
|
|
325
|
+
},
|
|
326
|
+
getTimeFormat() {
|
|
327
|
+
let date = new Date();
|
|
328
|
+
return (date.getFullYear() + "-" + this.getTimeFormat2((date.getMonth() + 1)) + "-" + this.getTimeFormat2(date.getDate()));
|
|
329
|
+
},
|
|
330
|
+
getTimeFormat2(num) {
|
|
331
|
+
return Number(num) < 10 ? "0" + num : num;
|
|
332
|
+
},
|
|
333
|
+
doCheckValidCode(){
|
|
334
|
+
let token = this.valid_token;
|
|
335
|
+
let valid_code = this.valid_code;
|
|
336
|
+
if(!valid_code) return;
|
|
337
|
+
|
|
338
|
+
jfbRootExec("checkValidCode", {
|
|
339
|
+
vm: this,
|
|
340
|
+
data: {
|
|
341
|
+
token,
|
|
342
|
+
valid_code
|
|
343
|
+
}
|
|
344
|
+
}).then(res => {
|
|
345
|
+
if(res.is_valid){
|
|
346
|
+
this.isShowDialog = false;
|
|
347
|
+
this.handleSubmit();
|
|
348
|
+
}else{
|
|
349
|
+
uni.showToast({
|
|
350
|
+
title: '验证码错误',
|
|
351
|
+
duration: 2000,
|
|
352
|
+
icon: "none"
|
|
353
|
+
});
|
|
354
|
+
this.switchValidToken();
|
|
355
|
+
}
|
|
356
|
+
})
|
|
357
|
+
},
|
|
358
|
+
switchValidToken(){
|
|
359
|
+
let valid_token = this.$xdUniHelper.randomChar(20);
|
|
360
|
+
this.valid_token = valid_token;
|
|
361
|
+
},
|
|
362
|
+
/**
|
|
363
|
+
* @description 监听事件变化
|
|
364
|
+
* @param container {object} 业务组件对象自己
|
|
365
|
+
*/
|
|
366
|
+
init(container) {
|
|
367
|
+
this.submitPagePath = getContainerPropsValue(container, 'content.submitPagePath', {value: ""}).value;
|
|
368
|
+
this.formBe = getContainerPropsValue(container, 'content.formBe', '1');
|
|
369
|
+
// this.description = getContainerPropsValue(container, 'content.description', "");
|
|
370
|
+
},
|
|
371
|
+
handleClearError(item){
|
|
372
|
+
this.$set(item, "error", "")
|
|
373
|
+
},
|
|
374
|
+
handleValidItem(item){
|
|
375
|
+
console.log("handleValidItem", item);
|
|
376
|
+
let fieldValue = this.form[item.field_value];
|
|
377
|
+
let err = "";
|
|
378
|
+
if(item.required && !fieldValue){
|
|
379
|
+
err = "请填写" + item.field_name;
|
|
380
|
+
}else{
|
|
381
|
+
err = this.validFromText(item, fieldValue);
|
|
382
|
+
}
|
|
383
|
+
if(err){
|
|
384
|
+
this.$set(item, "error", err);
|
|
385
|
+
}
|
|
386
|
+
},
|
|
387
|
+
doShowDialog(){
|
|
388
|
+
var err_arr = this.validFrom();
|
|
389
|
+
if(err_arr.length > 0) return;
|
|
390
|
+
|
|
391
|
+
this.isShowDialog = true;
|
|
392
|
+
},
|
|
393
|
+
handleSubmit(){
|
|
394
|
+
|
|
395
|
+
let contents = this.dynamicFormList.map(item => {
|
|
396
|
+
let fieldValue = this.form[item.field_value];
|
|
397
|
+
let field_id = item.field_id;
|
|
398
|
+
if(typeof fieldValue !== 'string'){
|
|
399
|
+
fieldValue = String(fieldValue);
|
|
400
|
+
}
|
|
401
|
+
return {
|
|
402
|
+
field_id,
|
|
403
|
+
content: fieldValue
|
|
404
|
+
}
|
|
405
|
+
})
|
|
406
|
+
if(contents.length === 0) return;
|
|
407
|
+
console.log(contents, "contents")
|
|
408
|
+
|
|
409
|
+
let submitFormFn = "submitDynamicForm"; //加盟商营销动态表单fn
|
|
410
|
+
if(this.formBe == 2) submitFormFn = "submitSaasDynamicForm"
|
|
411
|
+
|
|
412
|
+
this.$xdShowLoading({});
|
|
413
|
+
jfbRootExec(submitFormFn, {
|
|
414
|
+
vm: this,
|
|
415
|
+
data: {
|
|
416
|
+
contents,
|
|
417
|
+
form_id: this.form_id
|
|
418
|
+
}
|
|
419
|
+
}).then(res => {
|
|
420
|
+
this.$xdHideLoading();
|
|
421
|
+
this.form_status = 'success';
|
|
422
|
+
})
|
|
423
|
+
},
|
|
424
|
+
validFrom(){
|
|
425
|
+
console.log("validFrom")
|
|
426
|
+
var err_arr = [];
|
|
427
|
+
this.dynamicFormList.forEach(item => {
|
|
428
|
+
item.error = "";
|
|
429
|
+
let fieldValue = this.form[item.field_value];
|
|
430
|
+
console.log(fieldValue, "fieldValue")
|
|
431
|
+
|
|
432
|
+
if(item.required && !fieldValue){
|
|
433
|
+
let errTip = "";
|
|
434
|
+
if(item.field_type === 'text' || item.field_type === 'textarea'){
|
|
435
|
+
errTip = "请填写" + item.field_name;
|
|
436
|
+
}else{
|
|
437
|
+
errTip = "请选择" + item.field_name;
|
|
438
|
+
}
|
|
439
|
+
item.error = errTip;
|
|
440
|
+
err_arr.push(item);
|
|
441
|
+
}else if(item.required && item.field_type === 'select'){
|
|
442
|
+
if(fieldValue === '' || fieldValue.length == 0){
|
|
443
|
+
let errTip = "请选择" + item.field_name;
|
|
444
|
+
item.error = errTip;
|
|
445
|
+
err_arr.push(item);
|
|
446
|
+
}
|
|
447
|
+
}else if(item.field_type === 'text'){
|
|
448
|
+
let errTip = this.validFromText(item, fieldValue);
|
|
449
|
+
if(errTip) {
|
|
450
|
+
item.error = errTip;
|
|
451
|
+
err_arr.push(item);
|
|
452
|
+
}
|
|
453
|
+
}
|
|
454
|
+
})
|
|
455
|
+
console.log(this.dynamicForm);
|
|
456
|
+
if(err_arr.length > 0){
|
|
457
|
+
let tops = err_arr.map(item => {
|
|
458
|
+
return item.top;
|
|
459
|
+
})
|
|
460
|
+
let top = Math.min(...tops);
|
|
461
|
+
uni.pageScrollTo({
|
|
462
|
+
scrollTop: top,
|
|
463
|
+
duration: 0
|
|
464
|
+
});
|
|
465
|
+
}
|
|
466
|
+
return err_arr;
|
|
467
|
+
},
|
|
468
|
+
getIntTip(item){
|
|
469
|
+
let validate_rules = JSON.parse(item.validate_rules);
|
|
470
|
+
let { rule, limit } = validate_rules;
|
|
471
|
+
let { min, max, showRange } = limit;
|
|
472
|
+
let rangeTip = "";
|
|
473
|
+
if(showRange){
|
|
474
|
+
if(min && max){
|
|
475
|
+
rangeTip = `范围在最小${min},最大${max}`;
|
|
476
|
+
}else if(max){
|
|
477
|
+
rangeTip = "最大输入" + max;
|
|
478
|
+
}else if(min){
|
|
479
|
+
rangeTip = "最小输入" + min;
|
|
480
|
+
}
|
|
481
|
+
}
|
|
482
|
+
if(!rangeTip) return "请填写整数";
|
|
483
|
+
if(rangeTip) return `请填写整数且${rangeTip}`;
|
|
484
|
+
},
|
|
485
|
+
//小数报错提示
|
|
486
|
+
getDecimalTip(item){
|
|
487
|
+
let validate_rules = JSON.parse(item.validate_rules);
|
|
488
|
+
let { rule, limit } = validate_rules;
|
|
489
|
+
let { min, max, showRange, roundDecimal, showRoundDecimal } = limit;
|
|
490
|
+
let ruleTip = "";
|
|
491
|
+
let rangeTip = "";
|
|
492
|
+
if(showRoundDecimal && roundDecimal){ //保留小数位
|
|
493
|
+
ruleTip = "保留" + roundDecimal + "位";
|
|
494
|
+
}
|
|
495
|
+
if(showRange){
|
|
496
|
+
if(min && max){
|
|
497
|
+
rangeTip = `范围在最小${min},最大${max}`;
|
|
498
|
+
}else if(max){
|
|
499
|
+
rangeTip = "最大输入" + max;
|
|
500
|
+
}else if(min){
|
|
501
|
+
rangeTip = "最小输入" + min;
|
|
502
|
+
}
|
|
503
|
+
}
|
|
504
|
+
if(!ruleTip && !rangeTip) return "请填写小数";
|
|
505
|
+
if(ruleTip && rangeTip) return `请填写小数且${rangeTip},${ruleTip}`;
|
|
506
|
+
if(ruleTip && !rangeTip) return `请填写小数且${ruleTip}`;
|
|
507
|
+
if(!ruleTip && rangeTip) return `请填写小数且${rangeTip}`;
|
|
508
|
+
},
|
|
509
|
+
validFromText(item, fieldValue){
|
|
510
|
+
let validate_rules = JSON.parse(item.validate_rules);
|
|
511
|
+
let { rule, limit } = validate_rules;
|
|
512
|
+
let regExp = new RegExp(rule.RegExp);
|
|
513
|
+
let { min, max, showRange, roundDecimal } = limit;
|
|
514
|
+
let errTip = "";
|
|
515
|
+
let inputType = "text"; //text, number
|
|
516
|
+
let typeText = "";
|
|
517
|
+
|
|
518
|
+
switch(rule.value){
|
|
519
|
+
case 'all': //不限制
|
|
520
|
+
inputType = "text";
|
|
521
|
+
break;
|
|
522
|
+
case 'decimal': //小数
|
|
523
|
+
inputType = "number";
|
|
524
|
+
typeText = "小数";
|
|
525
|
+
break;
|
|
526
|
+
case 'positiveInteger': //正整数
|
|
527
|
+
inputType = "number";
|
|
528
|
+
typeText = "整数";
|
|
529
|
+
break;
|
|
530
|
+
case 'phone': //手机号码
|
|
531
|
+
typeText = "手机号";
|
|
532
|
+
break;
|
|
533
|
+
case 'email': //邮箱
|
|
534
|
+
typeText = "邮箱";
|
|
535
|
+
break;
|
|
536
|
+
case 'url': //网址
|
|
537
|
+
typeText = "网址";
|
|
538
|
+
break;
|
|
539
|
+
case 'idCard': //身份证
|
|
540
|
+
typeText = "身份证";
|
|
541
|
+
break;
|
|
542
|
+
case 'english': //英文
|
|
543
|
+
inputType = "text";
|
|
544
|
+
typeText = "英文";
|
|
545
|
+
}
|
|
546
|
+
|
|
547
|
+
if( fieldValue && regExp.test(fieldValue) === false){
|
|
548
|
+
if(rule.value === 'decimal'){
|
|
549
|
+
errTip = this.getDecimalTip(item);
|
|
550
|
+
}else if(rule.value === 'positiveInteger'){
|
|
551
|
+
errTip = this.getIntTip(item);
|
|
552
|
+
}else{
|
|
553
|
+
errTip = "请填写正确的" + (typeText || item.field_name);
|
|
554
|
+
}
|
|
555
|
+
return errTip;
|
|
556
|
+
}
|
|
557
|
+
|
|
558
|
+
//小数验证保留位数
|
|
559
|
+
if(rule.value === 'decimal' && fieldValue && limit.showRoundDecimal){
|
|
560
|
+
let roundDecimal = limit.roundDecimal;//保留小数位数
|
|
561
|
+
let decimal = fieldValue.split('.')[1] || "";
|
|
562
|
+
if(decimal.length != roundDecimal){
|
|
563
|
+
return this.getDecimalTip(item);
|
|
564
|
+
}
|
|
565
|
+
}
|
|
566
|
+
|
|
567
|
+
//开始验证限制范围
|
|
568
|
+
if(fieldValue && !showRange) return errTip;
|
|
569
|
+
max = Number(max);
|
|
570
|
+
min = Number(min);
|
|
571
|
+
if(inputType === 'text'){
|
|
572
|
+
if(max && fieldValue.length > max){
|
|
573
|
+
return "最多输入" + max + "个字符";
|
|
574
|
+
}
|
|
575
|
+
if(min && fieldValue.length < min){
|
|
576
|
+
return "最少输入" + min + "个字符";
|
|
577
|
+
}
|
|
578
|
+
}else if(inputType === 'number' || inputType === 'decimal'){
|
|
579
|
+
if((max && Number(fieldValue) > max) || (min && Number(fieldValue) < min)){
|
|
580
|
+
if(rule.value === 'decimal'){
|
|
581
|
+
return this.getDecimalTip(item);
|
|
582
|
+
}else if(rule.value === 'positiveInteger'){
|
|
583
|
+
return this.getIntTip(item);
|
|
584
|
+
}
|
|
585
|
+
}
|
|
586
|
+
}
|
|
587
|
+
|
|
588
|
+
return errTip;
|
|
589
|
+
},
|
|
590
|
+
handleDatepicker(e, item){
|
|
591
|
+
let value = e.detail.value;
|
|
592
|
+
this.$set(this.form, item.field_value, value);
|
|
593
|
+
this.$set(item, "error", "")
|
|
594
|
+
},
|
|
595
|
+
doClose(){
|
|
596
|
+
this.$xdUniHelper.navigateTo({
|
|
597
|
+
url: this.submitPagePath
|
|
598
|
+
})
|
|
599
|
+
// window.location.href = 'about:blank';
|
|
600
|
+
// window.close();
|
|
601
|
+
},
|
|
602
|
+
onJfbScroll(options) {
|
|
603
|
+
// console.log('event.onJfbScroll', options)
|
|
604
|
+
},
|
|
605
|
+
onJfbReachBottom(options) {
|
|
606
|
+
// console.log('event.onJfbReachBottom', options)
|
|
607
|
+
},
|
|
608
|
+
onJfbShow(options) {
|
|
609
|
+
console.log('event.onJfbShow', options)
|
|
610
|
+
},
|
|
611
|
+
onJfbHide(options) {
|
|
612
|
+
console.log('event.onJfbHide', options)
|
|
613
|
+
},
|
|
614
|
+
onJfbBack(options) {
|
|
615
|
+
console.log('event.onJfbBack', options)
|
|
616
|
+
},
|
|
617
|
+
onJfbUpdate(...data) {
|
|
618
|
+
console.log('event.onJfbUpdate', data)
|
|
619
|
+
},
|
|
620
|
+
onJfbCustomEvent(options) {
|
|
621
|
+
console.log('event.onJfbReachBottom', options)
|
|
622
|
+
},
|
|
623
|
+
}
|
|
624
|
+
}
|
|
625
|
+
|
|
626
|
+
</script>
|
|
627
|
+
|
|
628
|
+
<style scoped lang="less">
|
|
629
|
+
@import "./JfbFormsDynamicFormLess.less";
|
|
630
|
+
|
|
631
|
+
.jfb-forms-dynamic-form {
|
|
632
|
+
&__body{
|
|
633
|
+
padding: 32rpx 24rpx;
|
|
634
|
+
.form_status{
|
|
635
|
+
display: flex;
|
|
636
|
+
flex-direction: column;
|
|
637
|
+
align-items: center;
|
|
638
|
+
padding-top: 100rpx;
|
|
639
|
+
.status_tip{
|
|
640
|
+
color: #06bc85;
|
|
641
|
+
margin-top: 32rpx;
|
|
642
|
+
font-size: 40rpx;
|
|
643
|
+
&.error_tip{
|
|
644
|
+
color: #f0413d;
|
|
645
|
+
}
|
|
646
|
+
}
|
|
647
|
+
.status_name{
|
|
648
|
+
font-size: 32rpx;
|
|
649
|
+
margin: 78rpx 0;
|
|
650
|
+
}
|
|
651
|
+
.status_btn{
|
|
652
|
+
width: 80%;
|
|
653
|
+
border-radius: 4px;
|
|
654
|
+
background: #06bc85;
|
|
655
|
+
color: #fff;
|
|
656
|
+
font-size: 26rpx;
|
|
657
|
+
height: 80rpx;
|
|
658
|
+
line-height: 80rpx;
|
|
659
|
+
text-align: center;
|
|
660
|
+
}
|
|
661
|
+
}
|
|
662
|
+
|
|
663
|
+
.align-center{
|
|
664
|
+
display: flex;
|
|
665
|
+
align-items: center;
|
|
666
|
+
}
|
|
667
|
+
.input_icon{
|
|
668
|
+
width: 48rpx;
|
|
669
|
+
image{
|
|
670
|
+
width: 100%;
|
|
671
|
+
}
|
|
672
|
+
}
|
|
673
|
+
.valid_wrap{
|
|
674
|
+
display: flex;
|
|
675
|
+
align-items: center;
|
|
676
|
+
border: 1px solid #DDD;
|
|
677
|
+
}
|
|
678
|
+
.capture{
|
|
679
|
+
width: 180rpx;
|
|
680
|
+
height: 80rpx;
|
|
681
|
+
background: #DDD;
|
|
682
|
+
}
|
|
683
|
+
.form_datepicker{
|
|
684
|
+
font-size: 26rpx;
|
|
685
|
+
color: #666666;
|
|
686
|
+
height: 80rpx;
|
|
687
|
+
display: flex;
|
|
688
|
+
align-items: center;
|
|
689
|
+
padding: 0 20rpx;
|
|
690
|
+
}
|
|
691
|
+
/deep/ .uni-forms-item{
|
|
692
|
+
border-bottom: 1px solid #F5F5F5;
|
|
693
|
+
&:last-child{
|
|
694
|
+
border-bottom: none;
|
|
695
|
+
}
|
|
696
|
+
.checklist-box{
|
|
697
|
+
align-items: flex-start;
|
|
698
|
+
}
|
|
699
|
+
.uni-error-message{
|
|
700
|
+
height: 28rpx;
|
|
701
|
+
line-height: 28rpx;
|
|
702
|
+
z-index: 1111;
|
|
703
|
+
bottom: 12rpx;
|
|
704
|
+
.uni-error-message-text{
|
|
705
|
+
font-size: 20rpx;
|
|
706
|
+
}
|
|
707
|
+
}
|
|
708
|
+
.uni-forms-item__content{
|
|
709
|
+
padding-left: 10px;
|
|
710
|
+
&.is-input-error-border .uni-easyinput__placeholder-class{
|
|
711
|
+
color: #979797;
|
|
712
|
+
}
|
|
713
|
+
}
|
|
714
|
+
.mySelfradio{
|
|
715
|
+
.checklist-group{
|
|
716
|
+
flex-direction: column;
|
|
717
|
+
.checklist-text{
|
|
718
|
+
line-height: 32rpx;
|
|
719
|
+
}
|
|
720
|
+
}
|
|
721
|
+
}
|
|
722
|
+
}
|
|
723
|
+
/deep/ .uni-forms-item__inner{
|
|
724
|
+
padding-bottom: 20rpx;
|
|
725
|
+
padding-top: 8rpx;
|
|
726
|
+
.uni-forms-item__label{
|
|
727
|
+
height: auto;
|
|
728
|
+
}
|
|
729
|
+
|
|
730
|
+
.uni-forms-item__label .label-text{
|
|
731
|
+
font-size: 24rpx;
|
|
732
|
+
color: #666666;
|
|
733
|
+
line-height: 1.2;
|
|
734
|
+
}
|
|
735
|
+
.uni-easyinput__content-input{
|
|
736
|
+
font-size: 24rpx;
|
|
737
|
+
|
|
738
|
+
.uni-easyinput__placeholder-class{
|
|
739
|
+
font-size: 24rpx;
|
|
740
|
+
}
|
|
741
|
+
.uni-input-input{
|
|
742
|
+
color: #333333;
|
|
743
|
+
}
|
|
744
|
+
}
|
|
745
|
+
.xd-select__box > uni-view{
|
|
746
|
+
font-size: 24rpx !important;
|
|
747
|
+
border: none !important;
|
|
748
|
+
}
|
|
749
|
+
|
|
750
|
+
}
|
|
751
|
+
.description{
|
|
752
|
+
color: #666666;
|
|
753
|
+
font-size: 24rpx;
|
|
754
|
+
padding: 28rpx;
|
|
755
|
+
}
|
|
756
|
+
.footer_btn{
|
|
757
|
+
margin-top: 60rpx;
|
|
758
|
+
}
|
|
759
|
+
}
|
|
760
|
+
&__title{
|
|
761
|
+
height: 100rpx;
|
|
762
|
+
display: flex;
|
|
763
|
+
align-items: center;
|
|
764
|
+
justify-content: center;
|
|
765
|
+
}
|
|
766
|
+
}
|
|
767
|
+
</style>
|