appActions.js
2.02 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
/**
* # guideActions.js
*
* App user guide
*
*/
'use strict';
import ReactNative from 'react-native';
import {Actions} from 'react-native-router-flux';
import Immutable, {Map} from 'immutable';
import AppService from '../../services/AppService';
import RouterService from '../../services/RouterService';
import {goToSection, goToPost} from '../home/homeActions';
const {
SET_PLATFORM,
SET_CONTAINER,
SET_CHANNEL,
GO_ACTION,
} = require('../../constants/actionTypes').default;
export function setPlatform(platform) {
return {
type: SET_PLATFORM,
payload: platform
};
}
export function setContianer(container) {
return {
type: SET_CONTAINER,
payload: container
};
}
export function setChannel(channel) {
return {
type: SET_CHANNEL,
payload: channel
};
}
export function goAction(inputUrl) {
return (dispatch, getState) => {
let json = new RouterService().parseUrl(inputUrl);
let {action, params} = json;
let {param, share, shareparam, title, url} = params;
if (action == 'go.comm.forum') {
let id = params && params.forumid ? params.forumid : 0;
let name = '';
if (id != 0) {
dispatch(goToSection({id, name}));
}
} else if (action == 'go.comm.postdetail') {
let id = params && params.postid ? params.postid : 0;
if (id == 0) {
id = params && params.postId ? params.postId : 0;
}
if (id != 0) {
dispatch(goToPost(id));
}
} else if (action == 'go.comm.h5') {
let title = params.title ? params.title : '';
let url = params.url ? params.url : '';
if (!url || url.length == 0) {
return;
}
ReactNative.NativeModules.YH_CommunityHelper.displayH5({url, title});
} else if (action == 'go.comm.productDetail') {
let productSkn = params.product_skn ? params.product_skn : '';
productSkn = productSkn + '';
let tag = params.tag ? params.tag : '';
if (!productSkn || productSkn.length == 0) {
return;
}
ReactNative.NativeModules.YH_CommunityHelper.displayProductDetail({productSkn, tag});
}
};
}