1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94
|
const UserWhetherLogged = () => { const token = app.globalData.userInfo.token return token == '' || undefined || null ? false :true }
const LMMediaImagesOnload = u => { if (!u) return false let Image = new Image() Image.src = u return Image.complete ? true : false }
const LMPagesParam = (s = 1, u = false) => { const pages = getCurrentPages() const pageParam = pages[pages.length - s] if (u = true) { const param = LMJSToUrlParam(pageParam.options) const params = param !== false ? '?' + param : '' const redirect = (pageParam.route.indexOf('/') !== 0 ? '/' + pageParam.route : pageParam.route) + params return redirect } return pageParam }
const LMRouter = (u = '', t = 'navigateTo', auth = false) => { console.log('路由跳转:', u) switch (t) { case 'navigateBack': wx[t]({url: u}) break; case 'reLaunch': wx[t]({ url: u }) break; default: wx[t]({ url: u }) } }
const LMNotify = (m, t = 'primary', d = 3000) => { return Object.prototype.toString.call(m) === '[object Object]' ? Notify(m) : Notify({ message: m, type: t, duration: d}) }
const LMJSToUrlParam = (d) => { if (Object.keys(d).length == 0) { return false } return JSON.stringify(d).replace(/:/g, "=").replace(/"/g, "").replace(/,/g, "&").match(/\{([^)]*)\}/)[1] }
|