提交 ea727a20 编写于 作者: fxy060608's avatar fxy060608

chore: build

上级 5a2c58ed
...@@ -11528,7 +11528,52 @@ var serviceContext = (function (vue) { ...@@ -11528,7 +11528,52 @@ var serviceContext = (function (vue) {
phoneNumber: String, phoneNumber: String,
}; };
const API_ADD_PHONE_CONTACT = 'addPhoneContact'; const API_ADD_PHONE_CONTACT = 'addPhoneContact';
const AddPhoneContactOptions = {
formatArgs: {
firstName(firstName) {
if (!firstName)
return 'addPhoneContact:fail parameter error: parameter.firstName should not be empty;';
},
},
};
const AddPhoneContactProtocol = {
firstName: {
type: String,
required: true,
},
photoFilePath: String,
nickName: String,
lastName: String,
middleName: String,
remark: String,
mobilePhoneNumber: String,
weChatNumber: String,
addressCountry: String,
addressState: String,
addressCity: String,
addressStreet: String,
addressPostalCode: String,
organization: String,
title: String,
workFaxNumber: String,
workPhoneNumber: String,
hostNumber: String,
email: String,
url: String,
workAddressCountry: String,
workAddressState: String,
workAddressCity: String,
workAddressStreet: String,
workAddressPostalCode: String,
homeFaxNumber: String,
homePhoneNumber: String,
homeAddressCountry: String,
homeAddressState: String,
homeAddressCity: String,
homeAddressStreet: String,
homeAddressPostalCode: String,
};
const API_GET_CLIPBOARD_DATA = 'getClipboardData'; const API_GET_CLIPBOARD_DATA = 'getClipboardData';
const API_SET_CLIPBOARD_DATA = 'setClipboardData'; const API_SET_CLIPBOARD_DATA = 'setClipboardData';
...@@ -13686,166 +13731,150 @@ var serviceContext = (function (vue) { ...@@ -13686,166 +13731,150 @@ var serviceContext = (function (vue) {
return resolve(); return resolve();
}, MakePhoneCallProtocol); }, MakePhoneCallProtocol);
const addPhoneContact = defineAsyncApi(API_ADD_PHONE_CONTACT, ({ photoFilePath = '', nickName, lastName, middleName, firstName, remark, mobilePhoneNumber, weChatNumber, addressCountry, addressState, addressCity, addressStreet, addressPostalCode, organization, title, workFaxNumber, workPhoneNumber, hostNumber, email, url, workAddressCountry, workAddressState, workAddressCity, workAddressStreet, workAddressPostalCode, homeFaxNumber, homePhoneNumber, homeAddressCountry, homeAddressState, homeAddressCity, homeAddressStreet, homeAddressPostalCode, }, { resolve, reject }) => { const schema = {
plus.contacts.getAddressBook(plus.contacts.ADDRESSBOOK_PHONE, (addressbook) => { name: {
const contact = addressbook.create(); givenName: 'firstName',
const name = {}; middleName: 'middleName',
if (lastName) { familyName: 'lastName',
name.familyName = lastName; },
} nickname: 'nickName',
if (firstName) { photos: {
name.givenName = firstName; type: 'url',
} value: 'photoFilePath',
if (middleName) { },
name.middleName = middleName; note: 'remark',
} phoneNumbers: [
contact.name = name; {
if (nickName) {
contact.nickname = nickName;
}
if (photoFilePath) {
contact.photos = [
{
type: 'url',
value: photoFilePath,
},
];
}
if (remark) {
contact.note = remark;
}
const mobilePhone = {
type: 'mobile', type: 'mobile',
}; value: 'mobilePhoneNumber',
const workPhone = { },
{
type: 'work', type: 'work',
}; value: 'workPhoneNumber',
const companyPhone = { },
{
type: 'company', type: 'company',
}; value: 'hostNumber',
const homeFax = { },
{
type: 'home fax', type: 'home fax',
}; value: 'homeFaxNumber',
const workFax = { },
{
type: 'work fax', type: 'work fax',
}; value: 'workFaxNumber',
if (mobilePhoneNumber) { },
mobilePhone.value = mobilePhoneNumber; ],
} emails: [
if (workPhoneNumber) { {
workPhone.value = workPhoneNumber; type: 'home',
} value: 'email',
if (hostNumber) { },
companyPhone.value = hostNumber; ],
} urls: [
if (homeFaxNumber) { {
homeFax.value = homeFaxNumber; type: 'other',
} value: 'url',
if (workFaxNumber) { },
workFax.value = workFaxNumber; ],
} organizations: [
contact.phoneNumbers = [ {
mobilePhone, type: 'company',
workPhone, name: 'organization',
companyPhone, title: 'title',
homeFax, },
workFax, ],
]; ims: [
if (email) { {
contact.emails = [ type: 'other',
{ value: 'weChatNumber',
type: 'home', },
value: email, ],
}, addresses: [
]; {
}
if (url) {
contact.urls = [
{
type: 'other',
value: url,
},
];
}
if (weChatNumber) {
contact.ims = [
{
type: 'other',
value: weChatNumber,
},
];
}
const defaultAddress = {
type: 'other', type: 'other',
preferred: true, preferred: true,
}; country: 'addressCountry',
const homeAddress = { region: 'addressState',
locality: 'addressCity',
streetAddress: 'addressStreet',
postalCode: 'addressPostalCode',
},
{
type: 'home', type: 'home',
}; country: 'homeAddressCountry',
const companyAddress = { region: 'homeAddressState',
locality: 'homeAddressCity',
streetAddress: 'homeAddressStreet',
postalCode: 'homeAddressPostalCode',
},
{
type: 'company', type: 'company',
}; country: 'workAddressCountry',
if (addressCountry) { region: 'workAddressState',
defaultAddress.country = addressCountry; locality: 'workAddressCity',
} streetAddress: 'workAddressStreet',
if (addressState) { postalCode: 'workAddressPostalCode',
defaultAddress.region = addressState; },
} ],
if (addressCity) { };
defaultAddress.locality = addressCity; const keepFields = ['type', 'preferred'];
} function buildContact(contact, data, schema) {
if (addressStreet) { let hasValue = 0;
defaultAddress.streetAddress = addressStreet; Object.keys(schema).forEach((contactKey) => {
} const dataKey = schema[contactKey];
if (addressPostalCode) { const typed = typeof dataKey;
defaultAddress.postalCode = addressPostalCode; if (typed !== 'object') {
} if (keepFields.indexOf(contactKey) !== -1) {
if (homeAddressCountry) { contact[contactKey] = schema[contactKey];
homeAddress.country = homeAddressCountry; }
} else {
if (homeAddressState) { if (typeof data[dataKey] !== 'undefined') {
homeAddress.region = homeAddressState; hasValue++;
} contact[contactKey] = data[dataKey];
if (homeAddressCity) { }
homeAddress.locality = homeAddressCity; else {
} delete contact[contactKey];
if (homeAddressStreet) { }
homeAddress.streetAddress = homeAddressStreet; }
}
if (homeAddressPostalCode) {
homeAddress.postalCode = homeAddressPostalCode;
}
if (workAddressCountry) {
companyAddress.country = workAddressCountry;
}
if (workAddressState) {
companyAddress.region = workAddressState;
}
if (workAddressCity) {
companyAddress.locality = workAddressCity;
}
if (workAddressStreet) {
companyAddress.streetAddress = workAddressStreet;
} }
if (workAddressPostalCode) { else {
companyAddress.postalCode = workAddressPostalCode; if (dataKey instanceof Array) {
contact[contactKey] = [];
dataKey.forEach((item) => {
const obj = {};
if (buildContact(obj, data, item)) {
contact[contactKey].push(obj);
}
});
if (!contact[contactKey].length) {
delete contact[contactKey];
}
else {
hasValue++;
}
}
else {
contact[contactKey] = {};
if (buildContact(contact[contactKey], data, dataKey)) {
hasValue++;
}
else {
delete contact[contactKey];
}
}
} }
contact.addresses = [
defaultAddress,
homeAddress,
companyAddress,
];
contact.save(() => {
resolve({
errMsg: 'addPhoneContact:ok',
});
}, (e) => {
reject('addPhoneContact:fail');
});
}, (e) => {
reject('addPhoneContact:fail');
}); });
}, MakePhoneCallProtocol); return hasValue;
}
const addPhoneContact = defineAsyncApi(API_ADD_PHONE_CONTACT, (data, { resolve, reject }) => {
!data.photoFilePath && (data.photoFilePath = '');
plus.contacts.getAddressBook(plus.contacts.ADDRESSBOOK_PHONE, (addressbook) => {
const contact = addressbook.create();
buildContact(contact, data, schema);
contact.save(() => resolve(), (e) => reject());
}, (e) => reject());
}, AddPhoneContactProtocol, AddPhoneContactOptions);
function requireNativePlugin(pluginName) { function requireNativePlugin(pluginName) {
if (typeof weex !== 'undefined') { if (typeof weex !== 'undefined') {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册