|
@@ -166,7 +166,7 @@ import FreeUserAdvancedMask from '@/views/article/components/FreeUserAdvancedMas
|
|
|
import ThirdPartyVerifyPopup from '@/views/article/components/ThirdPartyVerifyPopup.vue'
|
|
|
import { throttle } from 'lodash'
|
|
|
import { mapState, mapMutations, mapActions, mapGetters } from 'vuex'
|
|
|
-import { getArticleShareInfo } from '@/api/modules/article'
|
|
|
+import { getArticleShareInfo, getContentShareEncrypt } from '@/api/modules/article'
|
|
|
import { LINKS } from '@/data'
|
|
|
import { openAppOrWxPage } from '@/utils/'
|
|
|
import setPageTdk from '@/utils/mixins/modules/set-tdk'
|
|
@@ -256,6 +256,10 @@ export default {
|
|
|
popup: {
|
|
|
thirdPartyVerify: false
|
|
|
},
|
|
|
+ wxShareCache: {
|
|
|
+ encryptid: '',
|
|
|
+ subhref: ''
|
|
|
+ },
|
|
|
pageState: {
|
|
|
id: '',
|
|
|
tabActive: ''
|
|
@@ -271,6 +275,9 @@ export default {
|
|
|
expandModel: (state) => state.article.expandModel,
|
|
|
otherModel: (state) => state.article.otherModel
|
|
|
}),
|
|
|
+ openid() {
|
|
|
+ return this.preAgentInfo.openid
|
|
|
+ },
|
|
|
...mapGetters('user', [
|
|
|
'isLogin',
|
|
|
'isSuper',
|
|
@@ -304,9 +311,9 @@ export default {
|
|
|
return (this.$envs.inWX ? 'jy' : 'jyapp') + '-wxcontent-bottom'
|
|
|
}
|
|
|
},
|
|
|
- created() {
|
|
|
+ async created() {
|
|
|
this.appHeaderActions()
|
|
|
- this.getPageState()
|
|
|
+ await this.getPageState()
|
|
|
this.initAppWxShare()
|
|
|
},
|
|
|
mounted() {
|
|
@@ -496,9 +503,14 @@ export default {
|
|
|
doShare() {
|
|
|
this.shareShow = true
|
|
|
},
|
|
|
- initAppWxShare() {
|
|
|
+ async initAppWxShare() {
|
|
|
if (this.$envs.inWX) {
|
|
|
- this.calcWxShareInfo()
|
|
|
+ try {
|
|
|
+ await this.getShareInfoReq()
|
|
|
+ } catch (error) {
|
|
|
+ console.log(error)
|
|
|
+ }
|
|
|
+ await this.calcWxShareInfo()
|
|
|
this.initShareMixin()
|
|
|
} else {
|
|
|
this.getShareInfoReq()
|
|
@@ -514,21 +526,86 @@ export default {
|
|
|
this.shareInfoRes = data
|
|
|
}
|
|
|
},
|
|
|
- calcWxShareInfo() {
|
|
|
- this.shareConf.title = this.getRandomShareText()
|
|
|
- this.shareConf.content = '全国招标信息免费看,不遮挡'
|
|
|
- this.shareConf.pathname = '/swordfish/about'
|
|
|
+ async calcWxShareInfo() {
|
|
|
+ const host = location.host
|
|
|
+ const id = this.content.id
|
|
|
+ const openid = this.openid ? encodeURIComponent(this.openid) : '-1'
|
|
|
+
|
|
|
+ // 计算title
|
|
|
+ const title = this.content.title
|
|
|
+ .replace(/<\/?.+?>/g, '')
|
|
|
+ .replace(/ /g, '')
|
|
|
+
|
|
|
+ // 计算content
|
|
|
+ const contentList = ['您的好友']
|
|
|
+ // 分享到微信或者朋友圈带上昵称
|
|
|
+ if (this.shareInfoRes.nickname) {
|
|
|
+ contentList.push(this.shareInfoRes.nickname)
|
|
|
+ }
|
|
|
+ contentList.push('向您推荐了剑鱼标讯')
|
|
|
+ const content = contentList.join('')
|
|
|
+
|
|
|
+ let link = `${host}/swordfish/about?param=${openid}__jy_extend&qrcodeType=wx_infocontent_timeline_z`
|
|
|
+ if (window.location.href.indexOf('open_infocontent') > -1) {
|
|
|
+ const query = window.location.search.slice(1)
|
|
|
+ link += `${query}`
|
|
|
+ } else {
|
|
|
+ link += '&source=wx_infocontentshare'
|
|
|
+ }
|
|
|
+
|
|
|
+ let subhref = location.href
|
|
|
+ let encryptid = ''
|
|
|
+ if (id) {
|
|
|
+ try {
|
|
|
+ const data = await getContentShareEncrypt({ id })
|
|
|
+ if(data.flag === 'T'){
|
|
|
+ encryptid = data.sid_openid
|
|
|
+ this.wxShareCache.encryptid = encryptid
|
|
|
+ var add1 = subhref.substring(0,subhref.indexOf('/content/'))
|
|
|
+ var add2 = subhref.substring(subhref.indexOf('.html'))
|
|
|
+ subhref = add1 + '/content/' + encryptid + add2
|
|
|
+ this.wxShareCache.subhref = subhref
|
|
|
+ }
|
|
|
+ } catch (error) {
|
|
|
+ console.warn(error)
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ if (encryptid) {
|
|
|
+ link = subhref
|
|
|
+ } else {
|
|
|
+ link = window.location.href
|
|
|
+ }
|
|
|
+ if (link.indexOf('?') === -1){
|
|
|
+ link += '?'
|
|
|
+ } else {
|
|
|
+ link += '&'
|
|
|
+ }
|
|
|
+ if(!encryptid){
|
|
|
+ link += `openid=${openid}&`
|
|
|
+ }
|
|
|
+ link += 'source=wx_infocontentshare'
|
|
|
+
|
|
|
+
|
|
|
+ this.shareConf.title = title
|
|
|
+ this.shareConf.content = content
|
|
|
+ this.shareConf.link = link
|
|
|
+
|
|
|
+ // const url = new URL(link)
|
|
|
+ // this.shareConf.pathname = url.pathname
|
|
|
+ // this.refreshShareLink()
|
|
|
+ console.log(JSON.stringify(this.shareConf))
|
|
|
},
|
|
|
calcAppShareInfo(t) {
|
|
|
const shareType = t.id
|
|
|
|
|
|
- const titleList = ['您的好友']
|
|
|
+ const contentList = ['您的好友']
|
|
|
// 分享到微信或者朋友圈带上昵称
|
|
|
if (this.shareInfoRes.nickname && shareType !== 2) {
|
|
|
- titleList.push(this.shareInfoRes.nickname)
|
|
|
+ contentList.push(this.shareInfoRes.nickname)
|
|
|
}
|
|
|
- titleList.push('向您推荐了剑鱼标讯')
|
|
|
- const content = titleList.join('')
|
|
|
+ contentList.push('向您推荐了剑鱼标讯')
|
|
|
+ const content = contentList.join('')
|
|
|
|
|
|
let link = `/swordfish/about?source=app_infocontentshare&from=${
|
|
|
this.shareInfoRes.userId || ''
|