|
|
import React, {PureComponent} from 'react';
|
|
|
import './index.scss'
|
|
|
import {collectApi} from '../../api/guochaoApi'
|
|
|
import {collectApi ,checkFavApi} from '../../api/guochaoApi'
|
|
|
import {getQueryObj,linkToMiniApp, invokeMethod,getEnv} from '../../../../../common/utils';
|
|
|
import { Link } from 'react-router-dom'
|
|
|
import wx from 'weixin-js-sdk';
|
...
|
...
|
@@ -11,17 +11,23 @@ export default class guochaoHome extends PureComponent { |
|
|
super(props);
|
|
|
this.state = {
|
|
|
env:'',
|
|
|
storage : window.localStorage,
|
|
|
storage : {},
|
|
|
display:false,
|
|
|
}
|
|
|
this.scrollTop = this.scrollTop.bind(this);
|
|
|
document.title = "YOHO 潮牌榜单";
|
|
|
this.init();
|
|
|
document.title = "中西碰撞";
|
|
|
}
|
|
|
init = async () =>{
|
|
|
await this.wxReady();
|
|
|
let result = await checkFavApi({uid:getQueryObj().uid,sessionKey:getQueryObj().session_key });
|
|
|
this.setState({
|
|
|
storage: result.data
|
|
|
})
|
|
|
}
|
|
|
|
|
|
collect = async (id) => {
|
|
|
let localStorage = window.localStorage;
|
|
|
//判断是否是clicked
|
|
|
if(localStorage[id]){
|
|
|
if(this.state.storage[id]){
|
|
|
return;
|
|
|
}else{
|
|
|
//判断用户登陆 未登陆跳登陆
|
...
|
...
|
@@ -33,22 +39,20 @@ export default class guochaoHome extends PureComponent { |
|
|
}
|
|
|
}
|
|
|
//发送请求
|
|
|
let result = await collectApi({id:id,uid:getQueryObj().uid,sessionKey:getQueryObj().session_key });
|
|
|
let result = await collectApi({id:id,uid:getQueryObj().uid,sessionKey:getQueryObj().session_key });
|
|
|
if(!result.result)
|
|
|
return;
|
|
|
//替换图标 本地存储
|
|
|
let storage = this.state.storage;
|
|
|
storage[id] = 'true';
|
|
|
storage[id] = true;
|
|
|
this.setState({
|
|
|
storage
|
|
|
})
|
|
|
localStorage[id] = 'true';
|
|
|
this.forceUpdate();
|
|
|
}
|
|
|
};
|
|
|
|
|
|
componentDidMount= ()=> {
|
|
|
this.wxReady();
|
|
|
window.addEventListener('scroll',this.handleScroll);
|
|
|
};
|
|
|
|
...
|
...
|
@@ -75,7 +79,7 @@ export default class guochaoHome extends PureComponent { |
|
|
if (wx.miniProgram.postMessage) {
|
|
|
wx.miniProgram.postMessage({
|
|
|
data: {
|
|
|
title: 'YOHO 潮牌榜单'
|
|
|
title: '中西碰撞'
|
|
|
}
|
|
|
});
|
|
|
}
|
...
|
...
|
@@ -84,7 +88,15 @@ export default class guochaoHome extends PureComponent { |
|
|
};
|
|
|
|
|
|
scrollTop= ()=> {
|
|
|
window.scrollTo({top:0,left:0,behavior:"smooth"})
|
|
|
let _this = this;
|
|
|
let timer = setTimeout(function() {
|
|
|
window.scrollBy(0, -100);
|
|
|
if (window.pageYOffset <= 0) {
|
|
|
clearTimeout(timer);
|
|
|
}else{
|
|
|
_this.scrollTop();
|
|
|
}
|
|
|
}, 20);
|
|
|
};
|
|
|
|
|
|
render (){
|
...
|
...
|
@@ -215,12 +227,12 @@ export default class guochaoHome extends PureComponent { |
|
|
href={env === "miniprogram" ? "javascript:void(0)" : 'http://search.m.yohobuy.com/?filter_poolId=26490&title=机能&openby:yohobuy={"action":"go.poollist","params":{"title":"机能","productPool":"26490"}}'}></a>
|
|
|
</div>
|
|
|
<div className='part4'>
|
|
|
<div className={this.state.storage[1282]?'item_4_1 clicked':'item_4_1 unclick'} onClick={()=>{this.collect(1282)}}></div>
|
|
|
<a className='block_4_1'
|
|
|
<div className={this.state.storage[1282]?'item_4_2 clicked':'item_4_2 unclick'} onClick={()=>{this.collect(1282)}}></div>
|
|
|
<a className='block_4_2'
|
|
|
data-url='/pages/goodsList/brandStore?shop_id=1282&shop_name=SANKUANZ' onClick={linkToMiniApp} data-type="miniApp"
|
|
|
href={env === "miniprogram" ? "javascript:void(0)" :'https://m.yohobuy.com/product/index/brand?shop_id=1282&openby:yohobuy={"action":"go.shop","params":{"shop_id":"1282","shop_template_type":"1","shop_name":"SANKUANZ","is_red_shop":"1"}}'}></a>
|
|
|
<div className={this.state.storage[2312]?'item_4_2 clicked':'item_4_2 unclick'} onClick={()=>{this.collect(2312)}}></div>
|
|
|
<a className='block_4_2'
|
|
|
<div className={this.state.storage[2312]?'item_4_1 clicked':'item_4_1 unclick'} onClick={()=>{this.collect(2312)}}></div>
|
|
|
<a className='block_4_1'
|
|
|
data-url='/pages/goodsList/brandStore?shop_id=2312&shop_name=UNDERCOVER' onClick={linkToMiniApp} data-type="miniApp"
|
|
|
href={env === "miniprogram" ? "javascript:void(0)" : 'https://m.yohobuy.com/product/index/brand?shop_id=2312&openby:yohobuy={"action":"go.shop","params":{"shop_id":"2312","shop_template_type":"1","shop_name":"UNDERCOVER","is_red_shop":"1"}}'}></a>
|
|
|
<div className={this.state.storage[1878]?'item_4_3 clicked':'item_4_3 unclick'} onClick={()=>{this.collect(1878)}}></div>
|
...
|
...
|
|