|
@@ -28,7 +28,7 @@
|
|
|
<div class="contacts"
|
|
|
v-show="myId?true:false">
|
|
|
<div>
|
|
|
- <h3>{{ menuberinfo }}</h3>
|
|
|
+ <h1>{{ menuberinfo }}</h1>
|
|
|
<!-- <div style="padding-bottom: 2vh;">河南建工集团||董事长</div> -->
|
|
|
<div style="margin-bottom: 3vw;"><span class="iconfont icon-weixin"
|
|
|
@click="showPopup"></span><span class="iconfont icon-dianhua"
|
|
@@ -60,6 +60,7 @@ export default {
|
|
|
data () {
|
|
|
return {
|
|
|
textdetaildata: {},
|
|
|
+ article_id: "",
|
|
|
isgood: '',
|
|
|
show: false,
|
|
|
menuberinfo: '',
|
|
@@ -76,23 +77,21 @@ export default {
|
|
|
}
|
|
|
},
|
|
|
created () {
|
|
|
-
|
|
|
- },
|
|
|
- mounted () {
|
|
|
+ if (!this.$route.query.id || this.$route.query.id === "" || this.$route.query.id === "undefined") {
|
|
|
+ Toast("页面参数错误");
|
|
|
+ return false
|
|
|
+ }
|
|
|
+ this.article_id = this.$route.query.id;
|
|
|
if (!this.myId) {
|
|
|
- this.myId = storage.getLocalstorage('user_id')
|
|
|
+ this.myId = storage.getLocalstorage('user_id')
|
|
|
}
|
|
|
if (this.myId != null && this.myId !== '' && this.myId !== 'undefined') {
|
|
|
this.getMemberapi(this.myId)
|
|
|
}
|
|
|
- if (this.$route.query.id) {
|
|
|
- this.textdetailapi(this.$route.query.id, this.myId)
|
|
|
- //获取分享的参数 执行config
|
|
|
- this.getUserIdparameter()
|
|
|
- } else {
|
|
|
- this.textdetailapi()
|
|
|
- }
|
|
|
- console.log('------------------', this.$route.query.id)
|
|
|
+ this.getUserIdparameter({'url': location.href.split('#')[0]})
|
|
|
+ },
|
|
|
+ mounted () {
|
|
|
+ this.textdetailapi(this.article_id, this.myId);
|
|
|
},
|
|
|
components: { Popup },
|
|
|
methods: {
|
|
@@ -105,33 +104,27 @@ export default {
|
|
|
if (this.isgood) {
|
|
|
Toast.fail('不能取消点赞');
|
|
|
} else {
|
|
|
- clkgoodInfo(this.$route.query.id, 'WeiQiJia')
|
|
|
+ clkgoodInfo(this.article_id, this.myId)
|
|
|
this.isgood = true
|
|
|
Toast.success('点赞成功');
|
|
|
- console.log(1111);
|
|
|
}
|
|
|
|
|
|
},
|
|
|
//文章详情接口
|
|
|
async textdetailapi (id, userId) {
|
|
|
- const res = await getArticleCategoryDetail(id, userId)
|
|
|
- if (res.code == 2000) {
|
|
|
- this.textdetaildata = res.data
|
|
|
- this.isgood = res.data.like
|
|
|
- // this.textdetaildata.flag = false
|
|
|
- // if (!res.data.flag) this.clkgood()
|
|
|
- console.log(res.data);
|
|
|
+ const res = await getArticleCategoryDetail(id, userId);
|
|
|
+ if (res.code === 2000) {
|
|
|
+ this.textdetaildata = res.data;
|
|
|
+ this.isgood = res.data.like;
|
|
|
}
|
|
|
|
|
|
- // this.isgood = res.data.like
|
|
|
},
|
|
|
GoUp () {
|
|
|
this.$router.go(-1)
|
|
|
},
|
|
|
//分享到对话框
|
|
|
shareDialogue () {
|
|
|
- var wx = window.wx
|
|
|
- wx.invoke(
|
|
|
+ window.wx.invoke(
|
|
|
"shareAppMessage", {
|
|
|
title: '', // 分享标题
|
|
|
desc: '', // 分享描述
|
|
@@ -139,7 +132,7 @@ export default {
|
|
|
imgUrl: '', // 分享封面
|
|
|
enableIdTrans: 0, // 是否开启id转译,不填默认为0
|
|
|
}, function (res) {
|
|
|
- if (res.err_msg == "shareAppMessage:ok") {
|
|
|
+ if (res.err_msg === "shareAppMessage:ok") {
|
|
|
//正确处理
|
|
|
} else {
|
|
|
//错误处理
|
|
@@ -150,13 +143,12 @@ export default {
|
|
|
//获取个人信息 //WeiQiJia
|
|
|
async getMemberapi (user_id) {
|
|
|
const res = await getMember(user_id)
|
|
|
- if (res.code == 2000) {
|
|
|
+ if (res.code === 2000) {
|
|
|
this.menuberinfo = res.data.name
|
|
|
this.avatar = res.data.avatar
|
|
|
this.phone = res.data.tel
|
|
|
this.qrcode = res.data.qrcode
|
|
|
}
|
|
|
- console.log(res)
|
|
|
},
|
|
|
//打电话
|
|
|
callPhone () {
|
|
@@ -164,25 +156,25 @@ export default {
|
|
|
},
|
|
|
//获取分享参数 在wx.ready执行分享的事件分享到朋友/朋友圈等
|
|
|
async getShareParmasinfo (id,myId) {
|
|
|
- const res = await getShareParmas(id,myId)
|
|
|
- console.log(res)
|
|
|
- this.shareData.title = res.data.title
|
|
|
- this.shareData.desc = res.data.desc
|
|
|
- this.shareData.link = res.data.link
|
|
|
- this.shareData.imgUrl = res.data.image
|
|
|
+ const res = await getShareParmas(id,myId);
|
|
|
+ let { title, desc, link, image } = res.data;
|
|
|
+ this.shareData.title = title;
|
|
|
+ this.shareData.desc = desc;
|
|
|
+ this.shareData.link = link;
|
|
|
+ this.shareData.imgUrl = image;
|
|
|
window.wx.onMenuShareAppMessage({
|
|
|
- title: res.data.title, // 分享标题
|
|
|
- desc: res.data.desc, // 分享描述
|
|
|
- link: res.data.link, // 分享链接;在微信上分享时,该链接的域名必须与企业某个应用的可信域名一致
|
|
|
- imgUrl: res.data.image, // 分享图标
|
|
|
+ title: title, // 分享标题
|
|
|
+ desc: desc, // 分享描述
|
|
|
+ link: link, // 分享链接;在微信上分享时,该链接的域名必须与企业某个应用的可信域名一致
|
|
|
+ imgUrl: image, // 分享图标
|
|
|
enableIdTrans: 0, // 是否开启id转译,不填默认为0
|
|
|
success: function () {
|
|
|
- this.postShareinfo({article:this.$route.query.id,userid:this.myId})
|
|
|
+ postShareinfo({'article':id,'userid':myId})
|
|
|
// 用户确认分享后执行的回调函数
|
|
|
},
|
|
|
error: function (res) {
|
|
|
if (res.errMsg.indexOf('no permission') > 0) {
|
|
|
- console.log('未agentConfig')
|
|
|
+ alert.log('未agentConfig')
|
|
|
}
|
|
|
},
|
|
|
cancel: function () {
|
|
@@ -190,14 +182,30 @@ export default {
|
|
|
}
|
|
|
});
|
|
|
window.wx.onMenuShareTimeline({
|
|
|
- title: res.data.title, // 分享标题
|
|
|
- desc: res.data.desc, // 分享描述
|
|
|
- link: res.data.link, // 分享链接;在微信上分享时,该链接的域名必须与企业某个应用的可信域名一致
|
|
|
- imgUrl: res.data.image, // 分享图标
|
|
|
+ title: title, // 分享标题
|
|
|
+ link: link, // 分享链接;在微信上分享时,该链接的域名必须与企业某个应用的可信域名一致
|
|
|
+ imgUrl: image, // 分享图标
|
|
|
enableIdTrans: 0, // 是否开启id转译,不填默认为0
|
|
|
success: function () {
|
|
|
- this.postShareinfo({article:this.$route.query.id,userid:this.myId})
|
|
|
- // 用户确认分享后执行的回调函数
|
|
|
+ postShareinfo({'article':id,'userid':myId})
|
|
|
+ },
|
|
|
+ error: function (res) {
|
|
|
+ if (res.errMsg.indexOf('no permission') > 0) {
|
|
|
+ alert('未agentConfig')
|
|
|
+ }
|
|
|
+ },
|
|
|
+ cancel: function () {
|
|
|
+ // 用户取消分享后执行的回调函数
|
|
|
+ }
|
|
|
+ });
|
|
|
+ window.wx.onMenuShareWechat({
|
|
|
+ title: title, // 分享标题
|
|
|
+ desc: desc, // 分享描述
|
|
|
+ link: link, // 分享链接;在微信上分享时,该链接的域名必须与企业某个应用的可信域名一致
|
|
|
+ imgUrl: image, // 分享图标
|
|
|
+ enableIdTrans: 0, // 是否开启id转译,不填默认为0
|
|
|
+ success: function () {
|
|
|
+ postShareinfo({'article':id,'userid':myId})
|
|
|
},
|
|
|
error: function (res) {
|
|
|
if (res.errMsg.indexOf('no permission') > 0) {
|
|
@@ -211,62 +219,70 @@ export default {
|
|
|
|
|
|
},
|
|
|
//config
|
|
|
- async getUserIdparameter () {
|
|
|
- const res = await getparameter()
|
|
|
- window.wx.config({
|
|
|
- beta: true, // 必须这么写,否则wx.invoke调用形式的jsapi会有问题
|
|
|
- debug: true, // 开启调试模式,调用的所有api的返回值会在客户端alert出来,若要查看传入的参数,可以在pc端打开,参数信息会通过log打出,仅在pc端时才会打印。
|
|
|
- appId: res.data.appId, // 必填,企业微信的corpID
|
|
|
- timestamp: res.data.timestamp, // 必填,生成签名的时间戳
|
|
|
- nonceStr: res.data.nonceStr, // 必填,生成签名的随机串
|
|
|
- signature: res.data.signature, // 必填,签名,见 附录-JS-SDK使用权限签名算法
|
|
|
- jsApiList: ["onMenuShareTimeline", "onMenuShareAppMessage", "onMenuShareWechat"], // 必填,需要使用的JS接口列表,凡是要调用的接口都需要传进来
|
|
|
- });
|
|
|
- window.wx.ready(() => {
|
|
|
- this.getShareParmasinfo(this.$route.query.id,this.myId)
|
|
|
- })
|
|
|
- window.wx.agentConfig({
|
|
|
- corpid: res.data.appId, // 必填,企业微信的corpid,必须与当前登录的企业一致
|
|
|
- agentid: res.data.agentid, // 必填,企业微信的应用id (e.g. 1000247)
|
|
|
- timestamp: res.data.timestamp, // 必填,生成签名的时间戳
|
|
|
- nonceStr: res.data.nonceStr, // 必填,生成签名的随机串
|
|
|
- signature: res.data.agent_signature,// 必填,签名,见附录-JS-SDK使用权限签名算法
|
|
|
- jsApiList: ['shareWechatMessage'], //必填,传入需要使用的接口名称
|
|
|
- success: function (res) {
|
|
|
- console.log('agentConfig=>成功')
|
|
|
- console.log('获取agentConfig的res', res)
|
|
|
- getShareParmas(this.$route.query.id,this.myId).then(res => {
|
|
|
- window.wx.invoke('shareWechatMessage', {
|
|
|
- title: res.data.title, // 分享标题
|
|
|
- desc: res.data.desc, // 分享描述
|
|
|
- link: res.data.link, // 分享链接
|
|
|
- imgUrl: res.data.imgUrl, // 分享封面
|
|
|
- enableIdTrans: 1, // 是否开启id转译,不填默认为0
|
|
|
- }, function (res) {
|
|
|
- if (res.err_msg == "shareWechatMessage:ok") {
|
|
|
- this.postShareinfo({article:this.$route.query.id,userid:this.myId})
|
|
|
- //正确处理
|
|
|
- } else {
|
|
|
- //错误处理
|
|
|
- }
|
|
|
- });
|
|
|
-
|
|
|
+ async getUserIdparameter (url) {
|
|
|
+ let result = await getparameter(url)
|
|
|
+ if (result.code !== 2000) {
|
|
|
+ Toast(result.msg)
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+ let { appId, agentid, timestamp, nonceStr, signature, agent_signature } = result.data;
|
|
|
+ this._Config(appId, timestamp, nonceStr, signature)
|
|
|
+ .then(data=> {
|
|
|
+ return this.getShareParmasinfo(this.article_id, this.myId)
|
|
|
})
|
|
|
-
|
|
|
- },
|
|
|
- fail: function (res) {
|
|
|
- console.log('agentConfig=>失败')
|
|
|
- if (res.errMsg.indexOf('function not exist') > -1) {
|
|
|
- console.log('版本过低请升级')
|
|
|
- }
|
|
|
+ .catch(data => {
|
|
|
+ Toast(data)
|
|
|
+ })
|
|
|
+ },
|
|
|
+ _Config (appId, timestamp, nonceStr, signature) {
|
|
|
+ return new Promise(function (resolve, reject) {
|
|
|
+ const wx = window.wx;
|
|
|
+ if (!wx) {
|
|
|
+ reject("企业微信apk引入失败,尝试刷新页面!")
|
|
|
+ }
|
|
|
+ wx.config({
|
|
|
+ beta: true, // 必须这么写,否则wx.invoke调用形式的jsapi会有问题
|
|
|
+ debug: true, // 开启调试模式,调用的所有api的返回值会在客户端alert出来,若要查看传入的参数,可以在pc端打开,参数信息会通过log打出,仅在pc端时才会打印。
|
|
|
+ appId: appId, // 必填,企业微信的corpID
|
|
|
+ timestamp: timestamp, // 必填,生成签名的时间戳
|
|
|
+ nonceStr: nonceStr, // 必填,生成签名的随机串
|
|
|
+ signature: signature, // 必填,签名,见 附录-JS-SDK使用权限签名算法
|
|
|
+ jsApiList: ["agentConfig", "onMenuShareTimeline", "onMenuShareAppMessage", "onMenuShareWechat"], // 必填,需要使用的JS接口列表,凡是要调用的接口都需要传进来
|
|
|
+ });
|
|
|
+ wx.ready(function () {
|
|
|
+ resolve()
|
|
|
+ });
|
|
|
+ wx.error(function (res) {
|
|
|
+ reject("注入权限验证失败")
|
|
|
+ })
|
|
|
+ })
|
|
|
+ },
|
|
|
+ _agentConfig(appId, agentid, timestamp, nonceStr, agent_signature) {
|
|
|
+ return new Promise(function (resolve, reject) {
|
|
|
+ const wx = window.wx;
|
|
|
+ if (!wx) {
|
|
|
+ reject("企业微信apk引入失败,尝试刷新页面!")
|
|
|
}
|
|
|
+ wx.agentConfig({
|
|
|
+ corpid: appId, // 必填,企业微信的corpid,必须与当前登录的企业一致
|
|
|
+ agentid: agentid, // 必填,企业微信的应用id (e.g. 1000247)
|
|
|
+ timestamp: timestamp, // 必填,生成签名的时间戳
|
|
|
+ nonceStr: nonceStr, // 必填,生成签名的随机串
|
|
|
+ signature: agent_signature,// 必填,签名,见附录-JS-SDK使用权限签名算法
|
|
|
+ jsApiList: ['getContext', 'getCurExternalContact'], //必填,传入需要使用的接口名称
|
|
|
+ success: function (res) {
|
|
|
+ resolve()
|
|
|
+ },
|
|
|
+ fail: function (res) {
|
|
|
+ if (res.errMsg.indexOf('function not exist') > -1) {
|
|
|
+ reject("版本过低请升级")
|
|
|
+ } else {
|
|
|
+ reject("应用注入权限验证失败")
|
|
|
+ }
|
|
|
+ }
|
|
|
+ })
|
|
|
})
|
|
|
},
|
|
|
- //转发成功调用添加转发记录
|
|
|
- async postShareinfo(data){
|
|
|
- const res= await postShareinfo(data)
|
|
|
- console.log('转发成功调用添加转发记录',res)
|
|
|
- }
|
|
|
},
|
|
|
}
|
|
|
</script>
|