12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667 |
- import router from '@/sheep/router';
- export default {
-
- callPhone(phoneNumber = '') {
- let num = phoneNumber.toString();
- uni.makePhoneCall({
- phoneNumber: num,
- fail(err) {
- console.log('makePhoneCall出错', err);
- },
- });
- },
-
- checkMPUrl(url) {
-
- if (
- url.substring(0, 4) === 'http' &&
- url.substring(0, 5) !== 'https' &&
- url.substring(0, 12) !== 'http://store' &&
- url.substring(0, 10) !== 'http://tmp' &&
- url.substring(0, 10) !== 'http://usr'
- ) {
- url = 'https' + url.substring(4, url.length);
- }
-
- return url;
- },
-
- getUuid(len = 32, firstU = true, radix = null) {
- const chars = '0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz'.split('');
- const uuid = [];
- radix = radix || chars.length;
- if (len) {
-
- for (let i = 0; i < len; i++) uuid[i] = chars[0 | (Math.random() * radix)];
- } else {
- let r;
-
- uuid[8] = uuid[13] = uuid[18] = uuid[23] = '-';
- uuid[14] = '4';
- for (let i = 0; i < 36; i++) {
- if (!uuid[i]) {
- r = 0 | (Math.random() * 16);
- uuid[i] = chars[i == 19 ? (r & 0x3) | 0x8 : r];
- }
- }
- }
-
- if (firstU) {
- uuid.shift();
- return `u${uuid.join('')}`;
- }
- return uuid.join('');
- },
- };
|