Commit 6b67d360 by liimin

调整utils结构

1 parent 7946d8c7
// app.js // app.js
// 初始化sentry // 初始化sentry
import sentryInit from '~/utils/sentryConfig/sentryInit' import sentryInit from '~/utils/sentryConfig/sentryInit'
sentryInit() sentryInit()
import api from './api/index' import api from './api/index'
import util from './utils/util' import {router} from './router/index'
import wxApi from './utils/utils_wx'
import router from './router/index'
import { setSystem_info } from '~/utils/cache/storageApi'
// 判断小程序是否需要更新 // 判断小程序是否需要更新
import getUpdateManager from './utils/lib/wxUpdateManager' import getUpdateManager from './lib/wxUpdateManager'
import utils from './utils/index'
// 埋点 有需要再引入 // 埋点 有需要再引入
// import './utils/track/Track' // import './utils/track/Track'
import eventbus from './utils/evenbus'
// 实例化对象存储
import { Storage } from './utils/cache/storage'
import './router/routerBefore'
App({ App({
onLaunch(options) { onLaunch(options) {
getUpdateManager() getUpdateManager()
/**挂载到wx对象 */ /**挂载到wx对象 */
wx.p={ wx.p={
authStatus:false, authStatus:false,
util, ...utils,
api, api,
router, router,
storage:new Storage(), storage:new utils.cache.Storage(),
eventbus,
wxApi
} }
// 存储设备信息 // 存储设备信息
setSystem_info() utils.cache.storageApi.setSystem_info()
}, },
/**页面不存在时触发 */ /**页面不存在时触发 */
onPageNotFound(e) { onPageNotFound(e) {
......
import Router from "./router.js"; import router from "./router.js";
import routerBefore from './routerBefore'
export default new Router(); module.exports={
router,
routerBefore
}
\ No newline at end of file \ No newline at end of file
...@@ -95,4 +95,4 @@ class Router { ...@@ -95,4 +95,4 @@ class Router {
} }
} }
export default Router;
\ No newline at end of file \ No newline at end of file
export default new Router();
\ No newline at end of file \ No newline at end of file
import Storage from './storage'
import userInfo from './userInfo'
import storageApi from './storageApi'
module.exports={Storage,userInfo,storageApi}
\ No newline at end of file \ No newline at end of file
...@@ -204,4 +204,4 @@ String.prototype.TrimStr = function () { ...@@ -204,4 +204,4 @@ String.prototype.TrimStr = function () {
return this.replace(/(^\s*)|(\s*$)/g, '') return this.replace(/(^\s*)|(\s*$)/g, '')
} }
export { Storage } export default Storage
// 实例化对象存储 // 实例化对象存储
import { Storage } from './storage' import Storage from './storage'
const storage = new Storage() const storage = new Storage()
// console.log(storage) // console.log(storage)
/** */ /** */
...@@ -55,3 +55,16 @@ export function setSystem_info(that) { ...@@ -55,3 +55,16 @@ export function setSystem_info(that) {
} }
}) })
} }
export default{
getSessionId,
setSessionId,
getUserInfo,
setUserInfo,
removeSystemStorage,
setStorageSync,
getStorageSync,
setNavigationBarTitleText,
getNavigationBarTitleText,
setSystem_info
}
...@@ -23,3 +23,9 @@ export function isMember(isNeedToHttp, callBack) { ...@@ -23,3 +23,9 @@ export function isMember(isNeedToHttp, callBack) {
} }
return wx.p.storage.get('isVIP') || false return wx.p.storage.get('isVIP') || false
} }
export default{
getUserInfo,
setUserInfo,
isMember
}
...@@ -20,3 +20,10 @@ export const IMG_VERSION = async () => { ...@@ -20,3 +20,10 @@ export const IMG_VERSION = async () => {
const accountInfo = await util.getMockData() const accountInfo = await util.getMockData()
return accountInfo?.version || Date.now() return accountInfo?.version || Date.now()
} }
export default{
IMG_URL,
DEFAULT_GET_STORAGEKEY,
STORAGE_OBJECTkEY,
IMG_VERSION
}
\ No newline at end of file \ No newline at end of file
...@@ -20,3 +20,9 @@ export function replaceEmoji(value) { ...@@ -20,3 +20,9 @@ export function replaceEmoji(value) {
let val = value.replace(emojiReg, '') let val = value.replace(emojiReg, '')
return val.trimStart().trimEnd() return val.trimStart().trimEnd()
} }
export default{
emojiReg,
haveEmoji,
replaceEmoji
}
...@@ -142,3 +142,13 @@ export function setPrice(price) { ...@@ -142,3 +142,13 @@ export function setPrice(price) {
if (!decimal) decimal = '00' if (!decimal) decimal = '00'
return (num || 0).toString().replace(/(\d)(?=(?:\d{3})+$)/g, '$1,') + `.${decimal}` return (num || 0).toString().replace(/(\d)(?=(?:\d{3})+$)/g, '$1,') + `.${decimal}`
} }
export default{
timeAgo,
commentTime,
iosTimeFormat,
getScopeTime,
decimal,
centsToyuan,
setPrice
}
import util from './util'
import wxApi from './utils_wx'
import constants from './constants'
import draw from './draw'
import emoji from './emoji'
import eventbus from './eventbus'
import format from './format'
import network from './network'
import routerApi from './routerApi'
import WxValidate from './WxValidate'
import cache from './cache/index'
import GlMap from './mapapi/mapapi'
module.exports ={util,wxApi,constants,draw,emoji,eventbus,format,network,routerApi,WxValidate,cache,GlMap}
\ No newline at end of file \ No newline at end of file
...@@ -52,3 +52,10 @@ export function decodeUrlLink(options) { ...@@ -52,3 +52,10 @@ export function decodeUrlLink(options) {
} }
} }
} }
export default{
getSceneId,
filterUrlParam,
goShoppingCart,
decodeUrlLink
}
\ No newline at end of file \ No newline at end of file
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!