|
@@ -28,7 +28,10 @@ export const appWxShareMixin = {
|
|
|
wx: ''
|
|
|
},
|
|
|
shareEnableConf: {
|
|
|
+ // 是否进入页面立即初始化分享流程
|
|
|
shareActionImmediate: true,
|
|
|
+ // 是否进入页面立即获取配置域名
|
|
|
+ getDomainImmediate: false,
|
|
|
app: true, // 开启app分享
|
|
|
wx: true // 开启wx分享
|
|
|
},
|
|
@@ -46,6 +49,8 @@ export const appWxShareMixin = {
|
|
|
console.log('app-wx-share')
|
|
|
if (this.shareEnableConf.shareActionImmediate) {
|
|
|
this.initShareMixin()
|
|
|
+ } else if (this.shareEnableConf.getDomainImmediate) {
|
|
|
+ this.getShareDomain()
|
|
|
}
|
|
|
},
|
|
|
methods: {
|
|
@@ -55,7 +60,7 @@ export const appWxShareMixin = {
|
|
|
} else {
|
|
|
if (this.shareEnableConf.app) {
|
|
|
if (this.shareConf.fetchDomain) {
|
|
|
- this.getShareDomain()
|
|
|
+ this.getShareDomain(true)
|
|
|
} else {
|
|
|
this.refreshShareLink()
|
|
|
this.registerWxShare()
|
|
@@ -63,22 +68,24 @@ export const appWxShareMixin = {
|
|
|
}
|
|
|
}
|
|
|
},
|
|
|
- refreshShareLink() {
|
|
|
+ refreshShareLink(origin) {
|
|
|
if (!this.shareConf.pathname) return
|
|
|
- this.shareConf.link = this.shareConf.origin + this.shareConf.pathname
|
|
|
+ const originLink = origin || this.shareConf.origin
|
|
|
+ this.shareConf.link = originLink + this.shareConf.pathname
|
|
|
},
|
|
|
- async getShareDomain() {
|
|
|
+ async getShareDomain(init = false) {
|
|
|
const { data, error_code: code, error_msg: msg } = await getAppsDomain()
|
|
|
- console.log(msg)
|
|
|
if (code === 0 && data) {
|
|
|
// app往微信分享会用到(app分享到微信,需要分享微信的域名)
|
|
|
Object.assign(this.domainConf, data)
|
|
|
- if (data.wx) {
|
|
|
- this.shareConf.origin = data.wx
|
|
|
- this.refreshShareLink()
|
|
|
- }
|
|
|
- if (this.isWeiXinBrowser) {
|
|
|
- this.registerWxShare()
|
|
|
+ if (init) {
|
|
|
+ if (data.wx) {
|
|
|
+ this.shareConf.origin = data.wx
|
|
|
+ this.refreshShareLink()
|
|
|
+ }
|
|
|
+ if (this.isWeiXinBrowser) {
|
|
|
+ this.registerWxShare()
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
},
|