Commit 56007b4b authored by 俞嘉婷's avatar 俞嘉婷

feat: 微信分享

parent 43600382
import { showPanel, showToast } from "../Module/UIFast";
import { wxShare } from "./Utils/Share";
import { getUrlParam } from "./Utils/Utils";
import { WebNetName, getWebData, sendWebNet, sendWebNetWithToken, getProjectId } from "./Utils/WebNet/WebNet";
import { UIMgr } from "db://assets/Module/UIMgr";
......@@ -34,21 +35,14 @@ export default class ShareCenter {
const inviteInfo = shareInfo.filter(item => item.type == type)[0]
if (this.isWeChat()) {
UIMgr.ins.showShare();
// FISH_TODO
// onUpdateShare({
// title: inviteInfo?.title,
// content: inviteInfo?.content,
// url: url,
// thumbnail: inviteInfo?.thumbnail,
// });
wxShare({
title: inviteInfo?.title,
content: inviteInfo?.content,
url: url,
thumbnail: inviteInfo?.thumbnail,
});
return;
}
console.info({
title: inviteInfo?.title,
content: inviteInfo?.content,
url: url,
thumbnail: inviteInfo?.thumbnail,
});
if (type == 'main') return; //初始化拦截
// @ts-ignore
MFS.share({
......
// 更新分享
export function wxShare(shareOpt) {
const { title, content, url, thumbnail } = shareOpt || {};
let share = {
title,
desc: content,
link: url,
imgUrl: thumbnail
};
console.info('wxShare分享信息', share)
// @ts-ignore
wx.onMenuShareTimeline({
title: share.title,
desc: share.desc,
link: share.link,
imgUrl: share.imgUrl,
success: function () {
},
cancel: function () {
}
});
// @ts-ignore
wx.onMenuShareAppMessage({
title: share.title,
desc: share.desc,
link: share.link,
imgUrl: share.imgUrl,
success: function () {
},
cancel: function () {
}
});
}
// 初始化微信分享
export function initWx(url = location.href) {
return new Promise(function (resolve) {
$.ajax({
type: 'get',
url: '/wechatShare/getShareInfo/v2',
data: {
wxdebug: false,
url: url
},
cache: false,
dataType: 'json',
success: function (res) {
if (!res.success) {
resolve(false)
return;
}
// @ts-ignore
wx.config({
debug: false,
appId: res.wxappid,
timestamp: res.wxtimestamp,
nonceStr: res.wxnonceStr,
signature: res.wxsignature,
jsApiList: ['checkJsApi', 'onMenuShareTimeline', 'onMenuShareAppMessage']
});
// @ts-ignore
wx.error(function (res) {
console.error("wx error", res);
resolve(false)
});
// @ts-ignore
wx.ready(function () {
resolve(true)
});
},
error: function (err) {
resolve(false)
}
});
})
}
{
"ver": "4.0.24",
"importer": "typescript",
"imported": true,
"uuid": "9ffc1043-7bca-400a-b14b-1a81a5c8c1b2",
"files": [],
"subMetas": {},
"userData": {}
}
......@@ -21,6 +21,7 @@ import store from '../Scripts/store/store';
import { getPreLoadList, preload } from "../Scripts/Utils/LoaderTools";
import { runMainPage } from "../Scripts/Scenes/runMain/runMainPage";
import ShareCenter from "../Scripts/ShareCenter";
import { initWx } from "../Scripts/Utils/Share";
const { ccclass, property } = _decorator;
......@@ -67,6 +68,8 @@ export class Start extends Component {
window.location.href = "https://wechat.urcb.com/store/index"
// window.location.href = "https://wxyhtst.urcb.com/store/index"
}
await initWx();
ShareCenter.ins.doShare('main');
}
......
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