123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566 |
- "use strict";
- var common_vendor = require("../common/vendor.js");
- const urlEncode = (obj = {}) => {
- const result = [];
- for (const key in obj) {
- const item = obj[key];
- if (!item) {
- continue;
- }
- if (isArray(item)) {
- item.forEach((val) => {
- result.push(key + "=" + val);
- });
- } else {
- result.push(key + "=" + item);
- }
- }
- return result.join("&");
- };
- const inArray = (search, array) => {
- for (var i in array) {
- if (array[i] == search)
- return true;
- }
- return false;
- };
- const isEmptyObject = (object) => {
- return Object.keys(object).length === 0;
- };
- const isObject = (object) => {
- return Object.prototype.toString.call(object) === "[object Object]";
- };
- const isArray = (array) => {
- return Object.prototype.toString.call(array) === "[object Array]";
- };
- const isEmpty = (value) => {
- if (isArray(value)) {
- return value.length === 0;
- }
- if (isObject(value)) {
- return isEmptyObject(value);
- }
- return !value;
- };
- function isLogin() {
- let obj = common_vendor.index.getStorageSync("AppToken");
- return !!obj;
- }
- function navTo(url) {
- common_vendor.index.navigateTo({
- url
- });
- }
- function getRegistrationID(type) {
- }
- function parsePhone(mobile) {
- var str = mobile.substr(0, 3) + "****" + mobile.substr(7);
- return str;
- }
- exports.getRegistrationID = getRegistrationID;
- exports.inArray = inArray;
- exports.isEmpty = isEmpty;
- exports.isLogin = isLogin;
- exports.navTo = navTo;
- exports.parsePhone = parsePhone;
- exports.urlEncode = urlEncode;
|