| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672 |
- <!DOCTYPE html>
- <html lang="zh-CN">
- <head>
- <meta charset="utf-8">
- <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no, viewport-fit=cover">
- <meta name="format-detection" content="telephone=no">
- <title>打卡分享</title>
- <style>
- :root {
- --orange: #F58220;
- --text: #333333;
- --text-secondary: #999999;
- --border: #EEEEEE;
- --bg: #FFFFFF;
- --safe-bottom: env(safe-area-inset-bottom, 0px);
- }
- * {
- margin: 0;
- padding: 0;
- box-sizing: border-box;
- }
- html {
- font-size: 16px;
- -webkit-tap-highlight-color: transparent;
- overflow-x: hidden;
- }
- body {
- font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Microsoft YaHei", "Helvetica Neue", sans-serif;
- background: var(--bg);
- color: var(--text);
- padding-bottom: calc(88px + var(--safe-bottom));
- min-height: 100vh;
- overflow-x: hidden;
- }
- .hero.hero--empty {
- display: flex;
- flex-direction: column;
- align-items: center;
- justify-content: center;
- padding: 48px 24px 56px;
- min-height: min(52vh, 440px);
- background: var(--bg);
- }
- .hero--empty__illustration {
- display: block;
- width: 100%;
- max-width: 280px;
- height: auto;
- object-fit: contain;
- }
- .hero--empty__tip {
- padding: 0 16px;
- margin-top: 12px;
- font-size: 15px;
- line-height: 1.5;
- color: var(--text-secondary);
- text-align: center;
- font-weight: 400;
- }
- .divider {
- height: 8px;
- background: #F7F7F7;
- margin: 0;
- }
- .more-title {
- padding: 8px 15px 12px;
- font-size: 16px;
- font-weight: 700;
- }
- .more-scroll {
- display: grid;
- grid-template-columns: repeat(2, 1fr);
- gap: 10px;
- padding: 0 15px 20px;
- }
- #recEmpty {
- grid-column: 1 / -1;
- }
- .rec-card {
- min-width: 0;
- background: #fff;
- border-radius: 10px;
- overflow: hidden;
- box-shadow: 0 2px 12px rgba(0, 0, 0, 0.06);
- }
- .rec-card__img {
- aspect-ratio: 4 / 3;
- background: #eee;
- }
- .rec-card__img img {
- width: 100%;
- height: 100%;
- object-fit: cover;
- display: block;
- border-radius: 0;
- }
- .rec-card__body {
- padding: 10px;
- }
- .rec-card__top {
- display: flex;
- justify-content: space-between;
- align-items: baseline;
- gap: 8px;
- margin-bottom: 6px;
- }
- .rec-card__name {
- font-size: 15px;
- font-weight: 700;
- flex: 1;
- min-width: 0;
- overflow: hidden;
- text-overflow: ellipsis;
- white-space: nowrap;
- }
- .rec-card__dist {
- font-size: 12px;
- color: var(--text-secondary);
- flex-shrink: 0;
- }
- .rec-card__rating {
- display: flex;
- align-items: center;
- flex-wrap: wrap;
- gap: 4px 6px;
- }
- .rec-card__rating .stars {
- display: inline-flex;
- align-items: center;
- gap: 2px;
- }
- .rec-card__rating .rec-star {
- display: block;
- flex-shrink: 0;
- }
- .rec-card__rating .rating-num {
- font-size: 12px;
- font-weight: 600;
- color: var(--orange);
- }
- .rec-meta {
- font-size: 12px;
- color: var(--text-secondary);
- }
- .rec-card__footer {
- margin-top: 8px;
- font-size: 12px;
- color: var(--text-secondary);
- overflow: hidden;
- text-overflow: ellipsis;
- white-space: nowrap;
- }
- .fab-wrap {
- position: fixed;
- left: 0;
- right: 0;
- bottom: 0;
- z-index: 200;
- padding: 12px 24px calc(12px + var(--safe-bottom));
- background: linear-gradient(to top, rgba(255, 255, 255, 0.98) 70%, transparent);
- pointer-events: none;
- }
- .fab-wrap .fab {
- pointer-events: auto;
- }
- .fab {
- display: flex;
- align-items: center;
- justify-content: center;
- gap: 10px;
- width: 100%;
- max-width: 320px;
- margin: 0 auto;
- height: 48px;
- border: none;
- border-radius: 24px;
- background: var(--orange);
- color: #fff;
- font-size: 16px;
- font-weight: 600;
- box-shadow: 0 4px 16px rgba(245, 130, 32, 0.45);
- cursor: pointer;
- }
- .fab img {
- flex-shrink: 0;
- }
- .home-indicator {
- height: 5px;
- background: #000;
- border-radius: 3px;
- width: 134px;
- margin: 8px auto 4px;
- opacity: 0.2;
- }
- </style>
- </head>
- <body>
- <div class="hero hero--empty" role="status" aria-live="polite">
- <img class="hero--empty__illustration" id="heroEmptyIllustration" src="images/empty.png" alt="" decoding="async">
- <p class="hero--empty__tip" id="heroEmptyTip">内容已删除</p>
- </div>
- <div class="divider"></div>
- <h3 class="more-title">更多推荐</h3>
- <div class="more-scroll" id="recList">
- <p id="recEmpty" style="padding:12px;color:#999;font-size:14px;display:none;">暂无推荐</p>
- </div>
- <div class="fab-wrap">
- <button type="button" class="fab" id="openApp">
- <img src="images/uBtn.png" alt="APP内打开" decoding="async">
- </button>
- <div class="home-indicator" aria-hidden="true"></div>
- </div>
- <script>
- (function () {
- 'use strict';
- /**
- * 更多推荐:POST …/dev-life-manager-ai/ai/multimodal-services/api/v1/search/global/store-recommend
- * 请求体:page、pageSize、storeId(字符串)、userCity、userLat、userLng;均可由 URL query 覆盖。
- */
- var API_LIFE_AI_BASE = 'http://124.93.18.180:9100';
- var STORE_GLOBAL_RECOMMEND_PATH =
- '/ai/multimodal-services/api/v1/search/global/store-recommend';
- var DEFAULT_USER_LAT = 38.925747;
- var DEFAULT_USER_LNG = 121.662531;
- var DEFAULT_USER_CITY = '大连市';
- var DEFAULT_STORE_ID = '378';
- var APP_ANDROID_PACKAGE = 'com.alien.Udianzaizhe';
- var APP_IOS_URL_SCHEME = 'shopro://';
- var APP_UNI_STORE_PATH = 'pages/checkIn/index';
- function qs() {
- return new URLSearchParams(location.search || '');
- }
- function q(name) {
- var v = qs().get(name);
- return v == null ? '' : String(v);
- }
- function showDownloadTip() {
- var msg = '请到应用商店下载';
- if (typeof uni !== 'undefined' && typeof uni.showToast === 'function') {
- uni.showToast({ title: msg, icon: 'none', duration: 2500 });
- } else {
- window.alert(msg);
- }
- }
- function mergeSearchAndHashParams() {
- var params = new URLSearchParams();
- function ingest(querySlice) {
- if (!querySlice) return;
- var p = new URLSearchParams(querySlice);
- p.forEach(function (val, key) {
- params.append(key, val);
- });
- }
- if (location.search && location.search.length > 1) {
- ingest(location.search.slice(1));
- }
- var hash = location.hash || '';
- var qi = hash.indexOf('?');
- if (qi >= 0) {
- ingest(hash.slice(qi + 1));
- }
- return params;
- }
- /** businessStatus=99(商户关闭):插图与文案;否则为「内容已删除」 */
- function applyEmptyHeroState() {
- var merged = mergeSearchAndHashParams();
- var bsRaw = merged.get('businessStatus');
- if (bsRaw == null || bsRaw === '') bsRaw = q('businessStatus');
- var bs = bsRaw == null ? '' : String(bsRaw).trim();
- var isClosed = Number(bs) === 99 || bs === '99';
- var img = document.getElementById('heroEmptyIllustration');
- var tip = document.getElementById('heroEmptyTip');
- if (!img || !tip) return;
- if (isClosed) {
- img.src = 'images/storeNone.png';
- img.alt = '';
- tip.textContent = '抱歉商户已关闭,看看别的吧';
- } else {
- img.src = 'images/empty.png';
- img.alt = '';
- tip.textContent = '内容已删除';
- }
- img.onerror = function () {
- this.onerror = null;
- this.src = 'images/empty.png';
- };
- }
- function buildAppOpenQueryStringMerged() {
- var params = mergeSearchAndHashParams();
- var sid = params.get('storeId') || params.get('id') || '';
- if (sid && !params.has('storeId')) {
- params.set('storeId', sid);
- }
- return params.toString() ? ('?' + params.toString()) : '';
- }
- function buildAppDeepLink() {
- var path = String(APP_UNI_STORE_PATH || 'pages/checkIn/index').replace(/^\//, '');
- var s = buildAppOpenQueryStringMerged();
- var root = APP_IOS_URL_SCHEME.replace(/\/$/, '');
- if (!s) {
- return root + '/' + path;
- }
- return root + '/' + path + s;
- }
- function launchAppDeepLink(deepLink) {
- try {
- var a = document.createElement('a');
- a.href = deepLink;
- a.setAttribute('target', '_self');
- document.body.appendChild(a);
- a.click();
- document.body.removeChild(a);
- } catch (e1) {}
- try {
- window.location.href = deepLink;
- } catch (e2) {}
- }
- function tryOpenHBuilderApp() {
- var deepLink = buildAppDeepLink();
- if (typeof plus !== 'undefined' && plus.runtime) {
- var installed = null;
- try {
- if (typeof plus.runtime.isApplicationExist === 'function') {
- installed = plus.runtime.isApplicationExist({
- pname: APP_ANDROID_PACKAGE,
- action: APP_IOS_URL_SCHEME
- });
- }
- } catch (e) {
- console.warn(e);
- }
- if (installed === false) {
- showDownloadTip();
- return;
- }
- if (installed === true) {
- try {
- plus.runtime.openURL(deepLink);
- } catch (e2) {
- console.warn(e2);
- showDownloadTip();
- }
- return;
- }
- }
- var t0 = Date.now();
- var done = false;
- function finish() {
- if (done) return;
- done = true;
- document.removeEventListener('visibilitychange', onVis);
- window.removeEventListener('pagehide', onHide);
- }
- function onVis() {
- if (document.visibilityState === 'hidden') finish();
- }
- function onHide() {
- finish();
- }
- document.addEventListener('visibilitychange', onVis);
- window.addEventListener('pagehide', onHide);
- launchAppDeepLink(deepLink);
- window.setTimeout(function () {
- if (done) return;
- if (document.visibilityState === 'visible' && Date.now() - t0 < 3500) {
- showDownloadTip();
- }
- finish();
- }, 2600);
- }
- function isApiOk(res) {
- if (!res || typeof res !== 'object') return false;
- if (res.success === false) return false;
- var c = res.code;
- return c === 200 || c === '200' || Number(c) === 200;
- }
- function fetchStoreGlobalRecommend() {
- var latRaw = (q('userLat') || q('latitude') || q('lat') || q('weidu')).trim();
- var lngRaw = (q('userLng') || q('longitude') || q('lon') || q('jingdu')).trim();
- var userLat =
- latRaw !== '' && !isNaN(Number(latRaw)) ? Number(latRaw) : DEFAULT_USER_LAT;
- var userLng =
- lngRaw !== '' && !isNaN(Number(lngRaw)) ? Number(lngRaw) : DEFAULT_USER_LNG;
- var page = parseInt(q('page') || '1', 10);
- var pageSize = parseInt(q('pageSize') || '10', 10);
- if (isNaN(page) || page < 1) page = 1;
- if (isNaN(pageSize) || pageSize < 1) pageSize = 10;
- var storeIdRaw = (q('storeId') || q('id') || '').trim();
- var storeId = storeIdRaw !== '' ? storeIdRaw : DEFAULT_STORE_ID;
- var userCityRaw = (q('userCity') || q('city') || '').trim();
- var userCity = userCityRaw !== '' ? userCityRaw : DEFAULT_USER_CITY;
- var body = {
- page: page,
- pageSize: pageSize,
- storeId: String(storeId),
- userCity: userCity,
- userLat: userLat,
- userLng: userLng
- };
- return fetch(API_LIFE_AI_BASE + STORE_GLOBAL_RECOMMEND_PATH, {
- method: 'POST',
- mode: 'cors',
- credentials: 'omit',
- headers: {
- Accept: 'application/json',
- 'Content-Type': 'application/json;charset=UTF-8'
- },
- body: JSON.stringify(body)
- }).then(function (res) {
- if (!res.ok) throw new Error('HTTP ' + res.status);
- return res.json();
- });
- }
- function normalizeStoreRecommendList(res) {
- if (!res || typeof res !== 'object') return [];
- var raw = res.data != null ? res.data : res.result;
- if (Array.isArray(raw)) return raw;
- if (raw && typeof raw === 'object') {
- if (Array.isArray(raw.list)) return raw.list;
- if (Array.isArray(raw.records)) return raw.records;
- if (Array.isArray(raw.rows)) return raw.rows;
- if (Array.isArray(raw.content)) return raw.content;
- if (Array.isArray(raw.stores)) return raw.stores;
- if (Array.isArray(raw.storeList)) return raw.storeList;
- if (Array.isArray(raw.storeVos)) return raw.storeVos;
- if (Array.isArray(raw.items)) return raw.items;
- }
- if (Array.isArray(res.list)) return res.list;
- if (Array.isArray(res.records)) return res.records;
- return [];
- }
- function formatRecDistance(item) {
- /** 后端 distance 为千米,展示为米 */
- if (item.distance != null && item.distance !== '') {
- var km = Number(item.distance);
- if (!isNaN(km) && km >= 0) {
- return Math.round(km * 1000) + '米';
- }
- return String(item.distance).trim();
- }
- if (item.position != null && String(item.position).trim() !== '') {
- return String(item.position).trim();
- }
- if (item.dist != null && item.dist !== '') {
- var dn = Number(item.dist);
- if (!isNaN(dn)) {
- return dn >= 1 ? dn.toFixed(dn % 1 === 0 ? 0 : 1) + 'km' : Math.round(dn * 1000) + '米';
- }
- }
- return '';
- }
- function escHtml(s) {
- return String(s == null ? '' : s)
- .replace(/&/g, '&')
- .replace(/</g, '<')
- .replace(/>/g, '>')
- .replace(/"/g, '"');
- }
- var STAR_PATH = 'M12 17.27L18.18 21l-1.64-7.03L22 9.24l-7.19-.61L12 2 9.19 8.63 2 9.24l5.46 4.73L5.82 21z';
- function starsHtml(score) {
- var s = Number(score);
- if (isNaN(s)) s = 0;
- s = Math.max(0, Math.min(5, s));
- var rounded = Math.round(s);
- var parts = [];
- var i;
- for (i = 1; i <= 5; i++) {
- var fill = i <= rounded ? '#F58220' : '#E5E5E5';
- parts.push(
- '<svg class="rec-star" width="11" height="11" viewBox="0 0 24 24" aria-hidden="true">' +
- '<path fill="' + fill + '" d="' + STAR_PATH + '"/></svg>'
- );
- }
- return '<span class="stars">' + parts.join('') + '</span>';
- }
- function pickScore(item) {
- var x =
- item.scoreAvg != null ? Number(item.scoreAvg)
- : item.score != null ? Number(item.score)
- : item.rating != null ? Number(item.rating)
- : item.starScore != null ? Number(item.starScore)
- : NaN;
- return isNaN(x) ? null : x;
- }
- function pickReviewCount(item) {
- var n =
- item.commitCount != null ? Number(item.commitCount)
- : item.commentCount != null ? Number(item.commentCount)
- : item.reviewCount != null ? Number(item.reviewCount)
- : item.evaluateCount != null ? Number(item.evaluateCount)
- : NaN;
- return isNaN(n) ? 0 : Math.max(0, Math.floor(n));
- }
- function renderRecommended(list) {
- var wrap = document.getElementById('recList');
- var empty = document.getElementById('recEmpty');
- wrap.querySelectorAll('.rec-card').forEach(function (n) {
- n.remove();
- });
- if (!list || !list.length) {
- empty.style.display = 'block';
- return;
- }
- empty.style.display = 'none';
- list.forEach(function (item) {
- if (!item || typeof item !== 'object') return;
- var imgUrlField = item.imgUrl != null ? String(item.imgUrl).trim() : '';
- var home = item.homeImage != null ? String(item.homeImage).trim() : '';
- if (home && /\.mp4(\?|#|$)/i.test(home)) {
- var vf = item.videoFirstFrame != null ? String(item.videoFirstFrame).trim() : '';
- if (vf) home = vf;
- }
- var imgUrl =
- imgUrlField ||
- home ||
- (item.coverUrl != null ? String(item.coverUrl).trim() : '') ||
- (item.mainImage != null ? String(item.mainImage).trim() : '') ||
- (item.goodsImage != null ? String(item.goodsImage).trim() : '') ||
- (item.entranceImage != null ? String(item.entranceImage).trim() : '') ||
- (Array.isArray(item.goodsImageList) && item.goodsImageList[0]) ||
- (Array.isArray(item.imageList) && item.imageList[0]) ||
- (Array.isArray(item.storeAlbumUrlList) && item.storeAlbumUrlList[0]) ||
- '';
- var name = item.title != null && String(item.title).trim() !== ''
- ? String(item.title).replace(/\r?\n/g, ' ').replace(/\s+/g, ' ').trim()
- : (item.storeName || item.goodsName || item.secondGoodsTitle || item.name || '推荐');
- var dist = formatRecDistance(item);
- var scoreVal = pickScore(item);
- var displayScore = scoreVal != null ? scoreVal.toFixed(1) : '—';
- var starScore = scoreVal != null ? scoreVal : 0;
- var rc = pickReviewCount(item);
- var reviewLabel = rc > 0 ? rc + '条评价' : '';
- var seller =
- item.userName != null && String(item.userName).trim() !== ''
- ? String(item.userName).trim()
- : (item.nickName != null && String(item.nickName).trim() !== ''
- ? String(item.nickName).trim()
- : '');
- var card = document.createElement('article');
- card.className = 'rec-card';
- card.innerHTML =
- '<div class="rec-card__img"><img class="rec-card__cover" src="" alt="" decoding="async"></div>' +
- '<div class="rec-card__body">' +
- '<div class="rec-card__top">' +
- '<span class="rec-card__name">' + escHtml(name) + '</span>' +
- (dist ? '<span class="rec-card__dist">' + escHtml(dist) + '</span>' : '') +
- '</div>' +
- '<div class="rec-card__rating">' +
- starsHtml(starScore) +
- '<span class="rating-num">' + escHtml(displayScore) + '</span>' +
- (reviewLabel ? '<span class="rec-meta">' + escHtml(reviewLabel) + '</span>' : '') +
- '</div>' +
- (seller ? '<div class="rec-card__footer">' + escHtml(seller) + '</div>' : '') +
- '</div>';
- var coverIm = card.querySelector('img.rec-card__cover');
- if (coverIm) {
- coverIm.src = imgUrl;
- coverIm.onerror = function () {
- this.onerror = null;
- this.src = '';
- };
- }
- wrap.appendChild(card);
- });
- }
- function run() {
- fetchStoreGlobalRecommend()
- .then(function (res) {
- var list = normalizeStoreRecommendList(res);
- if (!list.length && res && res.msg) {
- console.warn('[store-recommend]', res.msg);
- }
- renderRecommended(list);
- })
- .catch(function (e) {
- console.error(e);
- renderRecommended([]);
- });
- }
- function boot() {
- applyEmptyHeroState();
- run();
- var openBtn = document.getElementById('openApp');
- if (openBtn) {
- openBtn.addEventListener('click', function () {
- tryOpenHBuilderApp();
- });
- }
- }
- if (document.readyState === 'complete') {
- boot();
- } else {
- window.onload = boot;
- }
- })();
- </script>
- </body>
- </html>
|