|
|
import React, {PureComponent} from 'react';
|
|
|
import './index.scss'
|
|
|
import {guochaoListApi} from '../../api/guochaoApi'
|
|
|
import {getEnv, linkToMiniApp} from "../../../../../common/utils";
|
|
|
import {getEnv, linkToMiniApp, invokeMethod} from "../../../../../common/utils";
|
|
|
import { Link } from 'react-router-dom'
|
|
|
import wx from "weixin-js-sdk";
|
|
|
import config from "../../config";
|
|
|
import wxshare from "../../../../../common/wxshare";
|
|
|
|
|
|
|
|
|
export default class top40 extends PureComponent {
|
|
|
constructor(props) {
|
|
|
document.title ='中西碰撞 潮流无界'
|
|
|
super(props);
|
|
|
this.state = {
|
|
|
env:'',
|
...
|
...
|
@@ -16,7 +19,16 @@ export default class top40 extends PureComponent { |
|
|
}
|
|
|
this.init();
|
|
|
this.scrollTop = this.scrollTop.bind(this);
|
|
|
document.title = '潮流无界';
|
|
|
let shareData={
|
|
|
title: '国潮崛起年,中西碰撞博出位!',
|
|
|
imgUrl: 'https://img01.yohoboys.com/o_1cnilugbs15ajak1gfo1d2h1p348.png?imageView2/1/w/200/h/200',
|
|
|
desc: '这里有一份中西潮流榜单,请收好!',
|
|
|
link: 'https://ad.yoho.cn/html5/2018/09/guochao/40.html',
|
|
|
success: function () {
|
|
|
|
|
|
}
|
|
|
}
|
|
|
wxshare(shareData);
|
|
|
}
|
|
|
|
|
|
async init() {
|
...
|
...
|
@@ -60,22 +72,38 @@ export default class top40 extends PureComponent { |
|
|
|
|
|
|
|
|
wxReady= async ()=> {
|
|
|
let envFlag = await getEnv();
|
|
|
if (!envFlag && navigator.userAgent.match(/miniProgram/i)) {
|
|
|
this.setState({env:"miniprogram"});
|
|
|
envFlag = true;
|
|
|
let envFlag = window.__wxjs_environment;
|
|
|
if (!envFlag && navigator.userAgent.match(/yohobuy/i)) {
|
|
|
document.addEventListener('deviceready', function () {
|
|
|
});
|
|
|
this.setState({env: "app"});
|
|
|
} else if (!envFlag && navigator.userAgent.match(/miniProgram/i)) {
|
|
|
this.setState({env: "miniprogram"});
|
|
|
envFlag = true
|
|
|
} else {
|
|
|
this.setState({env: 'h5'})
|
|
|
}
|
|
|
if (envFlag) {
|
|
|
if (wx.miniProgram.postMessage) {
|
|
|
wx.miniProgram.postMessage({
|
|
|
data: {
|
|
|
title: '潮流无界'
|
|
|
title: '中西碰撞 潮流无界'
|
|
|
}
|
|
|
});
|
|
|
}
|
|
|
this.setState({env:"miniprogram"});
|
|
|
this.setState({env: "miniprogram"});
|
|
|
}
|
|
|
};
|
|
|
goBack = () =>{
|
|
|
if(this.state.env === 'app'){
|
|
|
invokeMethod({method:'go.back'})
|
|
|
}else if(this.state.env === 'miniprogram'){
|
|
|
wx.miniProgram.navigateBack();
|
|
|
}else{
|
|
|
history.go(-1);
|
|
|
}
|
|
|
}
|
|
|
|
|
|
render() {
|
|
|
let {data ,env} = this.state;
|
|
|
let list = (data, select) =>{
|
...
|
...
|
@@ -94,7 +122,7 @@ export default class top40 extends PureComponent { |
|
|
}
|
|
|
return (
|
|
|
<div className='wrap'>
|
|
|
<a href={config.routerPath+'/guochao.html'} className='back'></a>
|
|
|
<a onClick={()=>{this.goBack()}} className='back'></a>
|
|
|
<div onClick={this.scrollTop} className={this.state.display?'toTop':''}></div>
|
|
|
<div className='up'>
|
|
|
{list(data,0)}
|
...
|
...
|
|