Commit 7a3b2a14 authored by 郭志伟's avatar 郭志伟

feat(share): 分享功能开发

parent daf4c0a7
...@@ -4,5 +4,14 @@ import config from '../config'; ...@@ -4,5 +4,14 @@ import config from '../config';
export default { export default {
getPageById(params) { getPageById(params) {
return http.get(`${config.apiHost}/editor/get/${params.pageId}`); return http.get(`${config.apiHost}/editor/get/${params.pageId}`);
},
getMpSchema(params) {
return http.post(`${config.kdspHost}/api/kdsp/ka/info/getShareMiniUrl`);
},
getWxConfig(url = window.location.href.split('#')[0]) {
return http.post(`${config.kdspHost}/api/kdsp/wx/mp/getJsapiSign`, {
url,
appId: 'wx2f44c7fe7b08458d'
});
} }
}; };
\ No newline at end of file
...@@ -3,6 +3,7 @@ const protocol = EASY_ENV_IS_BROWSER ? window.location.protocol : 'https'; ...@@ -3,6 +3,7 @@ const protocol = EASY_ENV_IS_BROWSER ? window.location.protocol : 'https';
const hostMap = { const hostMap = {
apiHost: `${protocol}//quantum-blocks-vcc2.liangkebang.net`, apiHost: `${protocol}//quantum-blocks-vcc2.liangkebang.net`,
kdspHost: `${protocol}//talos-test1.liangkebang.net`,
shenceUrl: `${protocol}//bn.xyqb.com/sa?project=default`, shenceUrl: `${protocol}//bn.xyqb.com/sa?project=default`,
test: true test: true
}; };
......
const protocol = EASY_ENV_IS_BROWSER ? window.location.protocol : 'https'; const protocol = EASY_ENV_IS_BROWSER ? window.location.protocol : 'https';
export default { export default {
apiHost: `https://quantum-blocks.q-gp.com`, apiHost: `${protocol}//quantum-blocks.q-gp.com`,
kdspHost: `${protocol}//talos.q-gp.com`,
shenceUrl: `${protocol}//bn.xyqb.com/sa?project=production`, shenceUrl: `${protocol}//bn.xyqb.com/sa?project=production`,
// opapiHost: `${protocol}//opapi.q-gp.com`,
test: false test: false
}; };
...@@ -3,6 +3,7 @@ const protocol = EASY_ENV_IS_BROWSER ? window.location.protocol : 'https'; ...@@ -3,6 +3,7 @@ const protocol = EASY_ENV_IS_BROWSER ? window.location.protocol : 'https';
const hostMap = { const hostMap = {
apiHost: `${protocol}//quantum-blocks-vcc2.liangkebang.net`, apiHost: `${protocol}//quantum-blocks-vcc2.liangkebang.net`,
kdspHost: `${protocol}//talos-test1.liangkebang.net`,
shenceUrl: `${protocol}//bn.xyqb.com/sa?project=default`, shenceUrl: `${protocol}//bn.xyqb.com/sa?project=default`,
test: true test: true
}; };
......
<template>
<wx-open-launch-weapp
class="launch-btn"
username="gh_a976018bfb9e"
:path="jumpUrl"
@launch="launch"
@error="launchError"
>
<script type="text/wxtag-template">
<style>.btn {height: 96px}</style>
<div class="btn">打开小程序</div>
</script>
</wx-open-launch-weapp>
</template>
<script>
import wx from "weixin-js-sdk";
import api from '@/api/editor.api';
export default {
name: "Weapp",
props: {
jumpUrl: String
},
data() {
return {};
},
created() {
this.wxConfig();
},
methods: {
async wxConfig() {
const [res] = await api.getWxConfig();
wx.config({
debug: false,
jsApiList: ["onMenuShareTimeline", "onMenuShareAppMessage"], // 必填,需要使用的JS接口列表
openTagList: ["wx-open-launch-weapp"],
...res
});
},
launch() {
console.log("launch");
},
launchError() {
console.log("launchError");
}
}
};
</script>
<style lang="less">
.launch-btn {
position: absolute;
top: 0;
bottom: 0;
width: 100%;
opacity: 0;
z-index: 100;
left: 0;
}
</style>
...@@ -11,13 +11,18 @@ ...@@ -11,13 +11,18 @@
</div> </div>
<template #reference>提示</template> <template #reference>提示</template>
</cr-popover> </cr-popover>
<div v-if="showShareOverlay" class="share-overlay" @click="onShareOverlayClick">
<we-app :jump-url="mpLink" v-if="isWechat" />
</div>
</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 } from '@/service/utils.service'; import { isApp, isWxMp, isWechat } from '@/service/utils.service';
import api from '@/api/editor.api';
import WeApp from './components/weapp.vue';
const SHARE_CONFIG = { const SHARE_CONFIG = {
name: 'share', name: 'share',
txt: '', txt: '',
...@@ -26,6 +31,9 @@ const SHARE_CONFIG = { ...@@ -26,6 +31,9 @@ const SHARE_CONFIG = {
}; };
export default { export default {
name: 'BackTop', name: 'BackTop',
components: {
WeApp
},
props: { props: {
showBackTop: Boolean showBackTop: Boolean
}, },
...@@ -48,16 +56,41 @@ export default { ...@@ -48,16 +56,41 @@ export default {
tipTimer: null, tipTimer: null,
jsBridge: null, jsBridge: null,
wx: null, wx: null,
mpSchema: '',
mpLink: '',
showShareOverlay: isWechat || isH5Normal,
isWechat
}; };
}, },
computed: {
appSchema() {
return `xyqb://openhttp?jumpurl=${this.mpLink}`;
}
},
created() { created() {
if (!EASY_ENV_IS_NODE) { if (!EASY_ENV_IS_NODE) {
this.renderTpl = true; this.renderTpl = true;
this.jsBridge = new Bridge(); this.jsBridge = new Bridge();
this.wx = require('weixin-js-sdk'); this.wx = require('weixin-js-sdk');
this.mpLink = `${window.location.origin}${window.location.pathname}?vccToken={token}&vccChannel={registerFrom}`;
this.getMpSchema();
} }
}, },
methods: { methods: {
async getMpSchema() {
if (isH5Normal && EASY_ENV_IS_BROWSER) {
const [schema] = await api.getMpSchema({
miniUrl: 'pages/webview/webview',
params: `url=${encodeURIComponent(JSON.stringify(this.mpLink))}`
});
this.mpSchema = schema.nextUrl;
}
},
onShareOverlayClick() {
if (isH5Normal) {
window.location.href = this.pageInfo.shareOpenMethod === 1 ? this.mpSchema : this.appSchema;
}
},
handleBackTopClick(e) { handleBackTopClick(e) {
// ! 此处以1.3为准,但需要对齐分享功能 // ! 此处以1.3为准,但需要对齐分享功能
if (e && e.name === 'share') { if (e && e.name === 'share') {
...@@ -71,16 +104,17 @@ export default { ...@@ -71,16 +104,17 @@ export default {
}, },
share() { share() {
if (EASY_ENV_IS_NODE) return; if (EASY_ENV_IS_NODE) return;
const { coverImage, pageName, pageDescribe } = this.pageInfo; const { coverImage, pageName, pageDescribe, shareCoverImage } = this.pageInfo;
const link = `${window.location.origin}${window.location.pathname}?vccToken={token}&vccChannel={registerFrom}`;
const data = { const data = {
event: "showShareView", event: "showShareView",
data: { data: {
platform: ["weChat", "timeLine", "QQ", "QQZone", "CopyLink"], //依次分别是微信、朋友圈、QQ好友、QQ空间、复制链接 platform: ["weChat",  "CopyLink"],
shareDic: { shareDic: {
title: pageName || '羊小咩', title: pageName || '羊小咩',
desc: pageDescribe || '羊小咩', desc: pageDescribe || '羊小咩',
link: window.location.origin + window.location.pathname, // 页面地址 link,
imgUrl: coverImage // 图片地址 imgUrl: shareCoverImage || coverImage // 图片地址
} }
} }
}; };
...@@ -129,4 +163,12 @@ export default { ...@@ -129,4 +163,12 @@ export default {
} }
} }
} }
.share-overlay {
position: fixed;
top: 0;
left: 0;
height: 100%;
width: 100%;
z-index: 8;
}
</style> </style>
\ No newline at end of file
...@@ -7,7 +7,7 @@ import GridLayout from '../../component/VueGridLayout/GridLayout.vue'; ...@@ -7,7 +7,7 @@ import GridLayout from '../../component/VueGridLayout/GridLayout.vue';
import GridItem from '../../component/VueGridLayout/GridItem.vue'; import GridItem from '../../component/VueGridLayout/GridItem.vue';
import TransformStyleMixin from '@/page/mixins/transformStyle.mixin'; import TransformStyleMixin from '@/page/mixins/transformStyle.mixin';
import SaMixin from '@/page/mixins/sa.mixin'; import SaMixin from '@/page/mixins/sa.mixin';
import { getStyle, debounce, isApp } from '@/service/utils.service'; import { getStyle, debounce, isApp, isWechat, isH5Normal } from '@/service/utils.service';
import { EventBus } from '@qg/citrus-ui/src/helper/service/eventBus'; import { EventBus } from '@qg/citrus-ui/src/helper/service/eventBus';
import { setAppTitleColor } from '@/service/color.service'; import { setAppTitleColor } from '@/service/color.service';
import localStorage from '@/service/localStorage.service'; import localStorage from '@/service/localStorage.service';
...@@ -34,7 +34,6 @@ export default class Activity extends Mixins(TransformStyleMixin, SaMixin) { ...@@ -34,7 +34,6 @@ export default class Activity extends Mixins(TransformStyleMixin, SaMixin) {
targetEle: HTMLElement | null = null; targetEle: HTMLElement | null = null;
loading: boolean = true; loading: boolean = true;
modfiTabsStyleDebounce = debounce(this.modfiTabsStyle, 300); modfiTabsStyleDebounce = debounce(this.modfiTabsStyle, 300);
get layout() { get layout() {
return this.pageData && this.pageData.elements.map(v => v.point) || []; return this.pageData && this.pageData.elements.map(v => v.point) || [];
} }
...@@ -83,9 +82,7 @@ export default class Activity extends Mixins(TransformStyleMixin, SaMixin) { ...@@ -83,9 +82,7 @@ export default class Activity extends Mixins(TransformStyleMixin, SaMixin) {
mounted() { mounted() {
this.targetEle = document.querySelector('body'); this.targetEle = document.querySelector('body');
if (EASY_ENV_IS_BROWSER) { if (EASY_ENV_IS_BROWSER) { this.showBackTop = true; }
this.showBackTop = true;
}
this.pageVisibilityChange(); this.pageVisibilityChange();
if (EASY_ENV_IS_BROWSER) { if (EASY_ENV_IS_BROWSER) {
EventBus.$on('NATIVE_EVENT_LOGIN', json => { EventBus.$on('NATIVE_EVENT_LOGIN', json => {
......
...@@ -45,6 +45,8 @@ export interface PageInfo { ...@@ -45,6 +45,8 @@ export interface PageInfo {
enable?: number; enable?: number;
author?: string; author?: string;
coverImage?: string; coverImage?: string;
shareCoverImage?: string; // 分享缩略图
shareOpenMethod?: string; // 分享后的打开方式
isTemplate?: number; isTemplate?: number;
isPublish?: number | boolean; isPublish?: number | boolean;
appLoginState?: boolean; appLoginState?: boolean;
......
...@@ -139,6 +139,9 @@ export const isIOS = /iphone|ipad|ipod/.test(ua); ...@@ -139,6 +139,9 @@ export const isIOS = /iphone|ipad|ipod/.test(ua);
// 判读Android环境 // 判读Android环境
export const isAndroid = /android/.test(ua); export const isAndroid = /android/.test(ua);
// 判读非微信浏览器和appwebview和小程序webview
export const isH5Normal = !isWechat && !isWxMp && !isApp;
// 异常字段 // 异常字段
export const errorQueryValues = ['{token}', '{vccToken}', '{registerFrom}', '{vccChannel}', '{sonVccChannel}', '{h}', '{uuid}', '{}']; export const errorQueryValues = ['{token}', '{vccToken}', '{registerFrom}', '{vccChannel}', '{sonVccChannel}', '{h}', '{uuid}', '{}'];
......
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