Commit 7b9c9a55 by 李伟康

提交代码

1 parent 474f6825
...@@ -11,8 +11,10 @@ ...@@ -11,8 +11,10 @@
import { import {
reportData reportData
} from '~/api/index.js' } from '~/api/index.js'
import USERAPI from '~/api/usersApi/index'
const _WXUSERINFO_ = Symbol('_WXUSERINFO_')
class Share { class Share {
[_WXUSERINFO_] = null
constructor() { constructor() {
console.log('---------------- 分享初始化 ----------------') console.log('---------------- 分享初始化 ----------------')
this.initPageProxy() this.initPageProxy()
...@@ -29,10 +31,17 @@ class Share { ...@@ -29,10 +31,17 @@ class Share {
} }
} }
} }
async checkWxUserInfo() {
if (!this[_WXUSERINFO_]) {
const data = await USERAPI.getWXUserInfo()
this[_WXUSERINFO_] = data
}
}
/**设置全局分享 */ /**设置全局分享 */
pageLeaveProxy(page) { pageLeaveProxy(page) {
const that = this
if (page.onShareAppMessage) { if (page.onShareAppMessage) {
const that = this
this.checkWxUserInfo()
page.onShareAppMessage = function () { page.onShareAppMessage = function () {
let { let {
shareTitle, shareTitle,
...@@ -47,6 +56,7 @@ class Share { ...@@ -47,6 +56,7 @@ class Share {
if (sharePath) path = `/${sharePath}` if (sharePath) path = `/${sharePath}`
path += that.setCommonShareQuery() path += that.setCommonShareQuery()
if (shareQuery) path += `&${shareQuery}` if (shareQuery) path += `&${shareQuery}`
console.log(path)
if (!noPageAuth) path = `/login/loading/loading?url=${encodeURIComponent(path)}` if (!noPageAuth) path = `/login/loading/loading?url=${encodeURIComponent(path)}`
if (shareFun) shareFun() if (shareFun) shareFun()
if (shareTrackData) that.reportShareData(shareTrackData) if (shareTrackData) that.reportShareData(shareTrackData)
...@@ -79,7 +89,7 @@ class Share { ...@@ -79,7 +89,7 @@ class Share {
} }
} }
getCommonData() { getCommonData() {
const WXUSERINFO = wx.$storage.get('wx_user_info'), const WXUSERINFO = this[_WXUSERINFO_],
USERINFO = wx.$storage.get('userInfo') USERINFO = wx.$storage.get('userInfo')
return { return {
WXUSERINFO, WXUSERINFO,
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!