Commit b0eb3b05 authored by 郭志伟's avatar 郭志伟

feat(share): 功能完成

parent 7a3b2a14
......@@ -6,7 +6,7 @@ export default {
return http.get(`${config.apiHost}/editor/get/${params.pageId}`);
},
getMpSchema(params) {
return http.post(`${config.kdspHost}/api/kdsp/ka/info/getShareMiniUrl`);
return http.post(`http://talos-vcc3.liangkebang.net/api/kdsp/ka/info/getShareMiniUrl`, params);
},
getWxConfig(url = window.location.href.split('#')[0]) {
return http.post(`${config.kdspHost}/api/kdsp/wx/mp/getJsapiSign`, {
......
......@@ -21,11 +21,11 @@ if (process.env.SENTRY_ENV !== 'test' && process.env.NODE_ENV === 'production')
.install();
}
// if (EASY_ENV_IS_BROWSER && process.env.SENTRY_ENV === 'test' || process.env.NODE_ENV !== 'production') {
// // ! 上线后务必取掉;
// const vConsole = require('vconsole');
// new vConsole();
// }
if (EASY_ENV_IS_BROWSER) {
// ! 上线后务必取掉;
const vConsole = require('vconsole');
new vConsole();
}
if (EASY_ENV_IS_BROWSER) {
const isSafari = /^.*((iPhone)|(iPad)|(Safari))+.*$/;
......@@ -40,6 +40,7 @@ if (EASY_ENV_IS_BROWSER) {
Vue.use(lazyload);
const saDirective = new SaDirective();
Vue.directive('track', saDirective.directive);
Vue.config.ignoredElements = ['wx-open-launch-weapp', 'wx-open-launch-app'];
window.xyqbNativeEvent = function(res) {
const json = typeof res === 'string' ? JSON.parse(res) : res;
console.log('xyqbNativeEvent toggle');
......
import Vue from 'vue';
import { sync } from 'vuex-router-sync';
import api from '@/api/editor.api';
import { isWechat } from '@/service/utils.service';
import initService from '@/service/init.service';
export default class App {
config: any;
......@@ -25,6 +27,7 @@ export default class App {
const { initSa } = require('@/service/sa.service');
initService.init(router);
initSa(router);
this.setWxConfig();
}
return {
router,
......@@ -35,6 +38,18 @@ export default class App {
};
}
async setWxConfig() {
if (!isWechat) { return; }
const wx = require('weixin-js-sdk');
const [res] = await api.getWxConfig();
wx.config({
debug: false,
jsApiList: ['onMenuShareTimeline', 'onMenuShareAppMessage'], // 必填,需要使用的JS接口列表
openTagList: ['wx-open-launch-weapp', 'wx-open-launch-app'],
...res
});
}
fetch(vm): Promise<any> {
const { store, router } = vm;
const matchedComponents = router.getMatchedComponents();
......
<template>
<wx-open-launch-app
class="launch-btn"
@launch="launch"
@error="launchError"
id="launch-btn"
appid="wx75d5a207551d0b4d"
:extinfo="extinfo"
>
<script type="text/wxtag-template">
<style>.btn {height: 100vh;width: 100vw;}</style>
<div class="btn">打开APP</div>
</script>
</wx-open-launch-app>
</template>
<script>
import { navToDlApp } from '@qg/citrus-ui/src/helper/service/utils';
export default {
name: "LaunchApp",
props: {
jumpUrl: String,
appSchema: String
},
computed: {
extinfo() {
return JSON.stringify({
url: this.jumpUrl,
data: {}
});
}
},
methods: {
launch() {
setTimeout(() => {
navToDlApp();
}, 2500);
window.location.href = this.appSchema;
},
launchError(e) {
if (e.detail.errMsg === "launch:fail") {
navToDlApp();
}
},
}
};
</script>
<style lang="less">
.launch-btn {
position: absolute;
top: 0;
bottom: 0;
width: 100%;
opacity: 0;
z-index: 100;
left: 0;
}
</style>
......@@ -7,35 +7,21 @@
@error="launchError"
>
<script type="text/wxtag-template">
<style>.btn {height: 96px}</style>
<style>.btn {height: 100vh;width: 100vw;}</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",
name: "LaunchWeapp",
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");
},
......
<template>
<div>
<cr-back-top :show-back-top="showBackTop && pageData.props.showBackTop" :list="backTopList" @click="handleBackTopClick" ref="crBackTop" />
<cr-back-top :show-back-top="showTop" :list="backTopList" @click="handleBackTopClick" ref="crBackTop" />
<cr-popover
class="wxmp-tip"
:value="showMpTip"
......@@ -11,8 +11,9 @@
</div>
<template #reference>提示</template>
</cr-popover>
<div v-if="showShareOverlay" class="share-overlay" @click="onShareOverlayClick">
<we-app :jump-url="mpLink" v-if="isWechat" />
<div v-if="showShareOverlay" class="share-overlay" @click.self="onShareOverlayClick">
<launch-weapp :jump-url="mpSchema" v-if="isWechat && shareOpenMethod === 1" />
<launch-app :jump-url="link" app-schema="appSchema" v-if="isWechat && shareOpenMethod === 2" />
</div>
</div>
......@@ -20,9 +21,10 @@
<script>
import Bridge from '@qg/js-bridge';
import { mapGetters } from 'vuex';
import { isApp, isWxMp, isWechat } from '@/service/utils.service';
import { isApp, isWxMp, isWechat, isH5Normal } from '@/service/utils.service';
import api from '@/api/editor.api';
import WeApp from './components/weapp.vue';
import LaunchWeapp from './components/LaunchWeapp.vue';
import LaunchApp from './components/LaunchApp.vue';
const SHARE_CONFIG = {
name: 'share',
txt: '',
......@@ -32,23 +34,12 @@ const SHARE_CONFIG = {
export default {
name: 'BackTop',
components: {
WeApp
LaunchWeapp,
LaunchApp
},
props: {
showBackTop: Boolean
},
computed: {
...mapGetters(['pageData']),
...mapGetters(['pageInfo']),
backTopList() {
if (this.pageData && this.pageData.props && this.pageData.props.btAttachVal) {
const { btAttachVal, showShare } = this.pageData.props;
showShare && btAttachVal.push(SHARE_CONFIG);
return btAttachVal;
}
return [];
}
},
data() {
return {
renderTpl: false,
......@@ -57,38 +48,59 @@ export default {
jsBridge: null,
wx: null,
mpSchema: '',
mpLink: '',
link: '',
shareInfo: {},
showShareOverlay: isWechat || isH5Normal,
isWechat
};
},
computed: {
...mapGetters(['pageData', 'pageInfo']),
showTop() {
return this.showBackTop && this.pageData.props && this.pageData.props.showBackTop;
},
backTopList() {
if (this.pageData.props && this.pageData.props.btAttachVal) {
const { btAttachVal, showShare } = this.pageData.props;
showShare && btAttachVal.push(SHARE_CONFIG);
return btAttachVal;
}
return [];
},
appSchema() {
return `xyqb://openhttp?jumpurl=${this.mpLink}`;
return `xyqb://openhttp?jumpurl=${this.link}`;
},
shareOpenMethod() {
return this.pageInfo.shareOpenMethod;
}
},
created() {
if (!EASY_ENV_IS_NODE) {
this.renderTpl = true;
this.jsBridge = new Bridge();
this.wx = require('weixin-js-sdk');
this.mpLink = `${window.location.origin}${window.location.pathname}?vccToken={token}&vccChannel={registerFrom}`;
this.link = `${window.location.origin}${window.location.pathname}?vccToken={token}&vccChannel={registerFrom}`;
this.getMpSchema();
this.initShareInfo();
}
},
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;
try {
const [schema] = await api.getMpSchema({
miniUrl: 'pages/webview',
params: `url=${encodeURIComponent(JSON.stringify(this.link))}`
});
this.mpSchema = schema;
} catch (error) {
}
}
},
onShareOverlayClick() {
if (isH5Normal) {
window.location.href = this.pageInfo.shareOpenMethod === 1 ? this.mpSchema : this.appSchema;
window.location.href = this.shareOpenMethod === 1 ? this.mpSchema : this.appSchema;
}
},
handleBackTopClick(e) {
......@@ -102,11 +114,11 @@ export default {
}, 600);
}
},
share() {
initShareInfo() {
if (EASY_ENV_IS_NODE) return;
const { coverImage, pageName, pageDescribe, shareCoverImage } = this.pageInfo;
const link = `${window.location.origin}${window.location.pathname}?vccToken={token}&vccChannel={registerFrom}`;
const data = {
this.shareInfo = {
event: "showShareView",
data: {
platform: ["weChat",  "CopyLink"],
......@@ -118,17 +130,28 @@ export default {
}
}
};
if (isWxMp) {
this.postMpShareInfo();
}
},
share() {
if (EASY_ENV_IS_NODE) return;
if (isApp) {
this.appShare(data);
this.appShare();
} else if (isWxMp) {
this.mpShare(data);
this.mpShare();
}
},
appShare(data) {
this.jsBridge.showShareView(data);
appShare() {
this.jsBridge.showShareView(this.shareInfo);
},
postMpShareInfo() {
if (EASY_ENV_IS_NODE) return;
const wx = require('weixin-js-sdk');
const { shareInfo } = this;
wx.miniProgram.postMessage({ data: shareInfo });
},
mpShare(data) {
this.wx.miniProgram.postMessage(data);
mpShare() {
this.showMpTip = true;
setTimeout(() => {
this.showMpTip = false;
......
......@@ -12,6 +12,7 @@ export default class FreedomContainer extends Mixins(TransformStyleMixin, SaMixi
@Prop({type: Object, default: () => ({ child: [] })}) childItem;
@Prop({type: Object, default: () => ({})}) saInfo;
@Prop(String) link;
@Prop(String) backgroundImage;
mounted() {
......@@ -24,4 +25,5 @@ export default class FreedomContainer extends Mixins(TransformStyleMixin, SaMixi
// });
// }
}
}
\ No newline at end of file
}
<template>
<div class="freedom" v-track>
<div class="freedom" v-track="{ link }">
<div class="freedom-body">
<component :class="['freedom-body-item', { 'Fb-item_selected': curChildIndex === index }]" v-for="(item, index) in childItem.child" :style="transformStyle(item.commonStyle, 'container')" :is="item.name" :key="index" :sa-info="getSaInfo(item)" v-bind="item.props"></component>
</div>
......@@ -31,4 +31,4 @@
}
}
}
</style>
\ No newline at end of file
</style>
......@@ -1638,9 +1638,9 @@
"integrity": "sha512-shAmDyaQC4H92APFoIaVDHCx5bStIocgvbwQyxPRrbUY20V1EYTbSDchWbuwlMG3V17cprZhA6+78JfB+3DTPw=="
},
"@popperjs/core": {
"version": "2.9.2",
"resolved": "http://npmprivate.quantgroups.com/@popperjs%2fcore/-/core-2.9.2.tgz",
"integrity": "sha512-VZMYa7+fXHdwIq1TDhSXoVmSPEGM/aa+6Aiq3nVVJ9bXr24zScr+NlKFKC3iPljA7ho/GAZr+d2jOf5GIRC30Q=="
"version": "2.10.1",
"resolved": "http://npmprivate.quantgroups.com/@popperjs%2fcore/-/core-2.10.1.tgz",
"integrity": "sha1-co7NlasgequKmk5CHwQi2zKSMr4="
},
"@qg/apollo-nodejs": {
"version": "2.1.2",
......@@ -1648,9 +1648,9 @@
"integrity": "sha512-uOCUKu5mvX3PWee+7ZFXQSNIR1V5SN2JVE2yANmW9/wQOgpEct291gXGok8VMw0009HlTWB4JATURPwyOP2DFg=="
},
"@qg/cherry-ui": {
"version": "2.21.1",
"resolved": "http://npmprivate.quantgroups.com/@qg%2fcherry-ui/-/cherry-ui-2.21.1.tgz",
"integrity": "sha512-OQ9njfH6cs6FaNqPb7W+hEe/yftpdLXyjGXo2g4IwY7o/9Z5EH6Bn6B5X6dFGOka7LSyXyWRSfZzX0upIIpDFw==",
"version": "2.23.6",
"resolved": "http://npmprivate.quantgroups.com/@qg%2fcherry-ui/-/cherry-ui-2.23.6.tgz",
"integrity": "sha512-jKv/DMHaaQyba/yR3LUdY1lVhkLjcv9hb5o5ri/jb3Xhi7mglhdAeCEFmYyyKu1QXLbGZQdGKuYsfz5o87SJcQ==",
"requires": {
"@popperjs/core": "^2.5.4",
"vue-lazyload": "^1.3.3",
......@@ -1658,12 +1658,12 @@
}
},
"@qg/citrus-ui": {
"version": "0.2.27",
"resolved": "http://npmprivate.quantgroups.com/@qg%2fcitrus-ui/-/citrus-ui-0.2.27.tgz",
"integrity": "sha512-RQWArNw0AVF/am50n0heECgqtFxeeG2wvYzwZSmWf0zRwOpqyad32lnFp32pgUgVZfLkNuOVW7klJzbKYMFPKA==",
"version": "0.2.28",
"resolved": "http://npmprivate.quantgroups.com/@qg%2fcitrus-ui/-/citrus-ui-0.2.28.tgz",
"integrity": "sha512-uW9D2e7bs2Otkvum6ph0c11CkY2kZMzJTHLIBK8Jq1VmGBhCjjWOsy+wVYLHfc82sy/WtJ93Jyt/y4MUAfHrQg==",
"requires": {
"@better-scroll/core": "^2.1.1",
"@qg/cherry-ui": "^2.21.1",
"@qg/cherry-ui": "^2.23.6",
"@qg/js-bridge": "^1.1.11",
"axios": "^0.21.1",
"intersection-observer": "^0.12.0",
......@@ -8362,9 +8362,9 @@
}
},
"es5-shim": {
"version": "4.5.15",
"resolved": "http://npmprivate.quantgroups.com/es5-shim/-/es5-shim-4.5.15.tgz",
"integrity": "sha512-FYpuxEjMeDvU4rulKqFdukQyZSTpzhg4ScQHrAosrlVpR6GFyaw14f74yn2+4BugniIS0Frpg7TvwZocU4ZMTw=="
"version": "4.6.2",
"resolved": "http://npmprivate.quantgroups.com/es5-shim/-/es5-shim-4.6.2.tgz",
"integrity": "sha1-gnzdDG+1vrJv02jWVDDoterrqUI="
},
"es6-iterator": {
"version": "2.0.3",
......@@ -18814,9 +18814,9 @@
}
},
"parse-headers": {
"version": "2.0.3",
"resolved": "http://npmprivate.quantgroups.com/parse-headers/-/parse-headers-2.0.3.tgz",
"integrity": "sha512-QhhZ+DCCit2Coi2vmAKbq5RGTRcQUOE2+REgv8vdyu7MnYx2eZztegqtTx99TZ86GTIwqiy3+4nQTWZ2tgmdCA=="
"version": "2.0.4",
"resolved": "http://npmprivate.quantgroups.com/parse-headers/-/parse-headers-2.0.4.tgz",
"integrity": "sha512-psZ9iZoCNFLrgRjZ1d8mn0h9WRqJwFxM9q3x7iUjN/YT2OksthDJ5TiPCu2F38kS4zutqfW+YdVVkBZZx3/1aw=="
},
"parse-json": {
"version": "4.0.0",
......@@ -20930,9 +20930,9 @@
}
},
"sa-sdk-javascript": {
"version": "1.18.17",
"resolved": "http://npmprivate.quantgroups.com/sa-sdk-javascript/-/sa-sdk-javascript-1.18.17.tgz",
"integrity": "sha1-mLW7PyfL2jmwcCTb3G/Bes6H0n8="
"version": "1.18.18",
"resolved": "http://npmprivate.quantgroups.com/sa-sdk-javascript/-/sa-sdk-javascript-1.18.18.tgz",
"integrity": "sha1-gSIkQZUaeOEO+4GRBNB6aCn9YGs="
},
"safe-buffer": {
"version": "5.2.1",
......@@ -23440,9 +23440,9 @@
}
},
"url-toolkit": {
"version": "2.2.2",
"resolved": "http://npmprivate.quantgroups.com/url-toolkit/-/url-toolkit-2.2.2.tgz",
"integrity": "sha512-l25w6Sy+Iy3/IbogunxhWwljPaDnqpiKvrQRoLBm6DfISco7NyRIS7Zf6+Oxhy1T8kHxWdwLND7ZZba6NjXMug=="
"version": "2.2.3",
"resolved": "http://npmprivate.quantgroups.com/url-toolkit/-/url-toolkit-2.2.3.tgz",
"integrity": "sha512-Da75SQoxsZ+2wXS56CZBrj2nukQ4nlGUZUP/dqUBG5E1su5GKThgT94Q00x81eVII7AyS1Pn+CtTTZ4Z0pLUtQ=="
},
"urllib": {
"version": "2.37.1",
......
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