Commit ec78b36f by zhanghaozhe

weixin config

parent 2f4d90b4
......@@ -5,7 +5,7 @@ import { connect } from "react-redux";
import { setCurrentUser, startFetchUser } from "@/store/userAction";
import { withRouter } from 'react-router-dom'
import { compose } from 'redux'
import { getParam, http } from "@/utils";
import { getParam, http, browser } from "@/utils";
import { Toast } from "antd-mobile";
import { addDays } from 'date-fns'
......@@ -41,6 +41,10 @@ class App extends Component {
//平台信息
cookie.set('plat', '5', {domain: '.julyedu.com'})
if(browser.isWeixin && browser.isIOS){
sessionStorage.setItem('enter_url', window.location.href)
}
this.props.startFetchUser()
http.get(`${API.home}/m/user_info`).then(res => {
this.props.setCurrentUser(this.transformUser(res))
......@@ -51,7 +55,7 @@ class App extends Component {
history.listen(location => {
const {pathname} = location
if (pathname.startsWith('/passport')) {
if(routeMatchRule.test(pathname)){
if (routeMatchRule.test(pathname)) {
return
}
location.state = {from: this.previousLocation};
......@@ -159,7 +163,12 @@ class App extends Component {
}
render() {
return <Routes/>
return (
<>
<div style={{position: 'fixed', bottom: '0', right: '0', fontSize: '20px', color: 'red', zIndex: '1000'}} onClick={e => {alert(location.href)}}>url</div>
<Routes/>
</>
)
}
}
......
......@@ -46,12 +46,14 @@ class Detail extends Component {
}
componentDidMount() {
wxShare({
title: `课程详情页`,
desc: `课程详情页`,
link: encodeURI(location.origin + '/detail?id=' + getParam('id')),
imgUrl: ''
});
if(browser.isWeixin){
wxShare({
title: `课程详情页`,
desc: `课程详情页`,
link: location.href,
imgUrl: `${location.origin}/favicon.ico`
})
}
this.fetchCourseInfo();
const { location: { state = {} } } = this.props;
......
import { http } from "@/utils/index"
import { http, browser } from "@/utils"
const url = `https://res.wx.qq.com/open/js/jweixin-1.4.0.js`
......@@ -7,7 +7,7 @@ const jsApiList = ['updateAppMessageShareData','updateTimelineShareData','onMenu
export const getSignature = async (config = {}) => {
let res = await http.post(`${API['base-api']}/m/sale/signature`, {
url: window.location.href.split('#')[0]
url: browser.isWeixin && browser.isIOS ? sessionStorage.getItem('enter_url') : window.location.href.split('#')[0],
})
return wx.config({
debug: false, // 开启调试模式,
......
import { getWXObject, getSignature } from './base'
const shareApiList = ['updateAppMessageShareData','updateTimelineShareData','onMenuShareAppMessage', 'onMenuShareTimeline']
const shareApiList = ['updateAppMessageShareData', 'updateTimelineShareData', 'onMenuShareAppMessage', 'onMenuShareTimeline']
export default async function (data = {title: '',desc: '', link: '', imgUrl: ''}) {
export default async function (data = {title: '', desc: '', link: '', imgUrl: ''}, config = {}) {
await getWXObject()
await getSignature()
await getSignature(config)
wx.ready(function () {
console.log('ready');
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment