Commit 8957ac22 authored by shida.liu's avatar shida.liu

feat: 鸿蒙购物车跳h5,分享暂时隐藏;

parent 5d41b663
<template> <template>
<div> <div>
<cr-back-top :show-back-top="showTop" :list="backTopList" @click="handleBackTopClick" ref="crBackTop" @touchend.native="disTouch" :distance="100" /> <cr-back-top
<cr-popover :show-back-top="showTop"
class="wxmp-tip" :list="backTopList"
:value="showMpTip" @click="handleBackTopClick"
placement="bottom-end" ref="crBackTop"
> @touchend.native="disTouch"
:distance="100"
/>
<cr-popover class="wxmp-tip" :value="showMpTip" placement="bottom-end">
<div class="wxmp-tip__content" ref="content"> <div class="wxmp-tip__content" ref="content">
点击“<cr-icon type="weapp-nav" />”分享当前页面 点击“<cr-icon type="weapp-nav" />”分享当前页面
</div> </div>
<template #reference>提示</template> <template #reference>提示</template>
</cr-popover> </cr-popover>
<div v-if="showShareOverlay" class="share-overlay" @click.self="onShareOverlayClick" /> <div
v-if="showShareOverlay"
class="share-overlay"
@click.self="onShareOverlayClick"
/>
</div> </div>
</template> </template>
<script> <script>
import Bridge from '@qg/js-bridge'; import Bridge from "@qg/js-bridge";
import { mapGetters } from 'vuex'; import { mapGetters } from "vuex";
import { isApp, isWxMp, debounce, isWechat, isH5Normal, isDef, isHarmonyOS } from '@/service/utils.service'; import {
import { registeredEvents } from '@/service/sa.service'; isApp,
import api from '@/api/editor.api'; isWxMp,
import cfg from '@/config/index'; debounce,
import localStorage from '@/service/localStorage.service'; isWechat,
import DisableTouchMixin from '../../../mixins/disableTouch.mixin'; isH5Normal,
import { navToDlApp, getParameterByName } from '@qg/citrus-ui/src/helper/service/utils'; isDef,
import { EventBus } from '@qg/citrus-ui/src/helper/service/eventBus'; isHarmonyOS,
} from "@/service/utils.service";
import { registeredEvents } from "@/service/sa.service";
import api from "@/api/editor.api";
import cfg from "@/config/index";
import localStorage from "@/service/localStorage.service";
import DisableTouchMixin from "../../../mixins/disableTouch.mixin";
import {
navToDlApp,
getParameterByName,
} from "@qg/citrus-ui/src/helper/service/utils";
import { EventBus } from "@qg/citrus-ui/src/helper/service/eventBus";
const WEAPP_PATH = 'pages/webview/webview'; const WEAPP_PATH = "pages/webview/webview";
const APP_PATH = 'xyqb://openHttp'; const APP_PATH = "xyqb://openHttp";
export default { export default {
name: 'BackTop', name: "BackTop",
mixins: [DisableTouchMixin], mixins: [DisableTouchMixin],
props: { props: {
showBackTop: Boolean showBackTop: Boolean,
}, },
data() { data() {
return { return {
...@@ -45,40 +62,52 @@ export default { ...@@ -45,40 +62,52 @@ export default {
cartIndex: null, cartIndex: null,
cartCount: 0, cartCount: 0,
getCartCountDebounce: debounce(this.getCartCount, 2000), getCartCountDebounce: debounce(this.getCartCount, 2000),
mpSchema: '', mpSchema: "",
link: '', link: "",
shareInfo: {}, shareInfo: {},
showShareOverlay: ((isWechat && !isWxMp) || isH5Normal) && !(localStorage.get('vccChannel') || (localStorage.get('tenantId') && getParameterByName('fromHost', window.location.href))), showShareOverlay:
isWechat ((isWechat && !isWxMp) || isH5Normal) &&
!(
localStorage.get("vccChannel") ||
(localStorage.get("tenantId") &&
getParameterByName("fromHost", window.location.href))
),
isWechat,
}; };
}, },
computed: { computed: {
...mapGetters(['pageData', 'pageInfo']), ...mapGetters(["pageData", "pageInfo"]),
wxAppId() { wxAppId() {
return cfg.appIdMap[this.pageInfo.tenantId] || ''; return cfg.appIdMap[this.pageInfo.tenantId] || "";
}, },
backTopList() { backTopList() {
const btAttachVal = this.pageData.props?.btAttachVal || []; const btAttachVal = this.pageData.props?.btAttachVal || [];
if (isDef(this.cartIndex) && this.cartIndex !== -1 && btAttachVal.length) { if (
isDef(this.cartIndex) &&
this.cartIndex !== -1 &&
btAttachVal.length
) {
btAttachVal[this.cartIndex].info = this.cartCount; btAttachVal[this.cartIndex].info = this.cartCount;
} }
if (isApp) { if (isApp) {
if (isHarmonyOS) { if (isHarmonyOS) {
return btAttachVal.map(item => { return btAttachVal
if (item.persets === '购物车') { .map((item) => {
const appChannel = localStorage.get('appChannel') || ''; if (item.name === "购物车") {
const token = localStorage.get('vccToken') || ''; const appChannel = localStorage.get("appChannel") || "";
const tenantId = localStorage.get('tenantId') || ''; const token = localStorage.get("vccToken") || "";
const tenantId = localStorage.get("tenantId") || "";
item.url = `${cfg.h5MallHost}/shopCart?vccToken=${token}&tenantId=${tenantId}&appChannel=${appChannel}`; item.url = `${cfg.h5MallHost}/shopCart?vccToken=${token}&tenantId=${tenantId}&appChannel=${appChannel}`;
} }
return item; return item;
}); })
.filter((item) => item.persets !== "分享");
} }
return btAttachVal; return btAttachVal;
} else if (isWxMp) { } else if (isWxMp) {
return btAttachVal.filter(item => item.persets!== '购物车'); return btAttachVal.filter((item) => item.persets !== "购物车");
} }
return [] return [];
// if (this.pageData.props && this.pageData.props.btAttachVal) { // if (this.pageData.props && this.pageData.props.btAttachVal) {
// const { btAttachVal, showShare } = this.pageData.props; // const { btAttachVal, showShare } = this.pageData.props;
// const btAttachValDeep = JSON.parse(JSON.stringify(btAttachVal)); // const btAttachValDeep = JSON.parse(JSON.stringify(btAttachVal));
...@@ -88,24 +117,30 @@ export default { ...@@ -88,24 +117,30 @@ export default {
// return []; // return [];
}, },
showTop() { showTop() {
return this.showBackTop && this.pageData.props && this.pageData.props.showBackTop; return (
this.showBackTop &&
this.pageData.props &&
this.pageData.props.showBackTop
);
}, },
appSchema() { appSchema() {
return `${APP_PATH}?jumpUrl=${this.link}`; return `${APP_PATH}?jumpUrl=${this.link}`;
}, },
shareOpenMethod() { shareOpenMethod() {
return this.pageInfo.page.props.shareOpenMethod; return this.pageInfo.page.props.shareOpenMethod;
} },
}, },
watch: { watch: {
backTopList: { backTopList: {
immediate: true, immediate: true,
handler(val) { handler(val) {
this.cartIndex = (val || []).findIndex(item => item.persets === '购物车'); this.cartIndex = (val || []).findIndex(
(item) => item.persets === "购物车"
);
this.getCartCountDebounce(); this.getCartCountDebounce();
} },
} },
}, },
created() { created() {
if (!EASY_ENV_IS_NODE) { if (!EASY_ENV_IS_NODE) {
...@@ -115,7 +150,7 @@ export default { ...@@ -115,7 +150,7 @@ export default {
} }
}, },
mounted() { mounted() {
EventBus.$on("PAGE_VISIBILITY_STATE", state => { EventBus.$on("PAGE_VISIBILITY_STATE", (state) => {
if (!state) { if (!state) {
this.getCartCountDebounce(); this.getCartCountDebounce();
} }
...@@ -127,44 +162,52 @@ export default { ...@@ -127,44 +162,52 @@ export default {
if (isH5Normal && EASY_ENV_IS_BROWSER && this.wxAppId) { if (isH5Normal && EASY_ENV_IS_BROWSER && this.wxAppId) {
try { try {
console.log(this.pageInfo.tenantId); console.log(this.pageInfo.tenantId);
console.log('-----444444---------'); console.log("-----444444---------");
const [schema] = await api.getMpSchema({ const [schema] = await api.getMpSchema(
{
miniUrl: WEAPP_PATH, miniUrl: WEAPP_PATH,
params: `url=${encodeURIComponent(JSON.stringify(this.link))}` params: `url=${encodeURIComponent(JSON.stringify(this.link))}`,
}, this.wxAppId, this.pageInfo.tenantId); },
this.wxAppId,
this.pageInfo.tenantId
);
this.mpSchema = schema; this.mpSchema = schema;
} catch (error) { } catch (error) {}
}
} }
}, },
onShareOverlayClick() { onShareOverlayClick() {
if(this.pageInfo.diversion){ if (this.pageInfo.diversion) {
window.location.href = this.pageInfo.diversion; window.location.href = this.pageInfo.diversion;
return; return;
} }
if (isH5Normal) { if (isH5Normal) {
const fromHost = getParameterByName('fromHost', window.location.href); const fromHost = getParameterByName("fromHost", window.location.href);
const loginUrl = `${fromHost}/login?redirectUrl=${window.location.href}`; const loginUrl = `${fromHost}/login?redirectUrl=${window.location.href}`;
window.location.href = fromHost ? loginUrl : this.shareOpenMethod === 1 ? this.mpSchema : this.appSchema; window.location.href = fromHost
? loginUrl
: this.shareOpenMethod === 1
? this.mpSchema
: this.appSchema;
setTimeout(() => { setTimeout(() => {
this.shareOpenMethod === 2 && navToDlApp(); this.shareOpenMethod === 2 && navToDlApp();
}, 2000); }, 2000);
} else if (isWechat && !isWxMp) { } else if (isWechat && !isWxMp) {
const { shareOpenMethod, link: url } = this; const { shareOpenMethod, link: url } = this;
const jumpUrl = shareOpenMethod === 1 ? WEAPP_PATH : APP_PATH; const jumpUrl = shareOpenMethod === 1 ? WEAPP_PATH : APP_PATH;
window.location.href = `${cfg.mallHost}/common/launch?jumpUrl=${jumpUrl}&terminal=${shareOpenMethod || 2}&extraInfo=${encodeURIComponent(JSON.stringify({ url }))}`; window.location.href = `${
cfg.mallHost
}/common/launch?jumpUrl=${jumpUrl}&terminal=${shareOpenMethod ||
2}&extraInfo=${encodeURIComponent(JSON.stringify({ url }))}`;
} }
}, },
handleBackTopClick(e = {}) { handleBackTopClick(e = {}) {
// ! 此处以1.3为准,但需要对齐分享功能 // ! 此处以1.3为准,但需要对齐分享功能
registeredEvents('PD_WUXIEC_H5ActivityPageSuspendedBtnClick', { registeredEvents("PD_WUXIEC_H5ActivityPageSuspendedBtnClick", {
activity_id: this.pageInfo.uuid, activity_id: this.pageInfo.uuid,
jump_link: e.url, jump_link: e.url,
window_name: e.name, window_name: e.name,
}); });
if (e && e.persets === '分享') { if (e && e.persets === "分享") {
if (this.tipTimer) { if (this.tipTimer) {
clearTimeout(this.tipTimer); clearTimeout(this.tipTimer);
} }
...@@ -175,33 +218,42 @@ export default { ...@@ -175,33 +218,42 @@ export default {
}, },
initShareInfo() { initShareInfo() {
if (EASY_ENV_IS_NODE) return; if (EASY_ENV_IS_NODE) return;
let shareCoverImage = ''; let shareCoverImage = "";
try { try {
shareCoverImage = this.pageInfo.page.props.shareCoverImage; shareCoverImage = this.pageInfo.page.props.shareCoverImage;
} catch (e) { } catch (e) {
console.log(e); console.log(e);
} }
const { coverImage, pageName, pageDescribe } = this.pageInfo; const { coverImage, pageName, pageDescribe } = this.pageInfo;
let link = `${window.location.origin}${window.location.pathname}?vccToken={token}&tenantId=${localStorage.get('tenantId') || ''}&appChannel={appChannel}`; let link = `${window.location.origin}${
if (this.getUrlParamsVal('navId') !== false && this.getUrlParamsVal('index') !== false) { window.location.pathname
}?vccToken={token}&tenantId=${localStorage.get("tenantId") ||
""}&appChannel={appChannel}`;
if (
this.getUrlParamsVal("navId") !== false &&
this.getUrlParamsVal("index") !== false
) {
// 向分享URL中填充导航ID与位置索引 // 向分享URL中填充导航ID与位置索引
link += `&navId=${this.getUrlParamsVal("navId")}&index=${this.getUrlParamsVal('index')}` link += `&navId=${this.getUrlParamsVal(
"navId"
)}&index=${this.getUrlParamsVal("index")}`;
} }
this.link = link; this.link = link;
const defaultTitle = +localStorage.get('tenantId') === 560761 ? '羊小咩' : '活动页'; const defaultTitle =
+localStorage.get("tenantId") === 560761 ? "羊小咩" : "活动页";
let shareUrl = shareCoverImage || coverImage; let shareUrl = shareCoverImage || coverImage;
shareUrl += isApp ? '?imageMogr2/thumbnail/120x120' : '' shareUrl += isApp ? "?imageMogr2/thumbnail/120x120" : "";
this.shareInfo = { this.shareInfo = {
event: "showShareView", event: "showShareView",
data: { data: {
platform: ["weChat", "timeLine"], platform: ["weChat", "timeLine"],
shareDic: { shareDic: {
title: pageName || defaultTitle, title: pageName || defaultTitle,
desc: pageDescribe || '美好生活更从容', desc: pageDescribe || "美好生活更从容",
link, link,
imgUrl: shareUrl imgUrl: shareUrl,
} },
} },
}; };
if (isWxMp) { if (isWxMp) {
this.postMpShareInfo(); this.postMpShareInfo();
...@@ -220,7 +272,7 @@ export default { ...@@ -220,7 +272,7 @@ export default {
}, },
postMpShareInfo() { postMpShareInfo() {
if (EASY_ENV_IS_NODE || !this.wxAppId) return; if (EASY_ENV_IS_NODE || !this.wxAppId) return;
const wx = require('weixin-js-sdk'); const wx = require("weixin-js-sdk");
const { shareInfo } = this; const { shareInfo } = this;
wx.miniProgram.postMessage({ data: shareInfo }); wx.miniProgram.postMessage({ data: shareInfo });
}, },
...@@ -231,7 +283,7 @@ export default { ...@@ -231,7 +283,7 @@ export default {
}, 10000); }, 10000);
}, },
async getCartCount() { async getCartCount() {
if (localStorage.get('vccToken') && isDef(this.cartIndex) && isApp) { if (localStorage.get("vccToken") && isDef(this.cartIndex) && isApp) {
const [res, err] = await api.getShopCartCount(); const [res, err] = await api.getShopCartCount();
this.cartCount = err ? 0 : res.count || 0; this.cartCount = err ? 0 : res.count || 0;
this.$nextTick(() => { this.$nextTick(() => {
...@@ -241,18 +293,18 @@ export default { ...@@ -241,18 +293,18 @@ export default {
}, },
getUrlParamsVal(name) { getUrlParamsVal(name) {
let query = window.location.search.substring(1); let query = window.location.search.substring(1);
let vars = query.split('&'); let vars = query.split("&");
for (let i = 0; i < vars.length; i++) { for (let i = 0; i < vars.length; i++) {
let pair = vars[i].split("="); let pair = vars[i].split("=");
if (pair[0] == name) return pair[1]; if (pair[0] == name) return pair[1];
} }
return false; return false;
}
}, },
} },
};
</script> </script>
<style lang="less" scoped> <style lang="less" scoped>
@deep: ~'>>>'; @deep: ~">>>";
.cr-back-top { .cr-back-top {
z-index: 103; z-index: 103;
......
<template> <template>
<div class="pageContent"> <div class="pageContent">
<div class="activity" :class="{hasBottomNav: navigatorConfig}" :style="transformStyle(pageData.commonStyle)"> <div
class="activity"
:class="{ hasBottomNav: navigatorConfig }"
:style="transformStyle(pageData.commonStyle)"
>
<template v-if="!noPageData && tenantIdCorrect"> <template v-if="!noPageData && tenantIdCorrect">
<div class="layout"> <div class="layout">
<template v-for="(item, index) in pageData.elements"> <template v-for="(item, index) in pageData.elements">
<div :style="transformStyle(item.commonStyle, item.point, item.name)" <div
:style="transformStyle(item.commonStyle, item.point, item.name)"
:key="fixGridKey(item)" :key="fixGridKey(item)"
:id="`item_${item.id}`" :id="`item_${item.id}`"
@click="dot(item.title)" @click="dot(item.title)"
@touchend="disTouch" @touchend="disTouch"
> >
<component :data-index="index" :id="item.id" :containerIndex="index" :component-data="item" :childItem="item" :is="item.name" :sa-info="getSaInfo(item)" v-bind="item.props"></component> <component
:data-index="index"
:id="item.id"
:containerIndex="index"
:component-data="item"
:childItem="item"
:is="item.name"
:sa-info="getSaInfo(item)"
v-bind="item.props"
></component>
</div> </div>
</template> </template>
...@@ -22,35 +36,55 @@ ...@@ -22,35 +36,55 @@
<page-bottom-tip /> <page-bottom-tip />
</div> </div>
</div> </div>
<back-top v-if="showBackTop" :show-back-top="showBackTop" ref="backTop" /> <back-top
<invalid-notice v-model="pageInvalid" @toOtherActivity="toOtherActivity"/> v-if="showBackTop"
:show-back-top="showBackTop"
ref="backTop"
/>
<invalid-notice
v-model="pageInvalid"
@toOtherActivity="toOtherActivity"
/>
<coupon-modal :modal-data="couponModalData" v-model="showCouponModal" /> <coupon-modal :modal-data="couponModalData" v-model="showCouponModal" />
</template> </template>
<empty-state v-else /> <empty-state v-else />
</div> </div>
<!-- 底部导航 --> <!-- 底部导航 -->
<div v-if="navigatorConfig" class="bottomNav" :style="computedNavContainerStyle(navigatorConfig)"> <div
v-if="navigatorConfig"
class="bottomNav"
:style="computedNavContainerStyle(navigatorConfig)"
>
<div <div
class="navItem" class="navItem"
:class="{pic: item.type == 2, current: +navIndex === index}" :class="{ pic: item.type == 2, current: +navIndex === index }"
v-for="(item, index) in navigatorConfig.navigatorData" v-for="(item, index) in navigatorConfig.navigatorData"
:key="index" :key="index"
@click.stop="handleNavUrl(item, +navIndex === index)" @click.stop="handleNavUrl(item, +navIndex === index)"
> >
<img class="icon" :src="+navIndex === index ? item.selectIcon : item.icon" alt=""> <img
<span v-if="item.type == 1 && item.name" class="text" :style="computedNavTextStyle(item, +navIndex === index)">{{item.name}}</span> class="icon"
:src="+navIndex === index ? item.selectIcon : item.icon"
alt=""
/>
<span
v-if="item.type == 1 && item.name"
class="text"
:style="computedNavTextStyle(item, +navIndex === index)"
>{{ item.name }}</span
>
</div> </div>
</div> </div>
</div> </div>
</template> </template>
<script lang="ts" src="./index.ts"></script> <script lang="ts" src="./index.ts"></script>
<style lang="less" scoped> <style lang="less" scoped>
@deep: ~'>>>'; @deep: ~">>>";
.pageContent{ .pageContent {
width: 100%; width: 100%;
height: 100%; height: 100%;
position: relative; position: relative;
.bottomNav{ .bottomNav {
box-sizing: content-box; box-sizing: content-box;
width: 100%; width: 100%;
position: fixed; position: fixed;
...@@ -64,36 +98,36 @@ ...@@ -64,36 +98,36 @@
padding-bottom: env(safe-area-inset-bottom); padding-bottom: env(safe-area-inset-bottom);
display: flex; display: flex;
justify-content: space-around; justify-content: space-around;
.navItem{ .navItem {
width: 62px; width: 62px;
height: 55px; height: 55px;
display: flex; display: flex;
justify-content: center; justify-content: center;
flex-direction: column; flex-direction: column;
align-items: center; align-items: center;
&.pic{ &.pic {
.icon{ .icon {
max-width: 40px; max-width: 40px;
max-height: 40px; max-height: 40px;
} }
} }
.icon{ .icon {
max-width: 35px; max-width: 35px;
max-height: 35px; max-height: 35px;
} }
.text{ .text {
margin-top: 3px; margin-top: 3px;
text-align: center; text-align: center;
font-size: 10px; font-size: 10px;
} }
} }
} }
} }
.activity { .activity {
width: 100%; width: 100%;
min-height: 100%; min-height: 100%;
background-color: rgb(244, 244, 244); background-color: rgb(244, 244, 244);
&.hasBottomNav{ &.hasBottomNav {
padding-bottom: calc(constant(safe-area-inset-bottom) + 55px); padding-bottom: calc(constant(safe-area-inset-bottom) + 55px);
padding-bottom: calc(env(safe-area-inset-bottom) + 55px); padding-bottom: calc(env(safe-area-inset-bottom) + 55px);
} }
...@@ -120,11 +154,10 @@ ...@@ -120,11 +154,10 @@
} }
} }
} }
} }
.del_transform { .del_transform {
overflow: visible !important; overflow: visible !important;
transform: none !important; transform: none !important;
} }
</style> </style>
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment