Commit 50f7de97 by xuzhenghua

头像

parent 08b54cab
import React, { Component } from 'react'
import { HeaderBar } from '@/common'
import { http } from '@/utils'
import React, {Component} from 'react'
import {HeaderBar} from '@/common'
import {http} from '@/utils'
import './index.scss'
import QRCode from 'qrcode'
import html2canvas from 'html2canvas'
import scoreIconL from '@assets/image/score_icon-l.png'
import scoreIconR from '@assets/image/score_icon-r.png'
import scoreReportBg from '@assets/image/scoreReport_bg.png'
import { connect } from "react-redux"
import {connect} from "react-redux"
@connect(state => ({
user: state.user,
......@@ -23,7 +23,7 @@ class scoreReport extends Component {
myRankList: '',
imgUrl: '',
codeSrc: '',
avatar_file: '',
avatar_file: ''
}
}
......@@ -38,6 +38,14 @@ class scoreReport extends Component {
this.handleFetchInfo(0)
}
shouldComponentUpdate(nextProps, nextState, nextContext) {
if (this.props.user.data.avatar!==nextProps.user.data.avatar) {
this.getCanvas()
return false
}
return true
}
getCanvas() {
let _this = this
......@@ -64,7 +72,7 @@ class scoreReport extends Component {
// 获取二维码
getCodeWe() {
let _this = this
let qrCodeLink = '/ai-test'
let qrCodeLink = `${API.m}/ai-test`
return new Promise(resolve => {
QRCode.toDataURL(qrCodeLink, {}, function (err, url) {
_this.setState({
......@@ -80,15 +88,14 @@ class scoreReport extends Component {
const {code, data} = res.data
if (code === 200) {
this.setState({
myRankList: data,
myRankList: data
})
let avatar = this.props.user && this.props.user.data.avatar
this.getBase64(avatar)
setTimeout(() => {
this.getCanvas()
}, 100)
},100)
}
})
}
......
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