Commit 69a59d13 authored by wildfirecode13's avatar wildfirecode13

1

parent eebaf73d
...@@ -11,7 +11,6 @@ ...@@ -11,7 +11,6 @@
"dependencies": { "dependencies": {
"@spark/api-base": "^1.0.11", "@spark/api-base": "^1.0.11",
"@spark/projectx": "^1.0.3", "@spark/projectx": "^1.0.3",
"@spark/share": "^1.0.29",
"axios": "^0.19.2", "axios": "^0.19.2",
"css-loader": "^3.6.0", "css-loader": "^3.6.0",
"duiba-utils": "^1.0.2", "duiba-utils": "^1.0.2",
......
...@@ -11,16 +11,18 @@ ...@@ -11,16 +11,18 @@
<script src="//yun.duiba.com.cn/js-libs/rem/1.1.0/rem.min.js"></script> <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="//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> <script>
window.url = 'https://baidu.com'; window.url = 'https://baidu.com';
window.shareimg = 'https://yun.duiba.com.cn/spark/assets/e7bec756134eaca143ea54e9f6856b6a6e10d33f.png'; window.shareimg = 'https://yun.duiba.com.cn/spark/assets/e7bec756134eaca143ea54e9f6856b6a6e10d33f.png';
window.sharetitle = '欢趣专区全新升级,快来看看吧'; window.sharetitle = '欢趣专区全新升级,快来看看吧';
window.sharedesc = '养鸡养牛还能兑换更多好礼'; window.sharedesc = '养鸡养牛还能兑换更多好礼';
function getApp() { function getApp() {
return { return {
cloud: {}, cloud: {},
...@@ -44,6 +46,96 @@ ...@@ -44,6 +46,96 @@
// alert("【警告】检测到活动url中没有appID参数\n缺少该参数会导致埋点、分享、app信息获取错误。") // alert("【警告】检测到活动url中没有appID参数\n缺少该参数会导致埋点、分享、app信息获取错误。")
} }
</script> </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> </head>
<body> <body>
...@@ -64,4 +156,4 @@ ...@@ -64,4 +156,4 @@
</body> </body>
</html> </html>
\ No newline at end of file
...@@ -9,20 +9,20 @@ MD(); ...@@ -9,20 +9,20 @@ MD();
import Share from "./pages/share/share.jsx"; import Share from "./pages/share/share.jsx";
import {Weixin,start,updateShare} from '@spark/share' // import {Weixin,start,updateShare} from '@spark/share'
Weixin.debugMode = true; // Weixin.debugMode = true;
start([Weixin], (success)=>{ // start([Weixin], (success)=>{
//分享结果回调, success为是否成功 // //分享结果回调, success为是否成功
}); // });
//更新分享内容,多用于被动式分享,比如微信 // //更新分享内容,多用于被动式分享,比如微信
updateShare({ // updateShare({
title: window.sharetitle, //分享标题 // title: window.sharetitle, //分享标题
content: window.sharedesc, //分享内容 // content: window.sharedesc, //分享内容
url: location.href, //分享链接 // url: location.href, //分享链接
thumbnail: window.shareimg, //分享缩略图 // thumbnail: window.shareimg, //分享缩略图
}); // });
class App extends Component { 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