12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970 |
- const wx = require('weixin-js-sdk');
- const config = require('@/static/config.js');
- export default {
- install(Vue){
- Vue.mixin({
- data(){
- return {
-
- }
- },
- onLoad() {
- this.signJsapiTicket();
- },
- methods:{
- async signJsapiTicket(){
- let url = location.href.split('#')[0]
- let parmas = {
- url: url,
- }
- let self = this;
- let res = await this.$myRequest({
- url: '/wechat/signJsapiTicket',
- data: parmas,
- method:"GET",
- });
- if(res.data.success){
- let single = res.data.single;
- wx.config({
- debug: true,
- appId: config.appid,
- timestamp: single.timestamp,
- nonceStr: single.nonceStr,
- signature: single.signature,
- jsApiList: ["updateAppMessageShareData","updateTimelineShareData",'showMenuItems']
- });
- wx.ready(function() {
-
- });
- wx.error(function(res) {
-
- });
- }
- },
- config(title,desc,link,imgUrl){
- wx.showMenuItems({
- menuList: [ "menuItem:share:appMessage","menuItem:share:timeline"]
- });
- wx.updateAppMessageShareData({
- title: title,
- desc: desc,
- link: link,
- imgUrl: imgUrl,
- success: function() {
-
- }
- });
- wx.updateTimelineShareData({
- title: title,
- link: link,
- imgUrl: imgUrl,
- success: function() {
-
- }
- });
-
- }
- }
- })
- }
- }
|