Commit 68d68698 by FE

Merge branch '11-11' of gitlab.julyedu.com:baiguangyao/mr-julyedu into 11-11

parents be5dbe2c 015bdece
...@@ -20,7 +20,11 @@ import { CopyToClipboard } from 'react-copy-to-clipboard' ...@@ -20,7 +20,11 @@ import { CopyToClipboard } from 'react-copy-to-clipboard'
import { Toast } from "antd-mobile" import { Toast } from "antd-mobile"
import Live from './live' import Live from './live'
import Banner from './banner' import Banner from './banner'
import jsCookie from "js-cookie"; import cookie from "js-cookie";
import {setCurrentUser, startFetchUser} from "@/store/userAction"
import {addDays} from "date-fns";
import {compose} from "redux";
import {connect} from "react-redux";
...@@ -31,6 +35,7 @@ class BlessingPreheat extends Component { ...@@ -31,6 +35,7 @@ class BlessingPreheat extends Component {
this.navTop = 183 this.navTop = 183
this.prevY = 0 this.prevY = 0
this.state = { this.state = {
userInfoList: [],
isRule: false, isRule: false,
isCourse: false, isCourse: false,
inviteUrl: '', inviteUrl: '',
...@@ -86,8 +91,56 @@ class BlessingPreheat extends Component { ...@@ -86,8 +91,56 @@ class BlessingPreheat extends Component {
imgUrl: 'https://julyedu-cdn.oss-cn-beijing.aliyuncs.com/active19_1111/m/index-share-img.png', imgUrl: 'https://julyedu-cdn.oss-cn-beijing.aliyuncs.com/active19_1111/m/index-share-img.png',
}) })
} }
// 获取App登录信息
window['loginInfo'] = result => {
this.loginInfo(result)
}
}
// 获取app登录数据
loginInfo = (result) => {
this.setState({
userInfoList: result
})
if (this.state.userInfoList.length !== 0) {
this.props.startFetchUser()
this.appLogin()
}
}
// 保存cookie
appLogin = () => {
let expires = addDays(new Date(), 90)
this.state.userInfoList.map((item, index) => {
Toast.info(item.version, 3)
cookie.set("token", item.token, {expires, path: '/', domain: 'julyedu.com'});
cookie.set("plat", item.plat, {expires, path: '/', domain: 'julyedu.com'});
cookie.set("uid", item.uid, {expires, path: '/', domain: 'julyedu.com'});
cookie.set("uname", item.uname, {expires, path: '/', domain: 'julyedu.com'});
cookie.set("avatar_file", item.avatar_file, {expires, path: '/', domain: 'julyedu.com'});
});
this.props.setCurrentUser(this.transformUser(this.state.userInfoList))
}
transformUser = res => {
let payload
res.map((item, index) => {
payload = {
hasError: false,
data: {
username: item.uname,
avatar: item.avatar_file,
token: item.token,
uid: item.uid
},
isFetching: false
}
})
return payload
} }
getActiveIndex = (arr, n) => { getActiveIndex = (arr, n) => {
for (let i = 0, len = arr.length; i < len; i++) { for (let i = 0, len = arr.length; i < len; i++) {
if (arr[i] > n) { if (arr[i] > n) {
...@@ -142,7 +195,8 @@ class BlessingPreheat extends Component { ...@@ -142,7 +195,8 @@ class BlessingPreheat extends Component {
// H5 // H5
} }
const { userInfo } = this.state; const { userInfo } = this.state;
const {user, history} = this.props;
const uid = user && user.data && user.data.uid;
http.get(`${API.home}/sys/user/blessing`).then(res => { http.get(`${API.home}/sys/user/blessing`).then(res => {
const {code, data} = res.data const {code, data} = res.data
if (code === 200) { if (code === 200) {
...@@ -150,7 +204,7 @@ class BlessingPreheat extends Component { ...@@ -150,7 +204,7 @@ class BlessingPreheat extends Component {
isSign: !!data.today_signed, isSign: !!data.today_signed,
isFormal: data.is_activity, isFormal: data.is_activity,
userInfo: Object.assign({}, userInfo, { userInfo: Object.assign({}, userInfo, {
isLogin: !!data.is_login, isLogin: !!uid,
blessingVal: data.user_blessing_value, blessingVal: data.user_blessing_value,
buyBlessing: (data.types_total_blessing_value &&data.types_total_blessing_value.buy_course)? data.types_total_blessing_value.buy_course : 0, buyBlessing: (data.types_total_blessing_value &&data.types_total_blessing_value.buy_course)? data.types_total_blessing_value.buy_course : 0,
inviteBlessing: (data.types_total_blessing_value &&data.types_total_blessing_value.invite)? data.types_total_blessing_value.invite : 0, inviteBlessing: (data.types_total_blessing_value &&data.types_total_blessing_value.invite)? data.types_total_blessing_value.invite : 0,
...@@ -265,15 +319,6 @@ class BlessingPreheat extends Component { ...@@ -265,15 +319,6 @@ class BlessingPreheat extends Component {
} }
} }
toLogin = () => {
const { history } = this.props;
if(!getParam('version')) {
history.push('/passport');
}else{
SendMessageToApp("toLogin");
}
}
onCopy = () => { onCopy = () => {
Toast.info('复制成功', 2, null, false) Toast.info('复制成功', 2, null, false)
} }
...@@ -474,4 +519,9 @@ class BlessingPreheat extends Component { ...@@ -474,4 +519,9 @@ class BlessingPreheat extends Component {
} }
} }
export default BlessingPreheat export default compose(
connect(
state => ({user: state.user}),
{setCurrentUser, startFetchUser}
)
)(BlessingPreheat)
\ No newline at end of file
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