123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100 |
- <template>
- <div></div>
- </template>
- <script>
- import wx from 'weixin-js-sdk'
- import * as API_WeiXin from '@/apis/weixin'
- export default {
- name: 'Share',
- props: {
-
- },
- data() {
- return {
- url:'',
- isLoading: false,
- nowItem: {
- shareTitle: '',
- shareImg: '',
- shareDescription: ''
- }
- }
- },
- created() {},
- methods: {
-
- //获取微信jssdk配置信息
- get_wx_config() {
- this.isLoading = true;
- API_WeiXin.getConfig(window.location.href.split("#")[0]).then(response => {
- this.isLoading = false;
- var wxconfig = response.wxConfig;
- console.log(wxconfig.nonceStr)
- this.wxConfig = wxconfig;
- wx.config({
- debug: false, // 开启调试模式,
- appId: wxconfig.appId, // 必填,企业号的唯一标识,此处填写企业号corpid
- timestamp: wxconfig.timestamp, // 必填,生成签名的时间戳
- nonceStr: wxconfig.nonceStr, // 必填,生成签名的随机串
- signature: wxconfig.signature, // 必填,签名,见附录1
- jsApiList: ['onMenuShareTimeline', 'onMenuShareAppMessage', 'onMenuShareQQ', 'onMenuShareQZone'] // 必填,需要使用的JS接口列表,所有JS接口列表见附录2
- });
- //this.wxShare()
- }).catch(error => {
- this.isLoading = false;
- this.mui.toast(error);
- })
- },
- setUrl(url){
- this.url=window.location.href.split("#")[0]+"#"+url;
- },
- setTitle(text){
- this.title=text;
- this.wxShare()
-
- },
- //微信分享自定义
- wxShare() {
- var img=window.location.href.split("#")[0]+"/"+require("@/assets/img/logo_qilian.jpg")
- console.log(this.nowItem);
- var title="[荆州市企业联合会]"+this.title
- // var desc=
- let joinUrl = this.url;
- var _this = this;
- wx.ready(function() {
- wx.onMenuShareAppMessage({
- title: title,
- // desc:desc ,
- link: joinUrl,
- imgUrl: img,
- success: function() {
- // 设置成功
- _this.$emit("wxShare",null);
- }
- })
- wx.onMenuShareTimeline({
- title: title,
- //desc:desc ,
- link: joinUrl,
- imgUrl: img,
- success: function() {
- // 设置成功
- _this.$emit("wxShare",null);
- }
- })
- });
- }
- },
- mounted() {
- this.url=window.location.href;
- this.get_wx_config();
- },
- }
- </script>
- <style>
- </style>
|