UNPKG

yyp-utils

Version:

xhb-utils

56 lines (49 loc) 1.54 kB
'use strict'; Object.defineProperty(exports, '__esModule', { value: true }); /* * @Description: * @Author: yangyongpei * @Date: 2023-06-08 * @LastEditTime: 2023-08-28 * @LastEditors: yangyongpei * @FilePath: \spark-fe-pluginshub\xhb-utils\src\index.js */ const getXhbAdUserInfo = () => { if (typeof document === 'undefined') { return '' } let info = sessionStorage.getItem('xhb_ad_user_info'); info = info ? JSON.parse(info) : {}; return info }; const removeXhbAdUserInfo = () => { if (typeof document === 'undefined') { return '' } sessionStorage.removeItem('xhb_ad_user_info'); }; /** * description:目前只需要存手机号信息,后续还要存其他的信息,所以为后续功能的拓展需要存一个字符串对象 * @param {*} value * type:object * arguments: * phoneNo(手机号) * @returns */ const setXhbAdUserInfo = (value = {}) => { if (typeof document === 'undefined' || typeof value != 'object') { return; } let info = Object.assign(getXhbAdUserInfo(), value); sessionStorage.setItem('xhb_ad_user_info', JSON.stringify(info)); }; // 校验手机号 const isPhone = function (value) { return /^(13[0-9]|14[01456879]|15[0-35-9]|16[2567]|17[0-8]|18[0-9]|19[0-35-9])\d{8}$/.test( value ) }; exports.getXhbAdUserInfo = getXhbAdUserInfo; exports.isPhone = isPhone; exports.removeXhbAdUserInfo = removeXhbAdUserInfo; exports.setXhbAdUserInfo = setXhbAdUserInfo;