Authored by 盖剑秋

Order detail data. reviewed by redding.

'use strict';
import React from 'react';
import ReactNative, {
AppRegistry,
Platform,
} from 'react-native';
import ReactNative, {AppRegistry, Platform} from 'react-native';
import {
Provider,
connect
} from 'react-redux';
import {Provider, connect} from 'react-redux';
import configureStore from './store/configureStore';
import {Record, List, Map} from 'immutable';
... ... @@ -22,60 +15,51 @@ import detailInitialState from './reducers/detail/detailInitialState';
import ListContainer from './containers/ListContainer';
import DetailContainer from './containers/DetailContainer';
import {
setPlatform,
setHost,
setServiceHost,
setSingleHost,
} from './reducers/app/appActions';
import {setPlatform, setHost, setServiceHost, setSingleHost} from './reducers/app/appActions';
import {
setProductSKN,
} from './reducers/detail/detailActions';
import {setOrderCode} from './reducers/detail/detailActions';
import {
setFirstShowIndex
} from './reducers/list/listActions';
import {setFirstShowIndex} from './reducers/list/listActions';
function getInitialState() {
const _initState = {
app: (new appInitialState()),
list: (new listInitialState()),
detail: (new detailInitialState()),
};
return _initState;
const _initState = {
app: (new appInitialState()),
list: (new listInitialState()),
detail: (new detailInitialState())
};
return _initState;
}
export default function native(platform) {
let YH_Order = React.createClass({
render() {
const store = configureStore(getInitialState());
store.dispatch(setPlatform(platform));
store.dispatch(setHost(this.props.host));
store.dispatch(setServiceHost(this.props.serviceHost));
store.dispatch(setSingleHost(this.props.singleHost));
let type = this.props.type;
if (type == 'list') {
store.dispatch(setFirstShowIndex(this.props.firstShowIndex));
return (
<Provider store={store}>
<ListContainer />
</Provider>
);
} else {
store.dispatch(setProductSKN(this.props.product_skn));
return (
<Provider store={store}>
<DetailContainer />
</Provider>
);
}
}
});
AppRegistry.registerComponent('YH_Order', () => YH_Order);
let YH_Order = React.createClass({
render() {
const store = configureStore(getInitialState());
store.dispatch(setPlatform(platform));
store.dispatch(setHost(this.props.host));
store.dispatch(setServiceHost(this.props.serviceHost));
store.dispatch(setSingleHost(this.props.singleHost));
let type = this.props.type;
if (type == 'list') {
store.dispatch(setFirstShowIndex(this.props.firstShowIndex));
return (
<Provider store={store}>
<ListContainer/>
</Provider>
);
} else {
store.dispatch(setOrderCode(this.props.order_code));
return (
<Provider store={store}>
<DetailContainer/>
</Provider>
);
}
}
});
AppRegistry.registerComponent('YH_Order', () => YH_Order);
}
... ...
'use strict';
import React, {Component} from 'react';
import Immutable, {Map} from 'immutable';
import React, { Component } from 'react';
import Immutable, { Map } from 'immutable';
import ReactNative, {
View,
Text,
Image,
ListView,
StyleSheet,
Dimensions,
TouchableOpacity,
InteractionManager,
Platform,
} from 'react-native';
import ReactNative, { View, Text, Image, ListView, StyleSheet, Dimensions, TouchableOpacity, InteractionManager, Platform, } from 'react-native';
export default class Detail extends Component {
constructor(props) {
super(props);
this.state = {
totalHeight: 0
}
constructor(props) {
super(props);
this.state = {
totalHeight: 0
}
onLayout (reminder) {
let totalHeight = reminder.nativeEvent.layout.height + reminder.nativeEvent.layout.y + 15;
this.setState({totalHeight});
}
onLayout(reminder) {
let totalHeight = reminder.nativeEvent.layout.height + reminder.nativeEvent.layout.y + 15;
this.setState({
totalHeight
});
}
render() {
let data = this.props.data;
if (!data) {
return null;
}
render() {
let data = this.props.data;
if (!data) {
return null;
}
return (
<View style={[styles.container, {height: this.state.totalHeight}]}>
return (
<View style={[styles.container, {
height: this.state.totalHeight
}]}>
<Text style={styles.title}>{data.get('product_name')} </Text>
<View style={styles.pricePannel}>
<Text style={styles.price}> {data.get('format_sales_price')}</Text>
... ... @@ -49,77 +43,77 @@ export default class Detail extends Component {
<Text style={styles.tag}>{data.get('middle_sort_name')} </Text>
</View>
</View>
);
}
);
}
}
let {width, height} = Dimensions.get('window');
let styles = StyleSheet.create({
container: {
width: width,
flexDirection: 'column',
},
title: {
fontSize: 16,
width: width - 30,
marginLeft: 15,
marginTop: 16,
marginBottom: 0,
color: '#444444',
// backgroundColor: 'red',
},
pricePannel: {
marginLeft: 15,
marginTop: 16,
width: width - 30,
flexDirection: 'row',
// backgroundColor: 'red',
},
price: {
fontSize: 16,
color: '#d0021b',
marginRight: 0,
},
originPrice: {
fontSize: 16,
color: '#b0b0b0',
marginLeft: 20,
textDecorationLine: 'line-through'
},
phrase: {
marginLeft: 15,
marginTop: 6,
width: width - 30,
fontSize: 13,
color: '#b0b0b0',
lineHeight: 20,
// backgroundColor: 'red',
},
tagPannel: {
marginLeft: 15,
marginTop: 15,
width: width - 30,
flexDirection: 'row',
marginBottom: 15,
// backgroundColor: 'red',
},
tag: {
paddingTop: 4,
paddingLeft: 10,
paddingRight: 10,
paddingBottom: 4,
marginLeft: 0,
marginRight: 10,
backgroundColor: '#f0f0f0',
fontSize: 12,
color: '#b0b0b0',
}
container: {
width: width,
flexDirection: 'column',
},
title: {
fontSize: 16,
width: width - 30,
marginLeft: 15,
marginTop: 16,
marginBottom: 0,
color: '#444444',
// backgroundColor: 'red',
},
pricePannel: {
marginLeft: 15,
marginTop: 16,
width: width - 30,
flexDirection: 'row',
// backgroundColor: 'red',
},
price: {
fontSize: 16,
color: '#d0021b',
marginRight: 0,
},
originPrice: {
fontSize: 16,
color: '#b0b0b0',
marginLeft: 20,
textDecorationLine: 'line-through'
},
phrase: {
marginLeft: 15,
marginTop: 6,
width: width - 30,
fontSize: 13,
color: '#b0b0b0',
lineHeight: 20,
// backgroundColor: 'red',
},
tagPannel: {
marginLeft: 15,
marginTop: 15,
width: width - 30,
flexDirection: 'row',
marginBottom: 15,
// backgroundColor: 'red',
},
tag: {
paddingTop: 4,
paddingLeft: 10,
paddingRight: 10,
paddingBottom: 4,
marginLeft: 0,
marginRight: 10,
backgroundColor: '#f0f0f0',
fontSize: 12,
color: '#b0b0b0',
}
});
... ...
... ... @@ -3,9 +3,7 @@
import React, {Component} from 'react';
import Immutable, {Map} from 'immutable';
import LoadingIndicator from '../../../common/components/LoadingIndicator';
import GoodGoodsImagesView from './GoodGoodsImagesView'
import ContentCell from './ContentCell'
import BrandProductListCell from '../../../common/components/ListCell/ProductListCell';
import Footer from './Footer'
import ReactNative, {
... ... @@ -20,8 +18,6 @@ import ReactNative, {
Platform,
} from 'react-native';
export default class Detail extends Component {
constructor(props) {
... ... @@ -29,109 +25,44 @@ export default class Detail extends Component {
this.renderRow = this.renderRow.bind(this);
this.dataSource = new ListView.DataSource({
rowHasChanged: (r1, r2) => !Immutable.is(r1, r2),
sectionHeaderHasChanged: (s1, s2) => !Immutable.is(s1, s2),
sectionHeaderHasChanged: (s1, s2) => !Immutable.is(s1, s2)
});
}
renderRow(rowData,sectionID,rowID,highlightRow) {
renderRow(rowData, sectionID, rowID, highlightRow) {
switch (sectionID) {
case 'images': {
let ary = [];
for (var i = 0; i < rowData.length; i++) {
let item = rowData[i];
let url = item.get('image_url');
let tempAry = url.split('?');
// url = url.replace('{width}', 420).replace('{height}', 562).replace('{mode}',2);
ary.push(tempAry[0]);
}
return (
<View style={{
width,
height: 300,
}}>
<GoodGoodsImagesView
style={{
width,
height: 300,
backgroundColor: '#f0f0f0'
}}
items={ary}
/>
<View style={styles.separator}/>
</View>
)
}
break;
case 'content': {
return <ContentCell data={rowData}/>
}
break;
case 'similarTitle': {
return(
<View style={{width: width, height: 40, borderColor: '#ededed', borderBottomWidth: 1, backgroundColor: '#f0f0f0'}}>
<Text style={{flex: 1, textAlign: 'center', color:'#444444', fontSize: 16, paddingTop: 12}}>猜你喜欢</Text>
</View>
)
}
break;
case 'similar': {
let paddingLeft = rowID % 2 == 1 ? rowMarginHorizontal / 2 : rowMarginHorizontal;
let customStyle = rowID == 0 || rowID == 1 ? {paddingLeft} : {paddingLeft};
return (
<BrandProductListCell
style={[styles.listContainer, customStyle]}
key={'row' + rowID}
rowID={rowID}
data={rowData}
onPressProduct={this.props.onPressProduct}
/>
);
}
break;
default:
}
return null;
}
render() {
let {product_skn, favorite, product, similarList} = this.props.resource;
let isFetching = product.get('isFetching')||similarList.get('isFetching');
let images = product.getIn(['data','goods_list',0,'images_list']);
let similar = similarList&&similarList.get('data')&&similarList.get('data').toArray().length?similarList.get('data').toArray():[];
let {order_code, detail} = this.props.resource;
let isFetching = detail.get('isFetching');
let addressBlob = {
}
let dataSource = {
'images': images&&images.toArray().length?[images.toArray()]:[],
'content':product&&product.get('data')?[product.get('data')]:[],
'similarTitle':similar.length?[1]:[],
'similar':similar,
};
// //Test
// product_skn = '51148345';
// //
let buttonArray = detail.get('links')? detail.get('links').toJS() : [];
return (
<View style={styles.container}>
{!isFetching?
<View style={styles.container}>
<ListView
contentContainerStyle={styles.contentContainer}
enableEmptySections={true}
showsVerticalScrollIndicator={false}
dataSource={this.dataSource.cloneWithRowsAndSections(dataSource)}
renderRow={this.renderRow}
/>
<Footer
favorite={favorite}
onPressFavorite={this.props.onPressFavorite}
onPressProduct={this.props.onPressProduct}
product_skn={product_skn}
/>
</View>
:<LoadingIndicator
isVisible={isFetching}
/>}
{!isFetching
? <View style={styles.container}>
<ListView
contentContainerStyle={styles.contentContainer}
enableEmptySections={true}
showsVerticalScrollIndicator={false}
dataSource={this.dataSource.cloneWithRowsAndSections(dataSource)}
renderRow={this.renderRow}
/>
{buttonArray.length?<Footer resource={buttonArray}/>: null}
</View>
: <LoadingIndicator isVisible={isFetching}/>}
</View>
);
}
... ... @@ -139,23 +70,17 @@ export default class Detail extends Component {
let {width, height} = Dimensions.get('window');
let rowWidth = Math.ceil(137.5 * width / 320);
let rowHeight = Math.ceil(254 * width / 320);
let rowMarginTop = Math.ceil(10 * width / 320);
let rowMarginHorizontal = (width - rowWidth * 2) / 3;
let styles = StyleSheet.create({
container: {
flex: 1,
width: width,
width: width
},
contentContainer:{
contentContainer: {
backgroundColor: 'white',
flexDirection: 'row',
flexDirection: 'row',
flexWrap: 'wrap'
},
listContainer: {
width: width / 2,
},
width: width / 2
}
});
... ...
'use strict';
import React, {Component} from 'react';
import Immutable, {Map} from 'immutable';
import React, { Component } from 'react';
import Immutable, { Map } from 'immutable';
import ReactNative, {
View,
Text,
Image,
ListView,
StyleSheet,
Dimensions,
TouchableOpacity,
InteractionManager,
Platform,
} from 'react-native';
import ReactNative, { View, Text, Image, ListView, StyleSheet, Dimensions, TouchableOpacity, InteractionManager, Platform, } from 'react-native';
export default class Detail extends Component {
constructor(props) {
super(props);
constructor(props) {
super(props);
}
}
render() {
render() {
let fav_image = this.props.favorite?require('../../image/love_tab_ic_h.png'):require('../../image/love_tab_ic.png');
let fav_title = this.props.favorite?'已收藏':'收藏';
return (
<View style={styles.footer}>
<TouchableOpacity style={styles.favoriteButton} onPress={() => {this.props.onPressFavorite&&this.props.onPressFavorite(this.props.favorite)}}>
<View style={{flex: 1, flexDirection: 'row', alignItems: 'center'}}>
let fav_image = this.props.favorite ? require('../../image/love_tab_ic_h.png') : require('../../image/love_tab_ic.png');
let fav_title = this.props.favorite ? '已收藏' : '收藏';
return (
<View style={styles.footer}>
<TouchableOpacity style={styles.favoriteButton} onPress={() => {
this.props.onPressFavorite && this.props.onPressFavorite(this.props.favorite)
}}>
<View style={{
flex: 1,
flexDirection: 'row',
alignItems: 'center'
}}>
<Image style={styles.favIcon} source={fav_image}/>
<Text style={styles.favText}>{fav_title}</Text>
</View>
</TouchableOpacity>
<View style={styles.detailButton}>
<Text
style={styles.detailButtonText}
onPress={() => {this.props.onPressProduct&& this.props.onPressProduct(Immutable.fromJS({'product_skn':this.props.product_skn}))}}
>查看详情</Text>
style={styles.detailButtonText}
onPress={() => {
this.props.onPressProduct && this.props.onPressProduct(Immutable.fromJS({
'product_skn': this.props.product_skn
}))
}}
>查看详情</Text>
</View>
</View>
);
}
);
}
}
let {width, height} = Dimensions.get('window');
let styles = StyleSheet.create({
footer: {
width: width,
height: 59,
borderColor: '#ededed',
borderTopWidth: 1,
flexDirection: 'row',
alignItems: 'center',
},
detailButton: {
position: 'absolute',
width: 100,
height: 44,
top: 7,
left: width - 15 - 100,
backgroundColor: '#d0021b',
borderRadius: 4,
alignItems: 'center',
},
detailButtonText: {
marginTop: 4,
height: 36,
color: 'white',
paddingTop: 10,
textAlign: 'center',
fontSize: 15,
},
favoriteButton: {
width: 100,
height: 40,
},
favIcon: {
width: 17,
height: 16,
marginLeft: 20,
marginRight: 0,
},
favText: {
fontSize: 13,
color: '#b0b0b0',
marginLeft: 5,
},
footer: {
width: width,
height: 59,
borderColor: '#ededed',
borderTopWidth: 1,
flexDirection: 'row',
alignItems: 'center',
},
detailButton: {
position: 'absolute',
width: 100,
height: 44,
top: 7,
left: width - 15 - 100,
backgroundColor: '#d0021b',
borderRadius: 4,
alignItems: 'center',
},
detailButtonText: {
marginTop: 4,
height: 36,
color: 'white',
paddingTop: 10,
textAlign: 'center',
fontSize: 15,
},
favoriteButton: {
width: 100,
height: 40,
},
favIcon: {
width: 17,
height: 16,
marginLeft: 20,
marginRight: 0,
},
favText: {
fontSize: 13,
color: '#b0b0b0',
marginLeft: 5,
},
});
... ...
import React from 'react';
import ReactNative from 'react-native';
import ImmutablePropTypes from 'react-immutable-proptypes';
let {
requireNativeComponent,
View
} = ReactNative;
module.exports = requireNativeComponent('YH_GoodGoodsImagesView', null);
class GoodGoodsImagesView extends React.Component {
constructor(props) {
super(props);
this._onClick = this._onClick.bind(this);
}
_onClick(event: Event) {
if (!this.props.onClick) {
return;
}
this.props.onClick(event.nativeEvent);
}
render() {
return <YH_GoodGoodsImagesView {...this.props} items={this.props.items} />;
}
}
GoodGoodsImagesView.propTypes = {
items: React.PropTypes.arrayOf(
React.PropTypes.string
),
...View.propTypes // 包含默认的View的属性
};
let YH_GoodGoodsImagesView = requireNativeComponent('YH_GoodGoodsImagesView', GoodGoodsImagesView);
module.exports = GoodGoodsImagesView;
... ... @@ -8,23 +8,12 @@ export default keyMirror({
SET_CHANNEL: null,
SET_SINGLE_HOST: null,
SET_FIRST_SHOW_INDEX: null,
SET_PRODUCT_SKN: null,
SET_ORDER_CODE: null,
GET_DETAIL_REQUEST: null,
GET_DETAIL_SUCCESS: null,
GET_DETAIL_FAILURE: null,
GET_SIMILAR_REQUEST: null,
GET_SIMILAR_SUCCESS: null,
GET_SIMILAR_FAILURE: null,
SET_FAVORITE_STATUS: null,
// 列表
GET_ORDER_LIST_REQUEST: null,
GET_ORDER_LIST_SUCCESS: null,
GET_ORDER_LIST_FAILURE: null,
// 列表资源位
FETCH_BANNER_REQUEST: null,
FETCH_BANNER_SUCCESS: null,
FETCH_BANNER_FAILURE: null,
});
... ...
... ... @@ -46,40 +46,28 @@ function mapDispatchToProps(dispatch) {
class DetailContainer extends Component {
constructor(props) {
super(props);
this._onPressProduct = this._onPressProduct.bind(this);
this._onPressFavorite = this._onPressFavorite.bind(this);
this.subscription = NativeAppEventEmitter.addListener(
'YHNotificationChangeOnLinePayToCodPay',
(reminder) => {
this.props.actions.getDetail();
}
);
}
componentDidMount() {
this.props.actions.getDetail();
this.props.actions.getSimilar();
}
componentWillUnmount() {
}
_onPressProduct(product) {
let productSkn = product && product.get('product_skn', 0);
if (!productSkn) {
return;
}
let url = `http://m.yohobuy.com?openby:yohobuy={"action":"go.productDetail","params":{"product_skn":"${productSkn}"}}`;
ReactNative.NativeModules.YH_CommonHelper.jumpWithUrl(url);
this.subscription && this.subscription.remove();
}
_onPressFavorite(favorite) {
this.props.actions.changeFavoriteStatus(favorite);
}
render() {
let {detail} = this.props;
return (
<Detail
resource={detail}
onPressProduct={this._onPressProduct}
onPressFavorite={this._onPressFavorite}
/>
);
}
... ...
... ... @@ -5,44 +5,32 @@ import DetailService from '../../services/DetailService';
import Immutable, {Map} from 'immutable';
const {
SET_PRODUCT_SKN,
SET_ORDER_CODE,
GET_DETAIL_REQUEST,
GET_DETAIL_SUCCESS,
GET_DETAIL_FAILURE,
GET_SIMILAR_REQUEST,
GET_SIMILAR_SUCCESS,
GET_SIMILAR_FAILURE,
SET_FAVORITE_STATUS,
} = require('../../constants/actionTypes').default;
export function setProductSKN(product_skn) {
export function setOrderCode(order_code) {
return {
type: SET_PRODUCT_SKN,
payload: product_skn,
type: SET_ORDER_CODE,
payload: order_code,
};
}
export function getDetail() {
return (dispatch, getState) => {
let {app, detail} = getState();
let {product_skn} = detail;
// if (!product_skn) {
// return ;
// }
let {order_code} = detail;
dispatch(getDetailRequest());
return new DetailService(app.host).getDetailWithProductSKN(product_skn)
return new DetailService(app.host).getDetailWithOrderCode(order_code)
.then(json => {
// console.log(product_skn);
// console.log(json);
dispatch(getDetailSuccess(json));
return new DetailService(app.singleHost).getFavoriteStatusWithProductID(json.product_id)
.then(json => {
dispatch(setFavoriteStatus(json));
})
.catch(error => {
dispatch(setFavoriteStatus(false));
})
})
.catch(error => {
dispatch(getDetailFailure(error));
... ... @@ -50,28 +38,6 @@ export function getDetail() {
};
}
export function changeFavoriteStatus(favorite) {
return (dispatch, getState) => {
let {app, detail} = getState();
let product_id = detail.get('product').get('data').get('product_id');
if (product_id && favorite) {
new DetailService(app.host).cancelFavorite(product_id);
}
if (product_id && !favorite) {
new DetailService(app.host).addFavorite(product_id);
}
dispatch(setFavoriteStatus(!favorite));
}
}
export function setFavoriteStatus(favorite) {
return {
type: SET_FAVORITE_STATUS,
payload: favorite
};
}
export function getDetailRequest() {
return {
type: GET_DETAIL_REQUEST,
... ... @@ -91,45 +57,3 @@ export function getDetailFailure(error) {
payload: error
};
}
export function getSimilar() {
return (dispatch, getState) => {
let {app, detail} = getState();
let {product_skn} = detail;
// if (!product_skn) {
// return ;
// }
dispatch(getSimilarRequest());
return new DetailService(app.host).getSimilarListWithSKN(product_skn)
.then(json => {
// console.log(product_skn);
// console.log(json);
dispatch(getSimilarSuccess(json.product_list));
})
.catch(error => {
// console.log(product_skn);
// console.log(error);
dispatch(getSimilarFailure(error));
});
};
}
export function getSimilarRequest() {
return {
type: GET_SIMILAR_REQUEST,
};
}
export function getSimilarSuccess(json) {
return {
type: GET_SIMILAR_SUCCESS,
payload: json
};
}
export function getSimilarFailure(error) {
return {
type: GET_SIMILAR_FAILURE,
payload: error
};
}
... ...
... ... @@ -3,18 +3,12 @@
import {Record, List, Map} from 'immutable';
let InitialState = Record({
product_skn: '',
favorite: false,
product: new (Record({
order_code: '',
detail: new (Record({
isFetching: false,
error: null,
data: null,
})),
similarList: new (Record({
isFetching: false,
error: null,
data: List(),
})),
});
export default InitialState;
... ...
... ... @@ -4,50 +4,31 @@ import InitialState from './detailInitialState';
import Immutable, {Map} from 'immutable';
const {
SET_PRODUCT_SKN,
SET_ORDER_CODE,
GET_DETAIL_REQUEST,
GET_DETAIL_SUCCESS,
GET_DETAIL_FAILURE,
GET_SIMILAR_REQUEST,
GET_SIMILAR_SUCCESS,
GET_SIMILAR_FAILURE,
SET_FAVORITE_STATUS,
} = require('../../constants/actionTypes').default;
const initialState = new InitialState;
export default function detailReducer(state=initialState, action) {
switch(action.type) {
case SET_FAVORITE_STATUS: {
return state.set('favorite', action.payload);
}
case SET_PRODUCT_SKN: {
return state.set('product_skn', action.payload);
case SET_ORDER_CODE: {
return state.set('order_code', action.payload);
}
case GET_DETAIL_REQUEST: {
return state.setIn(['product', 'isFetching'], true);
return state.setIn(['detail', 'isFetching'], true);
}
case GET_DETAIL_SUCCESS: {
return state.setIn(['product', 'isFetching'], false)
.setIn(['product', 'data'], Immutable.fromJS(action.payload))
.setIn(['product', 'error'], null);
return state.setIn(['detail', 'isFetching'], false)
.setIn(['detail', 'data'], Immutable.fromJS(action.payload))
.setIn(['detail', 'error'], null);
}
case GET_DETAIL_FAILURE: {
return state.setIn(['product', 'isFetching'], false)
.setIn(['product', 'error'], action.payload);
}
case GET_SIMILAR_REQUEST: {
return state.setIn(['similarList', 'isFetching'], true);
}
case GET_SIMILAR_SUCCESS: {
return state.setIn(['similarList', 'isFetching'], false)
.setIn(['similarList', 'data'], Immutable.fromJS(action.payload))
.setIn(['similarList', 'error'], null);
}
case GET_SIMILAR_FAILURE: {
return state.setIn(['similarList', 'isFetching'], false)
.setIn(['similarList', 'error'], action.payload);
return state.setIn(['detail', 'isFetching'], false)
.setIn(['detail', 'error'], action.payload);
}
}
... ...
... ... @@ -4,103 +4,25 @@ import Request from '../../common/services/NativeRequest';
export default class DetailService {
constructor (host) {
let baseURL = 'http://service.yoho.cn';
if(host){
baseURL = host;
}
this.api = new Request(baseURL);
}
async getDetailWithProductSKN(product_skn) {
// product_skn = '51148345';
// this.api = new Request('http://dev-api.yohops.com:9999');
return await this.api.get({
url: '',
body: {
method: 'app.product.goodDetail',
// debug: 'XYZ',
product_skn
}
})
.then((json) => {
return json;
})
.catch((error) => {
throw(error);
});
}
async getSimilarListWithSKN(product_skn) {
// product_skn = '51148345';
return await this.api.get({
url: '',
body: {
method: 'app.search.findLike',
limit: 20,
product_skn
}
})
.then((json) => {
return json;
})
.catch((error) => {
throw(error);
});
}
async getFavoriteStatusWithProductID(id) {
return await this.api.get({
url: '',
body: {
method: 'app.favorite.isFavoriteNew',
id,
}
})
.then((json) => {
return json;
})
.catch((error) => {
throw(error);
});
}
async addFavorite(id) {
let type='product';
return await this.api.get({
url: '',
body: {
method: 'app.favorite.add',
id,
type,
}
})
.then((json) => {
return json;
})
.catch((error) => {
throw(error);
});
}
async cancelFavorite(id) {
let type='product';
return await this.api.get({
url: '',
body: {
method: 'app.favorite.cancel',
id,
type,
}
})
.then((json) => {
return json;
})
.catch((error) => {
throw(error);
});
}
constructor(host) {
let baseURL = 'http://service.yoho.cn';
if (host) {
baseURL = host;
}
this.api = new Request(baseURL);
}
async getDetailWithOrderCode(order_code) {
return await this.api.get({
url: '',
body: {
method: 'app.SpaceOrders.detail',
order_code,
}
}).then((json) => {
return json;
}).catch((error) => {
throw(error);
});
}
}
... ...