first
This commit is contained in:
1
node_modules/vant/es/contact-edit/index.css
generated
vendored
Normal file
1
node_modules/vant/es/contact-edit/index.css
generated
vendored
Normal file
@ -0,0 +1 @@
|
||||
.van-contact-edit{padding:16px}.van-contact-edit__fields{overflow:hidden;border-radius:4px}.van-contact-edit__fields .van-field__label{width:4.1em}.van-contact-edit__switch-cell{margin-top:10px;padding-top:9px;padding-bottom:9px;border-radius:4px}.van-contact-edit__buttons{padding:32px 0}.van-contact-edit .van-button{margin-bottom:12px;font-size:16px}
|
193
node_modules/vant/es/contact-edit/index.js
generated
vendored
Normal file
193
node_modules/vant/es/contact-edit/index.js
generated
vendored
Normal file
@ -0,0 +1,193 @@
|
||||
import _extends from "@babel/runtime/helpers/esm/extends";
|
||||
// Utils
|
||||
import { createNamespace } from '../utils';
|
||||
import { isMobile } from '../utils/validate/mobile'; // Components
|
||||
|
||||
import Cell from '../cell';
|
||||
import Field from '../field';
|
||||
import Button from '../button';
|
||||
import Dialog from '../dialog';
|
||||
import Switch from '../switch';
|
||||
|
||||
var _createNamespace = createNamespace('contact-edit'),
|
||||
createComponent = _createNamespace[0],
|
||||
bem = _createNamespace[1],
|
||||
t = _createNamespace[2];
|
||||
|
||||
var defaultContact = {
|
||||
tel: '',
|
||||
name: ''
|
||||
};
|
||||
export default createComponent({
|
||||
props: {
|
||||
isEdit: Boolean,
|
||||
isSaving: Boolean,
|
||||
isDeleting: Boolean,
|
||||
showSetDefault: Boolean,
|
||||
setDefaultLabel: String,
|
||||
contactInfo: {
|
||||
type: Object,
|
||||
default: function _default() {
|
||||
return _extends({}, defaultContact);
|
||||
}
|
||||
},
|
||||
telValidator: {
|
||||
type: Function,
|
||||
default: isMobile
|
||||
}
|
||||
},
|
||||
data: function data() {
|
||||
return {
|
||||
data: _extends({}, defaultContact, this.contactInfo),
|
||||
errorInfo: {
|
||||
name: '',
|
||||
tel: ''
|
||||
}
|
||||
};
|
||||
},
|
||||
watch: {
|
||||
contactInfo: function contactInfo(val) {
|
||||
this.data = _extends({}, defaultContact, val);
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
onFocus: function onFocus(key) {
|
||||
this.errorInfo[key] = '';
|
||||
},
|
||||
getErrorMessageByKey: function getErrorMessageByKey(key) {
|
||||
var value = this.data[key].trim();
|
||||
|
||||
switch (key) {
|
||||
case 'name':
|
||||
return value ? '' : t('nameInvalid');
|
||||
|
||||
case 'tel':
|
||||
return this.telValidator(value) ? '' : t('telInvalid');
|
||||
}
|
||||
},
|
||||
onSave: function onSave() {
|
||||
var _this = this;
|
||||
|
||||
var isValid = ['name', 'tel'].every(function (item) {
|
||||
var msg = _this.getErrorMessageByKey(item);
|
||||
|
||||
if (msg) {
|
||||
_this.errorInfo[item] = msg;
|
||||
}
|
||||
|
||||
return !msg;
|
||||
});
|
||||
|
||||
if (isValid && !this.isSaving) {
|
||||
this.$emit('save', this.data);
|
||||
}
|
||||
},
|
||||
onDelete: function onDelete() {
|
||||
var _this2 = this;
|
||||
|
||||
Dialog.confirm({
|
||||
title: t('confirmDelete')
|
||||
}).then(function () {
|
||||
_this2.$emit('delete', _this2.data);
|
||||
});
|
||||
}
|
||||
},
|
||||
render: function render() {
|
||||
var _this3 = this;
|
||||
|
||||
var h = arguments[0];
|
||||
var data = this.data,
|
||||
errorInfo = this.errorInfo;
|
||||
|
||||
var onFocus = function onFocus(name) {
|
||||
return function () {
|
||||
return _this3.onFocus(name);
|
||||
};
|
||||
};
|
||||
|
||||
return h("div", {
|
||||
"class": bem()
|
||||
}, [h("div", {
|
||||
"class": bem('fields')
|
||||
}, [h(Field, {
|
||||
"attrs": {
|
||||
"clearable": true,
|
||||
"maxlength": "30",
|
||||
"label": t('name'),
|
||||
"placeholder": t('nameEmpty'),
|
||||
"errorMessage": errorInfo.name
|
||||
},
|
||||
"on": {
|
||||
"focus": onFocus('name')
|
||||
},
|
||||
"model": {
|
||||
value: data.name,
|
||||
callback: function callback($$v) {
|
||||
_this3.$set(data, "name", $$v);
|
||||
}
|
||||
}
|
||||
}), h(Field, {
|
||||
"attrs": {
|
||||
"clearable": true,
|
||||
"type": "tel",
|
||||
"label": t('tel'),
|
||||
"placeholder": t('telEmpty'),
|
||||
"errorMessage": errorInfo.tel
|
||||
},
|
||||
"on": {
|
||||
"focus": onFocus('tel')
|
||||
},
|
||||
"model": {
|
||||
value: data.tel,
|
||||
callback: function callback($$v) {
|
||||
_this3.$set(data, "tel", $$v);
|
||||
}
|
||||
}
|
||||
})]), this.showSetDefault && h(Cell, {
|
||||
"attrs": {
|
||||
"title": this.setDefaultLabel,
|
||||
"border": false
|
||||
},
|
||||
"class": bem('switch-cell')
|
||||
}, [h(Switch, {
|
||||
"attrs": {
|
||||
"size": 24
|
||||
},
|
||||
"slot": "right-icon",
|
||||
"on": {
|
||||
"change": function change(event) {
|
||||
_this3.$emit('change-default', event);
|
||||
}
|
||||
},
|
||||
"model": {
|
||||
value: data.isDefault,
|
||||
callback: function callback($$v) {
|
||||
_this3.$set(data, "isDefault", $$v);
|
||||
}
|
||||
}
|
||||
})]), h("div", {
|
||||
"class": bem('buttons')
|
||||
}, [h(Button, {
|
||||
"attrs": {
|
||||
"block": true,
|
||||
"round": true,
|
||||
"type": "danger",
|
||||
"text": t('save'),
|
||||
"loading": this.isSaving
|
||||
},
|
||||
"on": {
|
||||
"click": this.onSave
|
||||
}
|
||||
}), this.isEdit && h(Button, {
|
||||
"attrs": {
|
||||
"block": true,
|
||||
"round": true,
|
||||
"text": t('delete'),
|
||||
"loading": this.isDeleting
|
||||
},
|
||||
"on": {
|
||||
"click": this.onDelete
|
||||
}
|
||||
})])]);
|
||||
}
|
||||
});
|
30
node_modules/vant/es/contact-edit/index.less
generated
vendored
Normal file
30
node_modules/vant/es/contact-edit/index.less
generated
vendored
Normal file
@ -0,0 +1,30 @@
|
||||
@import '../style/var';
|
||||
|
||||
.van-contact-edit {
|
||||
padding: @contact-edit-padding;
|
||||
|
||||
&__fields {
|
||||
overflow: hidden;
|
||||
border-radius: @contact-edit-fields-radius;
|
||||
|
||||
.van-field__label {
|
||||
width: @contact-edit-field-label-width;
|
||||
}
|
||||
}
|
||||
|
||||
&__switch-cell {
|
||||
margin-top: 10px;
|
||||
padding-top: 9px;
|
||||
padding-bottom: 9px;
|
||||
border-radius: @contact-edit-fields-radius;
|
||||
}
|
||||
|
||||
&__buttons {
|
||||
padding: @contact-edit-buttons-padding;
|
||||
}
|
||||
|
||||
.van-button {
|
||||
margin-bottom: @contact-edit-button-margin-bottom;
|
||||
font-size: @contact-edit-button-font-size;
|
||||
}
|
||||
}
|
14
node_modules/vant/es/contact-edit/style/index.js
generated
vendored
Normal file
14
node_modules/vant/es/contact-edit/style/index.js
generated
vendored
Normal file
@ -0,0 +1,14 @@
|
||||
import '../../style/base.css';
|
||||
import '../../overlay/index.css';
|
||||
import '../../info/index.css';
|
||||
import '../../icon/index.css';
|
||||
import '../../cell/index.css';
|
||||
import '../../field/index.css';
|
||||
import '../../popup/index.css';
|
||||
import '../../loading/index.css';
|
||||
import '../../switch/index.css';
|
||||
import '../../button/index.css';
|
||||
import '../../goods-action-button/index.css';
|
||||
import '../../goods-action/index.css';
|
||||
import '../../dialog/index.css';
|
||||
import '../index.css';
|
14
node_modules/vant/es/contact-edit/style/less.js
generated
vendored
Normal file
14
node_modules/vant/es/contact-edit/style/less.js
generated
vendored
Normal file
@ -0,0 +1,14 @@
|
||||
import '../../style/base.less';
|
||||
import '../../overlay/index.less';
|
||||
import '../../info/index.less';
|
||||
import '../../icon/index.less';
|
||||
import '../../cell/index.less';
|
||||
import '../../field/index.less';
|
||||
import '../../popup/index.less';
|
||||
import '../../loading/index.less';
|
||||
import '../../switch/index.less';
|
||||
import '../../button/index.less';
|
||||
import '../../goods-action-button/index.less';
|
||||
import '../../goods-action/index.less';
|
||||
import '../../dialog/index.less';
|
||||
import '../index.less';
|
Reference in New Issue
Block a user