1 | import { shouldBeObject, getParameterError } from '../../utils/index.js';
|
2 | import { MethodHandler } from '../../utils/handler.js';
|
3 |
|
4 | const makePhoneCall = (options) => {
|
5 |
|
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 |
|
27 | export { makePhoneCall };
|
28 |
|