Commit 50f7de97 by xuzhenghua

头像

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