| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081 |
- /**
- * Created by PanJiaChen on 16/11/18.
- */
- /**
- * @param {string} path
- * @returns {Boolean}
- */
- export function isExternal(path) {
- return /^(https?:|mailto:|tel:)/.test(path)
- }
- /**
- * @param {string} str
- * @returns {Boolean}
- */
- export function validUsername(str) {
- const valid_map = ['admin', 'editor']
- return valid_map.indexOf(str.trim()) >= 0
- }
- /**
- * @param {string} str
- * @returns {Boolean}
- */
- export function isString(str) {
- if (typeof str === 'string' || str instanceof String) {
- return true
- }
- return false
- }
- /**
- * @param {Array} arg
- * @returns {Boolean}
- */
- export function isArray(arg) {
- if (typeof Array.isArray === 'undefined') {
- return Object.prototype.toString.call(arg) === '[object Array]'
- }
- return Array.isArray(arg)
- }
- export function formatNumber(number) {
- number += '';
- let x = number.split('.');
- let x1 = x[0];
- let x2 = x.length > 1 ? '.' + x[1] : '';
- var rgx = /(\d+)(\d{3})/;
- while (rgx.test(x1)) {
- x1 = x1.replace(rgx, '$1' + ',' + '$2');
- }
- return x1 + x2;
- }
- export function viewUrl(url) {
- // #ifdef APP-PLUS
- plus.share.sendWithSystem({
- //type: 'text',
- href: url,
- //content: 'https://www.trecs.ai'
- }, success => {
-
- }, error => {
-
- })
- // #endif
- // #ifdef H5
- window.open(url)
- // #endif
- }
- export function openUrl(url) {
- // #ifdef APP-PLUS
- plus.runtime.openURL(url)
- // #endif
- // #ifdef H5
- //window.open(url)
- location.href = url;
- // #endif
- }
|