/* 底部胶囊 Tab(11-05 用户:「孕期百问、孕期计算器加上跟趣味小测试一样的底部 Tab」) 样式 / 行为照搬 guangchang/index.html 那条(左:本页 · 中:「记一下」橙色圆钮 · 右:返回首页 + 用户头像渐变圈), 类名统一加 mbt- 前缀,避免和首页自己的 .tabbar / .tab 撞车。 用法:MBTab.init({ root: '../../', // 到 mama-box 根目录的相对路径(取头像 / 回首页用) first: { t: '孕期计算器', ic: 'calc' }, // 左边那格:本页名字 + 图标(calc / qa) onFirst: fn, // 点左边(默认:滚回顶部) onHome: fn, // 点「返回首页」(默认:跳 root 带身份) onRec: fn, // 点「记一下」(默认:自带弹层,列后台已上架的孕期工具,同广场) mount: el, scroller: el // 挂在哪(默认 body,position:fixed);滚回顶部用的容器 }) */ (function (g) { 'use strict'; var CSS = '' + '.mbt-fade{position:fixed;left:0;right:0;bottom:0;z-index:29;pointer-events:none;height:calc(96px + env(safe-area-inset-bottom));background:linear-gradient(180deg,rgba(255,246,241,0),rgba(255,246,241,.75))}' + '.mbt{position:fixed;left:16px;right:16px;bottom:calc(22px + env(safe-area-inset-bottom));height:62px;z-index:30;border-radius:31px;padding:0 6px;display:grid;grid-template-columns:repeat(3,1fr);font-family:-apple-system,BlinkMacSystemFont,"PingFang SC","Hiragino Sans GB","Microsoft YaHei",sans-serif}' + '.mbt::before{content:"";position:absolute;inset:0;z-index:-1;border-radius:inherit;pointer-events:none;background:#FFF9F5;box-shadow:inset 0 0 0 1px rgba(255,255,255,.85),inset 0 1px 0 #fff;' + '-webkit-mask:radial-gradient(circle 31px at 50% 6px,transparent 30.5px,#000 31.5px);mask:radial-gradient(circle 31px at 50% 6px,transparent 30.5px,#000 31.5px)}' + '.mbt::after{content:"";position:absolute;inset:0;z-index:-2;border-radius:inherit;pointer-events:none;box-shadow:0 14px 34px rgba(200,100,70,.2),0 2px 6px rgba(200,100,70,.06)}' + '.mbt-t{position:relative;display:flex;flex-direction:column;align-items:center;justify-content:center;gap:2px;padding:0 0 6px;border:0;background:none;font-family:inherit;color:#A3958D;cursor:pointer;-webkit-tap-highlight-color:transparent}' + '.mbt-t.on{color:#F4593C}' + '.mbt-i{width:25px;height:25px;display:block;position:relative}' + '.mbt-i svg{display:block;width:100%;height:100%;overflow:visible}' + '.mbt-i .tf,.mbt-i .tl{fill:none;stroke:currentColor;stroke-width:1.8;stroke-linecap:round;stroke-linejoin:round}' + '.mbt-t.on .tf{fill:currentColor}.mbt-t.on .tl{stroke:#fff}' + '.mbt-x{font-size:12.5px;font-weight:600;line-height:1.1;letter-spacing:.2px;white-space:nowrap}.mbt-t.on .mbt-x{font-weight:800}' + '.mbt-t::after{content:"";position:absolute;left:50%;bottom:6px;width:4px;height:4px;margin-left:-2px;border-radius:50%;background:#F4593C;opacity:0}.mbt-t.on::after{opacity:1}' + '.mbt-fab::after{display:none}' + '.mbt-fab .fab{position:absolute;left:50%;top:-20px;width:52px;height:52px;margin-left:-26px;border-radius:50%;display:grid;place-items:center;overflow:visible;' + 'background:linear-gradient(150deg,#FF8A6E,#F4593C);box-shadow:0 6px 14px rgba(244,89,60,.32),inset 0 1px 0 rgba(255,255,255,.3);transition:transform .3s cubic-bezier(.3,1.6,.5,1)}' + '.mbt-fab .fab::before{content:"";display:block;width:20px;height:20px;opacity:.28;border-radius:2px;background:linear-gradient(#fff,#fff) center/100% 3px no-repeat,linear-gradient(#fff,#fff) center/3px 100% no-repeat}' + '.mbt-fab:active .fab{transform:scale(.9)}' + '.mbt-w{position:absolute;left:50%;top:50%;transform:translate(calc(-50% - 5px),-54%) rotate(-8deg);display:flex;align-items:center;white-space:nowrap;font-weight:900;font-style:normal;color:#4A1E14;line-height:1;pointer-events:none;' + 'text-shadow:1.6px 0 #fff,-1.6px 0 #fff,0 1.6px #fff,0 -1.6px #fff,1.2px 1.2px #fff,-1.2px 1.2px #fff,1.2px -1.2px #fff,-1.2px -1.2px #fff,0 3px 4px rgba(120,30,10,.25)}' + '.mbt-w i{font-style:normal;font-size:31px}.mbt-w em{font-style:normal;font-size:12.5px;line-height:1;margin:9px 0 0;letter-spacing:-.5px}.mbt-w s{text-decoration:none;font-size:20px;display:inline-block;transform:skewX(-8deg)}' + '.mbt-fab .mbt-x{position:absolute;width:1px;height:1px;overflow:hidden;clip:rect(0 0 0 0)}' + '.mbt-home .mbt-i{margin-bottom:6px}.mbt-home .mbt-x{font-size:11.5px;font-weight:600}' + '.mbt-av{position:absolute;inset:-3px;width:calc(100% + 6px);height:calc(100% + 6px);border-radius:50%;object-fit:cover;display:none;background:#fff;box-shadow:0 0 0 1.5px #fff,0 3px 10px rgba(226,105,74,.3)}' + '.mbt-hm{position:absolute;right:-8px;bottom:-5px;width:15px;height:15px;z-index:1;border-radius:50%;display:none;background:linear-gradient(150deg,#E2694A,#C24E31);box-shadow:0 0 0 1.5px #FFF6F1}.mbt-hm svg{display:block;width:10px;height:10px;margin:2.5px}' + '.mbt-i.has-av .mbt-av,.mbt-i.has-av .mbt-hm{display:block}.mbt-i.has-av svg.ts{visibility:hidden}' + '.mbt-i.has-av::before{content:"";position:absolute;inset:-7px;border-radius:50%;z-index:-1;pointer-events:none;background:conic-gradient(from 200deg,#FFB38A,#F4593C,#E2694A,#FF8FA3,#FFB38A);' + '-webkit-mask:radial-gradient(circle closest-side,transparent 82%,#000 85%);mask:radial-gradient(circle closest-side,transparent 82%,#000 85%)}' + /* 「记一下」弹层(同广场:标题一行 + 4 列工具宫格) */ '.mbt-mask{position:fixed;inset:0;z-index:60;background:rgba(40,20,14,.38);opacity:0;pointer-events:none;transition:opacity .25s}.mbt-mask.on{opacity:1;pointer-events:auto}' + '.mbt-sh{position:fixed;left:0;right:0;bottom:0;z-index:61;max-height:80vh;overflow:auto;padding:8px 18px calc(20px + env(safe-area-inset-bottom));border-radius:22px 22px 0 0;background:#FFF9F5;transform:translateY(105%);transition:transform .3s cubic-bezier(.2,.9,.3,1);font-family:-apple-system,BlinkMacSystemFont,"PingFang SC","Hiragino Sans GB","Microsoft YaHei",sans-serif}' + '.mbt-sh.on{transform:none}' + '.mbt-rh{display:flex;align-items:baseline;gap:10px;padding:10px 2px 14px}.mbt-rh b{font-size:19px;font-weight:800;color:#2A1E1E;flex:none}' + '.mbt-rh span{font-size:12px;color:#9C8F88;flex:1;min-width:0;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}' + '.mbt-rx{flex:none;align-self:center;width:30px;height:30px;border:0;border-radius:50%;display:grid;place-items:center;background:rgba(120,70,50,.08);color:#9C8F88;font-size:18px;line-height:1;cursor:pointer}' + '.mbt-apps{display:grid;grid-template-columns:repeat(4,1fr);gap:20px 6px;padding:4px 0 8px}' + '.mbt-app{position:relative;display:flex;flex-direction:column;align-items:center;gap:6px;min-width:0;border:0;background:none;font-family:inherit;color:#2A1E1E;cursor:pointer}' + '.mbt-app img,.mbt-app .rl{width:48px;height:48px;display:block;object-fit:contain;border-radius:14px}' + '.mbt-app .rl{display:grid;place-items:center;background:#F6D9CB;color:#C2553A;font-size:19px;font-weight:800}' + '.mbt-app span{display:block;max-width:100%;font-size:11.5px;font-weight:600;letter-spacing:-.2px;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}' + '.mbt-app.off img,.mbt-app.off .rl{opacity:.45;filter:grayscale(.4)}' + '.mbt-app.off i{position:absolute;top:-8px;left:calc(50% + 4px);font-style:normal;font-size:9px;font-weight:700;line-height:1;padding:3px 5px;border-radius:99px;background:#B9A9A2;color:#fff;white-space:nowrap}' + '.mbt-empty{grid-column:1/-1;padding:30px 0;text-align:center;font-size:13px;color:#9C8F88}' + '.mbt-toast{position:fixed;left:50%;bottom:calc(110px + env(safe-area-inset-bottom));z-index:70;max-width:80vw;padding:9px 14px;border-radius:12px;background:rgba(40,28,24,.86);color:#fff;font-size:13px;transform:translate(-50%,8px);opacity:0;transition:.25s;pointer-events:none}' + '.mbt-toast.on{opacity:1;transform:translate(-50%,0)}'; var IC = { calc: '', qa: '' }; var HOME = ''; function param(n) { var m = location.search.match(new RegExp('[?&]' + n + '=([^&]*)')) || location.hash.match(new RegExp('[#&]' + n + '=([^&]*)')); try { return m ? decodeURIComponent(m[1]) : ''; } catch (e) { return ''; } } function haptic() { try { navigator.vibrate && navigator.vibrate(8); } catch (e) {} } function esc(s) { return String(s == null ? '' : s).replace(/[&<>"']/g, function (c) { return { '&': '&', '<': '<', '>': '>', '"': '"', "'": ''' }[c]; }); } var realAv = function (u) { return !!u && !/\/uploads\/system\//.test(u); }; function defAv(oid) { var h = 0, s = String(oid || ''); for (var i = 0; i < s.length; i++) h = (h * 31 + s.charCodeAt(i)) >>> 0; var n = (h % 20) + 1; return 'https://mp.yizhezhe.com/_bridge/avatars/mom-' + (n < 10 ? '0' : '') + n + '.png'; } function init(o) { o = o || {}; var root = o.root || '../../', mount = o.mount || document.body; if (!document.getElementById('mbtCss')) { var st = document.createElement('style'); st.id = 'mbtCss'; st.textContent = CSS; document.head.appendChild(st); } var fade = document.createElement('div'); fade.className = 'mbt-fade'; fade.setAttribute('aria-hidden', 'true'); var bar = document.createElement('nav'); bar.className = 'mbt'; var f = o.first || { t: '本页', ic: 'qa' }; bar.innerHTML = '' + '' + ''; mount.appendChild(fade); mount.appendChild(bar); var OPENID = param('openid'); function homeURL() { var q = [], oid = param('openid'), uid = param('unionid'); if (oid) q.push('openid=' + encodeURIComponent(oid)); if (uid) q.push('unionid=' + encodeURIComponent(uid)); return root + (q.length ? '#' + q.join('&') : location.hash); } function goApp(url) { try { var u = new URL(url, location.href); if (u.origin === location.origin || /(^|\.)yizhezhe\.com$/.test(u.hostname)) url = u.pathname + u.search; } catch (e) {} var q = [], oid = param('openid'), uid = param('unionid'); if (oid) q.push('openid=' + encodeURIComponent(oid)); if (uid) q.push('unionid=' + encodeURIComponent(uid)); if (!oid && !uid) q.push('__no_identity=1'); var target = url + (url.indexOf('?') >= 0 ? '&' : '?') + q.join('&'); try { if (oid) { var api = '/api/mp/public/last-app?openid=' + encodeURIComponent(oid) + '&url=' + encodeURIComponent(location.origin + url); if (!(navigator.sendBeacon && navigator.sendBeacon(api)) && window.fetch) fetch(api, { method: 'POST', keepalive: true }).catch(function () {}); } if (window.wxAuth && wxAuth.reportLocation) wxAuth.reportLocation({ href: target }); } catch (e) {} /* 11-09:小程序里开容器页,「复制链接」才能直达这个应用(同 js/app.js openInHost,url 只放净地址) */ var mp = window.wx && window.wx.miniProgram; if ((window.__wxjs_environment === 'miniprogram' || /miniProgram/i.test(navigator.userAgent)) && mp && typeof mp.navigateTo === 'function') { try { var c = new URL(url, location.origin); ['openid', 'unionid', '__no_identity', 'return_url'].forEach(function (k) { c.searchParams.delete(k); }); mp.navigateTo({ url: '/pages/annex/web_view/index?url=' + encodeURIComponent(c.href), fail: function () { location.href = target; } }); return; } catch (e) {} } location.href = target; } var tt; function toast(s) { var t = document.querySelector('.mbt-toast'); if (!t) { t = document.createElement('div'); t.className = 'mbt-toast'; document.body.appendChild(t); } t.textContent = s; t.classList.add('on'); clearTimeout(tt); tt = setTimeout(function () { t.classList.remove('on'); }, 2200); } /* 「记一下」:后台 App 表已上架、category=孕期工具(同首页 / 广场);数胎动 16 / 数宫缩 20 / 胎儿估重 15 周前灰掉 */ var GATE = { taidong: [16, '数胎动'], gongsuopinlv: [20, '数宫缩'], taierguzhong: [15, '胎儿估重'] }, apps = null, busy = false, mask, sh; var myWeek = (function () { try { var w = JSON.parse(localStorage.getItem('mmbox.gcwk.v1') || 'null'); return w && !w.pp && w.w ? +w.w : 0; } catch (e) { return 0; } })(); function locked(a) { var x = GATE[a.identifier]; return x && myWeek && myWeek < x[0] ? x : null; } function appsHTML() { if (!apps) return '