gxd-uni-library-editx 1.0.0
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/.editorconfig +14 -0
- package/README.md +447 -0
- package/index.js +3 -0
- package/package.json +104 -0
- package/postcss.config.js +22 -0
- package/settings.js.tpl +68 -0
- package/src/XdAppClass.1.0.js +257 -0
- package/src/XdAppClass.js +150 -0
- package/src/components/XdAddress/XdAddress.vue +579 -0
- package/src/components/XdAddressSelect/XdAddressSelect.vue +243 -0
- package/src/components/XdBaiduMap/XdBaiduMap.vue +204 -0
- package/src/components/XdBaiduOverlay/XdBaiduOverlay.vue +345 -0
- package/src/components/XdBaiduSearch/XdBaiduSearch.vue +354 -0
- package/src/components/XdBar/XdBar.vue +339 -0
- package/src/components/XdButton/XdButton.vue +288 -0
- package/src/components/XdCartList/XdCartList.vue +791 -0
- package/src/components/XdCartNoStoreList/XdCartNoStoreList.vue +747 -0
- package/src/components/XdCity/XdCity.vue +620 -0
- package/src/components/XdCity/city.js +93 -0
- package/src/components/XdCity/testData.js +124 -0
- package/src/components/XdCityLocation/XdCityLocation.vue +314 -0
- package/src/components/XdCityLocation/jweixin.js +72 -0
- package/src/components/XdCityShow/XdCityShow.vue +354 -0
- package/src/components/XdClipImage/XdClipImage.vue +879 -0
- package/src/components/XdCoins/XdCoins.vue +66 -0
- package/src/components/XdConfirm/XdConfirm.vue +240 -0
- package/src/components/XdContentXss/XdContentXss.vue +71 -0
- package/src/components/XdDailog/XdDailog.vue +258 -0
- package/src/components/XdDate/XdDataItemOne.vue +236 -0
- package/src/components/XdDate/XdDate.vue +1081 -0
- package/src/components/XdDate/XdDateItem.vue +316 -0
- package/src/components/XdDate/XdDateTime.vue +929 -0
- package/src/components/XdDate/i18n/en.json +19 -0
- package/src/components/XdDate/i18n/index.js +8 -0
- package/src/components/XdDate/i18n/zh-Hans.json +19 -0
- package/src/components/XdDate/i18n/zh-Hant.json +19 -0
- package/src/components/XdDate/keypress.js +45 -0
- package/src/components/XdDate/util.js +418 -0
- package/src/components/XdDownDrawer/XdDownDrawer.vue +176 -0
- package/src/components/XdEditPwd/XdEditPwd.vue +305 -0
- package/src/components/XdEnterOrderList/XdEnterOrderList.vue +413 -0
- package/src/components/XdExpressTimeLine/XdExpressTimeLine.vue +280 -0
- package/src/components/XdFilter/XdFilter.vue +541 -0
- package/src/components/XdFontIcon/XdFontIcon.vue +165 -0
- package/src/components/XdFontIcon/css/icon.less +498 -0
- package/src/components/XdFooterBar/XdFooterBar.vue +291 -0
- package/src/components/XdFooterTabbar/XdFooterTabbar.vue +284 -0
- package/src/components/XdForm/XdForm.vue +481 -0
- package/src/components/XdForm/validate.js +486 -0
- package/src/components/XdFormCheckbox/XdFormCheckbox.vue +858 -0
- package/src/components/XdFormDate.vue +187 -0
- package/src/components/XdFormInput/XdFormInput.vue +535 -0
- package/src/components/XdFormInput/common.js +56 -0
- package/src/components/XdFormItem/XdFormItem.vue +583 -0
- package/src/components/XdFormSelect/XdFormSelect.vue +119 -0
- package/src/components/XdImage/XdImage.vue +113 -0
- package/src/components/XdItemCardUser/XdItemCardUser.vue +232 -0
- package/src/components/XdItemFilmImage/XdItemFilmImage.vue +146 -0
- package/src/components/XdItemFilmText/XdItemFilmText.vue +83 -0
- package/src/components/XdItemPhysical/XdItemPhysical.vue +410 -0
- package/src/components/XdItemPhysicalPack/XdItemPhysicalPack.vue +240 -0
- package/src/components/XdItemStore/XdItemStore.vue +236 -0
- package/src/components/XdItemUserInfo/XdItemUserInfo.vue +175 -0
- package/src/components/XdJson/XdJson.vue +398 -0
- package/src/components/XdKeyValue/XdKeyValue.vue +150 -0
- package/src/components/XdLabelNew/XdLabelNew.vue +193 -0
- package/src/components/XdLayout/XdLayout.vue +634 -0
- package/src/components/XdLoading/XdLoading.vue +165 -0
- package/src/components/XdMore/XdMore.vue +66 -0
- package/src/components/XdMpHtml/XdMpHtml.vue +458 -0
- package/src/components/XdMpHtml/node/node.vue +536 -0
- package/src/components/XdMpHtml/parser.js +1260 -0
- package/src/components/XdMpHtml/static/js/handler.js +1 -0
- package/src/components/XdMpHtml/static/js/uni.webview.min.js +1 -0
- package/src/components/XdMpHtml/static/local.html +1 -0
- package/src/components/XdMy/XdMy.vue +294 -0
- package/src/components/XdMySuccess/XdMySuccess.vue +603 -0
- package/src/components/XdNavTab/XdNavTab.vue +147 -0
- package/src/components/XdNoData/XdNoData.vue +87 -0
- package/src/components/XdNoticeBar/XdNoticeBar.vue +501 -0
- package/src/components/XdNumber/XdNumber.vue +210 -0
- package/src/components/XdNumberUni/XdNumberUni.vue +270 -0
- package/src/components/XdNumberUni/readme.md +42 -0
- package/src/components/XdOnlineConfirm/XdOnlineConfirm.vue +385 -0
- package/src/components/XdOnlineDetail/XdOnlineDetail.vue +332 -0
- package/src/components/XdOnlinePay/XdOnlinePay.vue +349 -0
- package/src/components/XdOnlineSchedule/XdOnlineSchedule.vue +453 -0
- package/src/components/XdOnlineSeat/XdOnlineSeat.vue +796 -0
- package/src/components/XdOnlineSeatMove/XdOnlineSeatMove.vue +1012 -0
- package/src/components/XdPayCombo/XdPayCombo.vue +118 -0
- package/src/components/XdPreviewImage/XdPreviewImage.vue +372 -0
- package/src/components/XdPwPay/XdPwPay.vue +214 -0
- package/src/components/XdRadio/XdRadio.vue +151 -0
- package/src/components/XdRangeSlider/XdRangeSlider.vue +355 -0
- package/src/components/XdRedName/XdRedName.vue +35 -0
- package/src/components/XdSearchBar/XdSearchBar.vue +286 -0
- package/src/components/XdSelect/XdSelect.vue +382 -0
- package/src/components/XdSelectCity/XdSelectCity.vue +270 -0
- package/src/components/XdSelectTime/XdSelectTime.vue +342 -0
- package/src/components/XdStar/XdStar.vue +261 -0
- package/src/components/XdStoreCashier/XdStoreCashier.vue +526 -0
- package/src/components/XdStoreItem/XdStoreItem.vue +400 -0
- package/src/components/XdStoreOrderDetail/XdStoreOrderDetail.vue +1571 -0
- package/src/components/XdStoreOrderList/XdStoreOrderList.vue +450 -0
- package/src/components/XdStoreProductInfo/XdStoreProductInfo.vue +940 -0
- package/src/components/XdStoreProductType/XdStoreProductType.vue +307 -0
- package/src/components/XdSuccess/XdSuccess.vue +527 -0
- package/src/components/XdSwipeSelect/XdSwipeSelect.vue +99 -0
- package/src/components/XdSwiper/XdSwiper.vue +124 -0
- package/src/components/XdSwitch/XdSwitch.vue +204 -0
- package/src/components/XdTab/XdTab.vue +220 -0
- package/src/components/XdTabScroll/XdTabScroll.vue +212 -0
- package/src/components/XdTag/XdTag.vue +423 -0
- package/src/components/XdTimeLine/XdTimeLine.vue +121 -0
- package/src/components/XdTips/XdTips.vue +212 -0
- package/src/components/XdTipsBlock/XdTipsBlock.vue +141 -0
- package/src/components/XdTitleSection/XdTitleSection.vue +152 -0
- package/src/components/XdTitleTab/XdTitleTab.vue +227 -0
- package/src/components/XdUnit/XdUnit.vue +206 -0
- package/src/components/XdUpload/XdUpload.vue +197 -0
- package/src/components/XdUploadImage/XdUploadImage.vue +145 -0
- package/src/components/Xdlogs/XdLogs.vue +144 -0
- package/src/components/autoload.js +211 -0
- package/src/components/swipeAction/UniSwipeAction.vue +43 -0
- package/src/components/swipeActionItem/UniSwipeActionItem.vue +386 -0
- package/src/components/swipeActionItem/bindingx.js +298 -0
- package/src/components/swipeActionItem/index.wxs +321 -0
- package/src/components/swipeActionItem/isPC.js +18 -0
- package/src/components/swipeActionItem/mpalipay.js +210 -0
- package/src/components/swipeActionItem/mpother.js +252 -0
- package/src/components/swipeActionItem/mpwxs.js +140 -0
- package/src/dome/dome/address.vue +415 -0
- package/src/dome/dome/auth/login.vue +166 -0
- package/src/dome/dome/baidu_show.vue +20 -0
- package/src/dome/dome/cake.vue +186 -0
- package/src/dome/dome/cart.vue +205 -0
- package/src/dome/dome/cart_store.vue +149 -0
- package/src/dome/dome/cashier/cashier.vue +73 -0
- package/src/dome/dome/cashier/check_cashier.vue +469 -0
- package/src/dome/dome/cashier/success.vue +127 -0
- package/src/dome/dome/city.vue +148 -0
- package/src/dome/dome/cityData.js +9 -0
- package/src/dome/dome/clip.vue +82 -0
- package/src/dome/dome/date/date.vue +273 -0
- package/src/dome/dome/date/selected.js +315 -0
- package/src/dome/dome/dcom/app1.vue +13 -0
- package/src/dome/dome/dcom/app2.vue +13 -0
- package/src/dome/dome/dcom/app3.vue +13 -0
- package/src/dome/dome/dcom/app4.vue +13 -0
- package/src/dome/dome/dcom/app5.vue +13 -0
- package/src/dome/dome/dcom/index.vue +1 -0
- package/src/dome/dome/debug/debug.vue +95 -0
- package/src/dome/dome/docache/docache.vue +88 -0
- package/src/dome/dome/express.vue +269 -0
- package/src/dome/dome/form.vue +312 -0
- package/src/dome/dome/icon.js +125 -0
- package/src/dome/dome/icon.vue +93 -0
- package/src/dome/dome/index.vue +725 -0
- package/src/dome/dome/item.vue +236 -0
- package/src/dome/dome/json/json.vue +88 -0
- package/src/dome/dome/layout.vue +105 -0
- package/src/dome/dome/line.vue +113 -0
- package/src/dome/dome/map/search.vue +70 -0
- package/src/dome/dome/my.vue +171 -0
- package/src/dome/dome/notice.vue +93 -0
- package/src/dome/dome/online/confirm.vue +92 -0
- package/src/dome/dome/online/detail.vue +80 -0
- package/src/dome/dome/online/pay.vue +78 -0
- package/src/dome/dome/online/schedule.vue +73 -0
- package/src/dome/dome/online/seat.vue +98 -0
- package/src/dome/dome/order/detail.vue +166 -0
- package/src/dome/dome/order/enter_order.vue +294 -0
- package/src/dome/dome/order/list.vue +219 -0
- package/src/dome/dome/order/order.js +18 -0
- package/src/dome/dome/order/success.vue +68 -0
- package/src/dome/dome/product.vue +179 -0
- package/src/dome/dome/store_cashier.vue +67 -0
- package/src/dome/dome/swiper.vue +32 -0
- package/src/dome/dome/webview.vue +61 -0
- package/src/install.js +183 -0
- package/src/main/address/address.vue +251 -0
- package/src/main/cart/cart.vue +149 -0
- package/src/main/cashier/cashier.vue +72 -0
- package/src/main/cashier/check_cashier.vue +483 -0
- package/src/main/city/city.vue +149 -0
- package/src/main/date/date.vue +260 -0
- package/src/main/order/order.js +19 -0
- package/src/main/order/order.vue +222 -0
- package/src/main/product/detail.vue +121 -0
- package/src/main/product/type.vue +108 -0
- package/src/main/search/search.vue +501 -0
- package/src/pages.json +337 -0
- package/src/plugins/CreatedComponentsPlugin.js +19 -0
- package/src/plugins/JsonRename.js +72 -0
- package/src/plugins/SetAppParams.js +171 -0
- package/src/project.js +18 -0
- package/src/utils/Cookie.js +68 -0
- package/src/utils/Runtime.js +105 -0
- package/src/utils/Storage.js +104 -0
- package/src/utils/XdNetwork.js +133 -0
- package/src/utils/helper.js +1321 -0
- package/src/utils/nourl.js +95 -0
- package/src/utils/project.js +17 -0
- package/src/utils/xd.auth.js +61 -0
- package/src/utils/xd.base.js +474 -0
- package/src/utils/xd.common.js +240 -0
- package/src/utils/xd.event.js +99 -0
- package/src/utils/xd.frame.js +96 -0
- package/src/utils/xd.path.js +96 -0
- package/src/utils/xdAppLog.js +170 -0
- package/src/utils/xdWxLog.js +302 -0
- package/src/utils/xdh5log.js +307 -0
- package/src/websetting.js +64 -0
- package/tsconfig.json +9 -0
- package/xd.less +180 -0
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @desc 函数防抖
|
|
3
|
+
* @param func 目标函数
|
|
4
|
+
* @param wait 延迟执行毫秒数
|
|
5
|
+
* @param immediate true - 立即执行, false - 延迟执行
|
|
6
|
+
*/
|
|
7
|
+
export const debounce = function(func, wait = 1000, immediate = true) {
|
|
8
|
+
let timer;
|
|
9
|
+
console.log(1);
|
|
10
|
+
return function() {
|
|
11
|
+
console.log(123);
|
|
12
|
+
let context = this,
|
|
13
|
+
args = arguments;
|
|
14
|
+
if (timer) clearTimeout(timer);
|
|
15
|
+
if (immediate) {
|
|
16
|
+
let callNow = !timer;
|
|
17
|
+
timer = setTimeout(() => {
|
|
18
|
+
timer = null;
|
|
19
|
+
}, wait);
|
|
20
|
+
if (callNow) func.apply(context, args);
|
|
21
|
+
} else {
|
|
22
|
+
timer = setTimeout(() => {
|
|
23
|
+
func.apply(context, args);
|
|
24
|
+
}, wait)
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
/**
|
|
29
|
+
* @desc 函数节流
|
|
30
|
+
* @param func 函数
|
|
31
|
+
* @param wait 延迟执行毫秒数
|
|
32
|
+
* @param type 1 使用表时间戳,在时间段开始的时候触发 2 使用表定时器,在时间段结束的时候触发
|
|
33
|
+
*/
|
|
34
|
+
export const throttle = (func, wait = 1000, type = 1) => {
|
|
35
|
+
let previous = 0;
|
|
36
|
+
let timeout;
|
|
37
|
+
return function() {
|
|
38
|
+
let context = this;
|
|
39
|
+
let args = arguments;
|
|
40
|
+
if (type === 1) {
|
|
41
|
+
let now = Date.now();
|
|
42
|
+
|
|
43
|
+
if (now - previous > wait) {
|
|
44
|
+
func.apply(context, args);
|
|
45
|
+
previous = now;
|
|
46
|
+
}
|
|
47
|
+
} else if (type === 2) {
|
|
48
|
+
if (!timeout) {
|
|
49
|
+
timeout = setTimeout(() => {
|
|
50
|
+
timeout = null;
|
|
51
|
+
func.apply(context, args)
|
|
52
|
+
}, wait)
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
}
|
|
@@ -0,0 +1,583 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<view
|
|
3
|
+
class="uni-forms-item"
|
|
4
|
+
:class="{
|
|
5
|
+
'uni-forms-item--border': border,
|
|
6
|
+
'is-first-border': border && isFirstBorder,
|
|
7
|
+
'uni-forms-item-error': msg,
|
|
8
|
+
'is-last-border': border && isLastBorder,
|
|
9
|
+
}"
|
|
10
|
+
:style="{
|
|
11
|
+
paddingLeft: paddingBetween + 'rpx',
|
|
12
|
+
paddingRight: paddingBetween + 'rpx'
|
|
13
|
+
}"
|
|
14
|
+
v-if="labelAli"
|
|
15
|
+
>
|
|
16
|
+
<view class="uni-forms-item__box">
|
|
17
|
+
<view class="uni-forms-item__inner" :class="['is-direction-' + labelPos]">
|
|
18
|
+
<view
|
|
19
|
+
class="uni-forms-item__label"
|
|
20
|
+
:style="{
|
|
21
|
+
width: labelPos==='top'? 'auto' : (labelWid.indexOf('rpx') !== -1 ? labelWid : labelWid + 'rpx') ,
|
|
22
|
+
justifyContent: justifyContent
|
|
23
|
+
}"
|
|
24
|
+
>
|
|
25
|
+
<slot name="label">
|
|
26
|
+
<text class="is-required"><template v-if="required">*</template></text>
|
|
27
|
+
<xd-font-icon
|
|
28
|
+
v-if="leftIcon"
|
|
29
|
+
class="label-icon"
|
|
30
|
+
size="32"
|
|
31
|
+
:icon="leftIcon"
|
|
32
|
+
:color="iconColor"
|
|
33
|
+
></xd-font-icon>
|
|
34
|
+
<text class="label-text">{{ label }}</text>
|
|
35
|
+
<view v-if="label" class="label-seat"></view>
|
|
36
|
+
</slot>
|
|
37
|
+
</view>
|
|
38
|
+
<view class="uni-forms-item__content" :class="{ 'is-input-error-border': msg }"><slot></slot></view>
|
|
39
|
+
</view>
|
|
40
|
+
<view
|
|
41
|
+
v-if="msg"
|
|
42
|
+
class="uni-error-message"
|
|
43
|
+
:class="{ 'uni-error-msg--boeder': border }"
|
|
44
|
+
:style="{
|
|
45
|
+
paddingLeft: labelLeft
|
|
46
|
+
}"
|
|
47
|
+
>
|
|
48
|
+
<text class="uni-error-message-text">{{ showMsg === 'undertext' ? msg : '' }}</text>
|
|
49
|
+
</view>
|
|
50
|
+
</view>
|
|
51
|
+
</view>
|
|
52
|
+
</template>
|
|
53
|
+
|
|
54
|
+
<script>
|
|
55
|
+
/**
|
|
56
|
+
* Field 输入框
|
|
57
|
+
* @description 此组件可以实现表单的输入与校验,包括 "text" 和 "textarea" 类型。
|
|
58
|
+
* @tutorial https://ext.dcloud.net.cn/plugin?id=21001
|
|
59
|
+
* @property {Boolean} required 是否必填,左边显示红色"*"号(默认false)
|
|
60
|
+
* @property {String} validateTrigger = [bind|submit] 校验触发器方式 默认 submit 可选
|
|
61
|
+
* @value bind 发生变化时触发
|
|
62
|
+
* @value submit 提交时触发
|
|
63
|
+
* @property {String } leftIcon label左边的图标,限 uni-ui 的图标名称
|
|
64
|
+
* @property {String } iconColor 左边通过icon配置的图标的颜色(默认#606266)
|
|
65
|
+
* @property {String } label 输入框左边的文字提示
|
|
66
|
+
* @property {Number } labelWidth label的宽度,单位px(默认65)
|
|
67
|
+
* @property {String } labelAlign = [left|center|right] label的文字对齐方式(默认left)
|
|
68
|
+
* @value left label 左侧显示
|
|
69
|
+
* @value center label 居中
|
|
70
|
+
* @value right label 右侧对齐
|
|
71
|
+
* @property {String } labelPosition = [top|left] label的文字的位置(默认left)
|
|
72
|
+
* @value top 顶部显示 label
|
|
73
|
+
* @value left 左侧显示 label
|
|
74
|
+
* @property {String } errorMessage 显示的错误提示内容,如果为空字符串或者false,则不显示错误信息
|
|
75
|
+
* @property {String } name 表单域的属性名,在使用校验规则时必填
|
|
76
|
+
*/
|
|
77
|
+
|
|
78
|
+
//https://www.iconfont.cn/manage/index?spm=a313x.7781069.1998910419.db775f1f3&manage_type=myprojects&projectId=2260472&keyword=&project_type=&page=
|
|
79
|
+
import XdFontIcon from "@/components/XdFontIcon/XdFontIcon";
|
|
80
|
+
|
|
81
|
+
export default {
|
|
82
|
+
name: 'XdFormItem',
|
|
83
|
+
components: {
|
|
84
|
+
XdFontIcon
|
|
85
|
+
},
|
|
86
|
+
props: {
|
|
87
|
+
// 自定义内容
|
|
88
|
+
custom: {
|
|
89
|
+
type: Boolean,
|
|
90
|
+
default: false
|
|
91
|
+
},
|
|
92
|
+
// 是否显示报错信息
|
|
93
|
+
showMessage: {
|
|
94
|
+
type: Boolean,
|
|
95
|
+
default: true
|
|
96
|
+
},
|
|
97
|
+
name: String,
|
|
98
|
+
required: Boolean,
|
|
99
|
+
validateTrigger: {
|
|
100
|
+
type: String,
|
|
101
|
+
default: ''
|
|
102
|
+
},
|
|
103
|
+
leftIcon: String,
|
|
104
|
+
iconColor: {
|
|
105
|
+
type: String,
|
|
106
|
+
default: '#606266'
|
|
107
|
+
},
|
|
108
|
+
label: String,
|
|
109
|
+
// 左边标题的宽度单位rpx
|
|
110
|
+
labelWidth: {
|
|
111
|
+
type: [Number, String],
|
|
112
|
+
default: ''
|
|
113
|
+
},
|
|
114
|
+
// 对齐方式,left|center|right
|
|
115
|
+
labelAlign: {
|
|
116
|
+
type: String,
|
|
117
|
+
default: ''
|
|
118
|
+
},
|
|
119
|
+
|
|
120
|
+
// 对齐方式,left|center|right
|
|
121
|
+
contentAlign: {
|
|
122
|
+
type: String,
|
|
123
|
+
default: ''
|
|
124
|
+
},
|
|
125
|
+
|
|
126
|
+
// lable的位置,可选为 left-左边,top-上边
|
|
127
|
+
labelPosition: {
|
|
128
|
+
type: String,
|
|
129
|
+
default: ''
|
|
130
|
+
},
|
|
131
|
+
errorMessage: {
|
|
132
|
+
type: [String, Boolean],
|
|
133
|
+
default: ''
|
|
134
|
+
},
|
|
135
|
+
// 表单校验规则
|
|
136
|
+
rules: {
|
|
137
|
+
type: Array,
|
|
138
|
+
default() {
|
|
139
|
+
return [];
|
|
140
|
+
}
|
|
141
|
+
}
|
|
142
|
+
},
|
|
143
|
+
data() {
|
|
144
|
+
return {
|
|
145
|
+
errorTop: false,
|
|
146
|
+
errorBottom: false,
|
|
147
|
+
labelMarginBottom: '',
|
|
148
|
+
errorWidth: '',
|
|
149
|
+
errMsg: '',
|
|
150
|
+
val: '',
|
|
151
|
+
labelPos: '',
|
|
152
|
+
labelWid: '',
|
|
153
|
+
labelAli: '',
|
|
154
|
+
showMsg: 'undertext',
|
|
155
|
+
border: false,
|
|
156
|
+
isFirstBorder: false,
|
|
157
|
+
isLastBorder: false,
|
|
158
|
+
isArray: false,
|
|
159
|
+
arrayField: '',
|
|
160
|
+
paddingBetween: '',
|
|
161
|
+
index: 0,
|
|
162
|
+
};
|
|
163
|
+
},
|
|
164
|
+
computed: {
|
|
165
|
+
msg() {
|
|
166
|
+
return this.errorMessage || this.errMsg;
|
|
167
|
+
},
|
|
168
|
+
fieldStyle() {
|
|
169
|
+
let style = {};
|
|
170
|
+
if (this.labelPos == 'top') {
|
|
171
|
+
style.padding = '0 0';
|
|
172
|
+
this.labelMarginBottom = '6px';
|
|
173
|
+
}
|
|
174
|
+
if (this.labelPos == 'left' && this.msg !== false && this.msg != '') {
|
|
175
|
+
style.paddingBottom = '0px';
|
|
176
|
+
this.errorBottom = true;
|
|
177
|
+
this.errorTop = false;
|
|
178
|
+
} else if (this.labelPos == 'top' && this.msg !== false && this.msg != '') {
|
|
179
|
+
this.errorBottom = false;
|
|
180
|
+
this.errorTop = true;
|
|
181
|
+
} else {
|
|
182
|
+
// style.paddingBottom = ''
|
|
183
|
+
this.errorTop = false;
|
|
184
|
+
this.errorBottom = false;
|
|
185
|
+
}
|
|
186
|
+
return style;
|
|
187
|
+
},
|
|
188
|
+
|
|
189
|
+
// uni不支持在computed中写style.justifyContent = 'center'的形式,故用此方法
|
|
190
|
+
justifyContent() {
|
|
191
|
+
if (this.labelAli === 'left') return 'flex-start';
|
|
192
|
+
if (this.labelAli === 'center') return 'center';
|
|
193
|
+
if (this.labelAli === 'right') return 'flex-end';
|
|
194
|
+
},
|
|
195
|
+
labelLeft(){
|
|
196
|
+
return (this.labelPos === 'left' ? parseInt(this.labelWid) : 0) + 'rpx'
|
|
197
|
+
}
|
|
198
|
+
},
|
|
199
|
+
watch: {
|
|
200
|
+
validateTrigger(trigger) {
|
|
201
|
+
this.formTrigger = trigger;
|
|
202
|
+
}
|
|
203
|
+
},
|
|
204
|
+
created() {
|
|
205
|
+
this.form = this.getForm();
|
|
206
|
+
this.group = this.getForm('uniGroup');
|
|
207
|
+
this.formRules = [];
|
|
208
|
+
this.formTrigger = this.validateTrigger;
|
|
209
|
+
// 处理 name,是否数组
|
|
210
|
+
if (this.name && this.name.indexOf('[') !== -1 && this.name.indexOf(']') !== -1) {
|
|
211
|
+
this.isArray = true;
|
|
212
|
+
this.arrayField = this.name
|
|
213
|
+
// fix by mehaotian 修改不修改的情况,动态值不检验的问题
|
|
214
|
+
this.form.formData[this.name] = this.form._getValue(this.name, '')
|
|
215
|
+
}
|
|
216
|
+
},
|
|
217
|
+
mounted() {
|
|
218
|
+
if (this.form) {
|
|
219
|
+
this.form.childrens.push(this);
|
|
220
|
+
}
|
|
221
|
+
this.init();
|
|
222
|
+
},
|
|
223
|
+
// #ifndef VUE3
|
|
224
|
+
destroyed() {
|
|
225
|
+
if(this.__isUnmounted) return
|
|
226
|
+
this.unInit()
|
|
227
|
+
},
|
|
228
|
+
// #endif
|
|
229
|
+
// #ifdef VUE3
|
|
230
|
+
unmounted(){
|
|
231
|
+
this.__isUnmounted = true
|
|
232
|
+
this.unInit()
|
|
233
|
+
},
|
|
234
|
+
// #endif
|
|
235
|
+
methods: {
|
|
236
|
+
init() {
|
|
237
|
+
if (this.form) {
|
|
238
|
+
let {
|
|
239
|
+
formRules,
|
|
240
|
+
validator,
|
|
241
|
+
formData, value, labelPosition, labelWidth,
|
|
242
|
+
labelAlign, errShowType, paddingBetween,
|
|
243
|
+
contentAlign
|
|
244
|
+
} = this.form;
|
|
245
|
+
this.labelPos = this.labelPosition ? this.labelPosition : labelPosition;
|
|
246
|
+
this.contentAlign = contentAlign;
|
|
247
|
+
|
|
248
|
+
if(this.label){
|
|
249
|
+
this.labelWid = (this.labelWidth ? this.labelWidth : (labelWidth||140))
|
|
250
|
+
}else{
|
|
251
|
+
this.labelWid =( this.labelWidth ? this.labelWidth : (labelWidth||'auto'))
|
|
252
|
+
}
|
|
253
|
+
if(this.labelWid && this.labelWid !=='auto') {
|
|
254
|
+
this.labelWid +='rpx'
|
|
255
|
+
}
|
|
256
|
+
this.labelAli = this.labelAlign ? this.labelAlign : labelAlign;
|
|
257
|
+
this.paddingBetween = paddingBetween;
|
|
258
|
+
|
|
259
|
+
//设置索引值
|
|
260
|
+
if(this.form.index === undefined) {
|
|
261
|
+
this.form.index = 1;
|
|
262
|
+
}else{
|
|
263
|
+
this.form.index++;
|
|
264
|
+
}
|
|
265
|
+
|
|
266
|
+
//判断最后一个
|
|
267
|
+
if(this.form.index === this.form.$children.length) {
|
|
268
|
+
this.isLastBorder = true;
|
|
269
|
+
}
|
|
270
|
+
|
|
271
|
+
|
|
272
|
+
// 判断第一个 item
|
|
273
|
+
if (!this.form.isFirstBorder) {
|
|
274
|
+
this.form.isFirstBorder = true;
|
|
275
|
+
this.isFirstBorder = true;
|
|
276
|
+
}
|
|
277
|
+
|
|
278
|
+
// 判断 group 里的第一个 item
|
|
279
|
+
if (this.group) {
|
|
280
|
+
if (!this.group.isFirstBorder) {
|
|
281
|
+
this.group.isFirstBorder = true;
|
|
282
|
+
this.isFirstBorder = true;
|
|
283
|
+
}
|
|
284
|
+
}
|
|
285
|
+
|
|
286
|
+
this.border = this.form.border;
|
|
287
|
+
this.showMsg = errShowType;
|
|
288
|
+
let name = this.isArray ? this.arrayField : this.name;
|
|
289
|
+
if(!name) return
|
|
290
|
+
if (formRules && this.rules.length > 0) {
|
|
291
|
+
if (!formRules[name]) {
|
|
292
|
+
formRules[name] = {
|
|
293
|
+
rules: this.rules
|
|
294
|
+
}
|
|
295
|
+
}
|
|
296
|
+
validator.updateSchema(formRules);
|
|
297
|
+
}
|
|
298
|
+
this.formRules = formRules[name] || {};
|
|
299
|
+
this.validator = validator;
|
|
300
|
+
} else {
|
|
301
|
+
this.labelPos = this.labelPosition || 'right';
|
|
302
|
+
this.labelWid = this.labelWidth || 130;
|
|
303
|
+
this.labelAli = this.labelAlign || 'right';
|
|
304
|
+
}
|
|
305
|
+
},
|
|
306
|
+
unInit(){
|
|
307
|
+
if (this.form) {
|
|
308
|
+
this.form.childrens.forEach((item, index) => {
|
|
309
|
+
if (item === this) {
|
|
310
|
+
this.form.childrens.splice(index, 1)
|
|
311
|
+
delete this.form.formData[item.name]
|
|
312
|
+
}
|
|
313
|
+
})
|
|
314
|
+
}
|
|
315
|
+
},
|
|
316
|
+
/**
|
|
317
|
+
* 获取父元素实例
|
|
318
|
+
*/
|
|
319
|
+
getForm(name = 'XdForm') {
|
|
320
|
+
let parent = this.$parent;
|
|
321
|
+
let parentName = parent.$options.name;
|
|
322
|
+
while (parentName !== name) {
|
|
323
|
+
parent = parent.$parent;
|
|
324
|
+
if (!parent) return false;
|
|
325
|
+
parentName = parent.$options.name;
|
|
326
|
+
}
|
|
327
|
+
return parent;
|
|
328
|
+
},
|
|
329
|
+
|
|
330
|
+
/**
|
|
331
|
+
* 移除该表单项的校验结果
|
|
332
|
+
*/
|
|
333
|
+
clearValidate() {
|
|
334
|
+
this.errMsg = '';
|
|
335
|
+
},
|
|
336
|
+
/**
|
|
337
|
+
* 子组件调用,如 easyinput
|
|
338
|
+
* @param {Object} value
|
|
339
|
+
*/
|
|
340
|
+
setValue(value) {
|
|
341
|
+
let name = this.isArray ? this.arrayField : this.name;
|
|
342
|
+
if (name) {
|
|
343
|
+
if (this.errMsg) this.errMsg = '';
|
|
344
|
+
// 给组件赋值
|
|
345
|
+
this.form.formData[name] = this.form._getValue(name, value);
|
|
346
|
+
if (!this.formRules || (typeof this.formRules && JSON.stringify(this.formRules) === '{}')) return;
|
|
347
|
+
this.triggerCheck(this.form._getValue(this.name, value));
|
|
348
|
+
}
|
|
349
|
+
},
|
|
350
|
+
|
|
351
|
+
/**
|
|
352
|
+
* 校验规则
|
|
353
|
+
* @param {Object} value
|
|
354
|
+
* @param {Boolean} formTrigger
|
|
355
|
+
*/
|
|
356
|
+
async triggerCheck(value,formTrigger) {
|
|
357
|
+
let promise = null;
|
|
358
|
+
this.errMsg = '';
|
|
359
|
+
// fix by mehaotian 解决没有检验规则的情况下,抛出错误的问题
|
|
360
|
+
if (!this.validator || Object.keys(this.formRules).length === 0) return;
|
|
361
|
+
const isNoField = this.isRequired(this.formRules.rules || []);
|
|
362
|
+
let isTrigger = this.isTrigger(this.formRules.validateTrigger, this.validateTrigger, this.form.validateTrigger);
|
|
363
|
+
let result = null;
|
|
364
|
+
if (!!isTrigger || formTrigger) {
|
|
365
|
+
let name = this.isArray ? this.arrayField : this.name;
|
|
366
|
+
result = await this.validator.validateUpdate(
|
|
367
|
+
{
|
|
368
|
+
[name]: value
|
|
369
|
+
},
|
|
370
|
+
this.form.formData
|
|
371
|
+
);
|
|
372
|
+
}
|
|
373
|
+
|
|
374
|
+
|
|
375
|
+
// 判断是否必填,非必填,不填不校验,填写才校验
|
|
376
|
+
if (!isNoField && (value === undefined || value === '')) {
|
|
377
|
+
result = null;
|
|
378
|
+
}
|
|
379
|
+
const inputComp = this.form.inputChildrens.find(child => child.rename === this.name);
|
|
380
|
+
|
|
381
|
+
if ((isTrigger || formTrigger) && result && result.errorMessage) {
|
|
382
|
+
if (inputComp) {
|
|
383
|
+
inputComp.errMsg = result.errorMessage;
|
|
384
|
+
}
|
|
385
|
+
console
|
|
386
|
+
if (this.form.errShowType === 'toast' || 1) {
|
|
387
|
+
this.$xdAlert({
|
|
388
|
+
content : result.errorMessage || '校验错误',
|
|
389
|
+
icon: 'icondanchuangguanbi_xian',
|
|
390
|
+
|
|
391
|
+
})
|
|
392
|
+
}
|
|
393
|
+
if (this.form.errShowType === 'modal' && 0) {
|
|
394
|
+
uni.showModal({
|
|
395
|
+
title: '提示',
|
|
396
|
+
content: result.errorMessage || '校验错误'
|
|
397
|
+
});
|
|
398
|
+
}
|
|
399
|
+
} else {
|
|
400
|
+
if (inputComp) {
|
|
401
|
+
inputComp.errMsg = '';
|
|
402
|
+
}
|
|
403
|
+
}
|
|
404
|
+
|
|
405
|
+
this.errMsg = !result ? '' : result.errorMessage;
|
|
406
|
+
// 触发validate事件
|
|
407
|
+
this.form.validateCheck(result ? result : null);
|
|
408
|
+
// typeof callback === 'function' && callback(result ? result : null);
|
|
409
|
+
// if (promise) return promise
|
|
410
|
+
return result ? result : null;
|
|
411
|
+
},
|
|
412
|
+
/**
|
|
413
|
+
* 触发时机
|
|
414
|
+
* @param {Object} event
|
|
415
|
+
*/
|
|
416
|
+
isTrigger(rule, itemRlue, parentRule) {
|
|
417
|
+
let rl = true;
|
|
418
|
+
// bind submit
|
|
419
|
+
if (rule === 'submit' || !rule) {
|
|
420
|
+
if (rule === undefined) {
|
|
421
|
+
if (itemRlue !== 'bind') {
|
|
422
|
+
if (!itemRlue) {
|
|
423
|
+
return parentRule === 'bind' ? true : false;
|
|
424
|
+
}
|
|
425
|
+
return false;
|
|
426
|
+
}
|
|
427
|
+
return true;
|
|
428
|
+
}
|
|
429
|
+
return false;
|
|
430
|
+
}
|
|
431
|
+
return true;
|
|
432
|
+
},
|
|
433
|
+
// 是否有必填字段
|
|
434
|
+
isRequired(rules) {
|
|
435
|
+
let isNoField = false;
|
|
436
|
+
for (let i = 0; i < rules.length; i++) {
|
|
437
|
+
const ruleData = rules[i];
|
|
438
|
+
if (ruleData.required) {
|
|
439
|
+
isNoField = true;
|
|
440
|
+
break;
|
|
441
|
+
}
|
|
442
|
+
}
|
|
443
|
+
return isNoField;
|
|
444
|
+
}
|
|
445
|
+
}
|
|
446
|
+
};
|
|
447
|
+
</script>
|
|
448
|
+
|
|
449
|
+
<style lang="less">
|
|
450
|
+
.uni-forms-item {
|
|
451
|
+
position: relative;
|
|
452
|
+
padding: 0;
|
|
453
|
+
text-align: left;
|
|
454
|
+
color: #000;
|
|
455
|
+
font-size: unit(30,rpx);
|
|
456
|
+
}
|
|
457
|
+
|
|
458
|
+
.uni-forms-item__box {
|
|
459
|
+
position: relative;
|
|
460
|
+
}
|
|
461
|
+
|
|
462
|
+
.uni-forms-item__inner {
|
|
463
|
+
/* #ifndef APP-NVUE */
|
|
464
|
+
display: flex;
|
|
465
|
+
/* #endif */
|
|
466
|
+
// flex-direction: row;
|
|
467
|
+
// align-items: center;
|
|
468
|
+
padding-bottom: unit(44, rpx);
|
|
469
|
+
// margin-bottom: 22px;
|
|
470
|
+
}
|
|
471
|
+
|
|
472
|
+
.is-direction-left {
|
|
473
|
+
flex-direction: row;
|
|
474
|
+
}
|
|
475
|
+
|
|
476
|
+
.is-direction-top {
|
|
477
|
+
flex-direction: column;
|
|
478
|
+
}
|
|
479
|
+
|
|
480
|
+
.uni-forms-item__label {
|
|
481
|
+
/* #ifndef APP-NVUE */
|
|
482
|
+
display: flex;
|
|
483
|
+
flex-shrink: 0;
|
|
484
|
+
box-sizing: border-box;
|
|
485
|
+
/* #endif */
|
|
486
|
+
flex-direction: row;
|
|
487
|
+
align-items: center;
|
|
488
|
+
width: unit(130, rpx);
|
|
489
|
+
padding: unit(10, rpx) 0;
|
|
490
|
+
height: unit(72, rpx);
|
|
491
|
+
line-height: unit(72, rpx);
|
|
492
|
+
|
|
493
|
+
.label-text {
|
|
494
|
+
font-size: unit(30, rpx);
|
|
495
|
+
color: #333;
|
|
496
|
+
}
|
|
497
|
+
.label-seat {
|
|
498
|
+
margin-right: unit(18, rpx);
|
|
499
|
+
}
|
|
500
|
+
}
|
|
501
|
+
|
|
502
|
+
.uni-forms-item__content {
|
|
503
|
+
/* #ifndef APP-NVUE */
|
|
504
|
+
width: 100%;
|
|
505
|
+
box-sizing: border-box;
|
|
506
|
+
min-height: unit(72, rpx);
|
|
507
|
+
/* #endif */
|
|
508
|
+
flex: 1;
|
|
509
|
+
}
|
|
510
|
+
|
|
511
|
+
.label-icon {
|
|
512
|
+
margin-right: unit(10, rpx);
|
|
513
|
+
margin-top: unit(-2, rpx);
|
|
514
|
+
}
|
|
515
|
+
|
|
516
|
+
// 必填
|
|
517
|
+
.is-required {
|
|
518
|
+
// color: $uni-color-error;
|
|
519
|
+
color: #dd524d;
|
|
520
|
+
font-weight: bold;
|
|
521
|
+
padding-right: unit(10, rpx);
|
|
522
|
+
width: unit(20, rpx);
|
|
523
|
+
}
|
|
524
|
+
|
|
525
|
+
.uni-error-message {
|
|
526
|
+
position: absolute;
|
|
527
|
+
bottom: 0;
|
|
528
|
+
left: 0;
|
|
529
|
+
text-align: left;
|
|
530
|
+
}
|
|
531
|
+
|
|
532
|
+
.uni-error-message-text {
|
|
533
|
+
line-height: unit(44, rpx);
|
|
534
|
+
color: #dd524d;
|
|
535
|
+
font-size: unit(28, rpx);
|
|
536
|
+
}
|
|
537
|
+
|
|
538
|
+
.uni-error-msg--boeder {
|
|
539
|
+
position: relative;
|
|
540
|
+
bottom: 0;
|
|
541
|
+
line-height: unit(44, rpx)
|
|
542
|
+
}
|
|
543
|
+
|
|
544
|
+
.is-input-error-border {
|
|
545
|
+
border-color: #dd524d;
|
|
546
|
+
}
|
|
547
|
+
|
|
548
|
+
.uni-forms-item--border {
|
|
549
|
+
margin-bottom: 0;
|
|
550
|
+
padding: unit(20, rpx) 0;
|
|
551
|
+
border-top: 1px #F9F9F9 solid;
|
|
552
|
+
border-bottom: 1px #F9F9F9 solid;
|
|
553
|
+
.uni-forms-item__inner {
|
|
554
|
+
padding: 0;
|
|
555
|
+
}
|
|
556
|
+
}
|
|
557
|
+
|
|
558
|
+
.uni-forms-item-error {
|
|
559
|
+
// padding-bottom: 0;
|
|
560
|
+
}
|
|
561
|
+
|
|
562
|
+
.is-first-border {
|
|
563
|
+
/* #ifndef APP-NVUE */
|
|
564
|
+
border-top: none;
|
|
565
|
+
/* #endif */
|
|
566
|
+
/* #ifdef APP-NVUE */
|
|
567
|
+
border-top-width: 0;
|
|
568
|
+
/* #endif */
|
|
569
|
+
}
|
|
570
|
+
|
|
571
|
+
.is-last-border {
|
|
572
|
+
/* #ifndef APP-NVUE */
|
|
573
|
+
border-bottom: none;
|
|
574
|
+
/* #endif */
|
|
575
|
+
/* #ifdef APP-NVUE */
|
|
576
|
+
border-bottom-width: 0;
|
|
577
|
+
/* #endif */
|
|
578
|
+
}
|
|
579
|
+
|
|
580
|
+
.uni-forms--no-padding {
|
|
581
|
+
padding: 0;
|
|
582
|
+
}
|
|
583
|
+
</style>
|