7 changed files with 161 additions and 31 deletions
Split View
Diff Options
-
6package.json
-
BINsrc/assets/images/icon/wx-icon.png
-
70src/main.js
-
72src/models/wxShare.js
-
6src/router/index.js
-
26src/view/home.vue
-
12src/view/poster.vue
@ -0,0 +1,72 @@ |
|||
|
|||
import Vue from 'vue' |
|||
import wx from 'weixin-js-sdk' |
|||
import axios from 'axios' |
|||
import utilsModel from './utils-model' |
|||
//微信分享功能
|
|||
|
|||
//Vue.prototype.wxShareL = function(link,params) {
|
|||
//// homeApi.getGoods(params).then(res => {})
|
|||
//// getGoods : (params) =>
|
|||
//// utilsModel
|
|||
//// .config(homeApi.getGoods)
|
|||
//// .request({
|
|||
//// params : params,
|
|||
//// }),
|
|||
// var getNews = function(params) =>
|
|||
// utilsModel
|
|||
// .config({
|
|||
// method: 'GET',
|
|||
// url: '/mall/web/share/config',
|
|||
// })
|
|||
// .request({
|
|||
// params : params,
|
|||
// })
|
|||
// getNews(params).then(res => {
|
|||
// console.log(res)
|
|||
// })
|
|||
//}
|
|||
|
|||
|
|||
Vue.prototype.wxShare = function(params) { |
|||
//var params = params || {}
|
|||
var wxconfigApi = 'http://192.168.40.82:8808/mall/web/share/config'; |
|||
console.log(params) |
|||
// /mall/web/share/config?merchantNo=2&source=0 //首页
|
|||
// /mall/web/share/config?merchantNo=2&source=1
|
|||
// /mall/web/share/config?couponNO=2&source=1
|
|||
|
|||
axios.get(wxconfigApi,{params:params}).then(function(response) { |
|||
var response = response |
|||
var jsApiSignConfig = response.data.data.jsApiSignConfig |
|||
var shareConfig = response.data.data.shareConfig |
|||
|
|||
wx.config({ |
|||
debug: false, // 开启调试模式,开发时可以开启
|
|||
appId: jsApiSignConfig.appId, // 必填,公众号的唯一标识 由接口返回
|
|||
timestamp: jsApiSignConfig.timestamp, // 必填,生成签名的时间戳 由接口返回
|
|||
nonceStr: jsApiSignConfig.nonceStr, // 必填,生成签名的随机串 由接口返回
|
|||
signature: jsApiSignConfig.signature, // 必填,签名 由接口返回
|
|||
jsApiList: response.data.data.jsApiList |
|||
}) |
|||
console.log('jsApiSignConfig',jsApiSignConfig) |
|||
console.log('shareConfig',shareConfig) |
|||
|
|||
|
|||
wx.ready(() => { |
|||
//获取“分享给朋友”按钮点击状态及自定义分享内容接口
|
|||
wx.onMenuShareAppMessage({ // 分享给朋友
|
|||
title: shareConfig.title, // 分享标题
|
|||
desc: shareConfig.desc, // 分享描述
|
|||
link: shareConfig.url, // 分享链接 默认以当前链接
|
|||
imgUrl: shareConfig.img, // 分享图标
|
|||
}) |
|||
}) |
|||
|
|||
|
|||
}) |
|||
.catch(function(error) { |
|||
console.log(error); |
|||
}); |
|||
|
|||
} |
|||
Write
Preview
Loading…
Cancel
Save