Commit 69a59d13 authored by wildfirecode13's avatar wildfirecode13

1

parent eebaf73d
......@@ -11,7 +11,6 @@
"dependencies": {
"@spark/api-base": "^1.0.11",
"@spark/projectx": "^1.0.3",
"@spark/share": "^1.0.29",
"axios": "^0.19.2",
"css-loader": "^3.6.0",
"duiba-utils": "^1.0.2",
......
......@@ -11,7 +11,8 @@
<script src="//yun.duiba.com.cn/js-libs/rem/1.1.0/rem.min.js"></script>
<script src="//yun.duiba.com.cn/h5/lib/zepto.min.js"></script>
<script src="https://res.wx.qq.com/open/js/jweixin-1.3.2.js"></script>
<script type="text/javascript" src="https://res.wx.qq.com/open/js/jweixin-1.3.2.js"></script>
<script>
window.url = 'https://baidu.com';
......@@ -21,6 +22,7 @@
window.sharedesc = '养鸡养牛还能兑换更多好礼';
function getApp() {
return {
cloud: {},
......@@ -44,6 +46,96 @@
// alert("【警告】检测到活动url中没有appID参数\n缺少该参数会导致埋点、分享、app信息获取错误。")
}
</script>
<script>
var sharetit = "欢趣专区全新升级,快来看看吧";
var sharecont = "养鸡养牛还能兑换更多好礼";
var shareimg = "https://yun.duiba.com.cn/spark/assets/e7bec756134eaca143ea54e9f6856b6a6e10d33f.png";
var shareurl = window.location.href;
console.log("分享调整233===》", shareurl);
//初始化微信分享
function invokeWX(stit, scont, surl, simg) {
var share = {
title: stit,
desc: scont,
url: surl,
imgUrl: simg,
};
wx.onMenuShareTimeline({
title: share.title,
desc: share.desc,
link: share.url,
imgUrl: share.imgUrl,
success: function () {
window["sharecallback"] && window["sharecallback"]();
},
cancel: function () {
}
});
wx.onMenuShareAppMessage({
title: share.title,
desc: share.desc,
link: share.url,
imgUrl: share.imgUrl,
success: function () {
window["sharecallback"] && window["sharecallback"]();
},
cancel: function () {
}
});
}
function initWx(url, stit, scont, surl, simg) {
$.ajax({
type: 'get',
url: '/wechatShare/getShareInfo/v2',
data: {
wxdebug: false,
url: encodeURIComponent(url)
},
cache: false,
dataType: 'json',
success: function (res) {
if (!res.success) {
return;
}
wx.config({
debug: false,
appId: res.wxappid,
timestamp: res.wxtimestamp,
nonceStr: res.wxnonceStr,
signature: res.wxsignature,
jsApiList: ['checkJsApi', 'onMenuShareTimeline', 'onMenuShareAppMessage']
});
wx.error(function (res) {
console.error("wx error", res);
});
wx.ready(function () {
console.error("wx ready", stit, scont, surl, simg);
invokeWX(stit, scont, surl, simg);
});
},
error: function (err) {
console.log("err====>", err);
}
});
}
initWx(shareurl, sharetit, sharecont, shareurl, shareimg);
</script>
</head>
<body>
......
......@@ -9,20 +9,20 @@ MD();
import Share from "./pages/share/share.jsx";
import {Weixin,start,updateShare} from '@spark/share'
Weixin.debugMode = true;
start([Weixin], (success)=>{
//分享结果回调, success为是否成功
});
//更新分享内容,多用于被动式分享,比如微信
updateShare({
title: window.sharetitle, //分享标题
content: window.sharedesc, //分享内容
url: location.href, //分享链接
thumbnail: window.shareimg, //分享缩略图
});
// import {Weixin,start,updateShare} from '@spark/share'
// Weixin.debugMode = true;
// start([Weixin], (success)=>{
// //分享结果回调, success为是否成功
// });
// //更新分享内容,多用于被动式分享,比如微信
// updateShare({
// title: window.sharetitle, //分享标题
// content: window.sharedesc, //分享内容
// url: location.href, //分享链接
// thumbnail: window.shareimg, //分享缩略图
// });
class App extends Component {
......
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