Authored by huangyi

新品活动,分享修改

... ... @@ -4,7 +4,7 @@
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=no, viewport-fit=cover">
<meta http-equiv="X-UA-Compatible" content="chrome=1,IE=edge">
<title></title>
<title><%= htmlWebpackPlugin.options.title %></title>
<script>
(function(win) {
var doc = win.document;
... ...
module.exports = {
production: {
routerPath: '/html5/2018/09/guochao',
domain: '//action.yoho.cn'
domain: 'https://action.yoho.cn'
},
development: {
routerPath: '/html5/2018/09/guochao',
... ...
... ... @@ -5,8 +5,8 @@ import config from './config';
import {BrowserRouter, Route,Switch,HashRouter,hashHistory,browserHistory} from 'react-router-dom';
// import guochaoHome from './view/guochaoHome';
// import top40 from './view/top40';1
1
// import top40 from './view/top40';
import Loadable from 'react-loadable';
const guochaoHome = Loadable({
... ...
... ... @@ -2,6 +2,7 @@ import React, {PureComponent} from 'react';
import './index.scss'
import {collectApi, checkFavApi} from '../../api/guochaoApi'
import {getQueryObj, linkToMiniApp, invokeMethod, parseUrl} from '../../../../../common/utils';
import wxshare from '../../../../../common/wxshare'
import wx from 'weixin-js-sdk';
import config from '../../config';
import cookie from 'react-cookies';
... ... @@ -9,6 +10,7 @@ import LazyLoad from 'react-lazy-load'
export default class guochaoHome extends PureComponent {
constructor(props) {
document.title ='中西碰撞 潮流无界'
super(props);
this.state = {
env: '',
... ... @@ -18,15 +20,26 @@ export default class guochaoHome extends PureComponent {
}
this.scrollTop = this.scrollTop.bind(this);
this.init();
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/guochao.html',
success: function () {
}
}
wxshare(shareData);
}
init = async () => {
if(!cookie.load('app_uid') || !parseInt(cookie.load('app_uid'))){
let uid = cookie.load('app_uid') || getQueryObj().uid || 0;
if(!uid || !parseInt(uid)){
return;
}
let result = await checkFavApi({
uid: cookie.load('app_uid') || getQueryObj().uid || 0,
uid: uid,
sessionKey: cookie.load('app_session_key') || getQueryObj().session_key || '',
sessionType: cookie.load('app_client_type') || '',
appVersion: cookie.load('app_version') || ''
... ... @@ -146,7 +159,7 @@ export default class guochaoHome extends PureComponent {
if (wx.miniProgram.postMessage) {
wx.miniProgram.postMessage({
data: {
title: '中西碰撞'
title: '中西碰撞 潮流无界'
}
});
}
... ... @@ -171,7 +184,7 @@ export default class guochaoHome extends PureComponent {
return (
<div className='wrap'>
<a id='url' href={url}></a>
<a href={config.routerPath + '/top40.html'} className='top40'></a>
<a data-url={config.routerPath + '/top40.html'} onClick={linkToMiniApp} href={env === "miniprogram" ? 'javascript:void(0)' : config.routerPath + '/top40.html?openby:yohobuy={"action": "go.h5", "params": {"url": "' + location.origin + config.routerPath + '/top40.html", "title": "中西碰撞 潮流无界"}}'} className='top40'></a>
<div onClick={this.scrollTop} className={this.state.display ? 'toTop' : ''}></div>
<div className='header'>
</div>
... ...
... ... @@ -23,13 +23,15 @@
position: relative;
}
.top40{
-webkit-tap-highlight-color: transparent;
cursor:pointer;
width: 1.7rem;
background-image: url(//img01.yohoboys.com/o_1cn6aonraub5s6mg6511t96no8.png) !important;
background-repeat: no-repeat !important;
background-size: cover !important;
height: 5rem;
position: fixed;
z-index: 2;
z-index: 7;
right: 0.25rem;
top: 12.5rem;
}
... ... @@ -45,28 +47,28 @@
right: 1rem;
}
.part1{
background:url("//img01.yohoboys.com/o_1cmknihct81g12q1u686na16mt8.jpg?imageMogr2/strip/thumbnail/750") no-repeat;
background:url("//img01.yohoboys.com/o_1cmknihct81g12q1u686na16mt8.jpg?imageMogr2/strip/thumbnail/750&imageslim") no-repeat;
height: 57.2rem;
width:100%;
background-size:cover;
position: relative;
}
.part2{
background:url("//img01.yohoboys.com/o_1cmlb2qke4cb1jko1rb7losdf68.jpg?imageMogr2/strip/thumbnail/750") no-repeat;
background:url("//img01.yohoboys.com/o_1cmlb2qke4cb1jko1rb7losdf68.jpg?imageMogr2/strip/thumbnail/750&imageslim") no-repeat;
height: 59.8rem;
width:100%;
background-size:cover;
position: relative;
}
.part3{
background: url("//img01.yohoboys.com/o_1cn3vs0frhlv3s81lt51kp4k6a8.jpg?imageMogr2/strip/thumbnail/750");
background: url("//img01.yohoboys.com/o_1cn3vs0frhlv3s81lt51kp4k6a8.jpg?imageMogr2/strip/thumbnail/750&imageslim");
height: 58.7rem;
width:100%;
background-size:cover;
position: relative;
}
.part4{
background: url("//img01.yohoboys.com/o_1cn3vh086i0h5n6vsk1akcl988.jpg?imageMogr2/strip/thumbnail/750");
background: url("//img01.yohoboys.com/o_1cn3vh086i0h5n6vsk1akcl988.jpg?imageMogr2/strip/thumbnail/750&imageslim");
height: 60.6rem;
width:100%;
background-size:cover;
... ... @@ -101,6 +103,9 @@
position: absolute;
}
.unclick {
z-index: 5;
-webkit-tap-highlight-color: transparent;
cursor:pointer;
position: absolute;
border-radius: 0.17rem;
width: 2.43rem;
... ...
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)}
... ...
... ... @@ -15,6 +15,8 @@
flex-direction: row;
flex-wrap: wrap;
justify-content: space-between;
-webkit-tap-highlight-color: transparent;
cursor:pointer;
.item {
width: 260px;
... ... @@ -35,6 +37,9 @@
flex-direction: row;
flex-wrap: wrap;
justify-content: flex-start;
-webkit-tap-highlight-color: transparent;
cursor:pointer;
.item {
width: 216px;
img {
... ... @@ -54,6 +59,8 @@
right: 2.7rem;
}
.back {
-webkit-tap-highlight-color: transparent;
cursor:pointer;
width: 2.4rem;
background-image: url(//img01.yohoboys.com/o_1cn4gic5h1hfr7nqcregn72ga8.png) !important;
background-repeat: no-repeat !important;
... ...
... ... @@ -17,7 +17,8 @@ export default merge(baseConfig, {
// }),
new HtmlWebpackPlugin({
filename: 'top40.html',
template: './app/guoChao/index.html',
template: './app/guoChao/index.ejs',
title:"中西碰撞 潮流无界",
inject: true,
minify: {
removeComments: true,
... ... @@ -27,7 +28,8 @@ export default merge(baseConfig, {
}),
new HtmlWebpackPlugin({
filename: 'guochao.html',
template: './app/guoChao/index.html',
template: './app/guoChao/index.ejs',
title:"中西碰撞 潮流无界",
inject: true,
minify: {
removeComments: true,
... ...
import _ from 'lodash';
import wx from 'weixin-js-sdk';
const linkToMiniApp = (event) => {
... ... @@ -15,10 +14,9 @@ const linkToMiniApp = (event) => {
let base_url = decodeURIComponent(url).split('?')[0];
let params = getQueryObj(url);
let paramStr = '';
_.each(params, (val, key) => {
paramStr += paramStr === '' ? '?' + key + '=' + val : '&' + key + '=' + val;
});
Object.keys(params).forEach(key => {
paramStr += paramStr === '' ? '?' + key + '=' + params[key] : '&' + key + '=' + params[key];
})
let mini_url = '/pages/webview/webview?url=' + base_url;
let scene = mini_url + encodeURIComponent(paramStr);
... ...
//初始化config信息
import httpServer from './httpService';
import wx from "weixin-js-sdk";
const _weChatInterface = '//action.yoho.cn/api/share/getSignPackage';//签名等相关配置,yoho公众号
module.exports = function wxCheck(shareDate) {
httpServer.get(_weChatInterface + "?pageurl=" + encodeURIComponent(location.href.split('#')[0])).then((json) => {
if (json !== undefined && json !== '') {
var _appId = json.appId.toString();
var _timestamp = json.timestamp;
var _nonceStr = json.nonceStr.toString();
var _signature = json.signature.toString();
wx.config({
debug: false,
appId: _appId,
timestamp: _timestamp,
nonceStr: _nonceStr,
signature: _signature,
jsApiList: [
'checkJsApi',
'onMenuShareTimeline',
'onMenuShareAppMessage',
'onMenuShareQQ',
'onMenuShareWeibo',
'hideMenuItems',
'showMenuItems',
'hideAllNonBaseMenuItem',
'showAllNonBaseMenuItem',
'translateVoice',
'startRecord',
'stopRecord',
'onVoiceRecordEnd',
'playVoice',
'pauseVoice',
'stopVoice',
'uploadVoice',
'onVoicePlayEnd',
'downloadVoice',
'chooseImage',
'previewImage',
'uploadImage',
'downloadImage',
'getNetworkType',
'openLocation',
'getLocation',
'hideOptionMenu',
'showOptionMenu',
'closeWindow',
'scanQRCode',
'chooseWXPay',
'openProductSpecificView',
'addCard',
'chooseCard',
'openCard'
]
});
let share_data = shareDate || {
title: '',
imgUrl: '',
desc: '',
link: document.location.href,
success: function(){}
};
function share() {
wx.ready(function () {
//构造分享信息
var shareData = share_data;
var voice_localId = '';
var is_start = false;
// 2.1 “分享给朋友”
wx.onMenuShareAppMessage(shareData);
// 2.2 “分享到朋友圈”
wx.onMenuShareTimeline(shareData);
// 2.3 “分享到QQ”
wx.onMenuShareQQ(shareData);
// 2.4 “分享到微博”
wx.onMenuShareWeibo(shareData);
//document.getElementById('media').play();
//bindUploadEvent();
});
}
setTimeout(share, 1000);
}
else {
}
})
}
... ...
... ... @@ -73,7 +73,7 @@ module.exports = {
port: 8080,
disableHostCheck: true,
},
devtool: "cheap-eval-source-map",
devtool: "source-map",
//模块路径
resolve:{
alias: {
... ...