yujialong 3 weeks ago
parent 7a34076558
commit 3d377ecbbd
  1. 1
      src/pages/Customer/index.tsx
  2. 81
      src/pages/UserHome/UserMessage/index.less
  3. 56
      src/pages/UserHome/UserMessage/index.tsx
  4. 2
      src/pages/UserHome/index.less

@ -8,6 +8,7 @@ export default function Customer() {
src='https://oss.jm-kid.com/wx_5colorflower/icons/customer.svg'
className='pic'
mode='aspectFill'
show-menu-by-longpress
></Image>
)
}

@ -3,56 +3,51 @@
background: #f1f1f1;
padding: 1rem;
.subscribe_scrollview {
height: 100vh;
display: flex;
flex-direction: column;
.subscribe_item {
position: relative;
padding: 1rem 1.5rem;
background: #fff;
border-radius: .6rem;
gap: 1rem;
margin-bottom: 1rem;
.subscribe_item {
position: relative;
padding: 1rem 1.5rem;
background: #fff;
border-radius: .6rem;
gap: 1rem;
margin-bottom: 1rem;
.item_header {
display: flex;
justify-content: space-between;
margin-bottom: .3rem;
.item_header {
display: flex;
justify-content: space-between;
margin-bottom: .3rem;
.item_header_title {
font-size: .9rem;
font-weight: 600;
color: #333;
}
.item_header_date {
font-size: .8rem;
color: #ccc;
}
.item_header_dot {
position: absolute;
top: .8rem;
right: .8rem;
width: .5rem;
height: .5rem;
background-color: #f00;
border-radius: 50%;
}
}
.item_des {
font-size: .9rem;
.item_header_title {
font-size: 1rem;
font-weight: 600;
color: #333;
}
.item_link {
margin-left: .5rem;
font-size: .9rem;
color: #3BA366;
.item_header_date {
font-size: .8rem;
color: #808080;
}
.item_header_dot {
position: absolute;
top: .5rem;
right: .7rem;
width: .5rem;
height: .5rem;
background-color: #f00;
border-radius: 50%;
}
}
.item_des {
font-size: .9rem;
color: #333;
}
.item_link {
margin-left: .5rem;
font-size: .9rem;
color: #3BA366;
}
}
.none {
padding-top: 3rem;
font-size: .8rem;

@ -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'>&gt; &gt;</Text>
{item.link && <Text className='item_link'>&gt; &gt;</Text>}
<View></View>
</View>
</View>
))
}
</ScrollView> :
</View> :
<View className='none'>~</View>
}
</View>

@ -91,6 +91,8 @@
&:nth-child(7) {
.user_home_content_item_des {
display: flex;
justify-content: center;
min-width: 1rem;
padding: .2rem .3rem;
color: #fff;
background-color: #ea2b2b;

Loading…
Cancel
Save