|
|
|
@ -1,6 +1,6 @@ |
|
|
|
|
import { ScrollView, View, Text } from '@tarojs/components' |
|
|
|
|
import React, { useState } from 'react' |
|
|
|
|
import Taro, { useLoad, useShareAppMessage, useShareTimeline } from '@tarojs/taro' |
|
|
|
|
import Taro, { useDidShow, useShareAppMessage, useShareTimeline } from '@tarojs/taro' |
|
|
|
|
import './index.less' |
|
|
|
|
|
|
|
|
|
interface subscribeProps { |
|
|
|
@ -34,7 +34,7 @@ export default function UserMessage() { |
|
|
|
|
|
|
|
|
|
const [userSubuscribed, setuserSubuscribed] = useState<subscribeProps[]>() |
|
|
|
|
|
|
|
|
|
useLoad(() => { |
|
|
|
|
useDidShow(() => { |
|
|
|
|
Taro.request({ |
|
|
|
|
url: 'https://interapi.jm-kid.com/api/message/list', |
|
|
|
|
method: 'POST', |
|
|
|
@ -52,42 +52,68 @@ export default function UserMessage() { |
|
|
|
|
}) |
|
|
|
|
|
|
|
|
|
//跳转详情页
|
|
|
|
|
const handleToCollectionDetail = (id: string) => { |
|
|
|
|
Taro.navigateTo({ |
|
|
|
|
url: '/pages/CollectionDetail/index?id=' + id |
|
|
|
|
}) |
|
|
|
|
const handleDetailClick = (item: any) => { |
|
|
|
|
if (item.read_at) { |
|
|
|
|
toDetail(item) |
|
|
|
|
} else { |
|
|
|
|
// 标记已读
|
|
|
|
|
Taro.request({ |
|
|
|
|
url: 'https://interapi.jm-kid.com/api/message/mark', |
|
|
|
|
method: 'POST', |
|
|
|
|
header: { |
|
|
|
|
authorization: `bearer ${Taro.getStorageSync('UserToken')}`, |
|
|
|
|
}, |
|
|
|
|
data: { |
|
|
|
|
timestamp: Date.now(), |
|
|
|
|
operate: 'read', |
|
|
|
|
msg_id: item.msg_id |
|
|
|
|
}, |
|
|
|
|
success: () => { |
|
|
|
|
toDetail(item) |
|
|
|
|
} |
|
|
|
|
}) |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
//跳转详情页
|
|
|
|
|
const toDetail = (item: any) => { |
|
|
|
|
if (item.link) { |
|
|
|
|
Taro.navigateTo({ |
|
|
|
|
url: `/pages/CollectionDetail/index?id=${item.link.prdt_id}` |
|
|
|
|
}) |
|
|
|
|
} else { |
|
|
|
|
Taro.switchTab({ |
|
|
|
|
url: '/pages/Home/index', |
|
|
|
|
}) |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
return ( |
|
|
|
|
<View className='subscribe_bg'> |
|
|
|
|
{ |
|
|
|
|
userSubuscribed && userSubuscribed.length ? |
|
|
|
|
<ScrollView |
|
|
|
|
scrollY |
|
|
|
|
scrollWithAnimation |
|
|
|
|
className='subscribe_scrollview' |
|
|
|
|
> |
|
|
|
|
<View> |
|
|
|
|
{ |
|
|
|
|
userSubuscribed.map((item: any, index: number) => ( |
|
|
|
|
<View |
|
|
|
|
className='subscribe_item' |
|
|
|
|
key={index} |
|
|
|
|
onClick={()=>handleToCollectionDetail(item.PrdtId)} |
|
|
|
|
onClick={()=>handleDetailClick(item)} |
|
|
|
|
> |
|
|
|
|
<View className='item_header'> |
|
|
|
|
<Text className='item_header_title'>{item.title}</Text> |
|
|
|
|
<Text className='item_header_date'>{item.created_at}</Text> |
|
|
|
|
{ item.read_at && <View className='item_header_dot'></View> } |
|
|
|
|
{ !item.read_at && <View className='item_header_dot'></View> } |
|
|
|
|
</View> |
|
|
|
|
<View className='item_content'> |
|
|
|
|
<Text className='item_des'>{item.content}</Text> |
|
|
|
|
<Text className='item_link'>立即查看> ></Text> |
|
|
|
|
{item.link && <Text className='item_link'>立即查看> ></Text>} |
|
|
|
|
<View></View> |
|
|
|
|
</View> |
|
|
|
|
</View> |
|
|
|
|
)) |
|
|
|
|
} |
|
|
|
|
</ScrollView> : |
|
|
|
|
</View> : |
|
|
|
|
<View className='none'>暂无消息~</View> |
|
|
|
|
} |
|
|
|
|
</View> |
|
|
|
|