Toggle navigation
Toggle navigation
This project
Loading...
Sign in
mobile
/
YH_RNComponent
·
Commits
Go to a project
GitLab
Go to group
Project
Activity
Files
Commits
Pipelines
0
Builds
0
Graphs
Milestones
Issues
0
Merge Requests
0
Members
Labels
Wiki
Forks
Network
Create a new issue
Download as
Email Patches
Plain Diff
Browse Files
Authored by
QC-L
6 years ago
Commit
7d32c066515d9d1870e209c25a656e0e9eb9fe26
1 parent
05887548
添加消息列表分享 review by sunkai
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
374 additions
and
10 deletions
js/alliance/components/MessageList.js
js/alliance/components/cell/MessageCell.js
js/alliance/containers/MessageContainer.js
js/common/utils/commonShareUtils.js
js/alliance/components/MessageList.js
View file @
7d32c06
...
...
@@ -21,6 +21,7 @@ export default class MessageList extends Component {
<
MessageCell
data
=
{
rowData
}
resourceJumpWithUrl
=
{
this
.
props
.
resourceJumpWithUrl
}
shareAction
=
{
this
.
props
.
shareAction
}
/>
);
}
...
...
js/alliance/components/cell/MessageCell.js
View file @
7d32c06
...
...
@@ -9,6 +9,21 @@ import {
import
YH_Image
from
'../../../common/components/YH_Image'
;
import
Immutable
from
'immutable'
;
function
ShareButton
(
props
)
{
return
(
<
TouchableOpacity
activeOpacity
=
{
1
}
style
=
{
styles
.
shareButton
}
onPress
=
{()
=>
{
props
.
shareAction
&&
props
.
shareAction
(
props
.
rowData
);
}}
>
<
Text
style
=
{
styles
.
shareButtonText
}
>
去分享
<
/Text
>
<
/TouchableOpacity
>
)
}
export
class
MessageCell
extends
Component
{
constructor
(
props
)
{
...
...
@@ -41,6 +56,8 @@ export class MessageCell extends Component {
return
null
;
}
data
=
data
.
toJS
();
let
isTrueDataType
=
data
.
type
>
0
&&
data
.
type
<
7
&&
data
.
type
!=
3
let
isShowShare
=
data
.
shareFlag
&&
isTrueDataType
?
true
:
false
;
return
(
<
TouchableOpacity
...
...
@@ -57,13 +74,20 @@ export class MessageCell extends Component {
url
=
{
data
.
image
}
style
=
{
styles
.
imageStyle
}
/
>
<
Text
style
=
{
styles
.
messageText
}
numberOfLines
=
{
2
}
>
{
data
.
content
}
<
/Text
>
<
Text
style
=
{
styles
.
startTimeText
}
>
{
data
.
createTime
}
<
/Text
>
<
View
style
=
{
styles
.
textBgView
}
>
<
Text
style
=
{
styles
.
messageText
}
numberOfLines
=
{
2
}
>
{
data
.
content
}
<
/Text
>
<
View
style
=
{
styles
.
timeAndShare
}
>
<
Text
style
=
{
styles
.
startTimeText
}
>
{
data
.
createTime
}
<
/Text
>
{
isShowShare
?
<
ShareButton
rowData
=
{
data
}
shareAction
=
{
this
.
props
.
shareAction
}
/> : nul
l
}
<
/View
>
<
/View
>
<
/View
>
<
/TouchableOpacity
>
);
...
...
@@ -86,6 +110,17 @@ let styles = StyleSheet.create({
marginRight
:
15
*
DEVICE_WIDTH_RATIO
,
flex
:
1
},
textBgView
:
{
flexDirection
:
'column'
,
flex
:
1
},
timeAndShare
:
{
flexDirection
:
'row'
,
alignItems
:
'center'
,
marginTop
:
10
*
DEVICE_HEIGHT_RATIO
,
marginBottom
:
20
*
DEVICE_HEIGHT_RATIO
,
justifyContent
:
'space-between'
},
imageStyle
:
{
marginTop
:
15
*
DEVICE_HEIGHT_RATIO
,
marginBottom
:
15
*
DEVICE_HEIGHT_RATIO
,
...
...
@@ -100,10 +135,20 @@ let styles = StyleSheet.create({
},
startTimeText
:
{
fontSize
:
12
,
marginTop
:
10
*
DEVICE_HEIGHT_RATIO
,
marginBottom
:
20
*
DEVICE_HEIGHT_RATIO
,
color
:
'#B0B0B0'
,
height
:
14
},
shareButton
:
{
width
:
60
,
height
:
30
,
borderRadius
:
3
,
backgroundColor
:
'#D0021B'
,
justifyContent
:
'center'
},
shareButtonText
:
{
fontSize
:
14
,
color
:
'white'
,
textAlign
:
'center'
,
}
});
...
...
js/alliance/containers/MessageContainer.js
View file @
7d32c06
...
...
@@ -6,10 +6,19 @@ import {bindActionCreators} from 'redux';
import
{
connect
}
from
'react-redux'
;
import
{
Map
}
from
'immutable'
;
import
*
as
allianceActions
from
'../reducers/alliance/allianceActions'
;
import
{
StyleSheet
,
View
,}
from
"react-native"
;
import
{
StyleSheet
,
View
,
Dimensions
}
from
"react-native"
;
import
MessageList
from
"../components/MessageList"
;
import
LoadingIndicator
from
'../../common/components/LoadingIndicator'
;
import
ReactNative
from
"react-native"
;
import
{
shareGroupPurchaseDetail
,
shareH5
,
shareGoodsDetail
,
shareGroupPurchaseList
,
shareStrollDetail
}
from
'../../common/utils/commonShareUtils'
import
Request
from
'../../common/services/NativeRequest'
;
import
{
getSlicedUrl
}
from
'../../classify/utils/Utils'
;
const
actions
=
[
allianceActions
,
...
...
@@ -38,6 +47,10 @@ class MessageContainer extends Component {
constructor
(
props
)
{
super
(
props
);
this
.
_resourceJumpWithUrl
=
this
.
_resourceJumpWithUrl
.
bind
(
this
);
this
.
_shareAction
=
this
.
_shareAction
.
bind
(
this
);
let
baseURL
=
'http://api.yoho.cn'
;
this
.
api
=
new
Request
(
baseURL
);
}
componentDidMount
()
{
...
...
@@ -56,6 +69,138 @@ class MessageContainer extends Component {
ReactNative
.
NativeModules
.
YH_CommonHelper
.
jumpWithUrl
(
url
);
}
async
_shareAction
(
params
)
{
const
union_type
=
ReactNative
.
NativeModules
.
YH_CommonHelper
.
unionType
();
switch
(
params
.
type
)
{
// 商品详情
case
1
:
{
let
shareInfo
=
{
productInfo
:
params
.
productInfo
,
union_type
}
let
shareParam
=
shareGoodsDetail
(
shareInfo
);
ReactNative
.
NativeModules
.
YH_CommonHelper
.
shareInfoWithParam
(
shareParam
);
break
;
}
// H5
case
2
:
{
let
shareId
=
params
.
someKey
;
this
.
api
.
get
({
url
:
'/operations/api/v5/webshare/getShare'
,
body
:
{
shareId
,
fromPage
:
'iFP_H5'
}
}).
then
((
json
)
=>
{
let
bigImage
=
json
.
data
.
bigImage
let
shareInfo
=
{
...
params
,
data
:
{
bigImage
:
bigImage
?
getSlicedUrl
(
bigImage
,
150
*
DEVICE_WIDTH_RATIO
,
120
*
DEVICE_WIDTH_RATIO
,
2
)
:
''
,
content
:
json
.
data
.
content
,
title
:
json
.
data
.
title
,
shareUrl
:
json
.
data
.
url
,
pic
:
json
.
data
.
pic
},
union_type
}
let
shareParam
=
shareH5
(
shareInfo
);
ReactNative
.
NativeModules
.
YH_CommonHelper
.
shareInfoWithAnyParam
(
shareParam
);
return
json
;
}).
catch
((
err
)
=>
{
let
url
=
`
$
{
params
.
url
.
split
(
'?'
)[
0
]}?
shareId
=
$
{
shareId
}
`
let
shareInfo
=
{
...
params
,
data
:
{
bigImage
:
params
.
image
,
content
:
params
.
content
,
title
:
params
.
content
,
shareUrl
:
url
,
pic
:
params
.
image
},
union_type
,
isCatch
:
true
}
let
shareParam
=
shareH5
(
shareInfo
);
ReactNative
.
NativeModules
.
YH_CommonHelper
.
shareInfoWithAnyParam
(
shareParam
);
throw
(
err
);
});
break
;
}
// 资讯
case
4
:
{
let
json
=
await
this
.
api
.
get
({
url
:
'/guang/api/v1/share/guang'
,
body
:
{
id
:
params
.
someKey
,
fromPage
:
'iFP_GuangDetail'
,
yh_channel
:
'1'
}
}).
catch
((
error
)
=>
{
throw
(
error
);
});
let
data
=
json
;
let
param
=
{
...
data
,
someKey
:
params
.
someKey
,
union_type
}
let
shareParam
=
shareStrollDetail
(
param
);
ReactNative
.
NativeModules
.
YH_CommonHelper
.
shareInfoWithGuangParam
(
shareParam
);
break
;
}
// 拼团列表
case
5
:
{
this
.
api
.
get
({
url
:
'/operations/api/v5/webshare/getShare'
,
body
:
{
shareId
:
5409
,
}
}).
then
((
json
)
=>
{
let
shareInfo
=
{
activityId
:
params
.
someKey
,
shareCodeInfo
:
json
.
data
,
union_type
}
let
shareParam
=
shareGroupPurchaseList
(
shareInfo
);
ReactNative
.
NativeModules
.
YH_CommonHelper
.
shareInfoWithAnyParam
(
shareParam
);
return
json
;
}).
catch
((
error
)
=>
{
let
json
=
{
"bigImage"
:
"http://img12.static.yhbimg.com/taobaocms/2018/09/13/09/020e504e869fcad106f9687aec57f263d1.jpeg"
,
"content"
:
"有货福利团!精选好货,拼团省钱!"
,
"pic"
:
"http://img13.static.yhbimg.com/taobaocms/2018/09/07/17/02f7cc420cfde1aeff46a9239b07221319.jpeg"
,
"praise_num"
:
0
,
"title"
:
"有货福利团!精选好货,拼团省钱!"
,
"url"
:
"https://m.yohobuy.com/?userUid=59100243"
};
let
shareInfo
=
{
activityId
:
params
.
someKey
,
shareCodeInfo
:
json
,
union_type
};
let
shareParam
=
shareGroupPurchaseList
(
shareInfo
);
ReactNative
.
NativeModules
.
YH_CommonHelper
.
shareInfoWithAnyParam
(
shareParam
);
throw
(
error
);
})
break
;
}
// 拼团详情
case
6
:
{
let
shareInfo
=
{
activityId
:
params
.
someKey
,
productInfo
:
params
.
productInfo
,
union_type
}
let
shareParam
=
shareGroupPurchaseDetail
(
shareInfo
);
ReactNative
.
NativeModules
.
YH_CommonHelper
.
shareInfoWithParam
(
shareParam
);
break
;
}
default
:
break
;
}
}
render
()
{
let
{
messageList
}
=
this
.
props
.
alliance
;
let
isFetching
=
messageList
.
isFetching
;
...
...
@@ -64,6 +209,7 @@ class MessageContainer extends Component {
<
MessageList
messageList
=
{
messageList
}
resourceJumpWithUrl
=
{
this
.
_resourceJumpWithUrl
}
shareAction
=
{
this
.
_shareAction
}
/>
<
LoadingIndicator
isVisible
=
{
isFetching
}
/>
<
/View>
...
...
@@ -71,6 +217,9 @@ class MessageContainer extends Component {
}
}
let
{
width
}
=
Dimensions
.
get
(
'window'
);
const
DEVICE_WIDTH_RATIO
=
width
/
375
;
let
styles
=
StyleSheet
.
create
({
container
:
{
flex
:
1
,
...
...
js/common/utils/commonShareUtils.js
0 → 100644
View file @
7d32c06
'use strict'
;
// union_type CPS 用户都要携带
// miniQrType=4 拼团详情 √
// miniQrType=7 商品详情 √
// miniQrType=9 h5 √
// miniQrType=15 拼团列表 √
// miniQrType=18 逛
// miniQrType=15
let
host
=
'http://api.yoho.cn'
;
const
shareGroupPurchaseList
=
(
shareInfo
)
=>
{
let
{
activityId
,
shareCodeInfo
}
=
shareInfo
;
let
param
=
{
activityId
,
}
let
qrCode
=
host
+
'/wechat/miniapp/img-check.jpg?param='
+
encodeURIComponent
(
JSON
.
stringify
(
param
))
+
'&miniQrType=15'
;
let
miniProgramPath
=
`
/
pages
/
groupPurchase
/
groupPurchase
?
activityId
=
$
{
activityId
}
`
;
let
fromPage
=
'GroupPurchase'
;
let
businessId
=
'collage'
;
let
shareParam
=
{
title
:
shareCodeInfo
.
content
?
shareCodeInfo
.
content
:
''
,
content
:
shareCodeInfo
.
content
?
shareCodeInfo
.
content
:
''
,
image
:
shareCodeInfo
.
pic
,
bigImage
:
shareCodeInfo
.
bigImage
,
url
:
shareCodeInfo
.
url
,
miniProgramPath
,
miniProgramQCodeUrl
:
qrCode
,
from
:
fromPage
,
businessId
};
return
shareParam
;
};
// miniQrType=17
const
shareGroupPurchaseDetail
=
(
shareInfo
)
=>
{
const
productSkn
=
shareInfo
.
productInfo
.
productSkn
;
let
{
activityId
,
productInfo
,
union_type
}
=
shareInfo
;
let
miniProgramPath
=
`
pages
/
groupPurchase
/
groupPurchaseDetail
?
productSkn
=
$
{
productSkn
}
&
activityId
=
$
{
activityId
}
&
union_type
=
$
{
union_type
}
`
let
param
=
{
productSkn
,
activityId
,
union_type
};
let
qrCode
=
host
+
'/wechat/miniapp/img-check.jpg?param='
+
encodeURIComponent
(
JSON
.
stringify
(
param
))
+
'&miniQrType=17'
;
let
shareParam
=
{
title
:
productInfo
.
productName
?
productInfo
.
productName
:
''
,
content
:
productInfo
.
productName
?
productInfo
.
productName
:
''
,
image
:
productInfo
.
colorImage
,
url
:
productInfo
.
productUrl
,
miniProgramPath
:
miniProgramPath
,
miniProgramQCodeUrl
:
qrCode
,
product_name
:
productInfo
.
productName
?
productInfo
.
productName
:
''
,
sales_price
:
`¥
$
{
productInfo
.
marketPrice
}
`
,
original_sales_price
:
`¥
$
{
productInfo
.
originalSalesPrice
}
`
,
productDefaultImage
:
productInfo
.
colorImage
,
fromType
:
'productDetail'
,
};
return
shareParam
;
};
// miniQrType=7
const
shareGoodsDetail
=
(
shareInfo
)
=>
{
let
{
productInfo
,
union_type
}
=
shareInfo
;
let
qrCode
;
let
productSkn
=
productInfo
.
productSkn
;
let
params
=
{
productSkn
,
union_type
,
}
let
paramsString
=
encodeURIComponent
(
JSON
.
stringify
(
params
));
qrCode
=
host
+
'/wechat/miniapp/img-check.jpg?param='
+
paramsString
+
'&miniQrType=7'
;
let
shareParam
=
{
title
:
productInfo
.
productName
?
productInfo
.
productName
:
''
,
content
:
productInfo
.
productName
?
productInfo
.
productName
:
''
,
image
:
productInfo
.
colorImage
,
url
:
productInfo
.
productUrl
,
miniProgramPath
:
'pages/goodsDetail/goodsDetail?productSkn='
+
productSkn
,
miniProgramQCodeUrl
:
qrCode
,
product_name
:
productInfo
.
productName
?
productInfo
.
productName
:
''
,
sales_price
:
`¥
$
{
productInfo
.
originalSalesPrice
}
`
,
productDefaultImage
:
productInfo
.
colorImage
,
fromType
:
'productDetail'
,
};
return
shareParam
;
};
// miniQrType=18
const
shareStrollDetail
=
(
shareInfo
)
=>
{
let
{
url
,
title
,
content
,
pic
,
minSortName
,
wechatShareImgUrl
,
union_type
}
=
shareInfo
;
let
params
=
{
id
:
shareInfo
.
someKey
,
union_type
}
let
paramsString
=
encodeURIComponent
(
JSON
.
stringify
(
params
));
let
qrCode
=
host
+
'/wechat/miniapp/img-check.jpg?param='
+
paramsString
+
'&miniQrType=18'
;
let
miniProgramPath
=
`
page
/
subPackage
/
pages
/
guang
/
detail
?
id
=
$
{
shareInfo
.
someKey
}
`
;
let
shareParam
=
{
title
:
title
?
title
:
''
,
content
:
content
?
content
:
''
,
pic
:
pic
,
bigImage
:
wechatShareImgUrl
,
url
:
url
,
minSortName
,
miniProgramQCodeUrl
:
qrCode
,
miniProgramPath
,
};
return
shareParam
;
}
// miniQrType=9
const
shareH5
=
(
shareInfo
)
=>
{
// 请求web数据
let
{
someKey
,
url
,
data
,
isCatch
}
=
shareInfo
;
let
param
=
{
shareId
:
someKey
,
url
:
data
.
shareUrl
}
let
qrCode
=
host
+
'/wechat/miniapp/img-check.jpg?param='
+
encodeURIComponent
(
JSON
.
stringify
(
param
))
+
'&miniQrType=9'
;
let
miniProgramPath
=
`
pages
/
webview
/
webview
?
url
=
$
{
url
}
&
title
=
$
{
data
.
content
}
`
;
let
shareParam
=
{
title
:
data
.
content
?
data
.
content
:
''
,
content
:
data
.
content
?
data
.
content
:
''
,
image
:
data
.
pic
,
bigImage
:
data
.
bigImage
,
url
:
url
,
miniProgramPath
,
miniProgramQCodeUrl
:
qrCode
,
from
:
'h5'
,
isCatch
,
};
return
shareParam
;
}
export
{
shareGroupPurchaseList
,
shareGroupPurchaseDetail
,
shareGoodsDetail
,
shareStrollDetail
,
shareH5
,
};
...
...
Please
register
or
login
to post a comment