UNPKG

966 BJavaScriptView Raw
1import { shouldBeObject, getParameterError } from '../../utils/index.js';
2import { MethodHandler } from '../../utils/handler.js';
3
4const makePhoneCall = (options) => {
5 // options must be an Object
6 const isObject = shouldBeObject(options);
7 if (!isObject.flag) {
8 const res = { errMsg: `makePhoneCall:fail ${isObject.msg}` };
9 console.error(res.errMsg);
10 return Promise.reject(res);
11 }
12 const { phoneNumber, success, fail, complete } = options;
13 const handle = new MethodHandler({ name: 'makePhoneCall', success, fail, complete });
14 if (typeof phoneNumber !== 'string') {
15 return handle.fail({
16 errMsg: getParameterError({
17 para: 'phoneNumber',
18 correct: 'String',
19 wrong: phoneNumber
20 })
21 });
22 }
23 window.location.href = `tel:${phoneNumber}`;
24 return handle.success();
25};
26
27export { makePhoneCall };
28//# sourceMappingURL=phone.js.map